summaryrefslogtreecommitdiff
path: root/wizards/source/sfdatabases
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2023-02-27 18:04:46 +0100
committerJean-Pierre Ledure <jp@ledure.be>2023-02-28 15:31:12 +0000
commitf36265ed0e0229dc9dacd18cc16867b22d655dbe (patch)
tree32d28a8c34d75d6db70e8d0e914f6e75dbe6bf0a /wizards/source/sfdatabases
parentf633d07a0b6993c8c13e63fa9d5259f0161cd6b2 (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.xba48
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 &apos; com.sun.star.awt.XControlModel - com.su
Private _ControlView As Object &apos; com.sun.star.awt.XControl - org.openoffice.comp.dbu.ODatasourceBrowser
Private _ColumnHeaders As Variant &apos; List of column headers as an array of strings
+&apos; Cache for static toolbar descriptions
+Private _Toolbars As Object &apos; 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 &apos; SFDatabases.SF_Datasheet Constructor
REM -----------------------------------------------------------------------------
@@ -682,6 +686,50 @@ Catch:
GoTo Finally
End Function &apos; SFDatabases.SF_Datasheet.SetProperty
+REM -----------------------------------------------------------------------------
+Public Function Toolbars(Optional ByVal ToolbarName As Variant) As Variant
+&apos;&apos;&apos; Returns either a list of the available toolbar names in the actual document
+&apos;&apos;&apos; or a Toolbar object instance.
+&apos;&apos;&apos; [Function identical with SFDocuments.SF_Document.Toolbars()]
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; ToolbarName: the usual name of one of the available toolbars
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; A zero-based array of toolbar names when the argument is absent,
+&apos;&apos;&apos; or a new Toolbar object instance from the SF_Widgets library.
+
+Const cstThisSub = &quot;SFDatabases.Datasheet.Toolbars&quot;
+Const cstSubArgs = &quot;[ToolbarName=&quot;&quot;&quot;&quot;]&quot;
+
+ If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
+
+Check:
+ If IsMissing(ToolbarName) Or IsEmpty(ToolbarName) Then ToolbarName = &quot;&quot;
+ 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) &gt; 0 Then
+ If Not ScriptForge.SF_Utils._Validate(ToolbarName, &quot;ToolbarName&quot;, V_STRING, _Toolbars.Keys()) Then GoTo Finally
+ End If
+ Else
+ If Not ScriptForge.SF_Utils._Validate(ToolbarName, &quot;ToolbarName&quot;, V_STRING) Then GoTo Finally &apos; Manage here the VarType error
+ End If
+ End If
+
+Try:
+ If Len(ToolbarName) = 0 Then
+ Toolbars = _Toolbars.Keys()
+ Else
+ Toolbars = CreateScriptService(&quot;SFWidgets.Toolbar&quot;, _Toolbars.Item(ToolbarName))
+ End If
+
+Finally:
+ ScriptForge.SF_Utils._ExitFunction(cstThisSub)
+ Exit Function
+Catch:
+ GoTo Finally
+End Function &apos; SF_Databases.SF_Datasheet.Toolbars
+
REM =========================================================== PRIVATE FUNCTIONS
REM -----------------------------------------------------------------------------