Le 13 oct. 06, à 16:54, Carsten Driesner a écrit :
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.
I agree; in the case of my add-on, I strongly needed to avoid manual
registration of a package.
As a "solution" to this drawback, I have chosen to remove the inserted
menu (modifying the configuration again) when OO quits (on OnCloseApp
event).
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
I have tried your suggestion. It doesn't seem to work, though all calls
seem to be successful.
I have only one (writer) document opened.
My code is parallel to yours, in C++ :
________________________________________________________________________
__________
Reference<XFrame> curFrame = m_appDesktop->getCurrentFrame();
Reference<XLayoutManager> layoutMgr(GetObjectProperty(curFrame,
"LayoutManager"), UNO_QUERY);
OUString element =
OUString::createFromAscii("private:resource/menubar/menubar");
layoutMgr->destroyElement(element);
layoutMgr->createElement(element);
________________________________________________________________________
__________
What may happen ?
Julien
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]