SFWidgets.Toolbar service/text/sbasic/shared/03/sf_toolbar.xhpToolbar service
SFWidgets.Toolbar service
The Toolbar service allows to retrieve information related to the toolbars available for a specific document window. With this service it is possible to:Toggle the visibility of specific toolbars.Access information about the buttons available in each toolbar.Each %PRODUCTNAME application has its own set of available toolbars. This service handles both built-in and custom toolbars.The status bar and the menu bar are not considered toolbars in the context of this service.
Service invocation
Before using the Toolbar service the ScriptForge library needs to be loaded or imported:The Toolbar service is invoked using the Toolbars method, which is available in the following services: Calc, Datasheet, Document, FormDocument and Writer.The example below gets an Array with the names of the toolbars available in the current document.oDoc = CreateScriptService("Document", ThisComponent)arrToolbars = oDoc.Toolbars()MsgBox SF_String.Represent(arrToolbars)Use the Toolbars method without arguments to retrieve an array with available toolbar names.The example below toggles the visibility of the toolbar:oDoc = CreateScriptService("Document", ThisComponent)toolbar = oDoc.Toolbars("standardbar")toolbar.Visible = Not toolbar.Visiblebas = CreateScriptService("Basic")doc = CreateScriptService("Document", bas.ThisComponent)arr_toolbars = doc.Toolbars()bas.MsgBox(repr(toolbars))bas = CreateScriptService("Basic")doc = CreateScriptService("Document", bas.ThisComponent)toolbar = doc.Toolbars("standardbar")toolbar.Visible = not toolbar.VisibleToolbar service;BuiltIn propertyToolbar service;Docked propertyToolbar service;HasGlobalScope propertyToolbar service;Name propertyToolbar service;ResourceURL propertyToolbar service;Visible propertyToolbar service;XUIElement property
Properties
NameReadonlyTypeDescriptionBuiltInYesBooleanReturns True when the toolbar is part of the set of standard toolbars shipped with %PRODUCTNAME.DockedYesBooleanReturns True when the toolbar is active in the window and docked.HasGlobalScopeYesBooleanReturns True when the toolbar is available in all documents of the same type.NameYesStringReturns the name of the toolbar.ResourceURLYesStringReturns the resource URL of the toolbar, in the form private:toolbar/toolbar_name.VisibleNoBooleanReturns True when the toolbar is active and visible in the document window.XUIElementYesUNO ObjectReturns the com.sun.star.ui.XUIElement UNO object that represents the toolbar.
List of Methods in the Toolbar Service
ToolbarButtons
Returns an Array containing the names of all toolbar buttons when called without arguments.Provide the name of a toolbar button as argument to obtain a ToolbarButton service instance.
svc.ToolbarButtons(opt buttonname: str): any
buttonname: The name of a toolbar button in the current toolbar.The example below returns the command executed when the button is clicked in the toolbar:oToolbar = oDoc.Toolbars("standardbar")oToolbarButton = oToolbar.ToolbarButtons("New")MsgBox oToolbarButton.OnClicktoolbar = doc.Toolbars("standardbar")toolbar_button = toolbar.ToolbarButtons("New")bas.MsgBox(toolbar_button.OnClick)Inactive toolbars do not have buttons. Therefore, calling the ToolbarButtons method will make the toolbar visible.