Hi Tuomas,
> How about hiding a whole menu (e.g. Edit) instead of a menuitem. Is it
> possible?
Yes.
> I haven't figured it out how, maybe something like:
>
> xLayoutManager.hideElement("private:resource/menubar/menubar/EditMenu");
This won't work. You can use:
xLayoutManager.hideElement("private:resource/menubar/menubar");
and this will hide your whole menubar (or you can specify a toolbar,...).
If you want to remove a whole menu, use this:
-----%<-----
/**
* This method removes the first menu from OpenOffice menubar.
* Changes are transient.
*
* @param xLayoutManager
* @param CommandURL
* @param action
* @throws Exception
*/
public void changeMenus(String CommandURL, String action)
{
// Init menu elements
// 1. Getting the menubar
com.sun.star.ui.XUIElement myMenubar
= xLayoutManager.getElement(
"private:resource/menubar/menubar");
// 2. Getting the menubar settings
XUIElementSettings myMenuBarSettings = (XUIElementSettings)
UnoRuntime.queryInterface(XUIElementSettings.class,
myMenubar);
// 3. Casting the settings into a container to be able to get
// the properties
XIndexContainer myMenuBarSettingsContainer = (XIndexContainer)
UnoRuntime.queryInterface(
XIndexContainer.class,
myMenuBarSettings.getSettings(true));
try
{
// Make changes only transient (temporary).
com.sun.star.beans.XPropertySet xPropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, myMenubar);
xPropSet.setPropertyValue("Persistent", new Boolean(false));
myMenuBarSettingsContainer.removeByIndex(1);
// Apply settings to the root container (includes all
// subcontainers)
myMenuBarSettings.setSettings(myMenuBarSettingsContainer);
}
catch (Exception e)
{
System.out.println("Cannot modify menubar. Reason: " + e);
}
}
-----%<-----
Greetings, Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]