ScriptForge (SFWidgets) new Toolbar and ToolbarButton services
Each component has its own set of toolbars, depending
on the component type (Calc, Writer, Basic IDE, ...).
In the context of the actual class, a toolbar
is presumed defined statically:
- either by the application
- or by a customization done by the user.
The definition of a toolbar can be stored
in the application configuration files
or in the current document.
Changes made by scripts to toolbars stored
in the application are persistent. They are valid
for all documents of the same type.
Note that the menubar and the statusbar
are not considered toolbars in this context.
A toolbar consists in a series of graphical
controls to trigger actions.
The "Toolbar" service gives access to the "ToolbarButton" service to manage
the individual buttons belonging to the toolbar.
The "Toolbar" service is triggered from next
services: Document, Calc, Writer, Base, FormDocument
and Datasheet. All those components might host toolbars.
Proposed properties in the Toolbar service:
BuiltIn
Docked
HasGlobalScope
Name
ResourceURL
Visible (r/w)
XUIElement
Proposed method:
ToolbarButtons()
Proposed properties in the ToolbarButton service:
Caption
Height
Index
OnClick (r/w)
Parent
TipText (r/w)
Visible (r/w)
X
Y
(The Height, Width, X, Y properties allow for
easy hook of a popup menu to tye button)
Proposed method:
Execute()
Both services are available both from Basic and Python user scripts.
An update of the dcumentation help is required.
Change-Id: I43cb523b52e3d6362994557d74c4ef9faa220507
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147925
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
diff --git a/wizards/Package_sfwidgets.mk b/wizards/Package_sfwidgets.mk
index 3e2041a..75fc0bd 100644
--- a/wizards/Package_sfwidgets.mk
+++ b/wizards/Package_sfwidgets.mk
@@ -24,6 +24,8 @@ $(eval $(call gb_Package_add_files,wizards_basicsrvsfwidgets,$(LIBO_SHARE_FOLDER
SF_MenuListener.xba \
SF_PopupMenu.xba \
SF_Register.xba \
SF_Toolbar.xba \
SF_ToolbarButton.xba \
__License.xba \
dialog.xlb \
script.xlb \
diff --git a/wizards/source/scriptforge/SF_PythonHelper.xba b/wizards/source/scriptforge/SF_PythonHelper.xba
index ffec0af..f7345d4 100644
--- a/wizards/source/scriptforge/SF_PythonHelper.xba
+++ b/wizards/source/scriptforge/SF_PythonHelper.xba
@@ -791,11 +791,15 @@ Try:
Case "SFDialogs.DialogControl"
If Script = "SetTableData" Then vReturn = vBasicObject.SetTableData(vArgs(0), vArgs(1), vArgs(2))
Case "SFDocuments.Document"
If Script = "Forms" Then vReturn = vBasicObject.Forms(vArgs(0))
Select Case Script
Case "Forms" : vReturn = vBasicObject.Forms(vArgs(0))
Case "Toolbars" : vReturn = vBasicObject.Toolbars(vArgs(0))
End Select
Case "SFDocuments.Base"
Select Case Script
Case "FormDocuments" : vReturn = vBasicObject.FormDocuments()
Case "Forms" : vReturn = vBasicObject.Forms(vArgs(0), vArgs(1))
Case "Toolbars" : vReturn = vBasicObject.Toolbars(vArgs(0))
End Select
Case "SFDocuments.Calc"
Select Case Script
@@ -806,6 +810,7 @@ Try:
Case "SetArray" : vReturn = vBasicObject.SetArray(vArgs(0), vArgs(1))
Case "SetFormula" : vReturn = vBasicObject.SetFormula(vArgs(0), vArgs(1))
Case "SetValue" : vReturn = vBasicObject.SetValue(vArgs(0), vArgs(1))
Case "Toolbars" : vReturn = vBasicObject.Toolbars(vArgs(0))
End Select
Case "SFDocuments.Form"
Select Case Script
@@ -815,7 +820,14 @@ Try:
Case "SFDocuments.FormControl"
If Script = "Controls" Then vReturn = vBasicObject.Controls(vArgs(0))
Case "SFDocuments.FormDocument"
If Script = "Forms" Then vReturn = vBasicObject.Forms(vArgs(0))
Select Case Script
Case "Forms" : vReturn = vBasicObject.Forms(vArgs(0))
Case "Toolbars" : vReturn = vBasicObject.Toolbars(vArgs(0))
End Select
Case "SFWidgets.Toolbar"
Select Case Script
Case "ToolbarButtons" : vReturn = vBasicObject.ToolbarButtons(vArgs(0))
End Select
End Select
End If
diff --git a/wizards/source/scriptforge/SF_Root.xba b/wizards/source/scriptforge/SF_Root.xba
index 8c9a0db..2966866 100644
--- a/wizards/source/scriptforge/SF_Root.xba
+++ b/wizards/source/scriptforge/SF_Root.xba
@@ -80,6 +80,8 @@ Private PackageProvider As Object ' com.sun.star.comp.deployment.PackageIn
Private MailService As Object ' com.sun.star.system.SimpleCommandMail or com.sun.star.system.SimpleSystemMail
Private GraphicExportFilter As Object ' com.sun.star.drawing.GraphicExportFilter
Private Toolkit As Object ' com.sun.star.awt.Toolkit
Private ModuleUIConfigurationManagerSupplier As Object
' com.sun.star.ui.ModuleUIConfigurationManagerSupplier
' Specific persistent services objects or properties
Private FileSystemNaming As String ' If "SYS", file and folder naming is based on operating system notation
@@ -149,6 +151,7 @@ Private Sub Class_Initialize()
Set MailService = Nothing
Set GraphicExportFilter = Nothing
Set Toolkit = Nothing
Set ModuleUIConfigurationManagerSupplier = Nothing
OSName = ""
SFDialogs = Empty
SFForms = Empty
diff --git a/wizards/source/scriptforge/SF_Services.xba b/wizards/source/scriptforge/SF_Services.xba
index 8de43d3..f5e0545 100644
--- a/wizards/source/scriptforge/SF_Services.xba
+++ b/wizards/source/scriptforge/SF_Services.xba
@@ -131,7 +131,8 @@ Try:
Case "dialog", "dialogevent" : sLibrary = "SFDialogs"
Case "database", "datasheet" : sLibrary = "SFDatabases"
Case "unittest" : sLibrary = "SFUnitTests"
Case "menu", "popupmenu" : sLibrary = "SFWidgets"
Case "menu", "popupmenu", "toolbar", "toolbarbutton"
sLibrary = "SFWidgets"
Case Else
End Select
Else
diff --git a/wizards/source/scriptforge/SF_UI.xba b/wizards/source/scriptforge/SF_UI.xba
index 4b96ac3..b01f613 100644
--- a/wizards/source/scriptforge/SF_UI.xba
+++ b/wizards/source/scriptforge/SF_UI.xba
@@ -56,6 +56,15 @@ Type Window
ParentName As String ' Identifier of the parent Base file when Window is a subcomponent
End Type
Type _Toolbar ' Proto-toolbar object. Passed to the "Toolbar" service, a full ScriptForge Toolbar object will be returned
Component As Object ' com.sun.star.lang.XComponent
ResourceURL As String ' Toolbar internal name
UIName As String ' Toolbar external name, may be ""
UIConfigurationManager As Object ' com.sun.star.ui.XUIConfigurationManager
ElementsInfoIndex As Long ' Index of the toolbar in the getElementsInfo(0) array
Storage As Long ' One of the toolbar location constants
End Type
' The progress/status bar of the active window
'Private oStatusBar As Object ' com.sun.star.task.XStatusIndicator
@@ -86,6 +95,11 @@ Const cstMACROEXECNORMAL = 0 ' Default, execution depends on user configu
Const cstMACROEXECNEVER = 1 ' Macros are not executed
Const cstMACROEXECALWAYS = 2 ' Macros are always executed
' Toolbar locations
Const cstBUILTINTOOLBAR = 0 ' Standard toolbar
Const cstCUSTOMTOOLBAR = 1 ' Toolbar added by user and stored in the LibreOffice application
Const cstCUSTOMDOCTOOLBAR = 2 ' Toolbar added by user solely for a single document
REM ===================================================== CONSTRUCTOR/DESTRUCTOR
REM -----------------------------------------------------------------------------
@@ -1277,7 +1291,7 @@ Dim FSO As Object ' Alias for SF_FileSystem
.WindowFileName = SF_Utils._GetPropertyValue(poComponent.Args, "URL")
If Len(.WindowFileName) > 0 Then .WindowName = FSO.GetName(FSO._ConvertFromUrl(.WindowFileName))
.DocumentType = BASEDOCUMENT
Case "org.openoffice.comp.dbu.ODatasourceBrowser" ' Base datasheet (table, query or sql in read mode
Case "org.openoffice.comp.dbu.ODatasourceBrowser" ' Base datasheet (table, query or sql) in read mode
Set .Frame = poComponent.Frame
If Not IsEmpty(poComponent.Selection) Then ' Empty for (F4) DatasourceBrowser !!
vSelection = poComponent.Selection
@@ -1333,6 +1347,132 @@ Catch:
End Function ' ScriptForge.SF_UI._IdentifyWindow
REM -----------------------------------------------------------------------------
Public Function _ListToolbars(ByRef poComponent As Object) As Object
''' Returns a SF_Dictionary object containing a list of all available
''' toolbars in the given component
''' A toolbar may be located:
''' - builtin in the LibreOffice configuration, but dependent on the component type
''' - added by the user and stored in the LibreOffice configuration of the user
''' - added by the user and stored in the component/document itself
''' The output dictionary has as
''' key: the UIName of the toolbar when not blank, otherwise the last component of its ResourceURL
''' item: a _Toolbar object (see top of module)
''' Menubar, statusbar and popup menus are ignored.
''' Args:
''' poComponent: any component in desktop, typically a document but not only
Dim oToolbarsDict As Object ' Return value
Dim oWindow As Object ' Window type
Dim oConfigMgr As Object ' com.sun.star.ui.ModuleUIConfigurationManagerSupplier
Dim sConfigurationManager As String ' Derived from the component's type
Dim oUIConfigMgr As Object ' com.sun.star.comp.framework.ModuleUIConfigurationManager
Dim vCommandBars As Variant ' Array of bars in component
Dim vCommandBar As Variant ' Array of PropertyValue about a single bar
Dim oToolbar As Object ' Toolbar description as a _Toolbar object
Dim sResourceURL As String ' Toolbar internal name as "private:resource/toolbar/..."
Dim sUIName As String ' Toolbar external name, may be zero-length string
Dim sBarName As String ' External bar name: either UIName or last component of resource URL
Dim i As Long
Const cstCUSTOM = "custom_"
Check:
' On Local Error GoTo Catch
If IsNull(poComponent) Then GoTo Catch
Try:
Set oToolbarsDict = CreateScriptService("Dictionary")
Set oWindow = _IdentifyWindow(poComponent)
' 1. Collect all builtin and custom toolbars stored in the LibreOffice configuration files
' Derive the name of the UI configuration manager from the component type
With oWindow
Select Case .WindowName
Case BASICIDE : sConfigurationManager = "com.sun.star.script.BasicIDE"
Case WELCOMESCREEN : sConfigurationManager = "com.sun.star.frame.StartModule"
Case Else
Select Case .DocumentType
Case BASEDOCUMENT : sConfigurationManager = "com.sun.star.sdb.OfficeDatabaseDocument"
Case CALCDOCUMENT : sConfigurationManager = "com.sun.star.sheet.SpreadsheetDocument"
Case DRAWDOCUMENT : sConfigurationManager = "com.sun.star.drawing.DrawingDocument"
Case FORMDOCUMENT : sConfigurationManager = "com.sun.star.sdb.FormDesign"
Case IMPRESSDOCUMENT : sConfigurationManager = "com.sun.star.presentation.PresentationDocument"
Case MATHDOCUMENT : sConfigurationManager = "com.sun.star.formula.FormulaProperties"
Case WRITERDOCUMENT : sConfigurationManager = "com.sun.star.text.TextDocument"
Case TABLEDATA, QUERYDATA, SQLDATA
sConfigurationManager = "com.sun.star.sdb.DataSourceBrowser"
Case Else : sConfigurationManager = ""
End Select
End Select
End With
Set oConfigMgr = SF_Utils._GetUNOService("ModuleUIConfigurationManagerSupplier")
Set oUIConfigMgr = oConfigMgr.getUIConfigurationManager(sConfigurationManager)
vCommandBars = oUIConfigMgr.getUIElementsInfo(com.sun.star.ui.UIElementType.TOOLBAR)
' Ignore statusbar, menubar and popup menus. Store toolbars in dictionary
For i = 0 To UBound(vCommandBars)
vCommandBar = vCommandBars(i)
sResourceURL = SF_Utils._GetPropertyValue(vCommandBar, "ResourceURL")
sUIName = SF_Utils._GetPropertyValue(vCommandBar, "UIName")
If Len(sUIName) > 0 Then sBarName = sUIName Else sBarName = Split(sResourceURL, "/")(2)
' Store a new entry in the returned dictionary
If Not oToolbarsDict.Exists(sBarName) Then
Set oToolbar = New _Toolbar
With oToolbar
Set .Component = poComponent
.ResourceURL = sResourceURL
.UIName = sUIName
Set .UIConfigurationManager = oUIConfigMgr
.ElementsInfoIndex = i
' Distinguish builtin and custom toolbars stored in the applcation
If SF_String.StartsWith(sBarName, cstCUSTOM, CaseSensitive := True) Then
.Storage = cstCUSTOMTOOLBAR
sBarName = Mid(sBarName, Len(cstCUSTOM) + 1)
Else
.Storage = cstBUILTINTOOLBAR
End If
End With
oToolbarsDict.Add(sBarName, oToolbar)
End If
Next i
' 2. Collect all toolbars stored in the current component/document
' Some components (e.g. datasheets) cannot contain own toolbars
If SF_Session.HasUnoMethod(poComponent, "getUIConfigurationManager") Then
Set oUIConfigMgr = poComponent.getUIConfigurationManager
vCommandBars = oUIConfigMgr.getUIElementsInfo(com.sun.star.ui.UIElementType.TOOLBAR)
For i = 0 To UBound(vCommandBars)
vCommandBar = vCommandBars(i)
sResourceURL = SF_Utils._GetPropertyValue(vCommandBar, "ResourceURL")
sUIName = SF_Utils._GetPropertyValue(vCommandBar, "UIName")
If Len(sUIName) > 0 Then sBarName = sUIName Else sBarName = Split(sResourceURL, "/")(2)
' Store a new entry in the returned dictionary
If Not oToolbarsDict.Exists(sBarName) Then
Set oToolbar = New _Toolbar
With oToolbar
Set .Component = poComponent
.ResourceURL = sResourceURL
.UIName = sUIName
Set .UIConfigurationManager = oUIConfigMgr
.ElementsInfoIndex = i
.Storage = cstCUSTOMDOCTOOLBAR
End With
oToolbarsDict.Add(sBarName, oToolbar)
End If
Next i
End If
Finally:
Set _ListToolbars = oToolbarsDict
Exit Function
Catch:
Set oToolbarsDict = Nothing
GoTo Finally
End Function ' ScriptForge.SF_UI._ListToolbars
REM -----------------------------------------------------------------------------
Public Function _PosSize() As Object
''' Returns the PosSize structure of the active window
diff --git a/wizards/source/scriptforge/SF_Utils.xba b/wizards/source/scriptforge/SF_Utils.xba
index d01d66a..c19f815 100644
--- a/wizards/source/scriptforge/SF_Utils.xba
+++ b/wizards/source/scriptforge/SF_Utils.xba
@@ -153,7 +153,7 @@ Finally:
End Function ' ScriptForge.SF_Utils._CStrToDate
REM -----------------------------------------------------------------------------
Public Function _EnterFunction(ByVal psSub As String, Optional ByVal psArgs As String)
Public Function _EnterFunction(ByVal psSub As String, Optional ByVal psArgs As String) As Boolean
''' Called on top of each public function
''' Used to trace routine in/outs (debug mode)
''' and to allow the explicit mention of the user call which caused an error
@@ -426,6 +426,11 @@ Dim oDefaultContext As Object
End If
End If
Set _GetUNOService = .MailService
Case "ModuleUIConfigurationManagerSupplier"
If IsEmpty(.ModuleUIConfigurationManagerSupplier) Or IsNull(.ModuleUIConfigurationManagerSupplier) Then
Set .ModuleUIConfigurationManagerSupplier = CreateUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
End If
Set _GetUNOService = .ModuleUIConfigurationManagerSupplier
Case "Number2Text"
If IsEmpty(.Number2Text) Or IsNull(.Number2Text) Then
Set .Number2Text = CreateUnoService("com.sun.star.linguistic2.NumberText")
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py
index a67dca4..7208ff81 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1806,6 +1806,9 @@ class SFDatabases:
def RemoveMenu(self, menuheader):
return self.ExecMethod(self.vbMethod, 'RemoveMenu', menuheader)
def Toolbars(self, toolbarname = ''):
return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Toolbars', toolbarname)
# #####################################################################################################################
# SFDialogs CLASS (alias of SFDialogs Basic library) ###
@@ -2022,6 +2025,9 @@ class SFDocuments:
def SetPrinter(self, printer = '', orientation = '', paperformat = ''):
return self.ExecMethod(self.vbMethod, 'SetPrinter', printer, orientation, paperformat)
def Toolbars(self, toolbarname = ''):
return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Toolbars', toolbarname)
# #########################################################################
# SF_Base CLASS
# #########################################################################
@@ -2590,6 +2596,46 @@ class SFWidgets:
def Execute(self, returnid = True):
return self.ExecMethod(self.vbMethod, 'Execute', returnid)
# #########################################################################
# SF_Toolbar CLASS
# #########################################################################
class SF_Toolbar(SFServices):
"""
Each component has its own set of toolbars, depending on the component type
(Calc, Writer, Basic IDE, ...).
In the context of the actual class, a toolbar is presumed defined statically:
- either by the application
- or by a customization done by the user.
"""
# Mandatory class properties for service registration
serviceimplementation = 'basic'
servicename = 'SFWidgets.Toolbar'
servicesynonyms = ('toolbar', 'sfwidgets.toolbar')
serviceproperties = dict(BuiltIn = False, Docked = False, HasGlobalScope = False, Name = False,
ResourceURL = False, Visible = True, XUIElement = False)
def ToolbarButtons(self, buttonname = ''):
return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'ToolbarButtons', buttonname)
# #########################################################################
# SF_ToolbarButton CLASS
# #########################################################################
class SF_ToolbarButton(SFServices):
"""
A toolbar consists in a series of graphical controls to trigger actions.
The "Toolbar" service gives access to the "ToolbarButton" service to manage
the individual buttons belonging to the toolbar.
"""
# Mandatory class properties for service registration
serviceimplementation = 'basic'
servicename = 'SFWidgets.ToolbarButton'
servicesynonyms = ('toolbarbutton', 'sfwidgets.toolbarbutton')
serviceproperties = dict(Caption = False, Height = False, Index = False, OnClick = True, Parent = False,
TipText = True, Visible = True, Width = False, X = False, Y = False)
def Execute(self):
return self.ExecMethod(self.vbMethod, 'Execute')
# ##############################################False##################################################################
# CreateScriptService() ###
diff --git a/wizards/source/sfdatabases/SF_Datasheet.xba b/wizards/source/sfdatabases/SF_Datasheet.xba
index 12b7f9e..775984f 100644
--- a/wizards/source/sfdatabases/SF_Datasheet.xba
+++ b/wizards/source/sfdatabases/SF_Datasheet.xba
@@ -66,6 +66,9 @@ Private _ControlModel As Object ' com.sun.star.awt.XControlModel - com.su
Private _ControlView As Object ' com.sun.star.awt.XControl - org.openoffice.comp.dbu.ODatasourceBrowser
Private _ColumnHeaders As Variant ' List of column headers as an array of strings
' Cache for static toolbar descriptions
Private _Toolbars As Object ' SF_Dictionary instance to hold toolbars stored in application or in document
REM ============================================================ MODULE CONSTANTS
REM ====================================================== CONSTRUCTOR/DESTRUCTOR
@@ -89,6 +92,7 @@ Private Sub Class_Initialize()
Set _ControlModel = Nothing
Set _ControlView = Nothing
_ColumnHeaders = Array()
Set _Toolbars = Nothing
End Sub ' SFDatabases.SF_Datasheet Constructor
REM -----------------------------------------------------------------------------
@@ -682,6 +686,50 @@ Catch:
GoTo Finally
End Function ' SFDatabases.SF_Datasheet.SetProperty
REM -----------------------------------------------------------------------------
Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
''' Returns either a list of the available toolbar names in the actual document
''' or a Toolbar object instance.
''' [Function identical with SFDocuments.SF_Document.Toolbars()]
''' Args:
''' ToolbarName: the usual name of one of the available toolbars
''' Returns:
''' A zero-based array of toolbar names when the argument is absent,
''' or a new Toolbar object instance from the SF_Widgets library.
Const cstThisSub = "SFDatabases.Datasheet.Toolbars"
Const cstSubArgs = "[ToolbarName=""""]"
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
Check:
If IsMissing(ToolbarName) Or IsEmpty(ToolbarName) Then ToolbarName = ""
If IsNull(_Toolbars) Then _Toolbars = ScriptForge.SF_UI._ListToolbars(_Component)
If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If Not _IsStillAlive() Then GoTo Finally
If VarType(ToolbarName) = V_STRING Then
If Len(ToolbarName) > 0 Then
If Not ScriptForge.SF_Utils._Validate(ToolbarName, "ToolbarName", V_STRING, _Toolbars.Keys()) Then GoTo Finally
End If
Else
If Not ScriptForge.SF_Utils._Validate(ToolbarName, "ToolbarName", V_STRING) Then GoTo Finally ' Manage here the VarType error
End If
End If
Try:
If Len(ToolbarName) = 0 Then
Toolbars = _Toolbars.Keys()
Else
Toolbars = CreateScriptService("SFWidgets.Toolbar", _Toolbars.Item(ToolbarName))
End If
Finally:
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SF_Databases.SF_Datasheet.Toolbars
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
diff --git a/wizards/source/sfdocuments/SF_Base.xba b/wizards/source/sfdocuments/SF_Base.xba
index e39b251..cc5ab48 100644
--- a/wizards/source/sfdocuments/SF_Base.xba
+++ b/wizards/source/sfdocuments/SF_Base.xba
@@ -948,6 +948,11 @@ Public Function SaveCopyAs(Optional ByVal FileName As Variant _
SaveCopyAs = [_Super].SaveCopyAs(FileName, Overwrite, Password, FilterName, FilterOptions)
End Function ' SFDocuments.SF_Base.SaveCopyAs
REM -----------------------------------------------------------------------------
Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
Toolbars = [_Super].Toolbars(ToolbarName)
End Function ' SFDocuments.SF_Base.Toolbars
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba
index dfd66fb..fe71b69 100644
--- a/wizards/source/sfdocuments/SF_Calc.xba
+++ b/wizards/source/sfdocuments/SF_Calc.xba
@@ -3780,6 +3780,11 @@ Public Function SetPrinter(Optional ByVal Printer As Variant _
SetPrinter = [_Super].SetPrinter(Printer, Orientation, PaperFormat)
End Function ' SFDocuments.SF_Calc.SetPrinter
REM -----------------------------------------------------------------------------
Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
Toolbars = [_Super].Toolbars(ToolbarName)
End Function ' SFDocuments.SF_Calc.Toolbars
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
diff --git a/wizards/source/sfdocuments/SF_Document.xba b/wizards/source/sfdocuments/SF_Document.xba
index 879d90c..2233aeb 100644
--- a/wizards/source/sfdocuments/SF_Document.xba
+++ b/wizards/source/sfdocuments/SF_Document.xba
@@ -80,6 +80,9 @@ Private _DocumentType As String ' Writer, Calc, ...
Private _DocumentProperties As Object ' Dictionary of document properties
Private _CustomProperties As Object ' Dictionary of custom properties
' Cache for static toolbar descriptions
Private _Toolbars As Object ' SF_Dictionary instance to hold toolbars stored in application or in document
REM ============================================================ MODULE CONSTANTS
Const ISDOCFORM = 1 ' Form is stored in a Writer document
@@ -101,6 +104,7 @@ Private Sub Class_Initialize()
_DocumentType = ""
Set _DocumentProperties = Nothing
Set _CustomProperties = Nothing
Set _Toolbars = Nothing
End Sub ' SFDocuments.SF_Document Constructor
REM -----------------------------------------------------------------------------
@@ -417,7 +421,7 @@ Try:
Set oContainer = _Frame.ContainerWindow
With oContainer
If .isVisible() = False Then .setVisible(True)
.IsMinimized = False
If .IsMinimized Then .IsMinimized = False
.setFocus()
.toFront() ' Force window change in Linux
Wait 1 ' Bypass desynchro issue in Linux
@@ -1357,6 +1361,49 @@ Catch:
GoTo Finally
End Function ' SFDocuments.SF_Document.SetProperty
REM -----------------------------------------------------------------------------
Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
''' Returns either a list of the available toolbar names in the actual document
''' or a Toolbar object instance.
''' Args:
''' ToolbarName: the usual name of one of the available toolbars
''' Returns:
''' A zero-based array of toolbar names when the argument is absent,
''' or a new Toolbar object instance from the SF_Widgets library.
Const cstThisSub = "SFDocuments.Document.Toolbars"
Const cstSubArgs = "[ToolbarName=""""]"
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
Check:
If IsMissing(ToolbarName) Or IsEmpty(ToolbarName) Then ToolbarName = ""
If IsNull(_Toolbars) Then _Toolbars = ScriptForge.SF_UI._ListToolbars(_Component)
If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If Not _IsStillAlive() Then GoTo Finally
If VarType(ToolbarName) = V_STRING Then
If Len(ToolbarName) > 0 Then
If Not ScriptForge.SF_Utils._Validate(ToolbarName, "ToolbarName", V_STRING, _Toolbars.Keys()) Then GoTo Finally
End If
Else
If Not ScriptForge.SF_Utils._Validate(ToolbarName, "ToolbarName", V_STRING) Then GoTo Finally ' Manage here the VarType error
End If
End If
Try:
If Len(ToolbarName) = 0 Then
Toolbars = _Toolbars.Keys()
Else
Toolbars = CreateScriptService("SFWidgets.Toolbar", _Toolbars.Item(ToolbarName))
End If
Finally:
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFDocuments.SF_Document.Toolbars
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
diff --git a/wizards/source/sfdocuments/SF_FormDocument.xba b/wizards/source/sfdocuments/SF_FormDocument.xba
index f0dfa51..a619ac1 100644
--- a/wizards/source/sfdocuments/SF_FormDocument.xba
+++ b/wizards/source/sfdocuments/SF_FormDocument.xba
@@ -535,6 +535,11 @@ Public Function SetPrinter(Optional ByVal Printer As Variant _
SetPrinter = [_Super].SetPrinter(Printer, Orientation, PaperFormat)
End Function ' SFDocuments.SF_FormDocument.SetPrinter
REM -----------------------------------------------------------------------------
Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
Toolbars = [_Super].Toolbars(ToolbarName)
End Function ' SFDocuments.SF_FormDocument.Toolbars
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
diff --git a/wizards/source/sfdocuments/SF_Writer.xba b/wizards/source/sfdocuments/SF_Writer.xba
index d19b18d..685fd20 100644
--- a/wizards/source/sfdocuments/SF_Writer.xba
+++ b/wizards/source/sfdocuments/SF_Writer.xba
@@ -574,6 +574,11 @@ Public Function SetPrinter(Optional ByVal Printer As Variant _
SetPrinter = [_Super].SetPrinter(Printer, Orientation, PaperFormat)
End Function ' SFDocuments.SF_Writer.SetPrinter
REM -----------------------------------------------------------------------------
Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
Toolbars = [_Super].Toolbars(ToolbarName)
End Function ' SFDocuments.SF_Writer.Toolbars
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
diff --git a/wizards/source/sfwidgets/SF_Register.xba b/wizards/source/sfwidgets/SF_Register.xba
index 7dc2708..d2c4245 100644
--- a/wizards/source/sfwidgets/SF_Register.xba
+++ b/wizards/source/sfwidgets/SF_Register.xba
@@ -52,6 +52,8 @@ Public Sub RegisterScriptServices() As Variant
With GlobalScope.ScriptForge.SF_Services
.RegisterService("Menu", "SFWidgets.SF_Register._NewMenu") ' Reference to the function initializing the service
.RegisterService("PopupMenu", "SFWidgets.SF_Register._NewPopupMenu") ' id.
.RegisterService("Toolbar", "SFWidgets.SF_Register._NewToolbar") ' id.
.RegisterService("ToolbarButton", "SFWidgets.SF_Register._NewToolbarButton") ' id.
End With
End Sub ' SFWidgets.SF_Register.RegisterScriptServices
@@ -131,6 +133,7 @@ Dim oSession As Object : Set oSession = ScriptForge.SF_Services.CreateScriptS
Dim oUi As Object : Set oUi = ScriptForge.SF_Services.CreateScriptService("ScriptForge.UI")
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
Set oMenu = Nothing
Check:
' Check and get arguments, their number may vary
@@ -145,7 +148,6 @@ Check:
If Not ScriptForge.SF_Utils._Validate(X, "X", ScriptForge.V_NUMERIC) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(Y, "Y", ScriptForge.V_NUMERIC) Then GoTo Finally
If Not ScriptForge.SF_Utils._Validate(SubmenuChar, "SubmenuChar", V_STRING) Then GoTo Finally
Set oMenu = Nothing
Try:
' Find and identify the control that triggered the popup menu
@@ -186,5 +188,70 @@ Catch:
GoTo Finally
End Function ' SFWidgets.SF_Register._NewPopupMenu
REM ============================================== END OF SFWidgets.SF_REGISTER
REM -----------------------------------------------------------------------------
Public Function _NewToolbar(Optional ByVal pvArgs As Variant) As Object
''' Create a new instance of the SF_Toolbar class
''' The "Toolbar" service must not be invoked directly in a user script
''' Args:
''' ToolbarDesc: a proto-toolbar object type. See ScriptForge.SF_UI for a detailed description
''' Returns:
''' the instance or Nothing
Dim oToolbar As Object ' Return value
Dim oToolbarDesc As Object ' A proto-toolbar description
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
Set oToolbar = Nothing
Check:
Set oToolbarDesc = pvArgs(0)
Try:
Set oToolbar = New SF_Toolbar
With oToolbar
Set .[Me] = oToolbar
._Initialize(oToolbarDesc)
End With
Finally:
Set _NewToolbar = oToolbar
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_Register._NewToolbar
REM -----------------------------------------------------------------------------
Public Function _NewToolbarButton(Optional ByVal pvArgs As Variant) As Object
''' Create a new instance of the SF_ToolbarButton class
''' The "ToolbarButton" service must not be invoked directly in a user script
''' Args:
''' ToolbarButtonDesc: a proto-toolbarButton object type. See SFWidgets.SF_Toolbar for a detailed description
''' Returns:
''' the instance or Nothing
Dim oToolbarButton As Object ' Return value
Dim oToolbarButtonDesc As Object ' A proto-toolbarbutton description
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
Set oToolbarButton = Nothing
Check:
Set oToolbarButtonDesc = pvArgs(0)
Try:
Set oToolbarButton = New SF_ToolbarButton
With oToolbarButton
Set .[Me] = oToolbarButton
._Initialize(oToolbarButtonDesc)
End With
Finally:
Set _NewToolbarButton = oToolbarButton
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_Register._NewToolbarButton
REM ============================================== END OF SFWIDGETS.SF_REGISTER
</script:module>
\ No newline at end of file
\ No newline at end of file
diff --git a/wizards/source/sfwidgets/SF_Toolbar.xba b/wizards/source/sfwidgets/SF_Toolbar.xba
new file mode 100644
index 0000000..16089e4
--- /dev/null
+++ b/wizards/source/sfwidgets/SF_Toolbar.xba
@@ -0,0 +1,541 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_Toolbar" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
REM === The SFWidgets library is one of the associated libraries. ===
REM === Full documentation is available on https://help.libreoffice.org/ ===
REM =======================================================================================================================
Option Compatible
Option ClassModule
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' SF_Toolbar
''' ==========
''' Hide/show a toolbar related to a component/document.
'''
''' Each component has its own set of toolbars, depending on the component type
''' (Calc, Writer, Basic IDE, ...).
''' In the context of the actual class, a toolbar is presumed defined statically:
''' - either by the application
''' - or by a customization done by the user.
''' The definition of a toolbar can be stored in the application configuration files
''' or in a specific document.
''' Changes made by scripts to toolbars stored in the application are persistent.
''' They are valid for all documents of the same type.
'''
''' Note that the menubar and the statusbar are not considered toolbars in this context.
'''
''' A toolbar consists in a series of graphical controls to trigger actions.
''' The "Toolbar" service gives access to the "ToolbarButton" service to manage
''' the individual buttons belonging to the toolbar.
'''
''' The name of a toolbar is either:
''' - its so-called UIName when it is available,
''' - or the last component of the resource URL: "private:resource/toolbar/the-name-here"
'''
''' Service invocation:
''' The Toolbars() method returns the list of available toolbar names
''' The Toolbars(toolbarname) returns a Toolbar service
''' It is available from
''' - the UI service to access the toolbars of the Basic IDE ("BASICIDE"),
''' the start center ("WELCOMESCREEN") or the active window
''' - the Document, Calc, Writer, Datasheet, FormDocument services to access
''' their respective set of toolbars.
''' Example:
''' Dim oCalc As Object, oToolbar As Object
''' Set oCalc = CreateScriptService("Calc", "myFile.ods")
''' Set oToolbar = oCalc.Toolbars("findbar")
REM ================================================================== EXCEPTIONS
REM ============================================================= PRIVATE MEMBERS
Private [Me] As Object
Private ObjectType As String ' Must be TOOLBAR
Private ServiceName As String
Private _Component As Object ' com.sun.star.lang.XComponent
Private _ResourceURL As String ' Toolbar internal name
Private _UIName As String ' Toolbar external name, may be ""
Private _UIConfigurationManager As Object ' com.sun.star.ui.XUIConfigurationManager
Private _ElementsInfoIndex As Long ' Index of the toolbar in the getElementsInfo(0) array
Private _Storage As Long ' One of the toolbar location constants
Private _LayoutManager As Object ' com.sun.star.comp.framework.LayoutManager
Private _ToolbarButtons As Object ' SF_Dictionary of toolbar buttons
Type _ToolbarButton
Toolbar As Object ' The actual SF_Toolbar object instance
Index As Long ' Entry number in buttons lists
Label As String ' Label (static description)
AccessibleName As String ' Name found in accessible context
Element As Object ' com.sun.star.ui.XUIElement
End Type
REM ============================================================ MODULE CONSTANTS
' Toolbar locations
Private Const cstBUILTINTOOLBAR = 0 ' Standard toolbar
Private Const cstCUSTOMTOOLBAR = 1 ' Toolbar added by user and stored in the LibreOffice application
Private Const cstCUSTOMDOCTOOLBAR = 2 ' Toolbar added by user solely for a single document
REM ====================================================== CONSTRUCTOR/DESTRUCTOR
REM -----------------------------------------------------------------------------
Private Sub Class_Initialize()
Set [Me] = Nothing
ObjectType = "TOOLBAR"
ServiceName = "SFWidgets.Toolbar"
Set _Component = Nothing
_ResourceURL = ""
_UIName = ""
Set _UIConfigurationManager = Nothing
_ElementsInfoIndex = -1
_Storage = 0
Set _LayoutManager = Nothing
Set _ToolbarButtons = Nothing
End Sub ' SFWidgets.SF_Toolbar Constructor
REM -----------------------------------------------------------------------------
Private Sub Class_Terminate()
Call Class_Initialize()
End Sub ' SFWidgets.SF_Toolbar Destructor
REM -----------------------------------------------------------------------------
Public Function Dispose() As Variant
Call Class_Terminate()
Set Dispose = Nothing
End Function ' SFWidgets.SF_Toolbar Explicit Destructor
REM ================================================================== PROPERTIES
REM -----------------------------------------------------------------------------
Property Get BuiltIn() As Boolean
''' Returns True when the toolbar is part of the set of standard toolbars shipped with the application.
''' Example:
''' MsgBox myToolbar.BuiltIn
BuiltIn = _PropertyGet("BuiltIn")
End Property ' SFWidgets.SF_Toolbar.BuiltIn (get)
REM -----------------------------------------------------------------------------
Property Get Docked() As Variant
''' Returns True when the toolbar is active in the window and Docked.
''' Example:
''' MsgBox myToolbar.Docked
Docked = _PropertyGet("Docked")
End Property ' SFWidgets.SF_Toolbar.Docked (get)
REM -----------------------------------------------------------------------------
Property Get HasGlobalScope() As Boolean
''' Returns True when the toolbar is available in all documents of the same type
''' Example:
''' MsgBox myToolbar.HasGlobalScope
HasGlobalScope = _PropertyGet("HasGlobalScope")
End Property ' SFWidgets.SF_Toolbar.HasGlobalScope (get)
REM -----------------------------------------------------------------------------
Property Get Name() As String
''' Returns the name of the toolbar
''' Example:
''' MsgBox myToolbar.Name
Name = _PropertyGet("Name")
End Property ' SFWidgets.SF_Toolbar.Name (get)
REM -----------------------------------------------------------------------------
Property Get ResourceURL() As String
''' Returns True when the toolbar is avaialble in all documents of the same type
''' Example:
''' MsgBox myToolbar.ResourceURL
ResourceURL = _PropertyGet("ResourceURL")
End Property ' SFWidgets.SF_Toolbar.ResourceURL (get)
REM -----------------------------------------------------------------------------
Property Get Visible() As Variant
''' Returns True when the toolbar is active in the window and visible.
''' Example:
''' MsgBox myToolbar.Visible
Visible = _PropertyGet("Visible")
End Property ' SFWidgets.SF_Toolbar.Visible (get)
REM -----------------------------------------------------------------------------
Property Let Visible(ByVal pvVisible As Variant)
''' Sets the visible status of the toolbar.
''' When the toolbar is not yet active i the window, it is first created.
''' Example:
''' myToolbar.Visible = True
_PropertySet("Visible", pvVisible)
End Property ' SFWidgets.SF_Toolbar.Visible (let)
REM -----------------------------------------------------------------------------
Property Get XUIElement() As Variant
''' Returns the com.sun.star.ui.XUIElement UNO object corresponding with the toolbar
''' Example:
''' MsgBox myToolbar.XUIElement
XUIElement = _PropertyGet("XUIElement")
End Property ' SFWidgets.SF_Toolbar.XUIElement (get)
REM ===================================================================== METHODS
REM -----------------------------------------------------------------------------
Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
''' Return the actual value of the given property
''' Args:
''' PropertyName: the name of the property as a string
''' Returns:
''' The actual value of the property
''' If the property does not exist, returns Null
''' Exceptions:
''' see the exceptions of the individual properties
''' Examples:
''' myToolbar.GetProperty("Visible")
Const cstThisSub = "SFWidgets.Toolbar.GetProperty"
Const cstSubArgs = ""
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
GetProperty = Null
Check:
If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If Not ScriptForge.SF_Utils._Validate(PropertyName, "PropertyName", V_STRING, Properties()) Then GoTo Catch
End If
Try:
GetProperty = _PropertyGet(PropertyName)
Finally:
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_Toolbar.GetProperty
REM -----------------------------------------------------------------------------
Public Function Methods() As Variant
''' Return the list of public methods of the Model service as an array
Methods = Array( _
"ToolbarButtons" _
)
End Function ' SFWidgets.SF_Toolbar.Methods
REM -----------------------------------------------------------------------------
Public Function Properties() As Variant
''' Return the list or properties of the Timer a.AddItem("B>B1")class as an array
Properties = Array( _
"BuiltIn" _
, "Docked" _
, "HasGlobalScope" _
, "Name" _
, "ResourceURL" _
, "Visible" _
, "XUIElement" _
)
End Function ' SFWidgets.SF_Toolbar.Properties
REM -----------------------------------------------------------------------------
Public Function SetProperty(Optional ByVal PropertyName As Variant _
, Optional ByRef Value As Variant _
) As Boolean
''' Set a new value to the given property
''' Args:
''' PropertyName: the name of the property as a string
''' Value: its new value
''' Exceptions
''' ARGUMENTERROR The property does not exist
Const cstThisSub = "SFWidgets.Toolbar.SetProperty"
Const cstSubArgs = "PropertyName, Value"
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
SetProperty = False
Check:
If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If Not SF_Utils._Validate(PropertyName, "PropertyName", V_STRING, Properties()) Then GoTo Catch
End If
Try:
SetProperty = _PropertySet(PropertyName, Value)
Finally:
SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_Toolbar.SetProperty
REM -----------------------------------------------------------------------------
Public Function ToolbarButtons(Optional ByVal ButtonName As Variant) As Variant
''' Returns either a list of the available toolbar button names in the actual toolbar
''' or a ToolbarButton object instance.
''' Args:
''' ButtonName: the usual name of one of the available buttons in the actual toolbar
''' Returns:
''' A zero-based array of button names when the argument is absent,
''' or a new ToolbarButton object instance.
''' An inactive toolbar has no buttons => the actual method forces the toolbar to be made visible first.
Const cstThisSub = "SFWidgets.Toolbar.ToolbarButtons"
Const cstSubArgs = "[ButtonName=""""]"
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
Check:
If IsMissing(ButtonName) Or IsEmpty(ButtonName) Then ButtonName = ""
' Store button descriptions in cache
_CollectAllButtons()
If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If VarType(ButtonName) = V_STRING Then
If Len(ButtonName) > 0 Then
If Not ScriptForge.SF_Utils._Validate(ButtonName, "ButtonName", V_STRING, _ToolbarButtons.Keys()) Then GoTo Finally
End If
Else
If Not ScriptForge.SF_Utils._Validate(ButtonName, "ButtonName", V_STRING) Then GoTo Finally ' Manage here the VarType error
End If
End If
Try:
If Len(ButtonName) = 0 Then
ToolbarButtons = _ToolbarButtons.Keys()
Else
ToolbarButtons = CreateScriptService("SFWidgets.ToolbarButton", _ToolbarButtons.Item(ButtonName))
End If
Finally:
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_Toolbar.ToolbarButtons
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
Private Sub _CollectAllButtons()
''' Stores a SF_Dictionary object instance, with
''' - key = name of the button
''' - item = a _ButtonDesc object type
''' into _ToolbarButtons, a cache for all buttons.
''' The toolbar is made visible before collecting the buttons.
'''
''' The name of the buttons is derived either from:
''' - the Label property of the static toolbar and toolbar buttons definitions
''' - or the AccessibleName property of the AccessibleContext of the button
''' whichever is found first.
''' Separators are skipped.
''' If there are homonyms (>= 2 buttons having the same name), only the 1st one is retained.
Dim oElement As Object ' com.sun.star.ui.XUIElement
Dim oSettings As Object ' com.sun.star.container.XIndexAccess
Dim vProperties() As Variant ' Array of property alues
Dim iType As Integer ' Separators have type = 1, others have Type = 0
Dim oAccessible As Object ' com.sun.star.accessibility.XAccessible
Dim sLabel As String ' Label in static description
Dim sAccessibleName As String ' Name in AccessibleContext
Dim sButtonName As String ' Key part in dictionary entry
Dim oButton As Object ' Item part in dictionary entry
Dim i As Long
On Local Error GoTo Catch
If Not IsNull(_ToolbarButtons) Then GoTo Finally ' Do not redo the job if already done
Try:
' Force the visibility of the toolbar
Visible = True
Set _ToolbarButtons = ScriptForge.SF_Services.CreateScriptService("ScriptForge.Dictionary")
Set oElement = _LayoutManager.getElement(_ResourceURL)
Set oSettings = oElement.getSettings(True)
With oSettings
For i = 0 To .Count - 1
vProperties = .getByIndex(i)
iType = ScriptForge.SF_Utils._GetPropertyValue(vProperties, "Type")
If iType = 0 Then ' Usual button
sLabel = ScriptForge.SF_Utils._GetPropertyValue(vProperties, "Label")
If Len(sLabel) = 0 Then
Set oAccessible = oElement.RealInterface.AccessibleContext.getAccessibleChild(i)
sAccessibleName = oAccessible.AccessibleName
Else
sAccessibleName = ""
End If
' Store in dictionary
sButtonName = sLabel & sAccessibleName ' At least 1 of them is blank
If Len(sButtonName) > 0 Then
Set oButton = New _ToolbarButton
With oButton
Set .Toolbar = [Me]
.Index = i
.Label = sLabel
.AccessibleName = sAccessibleName
Set .Element = oElement
End With
With _ToolbarButtons
If Not .Exists(sButtonName) Then .Add(sButtonName, oButton)
End With
End If
End If
Next i
End With
Finally:
Exit Sub
Catch:
' _ToolbarButtons is left unchanged
GoTo Finally
End Sub ' SFWidgets.SF_Toolbar._CollectAllButtons
REM -----------------------------------------------------------------------------
Public Sub _Initialize(ByRef poToolbar As Object)
''' Complete the object creation process:
''' - Initialize the toolbar descriptioner use
''' Args:
''' poToolbar: the toolbar description as a ui._Toolbr object
Try:
' Store the static description
With poToolbar
_Component = .Component
_ResourceURL = .ResourceURL
_UIName = .UIName
_UIConfigurationManager = .UIConfigurationManager
_ElementsInfoIndex = .ElementsInfoIndex
_Storage = .Storage
End With
' Complement
If Len(_UIName) = 0 Then _UIName = Split(_ResourceURL, "/")(2)
Set _LayoutManager = _Component.CurrentController.Frame.LayoutManager
Finally:
Exit Sub
End Sub ' SFWidgets.SF_Toolbar._Initialize
REM -----------------------------------------------------------------------------
Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
''' Return the value of the named property
''' Args:
''' psProperty: the name of the property
Dim vGet As Variant ' Return value
Dim oElement As Object ' com.sun.star.ui.XUIElement
Dim cstThisSub As String
Const cstSubArgs = ""
cstThisSub = "SFWidgets.Toolbar.get" & psProperty
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
_PropertyGet = Null
Select Case UCase(psProperty)
Case UCase("BuiltIn")
_PropertyGet = ( _Storage = cstBUILTINTOOLBAR )
Case UCase("Docked")
Set oElement = _LayoutManager.getElement(_ResourceURL)
If Not IsNull(oElement) Then _PropertyGet = _LayoutManager.isElementDocked(_ResourceURL) Else _PropertyGet = False
Case UCase("HasGlobalScope")
_PropertyGet = ( _Storage = cstBUILTINTOOLBAR Or _Storage = cstCUSTOMTOOLBAR )
Case UCase("Name")
_PropertyGet = _UIName
Case UCase("ResourceURL")
_PropertyGet = _ResourceURL
Case UCase("Visible")
Set oElement = _LayoutManager.getElement(_ResourceURL)
If Not IsNull(oElement) Then _PropertyGet = _LayoutManager.isElementVisible(_ResourceURL) Else _PropertyGet = False
Case UCase("XUIElement")
_PropertyGet = _LayoutManager.getElement(_ResourceURL)
Case Else
_PropertyGet = Null
End Select
Finally:
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_Toolbar._PropertyGet
REM -----------------------------------------------------------------------------
Private Function _PropertySet(Optional ByVal psProperty As String _
, Optional ByVal pvValue As Variant _
) As Boolean
''' Set the new value of the named property
''' Args:
''' psProperty: the name of the property
''' pvValue: the new value of the given property
Dim bSet As Boolean ' Return value
Dim oElement As Object ' com.sun.star.ui.XUIElement
Dim bVisible As Boolean ' Actual Visible state
Dim cstThisSub As String
Const cstSubArgs = "Value"
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
bSet = False
cstThisSub = "SFWidgets.Toolbar.set" & psProperty
ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
bSet = True
Select Case UCase(psProperty)
Case UCase("Visible")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Value", ScriptForge.V_BOOLEAN) Then GoTo Catch
With _LayoutManager
Set oElement = .getElement(_ResourceURL)
If Not IsNull(oElement) Then bVisible = .isElementVisible(_ResourceURL) Else bVisible = False
' If there is no change, do nothing
If Not bVisible = pvValue Then
If IsNull(oElement) And pvValue Then .createElement(_ResourceURL)
If pvValue Then .showElement(_ResourceURL) Else .hideElement(_ResourceURL)
End If
End With
Case Else
bSet = False
End Select
Finally:
_PropertySet = bSet
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
bSet = False
GoTo Finally
End Function ' SFWidgets.SF_Toolbar._PropertySet
REM -----------------------------------------------------------------------------
Private Function _Repr() As String
''' Convert the SF_Toolbar instance to a readable string, typically for debugging purposes (DebugPrint ...)
''' Args:
''' Return:
''' "[Toolbar]: Name, Type (dialogname)
_Repr = "[Toolbar]: " & _UIName & " - " & _ResourceURL
End Function ' SFWidgets.SF_Toolbar._Repr
REM ============================================ END OF SFWIDGETS.SF_TOOLBAR
</script:module>
\ No newline at end of file
diff --git a/wizards/source/sfwidgets/SF_ToolbarButton.xba b/wizards/source/sfwidgets/SF_ToolbarButton.xba
new file mode 100644
index 0000000..58c594f
--- /dev/null
+++ b/wizards/source/sfwidgets/SF_ToolbarButton.xba
@@ -0,0 +1,565 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_ToolbarButton" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
REM === The SFWidgets library is one of the associated libraries. ===
REM === Full documentation is available on https://help.libreoffice.org/ ===
REM =======================================================================================================================
Option Compatible
Option ClassModule
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' SF_ToolbarButton
''' ================
''' Hide/show toolbar elements, read and update their current behaviour..
'''
''' A toolbar consists in a series of graphical controls to trigger actions.
''' The "Toolbar" service gives access to the "ToolbarButton" service to manage
''' the individual buttons belonging to the toolbar.
'''
''' Changes made by scripts to buttons belonging to toolbars stored in the application
''' are persistent. They are valid for all documents of the same type.
'''
''' The name of a toolbar button is either:
''' - in custom toolbars, a predefined name given at its creation,
''' - in standard toolbars, a localized name as read in the Tools + Customize ... dialog box
'''
''' Service invocation:
''' It is available only from an active Toolbar service.
''' Example:
''' Dim oCalc As Object, oToolbar As Object, oToolbarButton As Object
''' Set oCalc = CreateScriptService("Calc", "myFile.ods")
''' Set oToolbar = oCalc.Toolbars("findbar")
''' Set oToolbarButton = oToolbar.ToolbarButtons("Find Next")
REM ================================================================== EXCEPTIONS
REM ============================================================= PRIVATE MEMBERS
Private [Me] As Object
Private ObjectType As String ' Must be TOOLBARBUTTON
Private ServiceName As String
Private [_Parent] As Object ' SF_Toolbar instance owning the button
Private _Index As Long ' Entry number in buttons lists
Private _Label As String ' Label (static description)
Private _AccessibleName As String ' Name found in accessible context
Private _Element As Object ' com.sun.star.ui.XUIElement
Private _CommandURL As String ' Uno command or script
Private _Height As Long ' Height may be cached
Private _Width As Long ' Width may be cached
REM ============================================================ MODULE CONSTANTS
REM ====================================================== CONSTRUCTOR/DESTRUCTOR
REM -----------------------------------------------------------------------------
Private Sub Class_Initialize()
Set [Me] = Nothing
ObjectType = "TOOLBARBUTTON"
ServiceName = "SFWidgets.ToolbarButton"
Set [_Parent] = Nothing
_Index = -1
_Label = ""
_AccessibleName = ""
Set _Element = Nothing
_CommandURL = ""
_Height = 0
_Width = 0
End Sub ' SFWidgets.SF_ToolbarButton Constructor
REM -----------------------------------------------------------------------------
Private Sub Class_Terminate()
Call Class_Initialize()
End Sub ' SFWidgets.SF_ToolbarButton Destructor
REM -----------------------------------------------------------------------------
Public Function Dispose() As Variant
Call Class_Terminate()
Set Dispose = Nothing
End Function ' SFWidgets.SF_ToolbarButton Explicit Destructor
REM ================================================================== PROPERTIES
REM -----------------------------------------------------------------------------
Property Get Caption() As String
''' Returns the name of the button
''' Example:
''' MsgBox myButton.Caption
Caption = _PropertyGet("Caption")
End Property ' SFWidgets.SF_ToolbarButton.Caption (get)
REM -----------------------------------------------------------------------------
Property Get Height() As Long
''' Returns the height in pixels of the button
''' Example:
''' MsgBox myButton.Height
Height = _PropertyGet("Height")
End Property ' SFWidgets.SF_ToolbarButton.Height (get)
REM -----------------------------------------------------------------------------
Property Get Index() As Long
''' Returns the index of the button
''' - in the Settings (com.sun.star.container.XIndexAccess) of the parent toolbar
''' - in the AccessibleContext (com.sun.star.comp.toolkit.AccessibleToolBox) of the parent toolbar
''' Both should be identical: the range number of the button in the toolbar, hidden buttons and separators included.
''' Example:
''' MsgBox myButton.Index
Index = _PropertyGet("Index")
End Property ' SFWidgets.SF_ToolbarButton.Index (get)
REM -----------------------------------------------------------------------------
Property Get OnClick() As Variant
''' Returns the UNO command or the script (expressed in the scripting framework_URI notation) run when the button is clicked
''' Read https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification
''' Note that no event object is passed to the script.
''' Example:
''' MsgBox myButton.OnClick
OnClick = _PropertyGet("OnClick")
End Property ' SFWidgets.SF_ToolbarButton.OnClick (get)
REM -----------------------------------------------------------------------------
Property Let OnClick(ByVal pvOnClick As Variant)
''' Sets the UNO command or the script (expressed in the scripting framework_URI notation) to trigger when the button is clicked
''' It is highly recommended to not modify standard buttons.
''' Example:
''' myButton.OnClick = ".uno:About"
''' myButton.OnClick = "vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&location=application"
_PropertySet("OnClick", pvOnClick)
End Property ' SFWidgets.SF_ToolbarButton.OnClick (let)
REM -----------------------------------------------------------------------------
Property Get Parent() As Object
''' Returns the parent toolbar as a SF_Toolbar object instance
''' Example:
''' Set oToolbar = myButton.Parent
Set Parent = _PropertyGet("Parent")
End Property ' SFWidgets.SF_ToolbarButton.Parent (get)
REM -----------------------------------------------------------------------------
Property Get TipText() As Variant
''' Specifies the text that appears in a screentip when you hold the mouse pointer over the button
''' Example:
''' MsgBox myButton.TipText
TipText = _PropertyGet("TipText")
End Property ' SFWidgets.SF_ToolbarButton.TipText (get)
REM -----------------------------------------------------------------------------
Property Let TipText(ByVal pvTipText As Variant)
''' Sets the screentip associated with the actual toolbar button
''' It is highly recommended to not modify standard buttons.
''' Example:
''' myButton.TipText = "Click here"
_PropertySet("TipText", pvTipText)
End Property ' SFWidgets.SF_ToolbarButton.TipText (let)
REM -----------------------------------------------------------------------------
Property Get Visible() As Variant
''' Returns True when the toolbar button is visible. Otherwise False.
''' Example:
''' MsgBox myButton.Visible
Visible = _PropertyGet("Visible")
End Property ' SFWidgets.SF_ToolbarButton.Visible (get)
REM -----------------------------------------------------------------------------
Property Let Visible(ByVal pvVisible As Variant)
''' Sets the visible status of the toolbar button.
''' Example:
''' myButton.Visible = True
_PropertySet("Visible", pvVisible)
End Property ' SFWidgets.SF_ToolbarButton.Visible (let)
REM -----------------------------------------------------------------------------
Property Get Width() As Long
''' Returns the width in pixels of the button
''' Example:
''' MsgBox myButton.Width
Width = _PropertyGet("Width")
End Property ' SFWidgets.SF_ToolbarButton.Width (get)
REM -----------------------------------------------------------------------------
Property Get X() As Long
''' Returns the X (horizontal) coordinate in pixels of the top-left corner of the button
''' Example:
''' MsgBox myButton.X
X = _PropertyGet("X")
End Property ' SFWidgets.SF_ToolbarButton.X (get)
REM -----------------------------------------------------------------------------
Property Get Y() As Long
''' Returns the Y (vertical) coordinate in pixels of the top-left corner of the button
''' Example:
''' MsgBox myButton.Y
Y = _PropertyGet("Y")
End Property ' SFWidgets.SF_ToolbarButton.Y (get)
REM ===================================================================== METHODS
REM -----------------------------------------------------------------------------
Public Function Execute() As Variant
''' Execute the command stored in the toolbar button.
''' The command can be a UNO command or a Basic/Python script (expressed in the scripting framework_URI notation)
''' Read https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification
''' No argument is passed to the script to execute.
''' Args:
''' Returns:
''' The output of the script or Null
''' Examples:
''' result = myButton.Execute()
Dim vResult As Variant ' Return value
Dim sCommand As String ' Command associated with button
Dim oFrame As Object ' com.sun.star.comp.framework.Frame
Dim oDispatcher As Object ' com.sun.star.frame.DispatchHelper
Dim vScript As Variant ' Split command in script/argument
Dim oSession As Object : Set oSession = ScriptForge.SF_Services.CreateScriptService("ScriptForge.Session")
Dim oArgs() As new com.sun.star.beans.PropertyValue
Const cstUnoPrefix = ".uno:"
Const cstThisSub = "SFWidgets.ToolbarButton.Execute"
Const cstSubArgs = ""
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
vResult = Null
Check:
ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
Try:
sCommand = GetProperty("OnClick")
If Len(sCommand) > 0 Then
' A button has been clicked necessarily in the current window (Document) or one of its subcomponents (FormDocument)
Set oFrame = StarDesktop.ActiveFrame
If oFrame.Frames.Count > 0 Then Set oFrame = oFrame.getActiveFrame()
' Command or script ?
If ScriptForge.SF_String.StartsWith(sCommand, cstUnoPrefix) Then
' Execute uno command
Set oDispatcher = ScriptForge.SF_Utils._GetUNOService("DispatchHelper")
oDispatcher.executeDispatch(oFrame, sCommand, "", 0, oArgs())
oFrame.activate()
Else
' Execute script
vResult = oSession._ExecuteScript(sCommand)
End If
End If
Finally:
Execute = vResult
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_ToolbarButton.Execute
REM -----------------------------------------------------------------------------
Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
''' Return the actual value of the given property
''' Args:
''' PropertyName: the name of the property as a string
''' Returns:
''' The actual value of the property
''' If the property does not exist, returns Null
''' Exceptions:
''' see the exceptions of the individual properties
''' Examples:
''' myToolbar.GetProperty("Visible")
Const cstThisSub = "SFWidgets.ToolbarButton.GetProperty"
Const cstSubArgs = ""
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
GetProperty = Null
Check:
If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If Not ScriptForge.SF_Utils._Validate(PropertyName, "PropertyName", V_STRING, Properties()) Then GoTo Catch
End If
Try:
GetProperty = _PropertyGet(PropertyName)
Finally:
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_ToolbarButton.GetProperty
REM -----------------------------------------------------------------------------
Public Function Methods() As Variant
''' Return the list of public methods of the Model service as an array
Methods = Array( _
"Execute" _
)
End Function ' SFWidgets.SF_ToolbarButton.Methods
REM -----------------------------------------------------------------------------
Public Function Properties() As Variant
''' Return the list or properties of the Timer a.AddItem("B>B1")class as an array
Properties = Array( _
"Caption" _
, "Height" _
, "Index" _
, "OnClick" _
, "Parent" _
, "TipText" _
, "Visible" _
, "Width" _
, "X" _
, "Y" _
)
End Function ' SFWidgets.SF_ToolbarButton.Properties
REM -----------------------------------------------------------------------------
Public Function SetProperty(Optional ByVal PropertyName As Variant _
, Optional ByRef Value As Variant _
) As Boolean
''' Set a new value to the given property
''' Args:
''' PropertyName: the name of the property as a string
''' Value: its new value
''' Exceptions
''' ARGUMENTERROR The property does not exist
Const cstThisSub = "SFWidgets.ToolbarButton.SetProperty"
Const cstSubArgs = "PropertyName, Value"
If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
SetProperty = False
Check:
If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
If Not SF_Utils._Validate(PropertyName, "PropertyName", V_STRING, Properties()) Then GoTo Catch
End If
Try:
SetProperty = _PropertySet(PropertyName, Value)
Finally:
SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_ToolbarButton.SetProperty
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------
Private Function _GetPosition() As Object
''' Determine the position of the top-left corner of the actual button.
''' Returns:
''' a com.sun.star.awt.Rectangle structure
Dim oElement As Object ' com.sun.star.ui.XUIElement
Dim oAccessible As Object ' com.sun.star.comp.toolkit.AccessibleToolBoxItem
Dim oAccessibleButton As Object ' com.sun.star.comp.toolkit.AccessibleToolBoxItem
Dim oAccessibleParent As Object ' com.sun.star.comp.toolkit.AccessibleToolBoxItem
Dim oRect As Object ' Return value As com.sun.star.awt.Rectangle
Try:
Set oElement = _Element.GetSettings(True).getByIndex(_Index)
Set oRect = CreateUnoStruct("com.sun.star.awt.Rectangle")
If ScriptForge.SF_Utils._GetPropertyValue(oElement, "IsVisible") Then
Set oAccessible = _Element.getRealInterface().getAccessibleContext() ' Toolbar level
Set oAccessibleParent = oAccessible.getAccessibleParent() ' Window level
Set oAccessibleButton = oAccessible.getAccessibleChild(_Index) ' Toolbar button level
' The X and Y coordinates are always computed correctly when the toolbar is docked.
' When the toolbar is floating, the Y ordinate may be overestimated with the height of
' the tabbed bar or similar. However no mean has been found to get that height via code.
With oRect
.X = oAccessible.Location.X + oAccessibleButton.Location.X + oAccessibleParent.PosSize.X
.Y = oAccessible.Location.Y + oAccessibleButton.Location.Y + oAccessibleParent.PosSize.Y
.Height = oAccessibleButton.Size.Height
.Width = oAccessibleButton.Size.Width
End With
Else
With oRect
.X = -1 : .Y = -1 : .Height = 0 : .Width = 0
End With
End If
Finally:
Set _GetPosition = oRect
Exit Function
End Function ' SFWidgets.SF_ToolbarButton._GetPosition
REM -----------------------------------------------------------------------------
Public Sub _Initialize(ByRef poToolbarButton As Object)
''' Complete the object creation process:
''' - Initialize the toolbar descriptioner use
''' Args:
''' poToolbarButton: the toolbar description as a ui._Toolbr object
Try:
' Store the static description
With poToolbarButton
Set [_Parent] = .Toolbar
_Index = .Index
_Label = .Label
_AccessibleName = .AccessibleName
Set _Element = .Element
End With
' Complement
_CommandURL = ScriptForge.SF_Utils._GetPropertyValue(_Element.getSettings(True).getByIndex(_Index), "CommandURL")
Finally:
Exit Sub
End Sub ' SFWidgets.SF_ToolbarButton._Initialize
REM -----------------------------------------------------------------------------
Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
''' Return the value of the named property
''' Args:
''' psProperty: the name of the property
Dim vGet As Variant ' Return value
Dim sTooltip As String ' ToolTip text
Dim oElement As Object ' com.sun.star.ui.XUIElement
Dim cstThisSub As String
Const cstSubArgs = ""
cstThisSub = "SFWidgets.ToolbarButton.get" & psProperty
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
_PropertyGet = Null
Select Case UCase(psProperty)
Case UCase("Caption")
_PropertyGet = Iif(Len(_Label) > 0, _Label, _AccessibleName)
Case UCase("Height")
If _Height > 0 Then _PropertyGet = _Height else _PropertyGet = _GetPosition().Height
Case UCase("Index")
_PropertyGet = _Index
Case UCase("OnClick")
Set oElement = _Element.GetSettings(True).getByIndex(_Index)
_PropertyGet = ScriptForge.SF_Utils._GetPropertyValue(oElement, "CommandURL")
Case UCase("Parent")
Set _PropertyGet = [_Parent]
Case UCase("TipText")
Set oElement = _Element.GetSettings(True).getByIndex(_Index)
sTooltip = ScriptForge.SF_Utils._GetPropertyValue(oElement, "Tooltip")
If Len(sTooltip) > 0 Then _PropertyGet = sTooltip Else _PropertyGet = Iif(Len(_Label) > 0, _Label, _AccessibleName)
Case UCase("Visible")
Set oElement = _Element.GetSettings(True).getByIndex(_Index)
_PropertyGet = ScriptForge.SF_Utils._GetPropertyValue(oElement, "IsVisible")
Case UCase("Width")
If _Width > 0 Then _PropertyGet = _Width else _PropertyGet = _GetPosition().Width
Case UCase("X")
_PropertyGet = _GetPosition().X
Case UCase("Y")
_PropertyGet = _GetPosition().Y
Case Else
_PropertyGet = Null
End Select
Finally:
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
GoTo Finally
End Function ' SFWidgets.SF_ToolbarButton._PropertyGet
REM -----------------------------------------------------------------------------
Private Function _PropertySet(Optional ByVal psProperty As String _
, Optional ByVal pvValue As Variant _
) As Boolean
''' Set the new value of the named property
''' Args:
''' psProperty: the name of the property
''' pvValue: the new value of the given property
Dim bSet As Boolean ' Return value
Dim oSettings As Object ' com.sun.star.container.XIndexAccess
Dim vProperties As Variant ' Array of PropertyValues
Dim bVisible As Boolean ' Actual Visible state
Dim cstThisSub As String
Const cstSubArgs = "Value"
Check:
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
bSet = False
cstThisSub = "SFWidgets.ToolbarButton.set" & psProperty
ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
Try:
bSet = True
Set oSettings = _Element.getSettings(True)
vProperties = oSettings.getByIndex(_Index)
Select Case UCase(psProperty)
Case UCase("OnClick")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Value", V_STRING) Then GoTo Catch
ScriptForge.SF_Utils._SetPropertyValue(vProperties, "CommandURL", pvValue)
Case UCase("TipText")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Value", V_STRING) Then GoTo Catch
ScriptForge.SF_Utils._SetPropertyValue(vProperties, "Tooltip", pvValue)
Case UCase("Visible")
If Not ScriptForge.SF_Utils._Validate(pvValue, "Value", ScriptForge.V_BOOLEAN) Then GoTo Catch
ScriptForge.SF_Utils._SetPropertyValue(vProperties, "IsVisible", pvValue)
Case Else
bSet = False
End Select
oSettings.replaceByIndex(_Index, vProperties)
_Element.setSettings(oSettings)
Finally:
_PropertySet = bSet
ScriptForge.SF_Utils._ExitFunction(cstThisSub)
Exit Function
Catch:
bSet = False
GoTo Finally
End Function ' SFWidgets.SF_ToolbarButton._PropertySet
REM -----------------------------------------------------------------------------
Private Function _Repr() As String
''' Convert the SF_ToolbarButton instance to a readable string, typically for debugging purposes (DebugPrint ...)
''' Args:
''' Return:
''' "[Toolbar]: Name, Type (dialogname)
_Repr = "[ToolbarButton]: " & Iif(Len(_Label) > 0, _Label, _AccessibleName) & " - " & _CommandURL
End Function ' SFWidgets.SF_ToolbarButton._Repr
REM ============================================ END OF SFWIDGETS.SF_TOOLBARBUTTON
</script:module>
\ No newline at end of file
diff --git a/wizards/source/sfwidgets/script.xlb b/wizards/source/sfwidgets/script.xlb
index 40e9f4c..06975e6 100644
--- a/wizards/source/sfwidgets/script.xlb
+++ b/wizards/source/sfwidgets/script.xlb
@@ -6,4 +6,6 @@
<library:element library:name="SF_PopupMenu"/>
<library:element library:name="SF_Menu"/>
<library:element library:name="SF_MenuListener"/>
<library:element library:name="SF_Toolbar"/>
<library:element library:name="SF_ToolbarButton"/>
</library:library>
\ No newline at end of file
\ No newline at end of file