diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2023-02-27 18:04:46 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2023-02-28 15:31:12 +0000 |
commit | f36265ed0e0229dc9dacd18cc16867b22d655dbe (patch) | |
tree | 32d28a8c34d75d6db70e8d0e914f6e75dbe6bf0a /wizards/source/sfdatabases | |
parent | f633d07a0b6993c8c13e63fa9d5259f0161cd6b2 (diff) |
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
Diffstat (limited to 'wizards/source/sfdatabases')
-rw-r--r-- | wizards/source/sfdatabases/SF_Datasheet.xba | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/wizards/source/sfdatabases/SF_Datasheet.xba b/wizards/source/sfdatabases/SF_Datasheet.xba index 12b7f9e4f9c0..775984f60d6f 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 ----------------------------------------------------------------------------- |