Hi together,
again a question from me... I want to rename a menu entry,
e.g. the
entry "Save as..." to "Secure Copy".
Please see the code below (esp. the
comment).
-----%<-----
/**
* This method renames menu items.The given Vector contains
a
* XIndexContainer at first position (the menu containing
the Item to
* remove) and an Integer at second position (the item
number of the
* item to remove.
* The changes are transient (temporary).
*
* param itemsToRename
* throws IllegalArgumentException
* throws IndexOutOfBoundsException
* throws WrappedTargetException
*/
public void renameMenuItems(Vector itemsToRename)
throws IllegalArgumentException,
IndexOutOfBoundsException,
WrappedTargetException
{
for (int i = 0; i < itemsToRename.size(); i++)
{
Vector thisVectorItem =
(Vector)itemsToRename.elementAt(i);
XIndexAccess thisAccess = (XIndexAccess)
thisVectorItem.elementAt(0);
Integer menuPosition =
(Integer)thisVectorItem.elementAt(1);
// Getting Properties to be able to change them
PropertyValue[] itemProperties =
(PropertyValue[])
com.sun.star.uno.AnyConverter.toObject(
PropertyValue[].class,
thisAccess.getByIndex(menuPosition));
for (int j = 0; j < itemProperties.length;
j++)
{
if(itemProperties[j].Name.equals("Label"))
{
itemProperties[j].Value =
"Sicherheitskopie";
}
// Up to now the item has the Command URL
".uno:SaveAs". uncommenting
// following lines will apply the changes of the Label.
// else
if(itemProperties[j].Name.equals("CommandURL"))
// {
// itemProperties[j].Value =
".uno:Save";
// }
}
XIndexContainer thisContainer =
(XIndexContainer)
UnoRuntime.queryInterface(XIndexContainer.class,
thisAccess);
thisContainer.replaceByIndex(menuPosition,
itemProperties);
}
}
-----%<-----
after calling this routine I apply the changes to the root
container.
Do I miss something? Is this a bug or feature?
Greetings, Tobias
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|