Julien Galand wrote:
Hi everybody,
I have written an add-on which inserts its menu in the "OfficeMenuBar"
as a top-level menu.
Instead of using a .xcu installed with the add-on package, it creates
and inserts its menu dynamically, using the "com.sun.star.configuration"
module to modify OO's configuration, at the
"/org.openoffice.Office.Addons/AddonUI/OfficeMenuBar" node.
I have limited this menu to com.sun.star.text.TextDocument modules.
Hi Julien,
Although this is a possible way to implement your add-on it looks a bit
strange and has a drawback you should consider. If the user choose to
uninstall your add-on all the changes you did programmatically in the
configuration won't be removed. The user would see a non-working
top-level menu! Therefore I cannot recommend to use this way.
Then the changes made in the configuration are committed through
XChangesBatch.commitChanges().
Everything works well, except that the menu bars of the currently opened
documents are not refreshed.
The new menu will appear only for documents opened afterwards.
I have tried XUIConfigurationPersistence.reload() on a
ModuleUIConfigurationManager service (itself retrieved by
XModuleUIConfigurationManagerSupplier.getUIConfigurationManager("com.sun.star.text.TextDocument")),
it doesn't seem to improve the behavior.
Does someone know a way to refresh the currently opened menu bars ?
You can use the layout manager from the frame to destroy and create the
menu bar again. The current implementation doesn't listen to changes in
the Addon.xcu file. The following Basic code snippet "refreshes" the
menu bar.
REM ***** BASIC *****
Sub Main
REM *** Initialize strings
sMenubar = "private:resource/menubar/menubar"
REM *** Retrieve the desktop service
oDesktop = createUnoService("com.sun.star.frame.Desktop")
REM *** Retrieve the current frame and layout manager
oCurrFrame = oDesktop.getCurrentFrame()
oLayoutManager = oCurrFrame.LayoutManager
REM *** Destroy and create menu bar to refresh content
oLayoutManager.destroyElement( sMenubar )
oLayoutManager.createElement( sMenubar )
End Sub
Regards,
Carsten
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]