Tobias Krais wrote:
Hi Carsten,
please allow me a more detailed question.
-----%<-----
PropertyValue[] oDateiMenuSettings = (PropertyValue[])
UnoRuntime.queryInterface(PropertyValue[].class,
oMenuBarSettings.getByIndex(0));
-----%<-----
That code snippet is wrong;
com.sun.star.container.XIndexAccess.getByIndex returns an ANY value,
which in the Java-UNO binding maps to
java.lang.Object/com.sun.star.uno.Any in a somewhat hard-to-use way:
PropertyValue[] oDateiMenuSettings;
try {
oDateiMenuSettings = com.sun.star.uno.AnyConverter.toObject(
PropertyValue[].class, oMenuBarSettings.getByIndex(0));
} catch (com.sun.star.lang.IllegalArgumentException e) {
throw new RuntimeException(e.toString());
}
UnoRuntime.queryInterface is used to go from a reference of UNO
interface type A to some UNO object to a reference of UNO interface type
B to the same UNO object. AnyConverter is used to extract (the Java
representations of) arbitrary UNO values contained in (the Java
representaton of) a UNO ANY value.
-Stephan
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").
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 ""...)
Is it true that the ItemDescriptorContainer contains all the Items and
Submenus. My Debugger says the ItemDescriptorContainer is the type
XIndexAccess. But I think I need a XIndexContainer or again a
PropertyValue[]. How can I get it?
Greetings, Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]