Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / wizards / source / sfwidgets / SF_Toolbar.xba
blobc457a62f1cad013787461bbb59b025ce8acaf48f
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;)
52 REM ================================================================== EXCEPTIONS
54 REM ============================================================= PRIVATE MEMBERS
56 Private [Me] As Object
57 Private ObjectType As String &apos; Must be TOOLBAR
58 Private ServiceName As String
60 Private _Component As Object &apos; com.sun.star.lang.XComponent
61 Private _ResourceURL As String &apos; Toolbar internal name
62 Private _UIName As String &apos; Toolbar external name, may be &quot;&quot;
63 Private _UIConfigurationManager As Object &apos; com.sun.star.ui.XUIConfigurationManager
64 Private _ElementsInfoIndex As Long &apos; Index of the toolbar in the getElementsInfo(0) array
65 Private _Storage As Long &apos; One of the toolbar location constants
66 Private _LayoutManager As Object &apos; com.sun.star.comp.framework.LayoutManager
68 Private _ToolbarButtons As Object &apos; SF_Dictionary of toolbar buttons
70 Type _ToolbarButton
71 Toolbar As Object &apos; The actual SF_Toolbar object instance
72 Index As Long &apos; Entry number in buttons lists
73 Label As String &apos; Label (static description)
74 AccessibleName As String &apos; Name found in accessible context
75 Element As Object &apos; com.sun.star.ui.XUIElement
76 End Type
78 REM ============================================================ MODULE CONSTANTS
80 &apos; Toolbar locations
81 Private Const cstBUILTINTOOLBAR = 0 &apos; Standard toolbar
82 Private Const cstCUSTOMTOOLBAR = 1 &apos; Toolbar added by user and stored in the LibreOffice application
83 Private Const cstCUSTOMDOCTOOLBAR = 2 &apos; Toolbar added by user solely for a single document
85 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
87 REM -----------------------------------------------------------------------------
88 Private Sub Class_Initialize()
89 Set [Me] = Nothing
90 ObjectType = &quot;TOOLBAR&quot;
91 ServiceName = &quot;SFWidgets.Toolbar&quot;
92 Set _Component = Nothing
93 _ResourceURL = &quot;&quot;
94 _UIName = &quot;&quot;
95 Set _UIConfigurationManager = Nothing
96 _ElementsInfoIndex = -1
97 _Storage = 0
98 Set _LayoutManager = Nothing
99 Set _ToolbarButtons = Nothing
100 End Sub &apos; SFWidgets.SF_Toolbar Constructor
102 REM -----------------------------------------------------------------------------
103 Private Sub Class_Terminate()
104 Call Class_Initialize()
105 End Sub &apos; SFWidgets.SF_Toolbar Destructor
107 REM -----------------------------------------------------------------------------
108 Public Function Dispose() As Variant
109 Call Class_Terminate()
110 Set Dispose = Nothing
111 End Function &apos; SFWidgets.SF_Toolbar Explicit Destructor
113 REM ================================================================== PROPERTIES
115 REM -----------------------------------------------------------------------------
116 Property Get BuiltIn() As Boolean
117 &apos;&apos;&apos; Returns True when the toolbar is part of the set of standard toolbars shipped with the application.
118 &apos;&apos;&apos; Example:
119 &apos;&apos;&apos; MsgBox myToolbar.BuiltIn
121 BuiltIn = _PropertyGet(&quot;BuiltIn&quot;)
123 End Property &apos; SFWidgets.SF_Toolbar.BuiltIn (get)
125 REM -----------------------------------------------------------------------------
126 Property Get Docked() As Variant
127 &apos;&apos;&apos; Returns True when the toolbar is active in the window and Docked.
128 &apos;&apos;&apos; Example:
129 &apos;&apos;&apos; MsgBox myToolbar.Docked
131 Docked = _PropertyGet(&quot;Docked&quot;)
133 End Property &apos; SFWidgets.SF_Toolbar.Docked (get)
135 REM -----------------------------------------------------------------------------
136 Property Get HasGlobalScope() As Boolean
137 &apos;&apos;&apos; Returns True when the toolbar is available in all documents of the same type
138 &apos;&apos;&apos; Example:
139 &apos;&apos;&apos; MsgBox myToolbar.HasGlobalScope
141 HasGlobalScope = _PropertyGet(&quot;HasGlobalScope&quot;)
143 End Property &apos; SFWidgets.SF_Toolbar.HasGlobalScope (get)
145 REM -----------------------------------------------------------------------------
146 Property Get Name() As String
147 &apos;&apos;&apos; Returns the name of the toolbar
148 &apos;&apos;&apos; Example:
149 &apos;&apos;&apos; MsgBox myToolbar.Name
151 Name = _PropertyGet(&quot;Name&quot;)
153 End Property &apos; SFWidgets.SF_Toolbar.Name (get)
155 REM -----------------------------------------------------------------------------
156 Property Get ResourceURL() As String
157 &apos;&apos;&apos; Returns URL of the toolbar, in the form private:toolbar/xxx
158 &apos;&apos;&apos; Example:
159 &apos;&apos;&apos; MsgBox myToolbar.ResourceURL
161 ResourceURL = _PropertyGet(&quot;ResourceURL&quot;)
163 End Property &apos; SFWidgets.SF_Toolbar.ResourceURL (get)
165 REM -----------------------------------------------------------------------------
166 Property Get Visible() As Variant
167 &apos;&apos;&apos; Returns True when the toolbar is active in the window and visible.
168 &apos;&apos;&apos; Example:
169 &apos;&apos;&apos; MsgBox myToolbar.Visible
171 Visible = _PropertyGet(&quot;Visible&quot;)
173 End Property &apos; SFWidgets.SF_Toolbar.Visible (get)
175 REM -----------------------------------------------------------------------------
176 Property Let Visible(ByVal pvVisible As Variant)
177 &apos;&apos;&apos; Sets the visible status of the toolbar.
178 &apos;&apos;&apos; When the toolbar is not yet active i the window, it is first created.
179 &apos;&apos;&apos; Example:
180 &apos;&apos;&apos; myToolbar.Visible = True
182 _PropertySet(&quot;Visible&quot;, pvVisible)
184 End Property &apos; SFWidgets.SF_Toolbar.Visible (let)
186 REM -----------------------------------------------------------------------------
187 Property Get XUIElement() As Variant
188 &apos;&apos;&apos; Returns the com.sun.star.ui.XUIElement UNO object corresponding with the toolbar
189 &apos;&apos;&apos; Example:
190 &apos;&apos;&apos; MsgBox myToolbar.XUIElement
192 XUIElement = _PropertyGet(&quot;XUIElement&quot;)
194 End Property &apos; SFWidgets.SF_Toolbar.XUIElement (get)
196 REM ===================================================================== METHODS
198 REM -----------------------------------------------------------------------------
199 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
200 &apos;&apos;&apos; Return the actual value of the given property
201 &apos;&apos;&apos; Args:
202 &apos;&apos;&apos; PropertyName: the name of the property as a string
203 &apos;&apos;&apos; Returns:
204 &apos;&apos;&apos; The actual value of the property
205 &apos;&apos;&apos; If the property does not exist, returns Null
206 &apos;&apos;&apos; Exceptions:
207 &apos;&apos;&apos; see the exceptions of the individual properties
208 &apos;&apos;&apos; Examples:
209 &apos;&apos;&apos; myToolbar.GetProperty(&quot;Visible&quot;)
211 Const cstThisSub = &quot;SFWidgets.Toolbar.GetProperty&quot;
212 Const cstSubArgs = &quot;&quot;
214 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
215 GetProperty = Null
217 Check:
218 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
219 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
220 End If
222 Try:
223 GetProperty = _PropertyGet(PropertyName)
225 Finally:
226 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
227 Exit Function
228 Catch:
229 GoTo Finally
230 End Function &apos; SFWidgets.SF_Toolbar.GetProperty
232 REM -----------------------------------------------------------------------------
233 Public Function Methods() As Variant
234 &apos;&apos;&apos; Return the list of public methods of the Model service as an array
236 Methods = Array( _
237 &quot;ToolbarButtons&quot; _
240 End Function &apos; SFWidgets.SF_Toolbar.Methods
242 REM -----------------------------------------------------------------------------
243 Public Function Properties() As Variant
244 &apos;&apos;&apos; Return the list or properties of the Timer a.AddItem(&quot;B&gt;B1&quot;)class as an array
246 Properties = Array( _
247 &quot;BuiltIn&quot; _
248 , &quot;Docked&quot; _
249 , &quot;HasGlobalScope&quot; _
250 , &quot;Name&quot; _
251 , &quot;ResourceURL&quot; _
252 , &quot;Visible&quot; _
253 , &quot;XUIElement&quot; _
256 End Function &apos; SFWidgets.SF_Toolbar.Properties
258 REM -----------------------------------------------------------------------------
259 Public Function SetProperty(Optional ByVal PropertyName As Variant _
260 , Optional ByRef Value As Variant _
261 ) As Boolean
262 &apos;&apos;&apos; Set a new value to the given property
263 &apos;&apos;&apos; Args:
264 &apos;&apos;&apos; PropertyName: the name of the property as a string
265 &apos;&apos;&apos; Value: its new value
266 &apos;&apos;&apos; Exceptions
267 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
269 Const cstThisSub = &quot;SFWidgets.Toolbar.SetProperty&quot;
270 Const cstSubArgs = &quot;PropertyName, Value&quot;
272 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
273 SetProperty = False
275 Check:
276 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
277 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
278 End If
280 Try:
281 SetProperty = _PropertySet(PropertyName, Value)
283 Finally:
284 SF_Utils._ExitFunction(cstThisSub)
285 Exit Function
286 Catch:
287 GoTo Finally
288 End Function &apos; SFWidgets.SF_Toolbar.SetProperty
290 REM -----------------------------------------------------------------------------
291 Public Function ToolbarButtons(Optional ByVal ButtonName As Variant) As Variant
292 &apos;&apos;&apos; Returns either a list of the available toolbar button names in the actual toolbar
293 &apos;&apos;&apos; or a ToolbarButton object instance.
294 &apos;&apos;&apos; Args:
295 &apos;&apos;&apos; ButtonName: the usual name of one of the available buttons in the actual toolbar
296 &apos;&apos;&apos; Returns:
297 &apos;&apos;&apos; A zero-based array of button names when the argument is absent,
298 &apos;&apos;&apos; or a new ToolbarButton object instance.
299 &apos;&apos;&apos; An inactive toolbar has no buttons =&gt; the actual method forces the toolbar to be made visible first.
301 Const cstThisSub = &quot;SFWidgets.Toolbar.ToolbarButtons&quot;
302 Const cstSubArgs = &quot;[ButtonName=&quot;&quot;&quot;&quot;]&quot;
304 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
306 Check:
307 If IsMissing(ButtonName) Or IsEmpty(ButtonName) Then ButtonName = &quot;&quot;
308 &apos; Store button descriptions in cache
309 _CollectAllButtons()
310 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
311 If VarType(ButtonName) = V_STRING Then
312 If Len(ButtonName) &gt; 0 Then
313 If Not ScriptForge.SF_Utils._Validate(ButtonName, &quot;ButtonName&quot;, V_STRING, _ToolbarButtons.Keys()) Then GoTo Finally
314 End If
315 Else
316 If Not ScriptForge.SF_Utils._Validate(ButtonName, &quot;ButtonName&quot;, V_STRING) Then GoTo Finally &apos; Manage here the VarType error
317 End If
318 End If
320 Try:
321 If Len(ButtonName) = 0 Then
322 ToolbarButtons = _ToolbarButtons.Keys()
323 Else
324 ToolbarButtons = CreateScriptService(&quot;SFWidgets.ToolbarButton&quot;, _ToolbarButtons.Item(ButtonName))
325 End If
327 Finally:
328 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
329 Exit Function
330 Catch:
331 GoTo Finally
332 End Function &apos; SFWidgets.SF_Toolbar.ToolbarButtons
334 REM =========================================================== PRIVATE FUNCTIONS
336 REM -----------------------------------------------------------------------------
337 Private Sub _CollectAllButtons()
338 &apos;&apos;&apos; Stores a SF_Dictionary object instance, with
339 &apos;&apos;&apos; - key = name of the button
340 &apos;&apos;&apos; - item = a _ButtonDesc object type
341 &apos;&apos;&apos; into _ToolbarButtons, a cache for all buttons.
342 &apos;&apos;&apos; The toolbar is made visible before collecting the buttons.
343 &apos;&apos;&apos;
344 &apos;&apos;&apos; The name of the buttons is derived either from:
345 &apos;&apos;&apos; - the Label property of the static toolbar and toolbar buttons definitions
346 &apos;&apos;&apos; - or the AccessibleName property of the AccessibleContext of the button
347 &apos;&apos;&apos; whichever is found first.
348 &apos;&apos;&apos; Separators are skipped.
349 &apos;&apos;&apos; If there are homonyms (&gt;= 2 buttons having the same name), only the 1st one is retained.
351 Dim oElement As Object &apos; com.sun.star.ui.XUIElement
352 Dim oSettings As Object &apos; com.sun.star.container.XIndexAccess
353 Dim vProperties() As Variant &apos; Array of property values
354 Dim iType As Integer &apos; Separators have type = 1, others have Type = 0
355 Dim oAccessible As Object &apos; com.sun.star.accessibility.XAccessible
356 Dim sLabel As String &apos; Label in static description
357 Dim sAccessibleName As String &apos; Name in AccessibleContext
358 Dim sButtonName As String &apos; Key part in dictionary entry
359 Dim oButton As Object &apos; Item part in dictionary entry
360 Dim i As Long
362 On Local Error GoTo Catch
363 If Not IsNull(_ToolbarButtons) Then GoTo Finally &apos; Do not redo the job if already done
365 Try:
366 &apos; Force the visibility of the toolbar
367 Visible = True
369 Set _ToolbarButtons = ScriptForge.SF_Services.CreateScriptService(&quot;ScriptForge.Dictionary&quot;)
370 Set oElement = _LayoutManager.getElement(_ResourceURL)
371 Set oSettings = oElement.getSettings(True)
373 With oSettings
374 For i = 0 To .Count - 1
375 vProperties = .getByIndex(i)
376 iType = ScriptForge.SF_Utils._GetPropertyValue(vProperties, &quot;Type&quot;)
377 If iType = 0 Then &apos; Usual button
378 sLabel = ScriptForge.SF_Utils._GetPropertyValue(vProperties, &quot;Label&quot;)
379 If Len(sLabel) = 0 Then
380 Set oAccessible = oElement.RealInterface.AccessibleContext.getAccessibleChild(i)
381 sAccessibleName = oAccessible.AccessibleName
382 Else
383 sAccessibleName = &quot;&quot;
384 End If
385 &apos; Store in dictionary
386 sButtonName = sLabel &amp; sAccessibleName &apos; At least 1 of them is blank
387 If Len(sButtonName) &gt; 0 Then
388 Set oButton = New _ToolbarButton
389 With oButton
390 Set .Toolbar = [Me]
391 .Index = i
392 .Label = sLabel
393 .AccessibleName = sAccessibleName
394 Set .Element = oElement
395 End With
396 With _ToolbarButtons
397 If Not .Exists(sButtonName) Then .Add(sButtonName, oButton)
398 End With
399 End If
400 End If
401 Next i
402 End With
404 Finally:
405 Exit Sub
406 Catch:
407 &apos; _ToolbarButtons is left unchanged
408 GoTo Finally
409 End Sub &apos; SFWidgets.SF_Toolbar._CollectAllButtons
411 REM -----------------------------------------------------------------------------
412 Public Sub _Initialize(ByRef poToolbar As Object)
413 &apos;&apos;&apos; Complete the object creation process:
414 &apos;&apos;&apos; - Initialize the toolbar descriptioner use
415 &apos;&apos;&apos; Args:
416 &apos;&apos;&apos; poToolbar: the toolbar description as a ui._Toolbr object
418 Try:
419 &apos; Store the static description
420 With poToolbar
421 _Component = .Component
422 _ResourceURL = .ResourceURL
423 _UIName = .UIName
424 _UIConfigurationManager = .UIConfigurationManager
425 _ElementsInfoIndex = .ElementsInfoIndex
426 _Storage = .Storage
427 End With
429 &apos; Complement
430 If Len(_UIName) = 0 Then _UIName = Split(_ResourceURL, &quot;/&quot;)(2)
431 Set _LayoutManager = _Component.CurrentController.Frame.LayoutManager
433 Finally:
434 Exit Sub
435 End Sub &apos; SFWidgets.SF_Toolbar._Initialize
437 REM -----------------------------------------------------------------------------
438 Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
439 &apos;&apos;&apos; Return the value of the named property
440 &apos;&apos;&apos; Args:
441 &apos;&apos;&apos; psProperty: the name of the property
443 Dim vGet As Variant &apos; Return value
444 Dim oElement As Object &apos; com.sun.star.ui.XUIElement
445 Dim cstThisSub As String
446 Const cstSubArgs = &quot;&quot;
448 cstThisSub = &quot;SFWidgets.Toolbar.get&quot; &amp; psProperty
449 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
451 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
452 _PropertyGet = Null
454 Select Case UCase(psProperty)
455 Case UCase(&quot;BuiltIn&quot;)
456 _PropertyGet = ( _Storage = cstBUILTINTOOLBAR )
457 Case UCase(&quot;Docked&quot;)
458 Set oElement = _LayoutManager.getElement(_ResourceURL)
459 If Not IsNull(oElement) Then _PropertyGet = _LayoutManager.isElementDocked(_ResourceURL) Else _PropertyGet = False
460 Case UCase(&quot;HasGlobalScope&quot;)
461 _PropertyGet = ( _Storage = cstBUILTINTOOLBAR Or _Storage = cstCUSTOMTOOLBAR )
462 Case UCase(&quot;Name&quot;)
463 _PropertyGet = _UIName
464 Case UCase(&quot;ResourceURL&quot;)
465 _PropertyGet = _ResourceURL
466 Case UCase(&quot;Visible&quot;)
467 Set oElement = _LayoutManager.getElement(_ResourceURL)
468 If Not IsNull(oElement) Then _PropertyGet = _LayoutManager.isElementVisible(_ResourceURL) Else _PropertyGet = False
469 Case UCase(&quot;XUIElement&quot;)
470 _PropertyGet = _LayoutManager.getElement(_ResourceURL)
471 Case Else
472 _PropertyGet = Null
473 End Select
475 Finally:
476 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
477 Exit Function
478 Catch:
479 GoTo Finally
480 End Function &apos; SFWidgets.SF_Toolbar._PropertyGet
482 REM -----------------------------------------------------------------------------
483 Private Function _PropertySet(Optional ByVal psProperty As String _
484 , Optional ByVal pvValue As Variant _
485 ) As Boolean
486 &apos;&apos;&apos; Set the new value of the named property
487 &apos;&apos;&apos; Args:
488 &apos;&apos;&apos; psProperty: the name of the property
489 &apos;&apos;&apos; pvValue: the new value of the given property
491 Dim bSet As Boolean &apos; Return value
492 Dim oElement As Object &apos; com.sun.star.ui.XUIElement
493 Dim bVisible As Boolean &apos; Actual Visible state
495 Dim cstThisSub As String
496 Const cstSubArgs = &quot;Value&quot;
498 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
499 bSet = False
501 cstThisSub = &quot;SFWidgets.Toolbar.set&quot; &amp; psProperty
502 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
504 bSet = True
505 Select Case UCase(psProperty)
506 Case UCase(&quot;Visible&quot;)
507 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_BOOLEAN) Then GoTo Catch
508 With _LayoutManager
509 Set oElement = .getElement(_ResourceURL)
510 If Not IsNull(oElement) Then bVisible = .isElementVisible(_ResourceURL) Else bVisible = False
511 &apos; If there is no change, do nothing
512 If Not bVisible = pvValue Then
513 If IsNull(oElement) And pvValue Then .createElement(_ResourceURL)
514 If pvValue Then .showElement(_ResourceURL) Else .hideElement(_ResourceURL)
515 End If
516 End With
517 Case Else
518 bSet = False
519 End Select
521 Finally:
522 _PropertySet = bSet
523 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
524 Exit Function
525 Catch:
526 bSet = False
527 GoTo Finally
528 End Function &apos; SFWidgets.SF_Toolbar._PropertySet
530 REM -----------------------------------------------------------------------------
531 Private Function _Repr() As String
532 &apos;&apos;&apos; Convert the SF_Toolbar instance to a readable string, typically for debugging purposes (DebugPrint ...)
533 &apos;&apos;&apos; Args:
534 &apos;&apos;&apos; Return:
535 &apos;&apos;&apos; &quot;[Toolbar]: Name, Type (dialogname)
536 _Repr = &quot;[Toolbar]: &quot; &amp; _UIName &amp; &quot; - &quot; &amp; _ResourceURL
538 End Function &apos; SFWidgets.SF_Toolbar._Repr
540 REM ============================================ END OF SFWIDGETS.SF_TOOLBAR
541 </script:module>