Mathias Bauer wrote:
> This requires the new menu configuration API of OOo2.0.
I took some sample code from an earlier mailing list post that was pointed
out to me on the forums (thanks DannyB) and modified it to add something to
the file menu.
I tried with both m79 and m87 and have some strange results. Since I don't
have a lot of data to reference I wanted to send this code out to see if
maybe I'm doing something wrong.
The desired result is for a single command to be added to the File menu
Actual result is the command is added however every time it is done another
complete file menu is added. So after 1 run there are two file menus, after
2 runs three etc. The command doesn't currently execute either.
I verified that index 0 is .uno:PickList
Code:
REM ***** BASIC *****
Sub Main
REM *** Adds a item to the File Menu
REM *** Initialize strings
sMenuBar = "private:resource/menubar/menubar"
sMyPopupMenuCmdId = ".uno:PickList"
REM *** Retrieve the module configuration manager from central module
configuration manager supplier
oModuleCfgMgrSupplier =
createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
REM *** Retrieve the module configuration manager with module identifier
REM *** See drafts.com.sun.star.frame.ModuleManager for more information
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager(
"com.sun.star.text.TextDocument" )
oMenuBarSettings = oModuleCfgMgr.getSettings( sMenuBar, true )
oPopupMenu = oMenuBarSettings.getByIndex(0)
oPopupMenuContainer = oPopupMenu(2).Value
oMenuItem = CreateMenuItem( "macro:///Standard.Module1.Test()",
"Standard.Module1.Test" )
oPopupMenuContainer.insertByIndex( 0,oMenuItem)
oMenuBarSettings.insertByIndex( nCount, oPopupMenu )
oModuleCfgMgr.replaceSettings( sMenuBar, oMenuBarSettings )
End Sub
Function CreateMenuItem( Command as String, Label as String ) as Variant
Dim aMenuItem(2) as new com.sun.star.beans.PropertyValue
aMenuItem(0).Name = "CommandURL"
aMenuItem(0).Value = Command
aMenuItem(1).Name = "Label"
aMenuItem(1).Value = Label
aMenuItem(2).Name = "Type"
aMenuItem(2).Value = 0
CreateMenuItem = aMenuItem()
End Function
Sub Test
MsgBox "Test"
End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]