To comment on the following update, log in, then open the issue: http://www.openoffice.org/issues/show_bug.cgi?id=104047 Issue #|104047 Summary|Cannot delete custom ToolBar from macro in global stor |age configuration Component|Word processor Version|OOO310m9 Platform|PC URL| OS/Version|Windows XP Status|UNCONFIRMED Status whiteboard| Keywords| Resolution| Issue type|DEFECT Priority|P3 Subcomponent|programming Assigned to|writerneedsconfirm Reported by|yajva
------- Additional comments from ya...@openoffice.org Thu Aug 6 09:18:10 +0000 2009 ------- Hi The following is an example code borrowed from Andrew Pitonyak's AndrewMacro.odt to illustrate a problem with custom toolbar removal from macros. Run CreateBasicIDEToolbar, the toolbar is installed. Run RemoveBasicIDEToolbar, the toolbar is removed. Now run the CreateBasicIDEToolbar again and all it creates is an empty toolbar which can neither be removed. This behaviour is only with global UIConfigurationManager. Uncomment ' oModuleCfgMgr = ThisComponent.getUIConfigurationManager in both CreateBasicIDEToolbar and RemoveBasicIDEToolbar. With an empty document open (reqd. for ThisComponent to have a valid value) repeated addition and removal of toolbars works perfectly on the document. I am on Windows XP, OO 3.1.0, OOO310m11, Build (9399) Regards Yajva REM ***** BASIC ***** global const tbURL = "private:resource/toolbar/custom_test4" Sub CreateBasicIDEToolbar Dim sToolbarURL$ ' URL of the custom toolbar. Dim sCmdID$ ' Command for a single toolbar button. Dim sCmdLable ' Lable for a single toolbar button. Dim sDocType$ ' Component type that will containt the toolbar. Dim sSupplier$ ' ModuleUIConfigurationManagerSupplier Dim oSupplier ' ModuleUIConfigurationManagerSupplier Dim oModuleCfgMgr ' Module manager. Dim oTBSettings ' Settings that comprise the toolbar. Dim oToolbarItem ' Single toolbar button. Dim nCount% REM Name of the custom toolbar; must start with "custom_". sToolbarURL = tbURL REM Retrieve the module configuration manager from the REM central module configuration manager supplier sSupplier = "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" oSupplier = CreateUnoService(sSupplier) REM Specify the document type associated with this toolbar. REM sDocType = "com.sun.star.text.TextDocument" sDocType = "com.sun.star.script.BasicIDE" REM Retrieve the module configuration manager with module identifier REM *** See com.sun.star.frame.ModuleManager for more information. oModuleCfgMgr = oSupplier.getUIConfigurationManager( sDocType ) ' oModuleCfgMgr = ThisComponent.getUIConfigurationManager 'THIS WORKS. Uncomment in RemoveBasicIDEToolbar() also REM To remove a toolbar, you can use something like the following: 'If (oModuleCfgMgr.hasSettings(sToolbarURL)) Then ' oModuleCfgMgr.removeSettings(sToolbarURL) ' Exit Sub 'End If REM Create a settings container to define the structure of the REM custom toolbar. oTBSettings = oModuleCfgMgr.createSettings() REM *** Set a title for our new custom toolbar oTBSettings.UIName = "My little custom toolbar" REM *** Create a button for our new custom toolbar sCmdID = "macro:///PitonyakUtil.UI.TBTest()" sCmdLable = "Test" nCount = 0 oToolbarItem = CreateSimpleToolbarItem( sCmdID, sCmdLable ) oTBSettings.insertByIndex( nCount, oToolbarItem ) REM To add a second item, increment nCount, create a new REM toolbar item, and insert it. REM *** Set the settings for our new custom toolbar. (replace/insert) If ( oModuleCfgMgr.hasSettings( sToolbarURL )) Then oModuleCfgMgr.replaceSettings( sToolbarURL, oTBSettings ) Else oModuleCfgMgr.insertSettings( sToolbarURL, oTBSettings ) End If End Sub Function CreateSimpleToolbarItem( sCommand$, sLabel ) as Variant Dim oItem(3) As New com.sun.star.beans.PropertyValue oItem(0).Name = "CommandURL" oItem(0).Value = sCommand oItem(1).Name = "Label" oItem(1).Value = sLabel REM Other supported types include SEPARATOR_LINE, rem SEPARATOR_SPACE, and SEPARATOR_LINEBREAK. oItem(2).Name = "Type" oItem(2).Value = com.sun.star.ui.ItemType.DEFAULT oItem(3).Name = "Visible" oItem(3).Value = True CreateSimpleToolbarItem = oItem() End Function Sub RemoveBasicIDEToolbar Dim sToolbarURL$ ' URL of the custom toolbar. Dim sCmdID$ ' Command for a single toolbar button. Dim sCmdLable ' Lable for a single toolbar button. Dim sDocType$ ' Component type that will containt the toolbar. Dim sSupplier$ ' ModuleUIConfigurationManagerSupplier Dim oSupplier ' ModuleUIConfigurationManagerSupplier Dim oModuleCfgMgr ' Module manager. Dim oTBSettings ' Settings that comprise the toolbar. Dim oToolbarItem ' Single toolbar button. Dim nCount% REM Name of the custom toolbar; must start with "custom_". sToolbarURL = tbURL REM Retrieve the module configuration manager from the REM central module configuration manager supplier sSupplier = "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" oSupplier = CreateUnoService(sSupplier) REM Specify the document type associated with this toolbar. REM sDocType = "com.sun.star.text.TextDocument" sDocType = "com.sun.star.script.BasicIDE" REM Retrieve the module configuration manager with module identifier REM *** See com.sun.star.frame.ModuleManager for more information. oModuleCfgMgr = oSupplier.getUIConfigurationManager( sDocType ) ' oModuleCfgMgr = ThisComponent.getUIConfigurationManager 'THIS WORKS. Uncomment in CreateBasicIDEToolbar() also REM To remove a toolbar, you can use something like the following: 'If (oModuleCfgMgr.hasSettings(sToolbarURL)) Then ' oModuleCfgMgr.removeSettings(sToolbarURL) ' Exit Sub 'End If REM Create a settings container to define the structure of the REM custom toolbar. ' oTBSettings = oModuleCfgMgr.createSettings() REM *** Set a title for our new custom toolbar ' oTBSettings.UIName = "My little custom toolbar" REM *** Create a button for our new custom toolbar ' sCmdID = "macro:///PitonyakUtil.UI.TBTest()" ' sCmdLable = "Test" ' nCount = 0 ' oToolbarItem = CreateSimpleToolbarItem( sCmdID, sCmdLable ) ' oTBSettings.insertByIndex( nCount, oToolbarItem ) REM To add a second item, increment nCount, create a new REM toolbar item, and insert it. REM *** Set the settings for our new custom toolbar. (replace/insert) If ( oModuleCfgMgr.hasSettings( sToolbarURL )) Then oModuleCfgMgr.removeSettings( sToolbarURL, oTBSettings ) ' Else ' oModuleCfgMgr.insertSettings( sToolbarURL, oTBSettings ) End If End Sub --------------------------------------------------------------------- Please do not reply to this automatically generated notification from Issue Tracker. Please log onto the website and enter your comments. http://qa.openoffice.org/issue_handling/project_issues.html#notification --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@sw.openoffice.org For additional commands, e-mail: issues-h...@sw.openoffice.org --------------------------------------------------------------------- To unsubscribe, e-mail: allbugs-unsubscr...@openoffice.org For additional commands, e-mail: allbugs-h...@openoffice.org