Tobias Krais wrote:
> Hi Carsten,
>
> your ideas made me think...
>
> Applying all your ideas the code looks like this. I
think it will be useful:
Hi Tobias,
I have two more comments to your code.
> -----%<-----
>
> com.sun.star.frame.XDesktop xDesktop =
> (com.sun.star.frame.XDesktop)
>
UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class,
> desktop);
> com.sun.star.frame.XFrame xFrame =
xDesktop.getCurrentFrame();
>
> XPropertySet xps = (XPropertySet)
UnoRuntime.queryInterface(
> XPropertySet.class, xFrame);
> XLayoutManager xLayoutManager =
(XLayoutManager)
> UnoRuntime.queryInterface(
> XLayoutManager.class,
>
xps.getPropertyValue("LayoutManager"));
> xLayoutManager.attachFrame(xFrame);
Because attachFrame() is automatically called by
loadComponentFromURL(),
you can remove this line without any problem. Normally
attachFrame() is
not used by developers. There are some special situations
where one can
use attachFrame(), e.g. if you dynamically want to use a
self-implemented layout manager.
>
> // Getting the menubar
> com.sun.star.ui.XUIElement myMenubar =
>
xLayoutManager.getElement("private:resource/menubar/me
nubar");
> // Getting the menubar settings
> XUIElementSettings myMenuBarSettings =
(XUIElementSettings)
>
UnoRuntime.queryInterface(XUIElementSettings.class,
> myMenubar);
> // Casting the settings into a container to be
able to get the
> //properties
> XIndexContainer myMenuBarSettingsContainer =
(XIndexContainer)
> UnoRuntime.queryInterface(
> XIndexContainer.class,
> myMenuBarSettings.getSettings(true));
>
> // Creating a Vector containing all menus with
a "Save" item
> Vector foundSaveMenuItems =
searchMenuForItem(".uno:Save",
> myMenuBarSettingsContainer,
> new Vector());
> // Remove the menu items
> removeMenuItems(foundSaveMenuItems);
>
Please don't forget to set the property
"Persistent" of the user
interface element to false (default is always true).
Otherwise your
changes will be persistent.
// Make changes only transient.
com.sun.star.beans.XPropertySet xPropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, myMenuBar);
xPropSet.setPropertyValue("Persistent", new
Boolean(false));
> // Apply settings to the root container
(includes all
> // subcontainers)
>
myMenuBarSettings.setSettings(myMenuBarSettingsContainer);
> }
>
Regards,
Carsten
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|