Tobias Krais wrote:
Hi Carsten,
please allow me a more detailed question.
-----%<-----
PropertyValue[] oDateiMenuSettings = (PropertyValue[])
UnoRuntime.queryInterface(PropertyValue[].class,
oMenuBarSettings.getByIndex(0));
-----%<-----
I have now as you adviced a PropertyValue[] oFileMenuSettings.
Can you tell me how to rename a single item of the file menu?
No, problem. You have to search for the properties "Label" and
"CommandURL". You have to change both to your needs, call
replaceByIndex() and provide your changed sequence< PropertyValue >.
PropertyValue [] aPropValue = (PropertyValue [])
oMenuBarSettings.getByIndex(0);
String aLabel( "Label" );
String aCommandURL( "CommandURL" );
for (int i = 0; i < aPropValue.length; i++) {
if (aLabel.equals(aPropValue[i].Name)){
..
}
else if ( aCommandURL.equals(aPropValue[i].Name)) {
..
}
}
Important: If you want to access a sub menu, you have to look for the
property called "ItemDescriptorContainer".
If I understand correctly my PropertyValue[] oDateiMenuSettings contains
now the whole menu "Datei" (in English "File").
Yes, the PropertyValue array contains the whole "File" menu. The
"ItemDescriptorContainer" provides you the next level of menu items.
Here it contains five values: CommandURL, HelpURL,
ItemDescriptorContainer, Label, Type. (Question: why is there no value
for Label? In my own menu the value is set to "JUDAS", but in all the
menus that already exist, the Label value is ""...)
OOo works with an indirection between command url and label. The label
is retrieved on runtime from configuration files using the command url
as a key. Therefore you won't get any label information for built-in
commands from the settings. If you want to identify a single menu item,
you should always use the command url, because the label would be
language dependent.
Is it true that the ItemDescriptorContainer contains all the Items and
Submenus. My Debugger says the ItemDescriptorContainer is the type
XIndexAccess.
XIndexAccess provides you with the following functions.
published interface XIndexAccess: com::sun::star::container::XElementAccess
{
/** @returns the number of elements in this container.*/
long getCount();
// DocMerge from idl: method
com::sun::star::container::XIndexAccess::getByIndex
/** @returns the element at the specified index.
@param Index
specifies the position in the array. The first index is 0.
*/
any getByIndex( [in] long Index )
raises( com::sun::star::lang::IndexOutOfBoundsException,
com::sun::star::lang::WrappedTargetException );
};
But I think I need a XIndexContainer or again a
PropertyValue[].
Why? You can call getByIndex and retrieve the next sequence<
PropertyValue >. Where is the problem?
How can I get it?
Just call getByIndex() using XIndexAccess. If you want to change
entries, you have to query the interface for XIndexContainer.
To make it clear:
oMenuBarSettings = oMenuBar.getSettings(true)
The index container provides the following information
0 1 n
|File|Edit|...|Help|
PropertyValue[] oFileMenu = oMenuBarSettings.getByIndex(0)
|"Label"|
The label of the menu item, if set by the user. Normally empty.
|"CommandURL"|
The command which should be dispatched.
|"ItemDescriptorContainer"|
The next level of the file menu (XIndexAccess) => |New|Open|Recent
Documents|---|...
I think you should read some documentation in the Developer's Guide to
better understand UNO based containers and the UNO interface concept.
Regards,
Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]