pqQFq‖SFWidgets.Toolbar service

oqrPc‖The Toolbar service allows to retrieve information related to the toolbars available for a specific document window. With this service it is possible to:

tGA5p‖Each LibreOfficeDev application has its own set of available toolbars. This service handles both built-in and custom toolbars.

note

EnCbC‖The status bar and the menu bar are not considered toolbars in the context of this service.


x39EK‖Service invocation

sDTg5‖Before using the Toolbar service the ScriptForge library needs to be loaded or imported:

note

gF8D8‖• Basic macros require to load ScriptForge library using the following statement:
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")

• Python scripts require an import from scriptforge module:
from scriptforge import CreateScriptService


T8Xfw‖The Toolbar service is invoked using the Toolbars method, which is available in SFDocuments.Document service.

3aa4B‖In Basic

DXXZt‖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)
  
tip

dCrhf‖Use the Toolbars method without arguments to retrieve an array with available toolbar names.


LGmwr‖The example below toggles the visibility of the Standard toolbar:


    oDoc = CreateScriptService("Document", ThisComponent)
    toolbar = oDoc.Toolbars("standardbar")
    toolbar.Visible = Not toolbar.Visible
  
BenDd‖In Python

    bas = 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.Visible
  

UDbvF‖Properties

JyMa7‖Name

ynz5j‖Readonly

2FULu‖Type

CXito‖Description

BuiltIn

NWaGJ‖Yes

Boolean

NFBvJ‖Returns True when the toolbar is part of the set of standard toolbars shipped with LibreOfficeDev.

Docked

2sRrz‖Yes

Boolean

kBEqC‖Returns True when the toolbar is active in the window and docked.

HasGlobalScope

wgQVn‖Yes

Boolean

pnCss‖Returns True when the toolbar is available in all documents of the same type.

Name

QdmGf‖Yes

String

JkADV‖Returns the name of the toolbar.

ResourceURL

SPCka‖Yes

String

9tRd5‖Returns the resource URL of the toolbar, in the form private:toolbar/toolbar_name.

Visible

JKEeR‖No

Boolean

cAQFF‖Returns True when the toolbar is active and visible in the document window.

XUIElement

DsnCd‖Yes

UNO Object

SBzqD‖Returns the com.sun.star.ui.XUIElement UNO object that represents the toolbar.


NaxAS‖List of Methods in the Toolbar Service

ToolbarButtons


ToolbarButtons

FED3g‖Returns an Array containing the names of all toolbar buttons when called without arguments.

ZFAQU‖Provide the name of a toolbar button as argument to obtain a ToolbarButton service instance.

FVEx2‖Syntax:

svc.ToolbarButtons(opt buttonname: str): any

WADQ4‖Parameters:

4FNvr‖buttonname: The name of a toolbar button in the current toolbar.

EFSA4‖Example:

KDGVG‖The example below returns the command executed when the button New is clicked in the Standard toolbar:

3aa4B‖In Basic

      oToolbar = oDoc.Toolbars("standardbar")
      oToolbarButton = oToolbar.ToolbarButtons("New")
      MsgBox oToolbarButton.OnClick
    
BenDd‖In Python

      toolbar = doc.Toolbars("standardbar")
      toolbar_button = toolbar.ToolbarButtons("New")
      bas.MsgBox(toolbar_button.OnClick)
    
note

wAXLm‖Inactive toolbars do not have buttons. Therefore, calling the ToolbarButtons method will make the toolbar visible.


warning

uzETY‖All ScriptForge Basic routines or identifiers that are prefixed with an underscore character "_" are reserved for internal use. They are not meant be used in Basic macros or Python scripts.