Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / wizards / source / sfwidgets / SF_ToolbarButton.xba
blob58c594f066124aa6049d0a0a80fcf2fde408d7ce
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_ToolbarButton" 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_ToolbarButton
16 &apos;&apos;&apos; ================
17 &apos;&apos;&apos; Hide/show toolbar elements, read and update their current behaviour..
18 &apos;&apos;&apos;
19 &apos;&apos;&apos; A toolbar consists in a series of graphical controls to trigger actions.
20 &apos;&apos;&apos; The &quot;Toolbar&quot; service gives access to the &quot;ToolbarButton&quot; service to manage
21 &apos;&apos;&apos; the individual buttons belonging to the toolbar.
22 &apos;&apos;&apos;
23 &apos;&apos;&apos; Changes made by scripts to buttons belonging to toolbars stored in the application
24 &apos;&apos;&apos; are persistent. They are valid for all documents of the same type.
25 &apos;&apos;&apos;
26 &apos;&apos;&apos; The name of a toolbar button is either:
27 &apos;&apos;&apos; - in custom toolbars, a predefined name given at its creation,
28 &apos;&apos;&apos; - in standard toolbars, a localized name as read in the Tools + Customize ... dialog box
29 &apos;&apos;&apos;
30 &apos;&apos;&apos; Service invocation:
31 &apos;&apos;&apos; It is available only from an active Toolbar service.
32 &apos;&apos;&apos; Example:
33 &apos;&apos;&apos; Dim oCalc As Object, oToolbar As Object, oToolbarButton As Object
34 &apos;&apos;&apos; Set oCalc = CreateScriptService(&quot;Calc&quot;, &quot;myFile.ods&quot;)
35 &apos;&apos;&apos; Set oToolbar = oCalc.Toolbars(&quot;findbar&quot;)
36 &apos;&apos;&apos; Set oToolbarButton = oToolbar.ToolbarButtons(&quot;Find Next&quot;)
38 REM ================================================================== EXCEPTIONS
40 REM ============================================================= PRIVATE MEMBERS
42 Private [Me] As Object
43 Private ObjectType As String &apos; Must be TOOLBARBUTTON
44 Private ServiceName As String
45 Private [_Parent] As Object &apos; SF_Toolbar instance owning the button
47 Private _Index As Long &apos; Entry number in buttons lists
48 Private _Label As String &apos; Label (static description)
49 Private _AccessibleName As String &apos; Name found in accessible context
50 Private _Element As Object &apos; com.sun.star.ui.XUIElement
52 Private _CommandURL As String &apos; Uno command or script
54 Private _Height As Long &apos; Height may be cached
55 Private _Width As Long &apos; Width may be cached
57 REM ============================================================ MODULE CONSTANTS
59 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
61 REM -----------------------------------------------------------------------------
62 Private Sub Class_Initialize()
63 Set [Me] = Nothing
64 ObjectType = &quot;TOOLBARBUTTON&quot;
65 ServiceName = &quot;SFWidgets.ToolbarButton&quot;
66 Set [_Parent] = Nothing
67 _Index = -1
68 _Label = &quot;&quot;
69 _AccessibleName = &quot;&quot;
70 Set _Element = Nothing
71 _CommandURL = &quot;&quot;
72 _Height = 0
73 _Width = 0
74 End Sub &apos; SFWidgets.SF_ToolbarButton Constructor
76 REM -----------------------------------------------------------------------------
77 Private Sub Class_Terminate()
78 Call Class_Initialize()
79 End Sub &apos; SFWidgets.SF_ToolbarButton Destructor
81 REM -----------------------------------------------------------------------------
82 Public Function Dispose() As Variant
83 Call Class_Terminate()
84 Set Dispose = Nothing
85 End Function &apos; SFWidgets.SF_ToolbarButton Explicit Destructor
87 REM ================================================================== PROPERTIES
89 REM -----------------------------------------------------------------------------
90 Property Get Caption() As String
91 &apos;&apos;&apos; Returns the name of the button
92 &apos;&apos;&apos; Example:
93 &apos;&apos;&apos; MsgBox myButton.Caption
95 Caption = _PropertyGet(&quot;Caption&quot;)
97 End Property &apos; SFWidgets.SF_ToolbarButton.Caption (get)
99 REM -----------------------------------------------------------------------------
100 Property Get Height() As Long
101 &apos;&apos;&apos; Returns the height in pixels of the button
102 &apos;&apos;&apos; Example:
103 &apos;&apos;&apos; MsgBox myButton.Height
105 Height = _PropertyGet(&quot;Height&quot;)
107 End Property &apos; SFWidgets.SF_ToolbarButton.Height (get)
109 REM -----------------------------------------------------------------------------
110 Property Get Index() As Long
111 &apos;&apos;&apos; Returns the index of the button
112 &apos;&apos;&apos; - in the Settings (com.sun.star.container.XIndexAccess) of the parent toolbar
113 &apos;&apos;&apos; - in the AccessibleContext (com.sun.star.comp.toolkit.AccessibleToolBox) of the parent toolbar
114 &apos;&apos;&apos; Both should be identical: the range number of the button in the toolbar, hidden buttons and separators included.
115 &apos;&apos;&apos; Example:
116 &apos;&apos;&apos; MsgBox myButton.Index
118 Index = _PropertyGet(&quot;Index&quot;)
120 End Property &apos; SFWidgets.SF_ToolbarButton.Index (get)
122 REM -----------------------------------------------------------------------------
123 Property Get OnClick() As Variant
124 &apos;&apos;&apos; Returns the UNO command or the script (expressed in the scripting framework_URI notation) run when the button is clicked
125 &apos;&apos;&apos; Read https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification
126 &apos;&apos;&apos; Note that no event object is passed to the script.
127 &apos;&apos;&apos; Example:
128 &apos;&apos;&apos; MsgBox myButton.OnClick
130 OnClick = _PropertyGet(&quot;OnClick&quot;)
132 End Property &apos; SFWidgets.SF_ToolbarButton.OnClick (get)
134 REM -----------------------------------------------------------------------------
135 Property Let OnClick(ByVal pvOnClick As Variant)
136 &apos;&apos;&apos; Sets the UNO command or the script (expressed in the scripting framework_URI notation) to trigger when the button is clicked
137 &apos;&apos;&apos; It is highly recommended to not modify standard buttons.
138 &apos;&apos;&apos; Example:
139 &apos;&apos;&apos; myButton.OnClick = &quot;.uno:About&quot;
140 &apos;&apos;&apos; myButton.OnClick = &quot;vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&amp;location=application&quot;
142 _PropertySet(&quot;OnClick&quot;, pvOnClick)
144 End Property &apos; SFWidgets.SF_ToolbarButton.OnClick (let)
146 REM -----------------------------------------------------------------------------
147 Property Get Parent() As Object
148 &apos;&apos;&apos; Returns the parent toolbar as a SF_Toolbar object instance
149 &apos;&apos;&apos; Example:
150 &apos;&apos;&apos; Set oToolbar = myButton.Parent
152 Set Parent = _PropertyGet(&quot;Parent&quot;)
154 End Property &apos; SFWidgets.SF_ToolbarButton.Parent (get)
156 REM -----------------------------------------------------------------------------
157 Property Get TipText() As Variant
158 &apos;&apos;&apos; Specifies the text that appears in a screentip when you hold the mouse pointer over the button
159 &apos;&apos;&apos; Example:
160 &apos;&apos;&apos; MsgBox myButton.TipText
162 TipText = _PropertyGet(&quot;TipText&quot;)
164 End Property &apos; SFWidgets.SF_ToolbarButton.TipText (get)
166 REM -----------------------------------------------------------------------------
167 Property Let TipText(ByVal pvTipText As Variant)
168 &apos;&apos;&apos; Sets the screentip associated with the actual toolbar button
169 &apos;&apos;&apos; It is highly recommended to not modify standard buttons.
170 &apos;&apos;&apos; Example:
171 &apos;&apos;&apos; myButton.TipText = &quot;Click here&quot;
173 _PropertySet(&quot;TipText&quot;, pvTipText)
175 End Property &apos; SFWidgets.SF_ToolbarButton.TipText (let)
177 REM -----------------------------------------------------------------------------
178 Property Get Visible() As Variant
179 &apos;&apos;&apos; Returns True when the toolbar button is visible. Otherwise False.
180 &apos;&apos;&apos; Example:
181 &apos;&apos;&apos; MsgBox myButton.Visible
183 Visible = _PropertyGet(&quot;Visible&quot;)
185 End Property &apos; SFWidgets.SF_ToolbarButton.Visible (get)
187 REM -----------------------------------------------------------------------------
188 Property Let Visible(ByVal pvVisible As Variant)
189 &apos;&apos;&apos; Sets the visible status of the toolbar button.
190 &apos;&apos;&apos; Example:
191 &apos;&apos;&apos; myButton.Visible = True
193 _PropertySet(&quot;Visible&quot;, pvVisible)
195 End Property &apos; SFWidgets.SF_ToolbarButton.Visible (let)
197 REM -----------------------------------------------------------------------------
198 Property Get Width() As Long
199 &apos;&apos;&apos; Returns the width in pixels of the button
200 &apos;&apos;&apos; Example:
201 &apos;&apos;&apos; MsgBox myButton.Width
203 Width = _PropertyGet(&quot;Width&quot;)
205 End Property &apos; SFWidgets.SF_ToolbarButton.Width (get)
207 REM -----------------------------------------------------------------------------
208 Property Get X() As Long
209 &apos;&apos;&apos; Returns the X (horizontal) coordinate in pixels of the top-left corner of the button
210 &apos;&apos;&apos; Example:
211 &apos;&apos;&apos; MsgBox myButton.X
213 X = _PropertyGet(&quot;X&quot;)
215 End Property &apos; SFWidgets.SF_ToolbarButton.X (get)
217 REM -----------------------------------------------------------------------------
218 Property Get Y() As Long
219 &apos;&apos;&apos; Returns the Y (vertical) coordinate in pixels of the top-left corner of the button
220 &apos;&apos;&apos; Example:
221 &apos;&apos;&apos; MsgBox myButton.Y
223 Y = _PropertyGet(&quot;Y&quot;)
225 End Property &apos; SFWidgets.SF_ToolbarButton.Y (get)
227 REM ===================================================================== METHODS
229 REM -----------------------------------------------------------------------------
230 Public Function Execute() As Variant
231 &apos;&apos;&apos; Execute the command stored in the toolbar button.
232 &apos;&apos;&apos; The command can be a UNO command or a Basic/Python script (expressed in the scripting framework_URI notation)
233 &apos;&apos;&apos; Read https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification
234 &apos;&apos;&apos; No argument is passed to the script to execute.
235 &apos;&apos;&apos; Args:
236 &apos;&apos;&apos; Returns:
237 &apos;&apos;&apos; The output of the script or Null
238 &apos;&apos;&apos; Examples:
239 &apos;&apos;&apos; result = myButton.Execute()
241 Dim vResult As Variant &apos; Return value
242 Dim sCommand As String &apos; Command associated with button
243 Dim oFrame As Object &apos; com.sun.star.comp.framework.Frame
244 Dim oDispatcher As Object &apos; com.sun.star.frame.DispatchHelper
245 Dim vScript As Variant &apos; Split command in script/argument
246 Dim oSession As Object : Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;ScriptForge.Session&quot;)
247 Dim oArgs() As new com.sun.star.beans.PropertyValue
248 Const cstUnoPrefix = &quot;.uno:&quot;
250 Const cstThisSub = &quot;SFWidgets.ToolbarButton.Execute&quot;
251 Const cstSubArgs = &quot;&quot;
253 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
254 vResult = Null
256 Check:
257 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
259 Try:
260 sCommand = GetProperty(&quot;OnClick&quot;)
261 If Len(sCommand) &gt; 0 Then
262 &apos; A button has been clicked necessarily in the current window (Document) or one of its subcomponents (FormDocument)
263 Set oFrame = StarDesktop.ActiveFrame
264 If oFrame.Frames.Count &gt; 0 Then Set oFrame = oFrame.getActiveFrame()
265 &apos; Command or script ?
266 If ScriptForge.SF_String.StartsWith(sCommand, cstUnoPrefix) Then
267 &apos; Execute uno command
268 Set oDispatcher = ScriptForge.SF_Utils._GetUNOService(&quot;DispatchHelper&quot;)
269 oDispatcher.executeDispatch(oFrame, sCommand, &quot;&quot;, 0, oArgs())
270 oFrame.activate()
271 Else
272 &apos; Execute script
273 vResult = oSession._ExecuteScript(sCommand)
274 End If
275 End If
277 Finally:
278 Execute = vResult
279 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
280 Exit Function
281 Catch:
282 GoTo Finally
283 End Function &apos; SFWidgets.SF_ToolbarButton.Execute
285 REM -----------------------------------------------------------------------------
286 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
287 &apos;&apos;&apos; Return the actual value of the given property
288 &apos;&apos;&apos; Args:
289 &apos;&apos;&apos; PropertyName: the name of the property as a string
290 &apos;&apos;&apos; Returns:
291 &apos;&apos;&apos; The actual value of the property
292 &apos;&apos;&apos; If the property does not exist, returns Null
293 &apos;&apos;&apos; Exceptions:
294 &apos;&apos;&apos; see the exceptions of the individual properties
295 &apos;&apos;&apos; Examples:
296 &apos;&apos;&apos; myToolbar.GetProperty(&quot;Visible&quot;)
298 Const cstThisSub = &quot;SFWidgets.ToolbarButton.GetProperty&quot;
299 Const cstSubArgs = &quot;&quot;
301 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
302 GetProperty = Null
304 Check:
305 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
306 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
307 End If
309 Try:
310 GetProperty = _PropertyGet(PropertyName)
312 Finally:
313 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
314 Exit Function
315 Catch:
316 GoTo Finally
317 End Function &apos; SFWidgets.SF_ToolbarButton.GetProperty
319 REM -----------------------------------------------------------------------------
320 Public Function Methods() As Variant
321 &apos;&apos;&apos; Return the list of public methods of the Model service as an array
323 Methods = Array( _
324 &quot;Execute&quot; _
327 End Function &apos; SFWidgets.SF_ToolbarButton.Methods
329 REM -----------------------------------------------------------------------------
330 Public Function Properties() As Variant
331 &apos;&apos;&apos; Return the list or properties of the Timer a.AddItem(&quot;B&gt;B1&quot;)class as an array
333 Properties = Array( _
334 &quot;Caption&quot; _
335 , &quot;Height&quot; _
336 , &quot;Index&quot; _
337 , &quot;OnClick&quot; _
338 , &quot;Parent&quot; _
339 , &quot;TipText&quot; _
340 , &quot;Visible&quot; _
341 , &quot;Width&quot; _
342 , &quot;X&quot; _
343 , &quot;Y&quot; _
346 End Function &apos; SFWidgets.SF_ToolbarButton.Properties
348 REM -----------------------------------------------------------------------------
349 Public Function SetProperty(Optional ByVal PropertyName As Variant _
350 , Optional ByRef Value As Variant _
351 ) As Boolean
352 &apos;&apos;&apos; Set a new value to the given property
353 &apos;&apos;&apos; Args:
354 &apos;&apos;&apos; PropertyName: the name of the property as a string
355 &apos;&apos;&apos; Value: its new value
356 &apos;&apos;&apos; Exceptions
357 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
359 Const cstThisSub = &quot;SFWidgets.ToolbarButton.SetProperty&quot;
360 Const cstSubArgs = &quot;PropertyName, Value&quot;
362 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
363 SetProperty = False
365 Check:
366 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
367 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
368 End If
370 Try:
371 SetProperty = _PropertySet(PropertyName, Value)
373 Finally:
374 SF_Utils._ExitFunction(cstThisSub)
375 Exit Function
376 Catch:
377 GoTo Finally
378 End Function &apos; SFWidgets.SF_ToolbarButton.SetProperty
380 REM =========================================================== PRIVATE FUNCTIONS
382 REM -----------------------------------------------------------------------------
383 Private Function _GetPosition() As Object
384 &apos;&apos;&apos; Determine the position of the top-left corner of the actual button.
385 &apos;&apos;&apos; Returns:
386 &apos;&apos;&apos; a com.sun.star.awt.Rectangle structure
388 Dim oElement As Object &apos; com.sun.star.ui.XUIElement
389 Dim oAccessible As Object &apos; com.sun.star.comp.toolkit.AccessibleToolBoxItem
390 Dim oAccessibleButton As Object &apos; com.sun.star.comp.toolkit.AccessibleToolBoxItem
391 Dim oAccessibleParent As Object &apos; com.sun.star.comp.toolkit.AccessibleToolBoxItem
392 Dim oRect As Object &apos; Return value As com.sun.star.awt.Rectangle
394 Try:
395 Set oElement = _Element.GetSettings(True).getByIndex(_Index)
396 Set oRect = CreateUnoStruct(&quot;com.sun.star.awt.Rectangle&quot;)
397 If ScriptForge.SF_Utils._GetPropertyValue(oElement, &quot;IsVisible&quot;) Then
398 Set oAccessible = _Element.getRealInterface().getAccessibleContext() &apos; Toolbar level
399 Set oAccessibleParent = oAccessible.getAccessibleParent() &apos; Window level
400 Set oAccessibleButton = oAccessible.getAccessibleChild(_Index) &apos; Toolbar button level
401 &apos; The X and Y coordinates are always computed correctly when the toolbar is docked.
402 &apos; When the toolbar is floating, the Y ordinate may be overestimated with the height of
403 &apos; the tabbed bar or similar. However no mean has been found to get that height via code.
404 With oRect
405 .X = oAccessible.Location.X + oAccessibleButton.Location.X + oAccessibleParent.PosSize.X
406 .Y = oAccessible.Location.Y + oAccessibleButton.Location.Y + oAccessibleParent.PosSize.Y
407 .Height = oAccessibleButton.Size.Height
408 .Width = oAccessibleButton.Size.Width
409 End With
410 Else
411 With oRect
412 .X = -1 : .Y = -1 : .Height = 0 : .Width = 0
413 End With
414 End If
416 Finally:
417 Set _GetPosition = oRect
418 Exit Function
419 End Function &apos; SFWidgets.SF_ToolbarButton._GetPosition
421 REM -----------------------------------------------------------------------------
422 Public Sub _Initialize(ByRef poToolbarButton As Object)
423 &apos;&apos;&apos; Complete the object creation process:
424 &apos;&apos;&apos; - Initialize the toolbar descriptioner use
425 &apos;&apos;&apos; Args:
426 &apos;&apos;&apos; poToolbarButton: the toolbar description as a ui._Toolbr object
428 Try:
429 &apos; Store the static description
430 With poToolbarButton
431 Set [_Parent] = .Toolbar
432 _Index = .Index
433 _Label = .Label
434 _AccessibleName = .AccessibleName
435 Set _Element = .Element
436 End With
438 &apos; Complement
439 _CommandURL = ScriptForge.SF_Utils._GetPropertyValue(_Element.getSettings(True).getByIndex(_Index), &quot;CommandURL&quot;)
441 Finally:
442 Exit Sub
443 End Sub &apos; SFWidgets.SF_ToolbarButton._Initialize
445 REM -----------------------------------------------------------------------------
446 Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
447 &apos;&apos;&apos; Return the value of the named property
448 &apos;&apos;&apos; Args:
449 &apos;&apos;&apos; psProperty: the name of the property
451 Dim vGet As Variant &apos; Return value
452 Dim sTooltip As String &apos; ToolTip text
453 Dim oElement As Object &apos; com.sun.star.ui.XUIElement
454 Dim cstThisSub As String
455 Const cstSubArgs = &quot;&quot;
457 cstThisSub = &quot;SFWidgets.ToolbarButton.get&quot; &amp; psProperty
458 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
460 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
461 _PropertyGet = Null
463 Select Case UCase(psProperty)
464 Case UCase(&quot;Caption&quot;)
465 _PropertyGet = Iif(Len(_Label) &gt; 0, _Label, _AccessibleName)
466 Case UCase(&quot;Height&quot;)
467 If _Height &gt; 0 Then _PropertyGet = _Height else _PropertyGet = _GetPosition().Height
468 Case UCase(&quot;Index&quot;)
469 _PropertyGet = _Index
470 Case UCase(&quot;OnClick&quot;)
471 Set oElement = _Element.GetSettings(True).getByIndex(_Index)
472 _PropertyGet = ScriptForge.SF_Utils._GetPropertyValue(oElement, &quot;CommandURL&quot;)
473 Case UCase(&quot;Parent&quot;)
474 Set _PropertyGet = [_Parent]
475 Case UCase(&quot;TipText&quot;)
476 Set oElement = _Element.GetSettings(True).getByIndex(_Index)
477 sTooltip = ScriptForge.SF_Utils._GetPropertyValue(oElement, &quot;Tooltip&quot;)
478 If Len(sTooltip) &gt; 0 Then _PropertyGet = sTooltip Else _PropertyGet = Iif(Len(_Label) &gt; 0, _Label, _AccessibleName)
479 Case UCase(&quot;Visible&quot;)
480 Set oElement = _Element.GetSettings(True).getByIndex(_Index)
481 _PropertyGet = ScriptForge.SF_Utils._GetPropertyValue(oElement, &quot;IsVisible&quot;)
482 Case UCase(&quot;Width&quot;)
483 If _Width &gt; 0 Then _PropertyGet = _Width else _PropertyGet = _GetPosition().Width
484 Case UCase(&quot;X&quot;)
485 _PropertyGet = _GetPosition().X
486 Case UCase(&quot;Y&quot;)
487 _PropertyGet = _GetPosition().Y
488 Case Else
489 _PropertyGet = Null
490 End Select
492 Finally:
493 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
494 Exit Function
495 Catch:
496 GoTo Finally
497 End Function &apos; SFWidgets.SF_ToolbarButton._PropertyGet
499 REM -----------------------------------------------------------------------------
500 Private Function _PropertySet(Optional ByVal psProperty As String _
501 , Optional ByVal pvValue As Variant _
502 ) As Boolean
503 &apos;&apos;&apos; Set the new value of the named property
504 &apos;&apos;&apos; Args:
505 &apos;&apos;&apos; psProperty: the name of the property
506 &apos;&apos;&apos; pvValue: the new value of the given property
508 Dim bSet As Boolean &apos; Return value
509 Dim oSettings As Object &apos; com.sun.star.container.XIndexAccess
510 Dim vProperties As Variant &apos; Array of PropertyValues
511 Dim bVisible As Boolean &apos; Actual Visible state
513 Dim cstThisSub As String
514 Const cstSubArgs = &quot;Value&quot;
516 Check:
517 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
518 bSet = False
520 cstThisSub = &quot;SFWidgets.ToolbarButton.set&quot; &amp; psProperty
521 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
523 Try:
524 bSet = True
525 Set oSettings = _Element.getSettings(True)
526 vProperties = oSettings.getByIndex(_Index)
528 Select Case UCase(psProperty)
529 Case UCase(&quot;OnClick&quot;)
530 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_STRING) Then GoTo Catch
531 ScriptForge.SF_Utils._SetPropertyValue(vProperties, &quot;CommandURL&quot;, pvValue)
532 Case UCase(&quot;TipText&quot;)
533 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_STRING) Then GoTo Catch
534 ScriptForge.SF_Utils._SetPropertyValue(vProperties, &quot;Tooltip&quot;, pvValue)
535 Case UCase(&quot;Visible&quot;)
536 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_BOOLEAN) Then GoTo Catch
537 ScriptForge.SF_Utils._SetPropertyValue(vProperties, &quot;IsVisible&quot;, pvValue)
538 Case Else
539 bSet = False
540 End Select
542 oSettings.replaceByIndex(_Index, vProperties)
543 _Element.setSettings(oSettings)
545 Finally:
546 _PropertySet = bSet
547 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
548 Exit Function
549 Catch:
550 bSet = False
551 GoTo Finally
552 End Function &apos; SFWidgets.SF_ToolbarButton._PropertySet
554 REM -----------------------------------------------------------------------------
555 Private Function _Repr() As String
556 &apos;&apos;&apos; Convert the SF_ToolbarButton instance to a readable string, typically for debugging purposes (DebugPrint ...)
557 &apos;&apos;&apos; Args:
558 &apos;&apos;&apos; Return:
559 &apos;&apos;&apos; &quot;[Toolbar]: Name, Type (dialogname)
560 _Repr = &quot;[ToolbarButton]: &quot; &amp; Iif(Len(_Label) &gt; 0, _Label, _AccessibleName) &amp; &quot; - &quot; &amp; _CommandURL
562 End Function &apos; SFWidgets.SF_ToolbarButton._Repr
564 REM ============================================ END OF SFWIDGETS.SF_TOOLBARBUTTON
565 </script:module>