docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / wizards / source / sfwidgets / SF_Toolbar.xba
blob1f8329ed14238da57e716dffd6ada0193f7133e6
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_Toolbar" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
4 REM === The ScriptForge library and its associated libraries are part of the LibreOffice project. ===
5 REM === The SFWidgets library is one of the associated libraries. ===
6 REM === Full documentation is available on https://help.libreoffice.org/ ===
7 REM =======================================================================================================================
9 Option Compatible
10 Option ClassModule
12 Option Explicit
14 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
15 &apos;&apos;&apos; SF_Toolbar
16 &apos;&apos;&apos; ==========
17 &apos;&apos;&apos; Hide/show a toolbar related to a component/document.
18 &apos;&apos;&apos;
19 &apos;&apos;&apos; Each component has its own set of toolbars, depending on the component type
20 &apos;&apos;&apos; (Calc, Writer, Basic IDE, ...).
21 &apos;&apos;&apos; In the context of the actual class, a toolbar is presumed defined statically:
22 &apos;&apos;&apos; - either by the application
23 &apos;&apos;&apos; - or by a customization done by the user.
24 &apos;&apos;&apos; The definition of a toolbar can be stored in the application configuration files
25 &apos;&apos;&apos; or in a specific document.
26 &apos;&apos;&apos; Changes made by scripts to toolbars stored in the application are persistent.
27 &apos;&apos;&apos; They are valid for all documents of the same type.
28 &apos;&apos;&apos;
29 &apos;&apos;&apos; Note that the menubar and the statusbar are not considered toolbars in this context.
30 &apos;&apos;&apos;
31 &apos;&apos;&apos; A toolbar consists in a series of graphical controls to trigger actions.
32 &apos;&apos;&apos; The &quot;Toolbar&quot; service gives access to the &quot;ToolbarButton&quot; service to manage
33 &apos;&apos;&apos; the individual buttons belonging to the toolbar.
34 &apos;&apos;&apos;
35 &apos;&apos;&apos; The name of a toolbar is either:
36 &apos;&apos;&apos; - its so-called UIName when it is available,
37 &apos;&apos;&apos; - or the last component of the resource URL: &quot;private:resource/toolbar/the-name-here&quot;
38 &apos;&apos;&apos;
39 &apos;&apos;&apos; Service invocation:
40 &apos;&apos;&apos; The Toolbars() method returns the list of available toolbar names
41 &apos;&apos;&apos; The Toolbars(toolbarname) returns a Toolbar service
42 &apos;&apos;&apos; It is available from
43 &apos;&apos;&apos; - the UI service to access the toolbars of the Basic IDE (&quot;BASICIDE&quot;),
44 &apos;&apos;&apos; the start center (&quot;WELCOMESCREEN&quot;) or the active window
45 &apos;&apos;&apos; - the Document, Calc, Writer, Datasheet, FormDocument services to access
46 &apos;&apos;&apos; their respective set of toolbars.
47 &apos;&apos;&apos; Example:
48 &apos;&apos;&apos; Dim oCalc As Object, oToolbar As Object
49 &apos;&apos;&apos; Set oCalc = CreateScriptService(&quot;Calc&quot;, &quot;myFile.ods&quot;)
50 &apos;&apos;&apos; Set oToolbar = oCalc.Toolbars(&quot;findbar&quot;)
51 &apos;&apos;&apos;
52 &apos;&apos;&apos;
53 &apos;&apos;&apos; Detailed user documentation:
54 &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/toolbar.html?DbPAR=BASIC
55 &apos;&apos;&apos;
56 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
58 REM ================================================================== EXCEPTIONS
60 REM ============================================================= PRIVATE MEMBERS
62 Private [Me] As Object
63 Private ObjectType As String &apos; Must be TOOLBAR
64 Private ServiceName As String
66 Private _Component As Object &apos; com.sun.star.lang.XComponent
67 Private _ResourceURL As String &apos; Toolbar internal name
68 Private _UIName As String &apos; Toolbar external name, may be &quot;&quot;
69 Private _UIConfigurationManager As Object &apos; com.sun.star.ui.XUIConfigurationManager
70 Private _ElementsInfoIndex As Long &apos; Index of the toolbar in the getElementsInfo(0) array
71 Private _Storage As Long &apos; One of the toolbar location constants
72 Private _LayoutManager As Object &apos; com.sun.star.comp.framework.LayoutManager
74 Private _ToolbarButtons As Object &apos; SF_Dictionary of toolbar buttons
76 Type _ToolbarButton
77 Toolbar As Object &apos; The actual SF_Toolbar object instance
78 Index As Long &apos; Entry number in buttons lists
79 Label As String &apos; Label (static description)
80 AccessibleName As String &apos; Name found in accessible context
81 Element As Object &apos; com.sun.star.ui.XUIElement
82 End Type
84 REM ============================================================ MODULE CONSTANTS
86 &apos; Toolbar locations
87 Private Const cstBUILTINTOOLBAR = 0 &apos; Standard toolbar
88 Private Const cstCUSTOMTOOLBAR = 1 &apos; Toolbar added by user and stored in the LibreOffice application
89 Private Const cstCUSTOMDOCTOOLBAR = 2 &apos; Toolbar added by user solely for a single document
91 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
93 REM -----------------------------------------------------------------------------
94 Private Sub Class_Initialize()
95 Set [Me] = Nothing
96 ObjectType = &quot;TOOLBAR&quot;
97 ServiceName = &quot;SFWidgets.Toolbar&quot;
98 Set _Component = Nothing
99 _ResourceURL = &quot;&quot;
100 _UIName = &quot;&quot;
101 Set _UIConfigurationManager = Nothing
102 _ElementsInfoIndex = -1
103 _Storage = 0
104 Set _LayoutManager = Nothing
105 Set _ToolbarButtons = Nothing
106 End Sub &apos; SFWidgets.SF_Toolbar Constructor
108 REM -----------------------------------------------------------------------------
109 Private Sub Class_Terminate()
110 Call Class_Initialize()
111 End Sub &apos; SFWidgets.SF_Toolbar Destructor
113 REM -----------------------------------------------------------------------------
114 Public Function Dispose() As Variant
115 Call Class_Terminate()
116 Set Dispose = Nothing
117 End Function &apos; SFWidgets.SF_Toolbar Explicit Destructor
119 REM ================================================================== PROPERTIES
121 REM -----------------------------------------------------------------------------
122 Property Get BuiltIn() As Boolean
123 &apos;&apos;&apos; Returns True when the toolbar is part of the set of standard toolbars shipped with the application.
124 &apos;&apos;&apos; Example:
125 &apos;&apos;&apos; MsgBox myToolbar.BuiltIn
127 BuiltIn = _PropertyGet(&quot;BuiltIn&quot;)
129 End Property &apos; SFWidgets.SF_Toolbar.BuiltIn (get)
131 REM -----------------------------------------------------------------------------
132 Property Get Docked() As Variant
133 &apos;&apos;&apos; Returns True when the toolbar is active in the window and Docked.
134 &apos;&apos;&apos; Example:
135 &apos;&apos;&apos; MsgBox myToolbar.Docked
137 Docked = _PropertyGet(&quot;Docked&quot;)
139 End Property &apos; SFWidgets.SF_Toolbar.Docked (get)
141 REM -----------------------------------------------------------------------------
142 Property Get HasGlobalScope() As Boolean
143 &apos;&apos;&apos; Returns True when the toolbar is available in all documents of the same type
144 &apos;&apos;&apos; Example:
145 &apos;&apos;&apos; MsgBox myToolbar.HasGlobalScope
147 HasGlobalScope = _PropertyGet(&quot;HasGlobalScope&quot;)
149 End Property &apos; SFWidgets.SF_Toolbar.HasGlobalScope (get)
151 REM -----------------------------------------------------------------------------
152 Property Get Name() As String
153 &apos;&apos;&apos; Returns the name of the toolbar
154 &apos;&apos;&apos; Example:
155 &apos;&apos;&apos; MsgBox myToolbar.Name
157 Name = _PropertyGet(&quot;Name&quot;)
159 End Property &apos; SFWidgets.SF_Toolbar.Name (get)
161 REM -----------------------------------------------------------------------------
162 Property Get ResourceURL() As String
163 &apos;&apos;&apos; Returns URL of the toolbar, in the form private:toolbar/xxx
164 &apos;&apos;&apos; Example:
165 &apos;&apos;&apos; MsgBox myToolbar.ResourceURL
167 ResourceURL = _PropertyGet(&quot;ResourceURL&quot;)
169 End Property &apos; SFWidgets.SF_Toolbar.ResourceURL (get)
171 REM -----------------------------------------------------------------------------
172 Property Get Visible() As Variant
173 &apos;&apos;&apos; Returns True when the toolbar is active in the window and visible.
174 &apos;&apos;&apos; Example:
175 &apos;&apos;&apos; MsgBox myToolbar.Visible
177 Visible = _PropertyGet(&quot;Visible&quot;)
179 End Property &apos; SFWidgets.SF_Toolbar.Visible (get)
181 REM -----------------------------------------------------------------------------
182 Property Let Visible(ByVal pvVisible As Variant)
183 &apos;&apos;&apos; Sets the visible status of the toolbar.
184 &apos;&apos;&apos; When the toolbar is not yet active i the window, it is first created.
185 &apos;&apos;&apos; Example:
186 &apos;&apos;&apos; myToolbar.Visible = True
188 _PropertySet(&quot;Visible&quot;, pvVisible)
190 End Property &apos; SFWidgets.SF_Toolbar.Visible (let)
192 REM -----------------------------------------------------------------------------
193 Property Get XUIElement() As Variant
194 &apos;&apos;&apos; Returns the com.sun.star.ui.XUIElement UNO object corresponding with the toolbar
195 &apos;&apos;&apos; Example:
196 &apos;&apos;&apos; MsgBox myToolbar.XUIElement
198 XUIElement = _PropertyGet(&quot;XUIElement&quot;)
200 End Property &apos; SFWidgets.SF_Toolbar.XUIElement (get)
202 REM ===================================================================== METHODS
204 REM -----------------------------------------------------------------------------
205 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
206 &apos;&apos;&apos; Return the actual value of the given property
207 &apos;&apos;&apos; Args:
208 &apos;&apos;&apos; PropertyName: the name of the property as a string
209 &apos;&apos;&apos; Returns:
210 &apos;&apos;&apos; The actual value of the property
211 &apos;&apos;&apos; If the property does not exist, returns Null
212 &apos;&apos;&apos; Exceptions:
213 &apos;&apos;&apos; see the exceptions of the individual properties
214 &apos;&apos;&apos; Examples:
215 &apos;&apos;&apos; myToolbar.GetProperty(&quot;Visible&quot;)
217 Const cstThisSub = &quot;SFWidgets.Toolbar.GetProperty&quot;
218 Const cstSubArgs = &quot;&quot;
220 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
221 GetProperty = Null
223 Check:
224 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
225 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
226 End If
228 Try:
229 GetProperty = _PropertyGet(PropertyName)
231 Finally:
232 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
233 Exit Function
234 Catch:
235 GoTo Finally
236 End Function &apos; SFWidgets.SF_Toolbar.GetProperty
238 REM -----------------------------------------------------------------------------
239 Public Function Methods() As Variant
240 &apos;&apos;&apos; Return the list of public methods of the Model service as an array
242 Methods = Array( _
243 &quot;ToolbarButtons&quot; _
246 End Function &apos; SFWidgets.SF_Toolbar.Methods
248 REM -----------------------------------------------------------------------------
249 Public Function Properties() As Variant
250 &apos;&apos;&apos; Return the list or properties of the Timer a.AddItem(&quot;B&gt;B1&quot;)class as an array
252 Properties = Array( _
253 &quot;BuiltIn&quot; _
254 , &quot;Docked&quot; _
255 , &quot;HasGlobalScope&quot; _
256 , &quot;Name&quot; _
257 , &quot;ResourceURL&quot; _
258 , &quot;Visible&quot; _
259 , &quot;XUIElement&quot; _
262 End Function &apos; SFWidgets.SF_Toolbar.Properties
264 REM -----------------------------------------------------------------------------
265 Public Function SetProperty(Optional ByVal PropertyName As Variant _
266 , Optional ByRef Value As Variant _
267 ) As Boolean
268 &apos;&apos;&apos; Set a new value to the given property
269 &apos;&apos;&apos; Args:
270 &apos;&apos;&apos; PropertyName: the name of the property as a string
271 &apos;&apos;&apos; Value: its new value
272 &apos;&apos;&apos; Exceptions
273 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
275 Const cstThisSub = &quot;SFWidgets.Toolbar.SetProperty&quot;
276 Const cstSubArgs = &quot;PropertyName, Value&quot;
278 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
279 SetProperty = False
281 Check:
282 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
283 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
284 End If
286 Try:
287 SetProperty = _PropertySet(PropertyName, Value)
289 Finally:
290 SF_Utils._ExitFunction(cstThisSub)
291 Exit Function
292 Catch:
293 GoTo Finally
294 End Function &apos; SFWidgets.SF_Toolbar.SetProperty
296 REM -----------------------------------------------------------------------------
297 Public Function ToolbarButtons(Optional ByVal ButtonName As Variant) As Variant
298 &apos;&apos;&apos; Returns either a list of the available toolbar button names in the actual toolbar
299 &apos;&apos;&apos; or a ToolbarButton object instance.
300 &apos;&apos;&apos; Args:
301 &apos;&apos;&apos; ButtonName: the usual name of one of the available buttons in the actual toolbar
302 &apos;&apos;&apos; Returns:
303 &apos;&apos;&apos; A zero-based array of button names when the argument is absent,
304 &apos;&apos;&apos; or a new ToolbarButton object instance.
305 &apos;&apos;&apos; An inactive toolbar has no buttons =&gt; the actual method forces the toolbar to be made visible first.
307 Const cstThisSub = &quot;SFWidgets.Toolbar.ToolbarButtons&quot;
308 Const cstSubArgs = &quot;[ButtonName=&quot;&quot;&quot;&quot;]&quot;
310 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
312 Check:
313 If IsMissing(ButtonName) Or IsEmpty(ButtonName) Then ButtonName = &quot;&quot;
314 &apos; Store button descriptions in cache
315 _CollectAllButtons()
316 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
317 If VarType(ButtonName) = V_STRING Then
318 If Len(ButtonName) &gt; 0 Then
319 If Not ScriptForge.SF_Utils._Validate(ButtonName, &quot;ButtonName&quot;, V_STRING, _ToolbarButtons.Keys()) Then GoTo Finally
320 End If
321 Else
322 If Not ScriptForge.SF_Utils._Validate(ButtonName, &quot;ButtonName&quot;, V_STRING) Then GoTo Finally &apos; Manage here the VarType error
323 End If
324 End If
326 Try:
327 If Len(ButtonName) = 0 Then
328 ToolbarButtons = _ToolbarButtons.Keys()
329 Else
330 ToolbarButtons = CreateScriptService(&quot;SFWidgets.ToolbarButton&quot;, _ToolbarButtons.Item(ButtonName))
331 End If
333 Finally:
334 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
335 Exit Function
336 Catch:
337 GoTo Finally
338 End Function &apos; SFWidgets.SF_Toolbar.ToolbarButtons
340 REM =========================================================== PRIVATE FUNCTIONS
342 REM -----------------------------------------------------------------------------
343 Private Sub _CollectAllButtons()
344 &apos;&apos;&apos; Stores a SF_Dictionary object instance, with
345 &apos;&apos;&apos; - key = name of the button
346 &apos;&apos;&apos; - item = a _ButtonDesc object type
347 &apos;&apos;&apos; into _ToolbarButtons, a cache for all buttons.
348 &apos;&apos;&apos; The toolbar is made visible before collecting the buttons.
349 &apos;&apos;&apos;
350 &apos;&apos;&apos; The name of the buttons is derived either from:
351 &apos;&apos;&apos; - the Label property of the static toolbar and toolbar buttons definitions
352 &apos;&apos;&apos; - or the AccessibleName property of the AccessibleContext of the button
353 &apos;&apos;&apos; whichever is found first.
354 &apos;&apos;&apos; Separators are skipped.
355 &apos;&apos;&apos; If there are homonyms (&gt;= 2 buttons having the same name), only the 1st one is retained.
357 Dim oElement As Object &apos; com.sun.star.ui.XUIElement
358 Dim oSettings As Object &apos; com.sun.star.container.XIndexAccess
359 Dim vProperties() As Variant &apos; Array of property values
360 Dim iType As Integer &apos; Separators have type = 1, others have Type = 0
361 Dim oAccessible As Object &apos; com.sun.star.accessibility.XAccessible
362 Dim sLabel As String &apos; Label in static description
363 Dim sAccessibleName As String &apos; Name in AccessibleContext
364 Dim sButtonName As String &apos; Key part in dictionary entry
365 Dim oButton As Object &apos; Item part in dictionary entry
366 Dim i As Long
368 On Local Error GoTo Catch
369 If Not IsNull(_ToolbarButtons) Then GoTo Finally &apos; Do not redo the job if already done
371 Try:
372 &apos; Force the visibility of the toolbar
373 Visible = True
375 Set _ToolbarButtons = ScriptForge.SF_Services.CreateScriptService(&quot;ScriptForge.Dictionary&quot;, True) &apos; with case-sensitive comparison of keys
376 Set oElement = _LayoutManager.getElement(_ResourceURL)
377 Set oSettings = oElement.getSettings(True)
379 With oSettings
380 For i = 0 To .Count - 1
381 vProperties = .getByIndex(i)
382 iType = ScriptForge.SF_Utils._GetPropertyValue(vProperties, &quot;Type&quot;)
383 If iType = 0 Then &apos; Usual button
384 sLabel = ScriptForge.SF_Utils._GetPropertyValue(vProperties, &quot;Label&quot;)
385 If Len(sLabel) = 0 Then
386 Set oAccessible = oElement.RealInterface.AccessibleContext.getAccessibleChild(i)
387 sAccessibleName = oAccessible.AccessibleName
388 Else
389 sAccessibleName = &quot;&quot;
390 End If
391 &apos; Store in dictionary
392 sButtonName = sLabel &amp; sAccessibleName &apos; At least 1 of them is blank
393 If Len(sButtonName) &gt; 0 Then
394 Set oButton = New _ToolbarButton
395 With oButton
396 Set .Toolbar = [Me]
397 .Index = i
398 .Label = sLabel
399 .AccessibleName = sAccessibleName
400 Set .Element = oElement
401 End With
402 With _ToolbarButtons
403 If Not .Exists(sButtonName) Then .Add(sButtonName, oButton)
404 End With
405 End If
406 End If
407 Next i
408 End With
410 Finally:
411 Exit Sub
412 Catch:
413 &apos; _ToolbarButtons is left unchanged
414 GoTo Finally
415 End Sub &apos; SFWidgets.SF_Toolbar._CollectAllButtons
417 REM -----------------------------------------------------------------------------
418 Public Sub _Initialize(ByRef poToolbar As Object)
419 &apos;&apos;&apos; Complete the object creation process:
420 &apos;&apos;&apos; - Initialize the toolbar descriptioner use
421 &apos;&apos;&apos; Args:
422 &apos;&apos;&apos; poToolbar: the toolbar description as a ui._Toolbr object
424 Try:
425 &apos; Store the static description
426 With poToolbar
427 _Component = .Component
428 _ResourceURL = .ResourceURL
429 _UIName = .UIName
430 _UIConfigurationManager = .UIConfigurationManager
431 _ElementsInfoIndex = .ElementsInfoIndex
432 _Storage = .Storage
433 End With
435 &apos; Complement
436 If Len(_UIName) = 0 Then _UIName = Split(_ResourceURL, &quot;/&quot;)(2)
437 Set _LayoutManager = _Component.CurrentController.Frame.LayoutManager
439 Finally:
440 Exit Sub
441 End Sub &apos; SFWidgets.SF_Toolbar._Initialize
443 REM -----------------------------------------------------------------------------
444 Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
445 &apos;&apos;&apos; Return the value of the named property
446 &apos;&apos;&apos; Args:
447 &apos;&apos;&apos; psProperty: the name of the property
449 Dim vGet As Variant &apos; Return value
450 Dim oElement As Object &apos; com.sun.star.ui.XUIElement
451 Dim cstThisSub As String
452 Const cstSubArgs = &quot;&quot;
454 cstThisSub = &quot;SFWidgets.Toolbar.get&quot; &amp; psProperty
455 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
457 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
458 _PropertyGet = Null
460 Select Case UCase(psProperty)
461 Case UCase(&quot;BuiltIn&quot;)
462 _PropertyGet = ( _Storage = cstBUILTINTOOLBAR )
463 Case UCase(&quot;Docked&quot;)
464 Set oElement = _LayoutManager.getElement(_ResourceURL)
465 If Not IsNull(oElement) Then _PropertyGet = _LayoutManager.isElementDocked(_ResourceURL) Else _PropertyGet = False
466 Case UCase(&quot;HasGlobalScope&quot;)
467 _PropertyGet = ( _Storage = cstBUILTINTOOLBAR Or _Storage = cstCUSTOMTOOLBAR )
468 Case UCase(&quot;Name&quot;)
469 _PropertyGet = _UIName
470 Case UCase(&quot;ResourceURL&quot;)
471 _PropertyGet = _ResourceURL
472 Case UCase(&quot;Visible&quot;)
473 Set oElement = _LayoutManager.getElement(_ResourceURL)
474 If Not IsNull(oElement) Then _PropertyGet = _LayoutManager.isElementVisible(_ResourceURL) Else _PropertyGet = False
475 Case UCase(&quot;XUIElement&quot;)
476 _PropertyGet = _LayoutManager.getElement(_ResourceURL)
477 Case Else
478 _PropertyGet = Null
479 End Select
481 Finally:
482 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
483 Exit Function
484 Catch:
485 GoTo Finally
486 End Function &apos; SFWidgets.SF_Toolbar._PropertyGet
488 REM -----------------------------------------------------------------------------
489 Private Function _PropertySet(Optional ByVal psProperty As String _
490 , Optional ByVal pvValue As Variant _
491 ) As Boolean
492 &apos;&apos;&apos; Set the new value of the named property
493 &apos;&apos;&apos; Args:
494 &apos;&apos;&apos; psProperty: the name of the property
495 &apos;&apos;&apos; pvValue: the new value of the given property
497 Dim bSet As Boolean &apos; Return value
498 Dim oElement As Object &apos; com.sun.star.ui.XUIElement
499 Dim bVisible As Boolean &apos; Actual Visible state
501 Dim cstThisSub As String
502 Const cstSubArgs = &quot;Value&quot;
504 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
505 bSet = False
507 cstThisSub = &quot;SFWidgets.Toolbar.set&quot; &amp; psProperty
508 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
510 bSet = True
511 Select Case UCase(psProperty)
512 Case UCase(&quot;Visible&quot;)
513 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_BOOLEAN) Then GoTo Catch
514 With _LayoutManager
515 Set oElement = .getElement(_ResourceURL)
516 If Not IsNull(oElement) Then bVisible = .isElementVisible(_ResourceURL) Else bVisible = False
517 &apos; If there is no change, do nothing
518 If Not bVisible = pvValue Then
519 If IsNull(oElement) And pvValue Then .createElement(_ResourceURL)
520 If pvValue Then .showElement(_ResourceURL) Else .hideElement(_ResourceURL)
521 End If
522 End With
523 Case Else
524 bSet = False
525 End Select
527 Finally:
528 _PropertySet = bSet
529 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
530 Exit Function
531 Catch:
532 bSet = False
533 GoTo Finally
534 End Function &apos; SFWidgets.SF_Toolbar._PropertySet
536 REM -----------------------------------------------------------------------------
537 Private Function _Repr() As String
538 &apos;&apos;&apos; Convert the SF_Toolbar instance to a readable string, typically for debugging purposes (DebugPrint ...)
539 &apos;&apos;&apos; Args:
540 &apos;&apos;&apos; Return:
541 &apos;&apos;&apos; &quot;[Toolbar]: Name, Type (dialogname)
542 _Repr = &quot;[Toolbar]: &quot; &amp; _UIName &amp; &quot; - &quot; &amp; _ResourceURL
544 End Function &apos; SFWidgets.SF_Toolbar._Repr
546 REM ============================================ END OF SFWIDGETS.SF_TOOLBAR
547 </script:module>