summaryrefslogtreecommitdiffstats
path: root/wizards/source/sfwidgets/SF_Toolbar.xba
blob: c457a62f1cad013787461bbb59b025ce8acaf48f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="SF_Toolbar" script:language="StarBasic" script:moduleType="normal">REM =======================================================================================================================
REM ===			The ScriptForge library and its associated libraries are part of the LibreOffice project.				===
REM	===						The SFWidgets library is one of the associated libraries.									===
REM ===					Full documentation is available on https://help.libreoffice.org/								===
REM =======================================================================================================================

Option Compatible
Option ClassModule

Option Explicit

&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;
&apos;&apos;&apos;	SF_Toolbar
&apos;&apos;&apos;	==========
&apos;&apos;&apos;		Hide/show a toolbar related to a component/document.
&apos;&apos;&apos;
&apos;&apos;&apos;		Each component has its own set of toolbars, depending on the component type
&apos;&apos;&apos;		(Calc, Writer, Basic IDE, ...).
&apos;&apos;&apos;		In the context of the actual class, a toolbar is presumed defined statically:
&apos;&apos;&apos;			- either by the application
&apos;&apos;&apos;			- or by a customization done by the user.
&apos;&apos;&apos;		The definition of a toolbar can be stored in the application configuration files
&apos;&apos;&apos;		or in a specific document.
&apos;&apos;&apos;		Changes made by scripts to toolbars stored in the application are persistent.
&apos;&apos;&apos;		They are valid for all documents of the same type.
&apos;&apos;&apos;
&apos;&apos;&apos;		Note that the menubar and the statusbar are not considered toolbars in this context.
&apos;&apos;&apos;
&apos;&apos;&apos;		A toolbar consists in a series of graphical controls to trigger actions.
&apos;&apos;&apos;		The &quot;Toolbar&quot; service gives access to the &quot;ToolbarButton&quot; service to manage
&apos;&apos;&apos;		the individual buttons belonging to the toolbar.
&apos;&apos;&apos;
&apos;&apos;&apos;		The name of a toolbar is either:
&apos;&apos;&apos;			- its so-called UIName when it is available,
&apos;&apos;&apos;			- or the last component of the resource URL: &quot;private:resource/toolbar/the-name-here&quot;
&apos;&apos;&apos;
&apos;&apos;&apos;		Service invocation:
&apos;&apos;&apos;			The Toolbars() method returns the list of available toolbar names
&apos;&apos;&apos;			The Toolbars(toolbarname) returns a Toolbar service
&apos;&apos;&apos;			It is available from
&apos;&apos;&apos;				- the UI service to access the toolbars of the Basic IDE (&quot;BASICIDE&quot;),
&apos;&apos;&apos;				  the start center (&quot;WELCOMESCREEN&quot;) or the active window
&apos;&apos;&apos;				- the Document, Calc, Writer, Datasheet, FormDocument services to access
&apos;&apos;&apos;				  their respective set of toolbars.
&apos;&apos;&apos;			Example:
&apos;&apos;&apos;				Dim oCalc As Object, oToolbar As Object
&apos;&apos;&apos;				Set oCalc = CreateScriptService(&quot;Calc&quot;, &quot;myFile.ods&quot;)
&apos;&apos;&apos;				Set oToolbar = oCalc.Toolbars(&quot;findbar&quot;)

REM ================================================================== EXCEPTIONS

REM ============================================================= PRIVATE MEMBERS

Private [Me]					As Object
Private ObjectType				As String		&apos; Must be TOOLBAR
Private ServiceName 			As String

Private _Component				As Object		&apos; com.sun.star.lang.XComponent
Private _ResourceURL			As String		&apos; Toolbar internal name
Private _UIName					As String		&apos; Toolbar external name, may be &quot;&quot;
Private _UIConfigurationManager	As Object		&apos; com.sun.star.ui.XUIConfigurationManager
Private _ElementsInfoIndex		As Long			&apos; Index of the toolbar in the getElementsInfo(0) array
Private _Storage				As Long			&apos; One of the toolbar location constants
Private _LayoutManager			As Object		&apos; com.sun.star.comp.framework.LayoutManager

Private _ToolbarButtons			As Object		&apos; SF_Dictionary of toolbar buttons

Type _ToolbarButton
	Toolbar						As Object		&apos; The actual SF_Toolbar object instance
	Index						As Long			&apos; Entry number in buttons lists
	Label						As String		&apos; Label (static description)
	AccessibleName				As String		&apos; Name found in accessible context
	Element						As Object		&apos; com.sun.star.ui.XUIElement
End Type

REM ============================================================ MODULE CONSTANTS

&apos;	Toolbar locations
Private Const cstBUILTINTOOLBAR			= 0		&apos; Standard toolbar
Private Const cstCUSTOMTOOLBAR			= 1		&apos; Toolbar added by user and stored in the LibreOffice application
Private Const cstCUSTOMDOCTOOLBAR		= 2		&apos; Toolbar added by user solely for a single document

REM ====================================================== CONSTRUCTOR/DESTRUCTOR

REM -----------------------------------------------------------------------------
Private Sub Class_Initialize()
	Set [Me] = Nothing
	ObjectType = &quot;TOOLBAR&quot;
	ServiceName = &quot;SFWidgets.Toolbar&quot;
	Set _Component = Nothing
	_ResourceURL = &quot;&quot;
	_UIName = &quot;&quot;
	Set _UIConfigurationManager = Nothing
	_ElementsInfoIndex = -1
	_Storage = 0
	Set _LayoutManager = Nothing
	Set _ToolbarButtons = Nothing
End Sub		&apos;	SFWidgets.SF_Toolbar Constructor

REM -----------------------------------------------------------------------------
Private Sub Class_Terminate()
	Call Class_Initialize()
End Sub		&apos;	SFWidgets.SF_Toolbar Destructor

REM -----------------------------------------------------------------------------
Public Function Dispose() As Variant
	Call Class_Terminate()
	Set Dispose = Nothing
End Function	&apos;	SFWidgets.SF_Toolbar Explicit Destructor

REM ================================================================== PROPERTIES

REM -----------------------------------------------------------------------------
Property Get BuiltIn() As Boolean
&apos;&apos;&apos;	Returns True when the toolbar is part of the set of standard toolbars shipped with the application.
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		MsgBox myToolbar.BuiltIn

	BuiltIn = _PropertyGet(&quot;BuiltIn&quot;)

End Property	&apos;	SFWidgets.SF_Toolbar.BuiltIn (get)

REM -----------------------------------------------------------------------------
Property Get Docked() As Variant
&apos;&apos;&apos;	Returns True when the toolbar is active in the window and Docked.
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		MsgBox myToolbar.Docked

	Docked = _PropertyGet(&quot;Docked&quot;)

End Property	&apos;	SFWidgets.SF_Toolbar.Docked (get)

REM -----------------------------------------------------------------------------
Property Get HasGlobalScope() As Boolean
&apos;&apos;&apos;	Returns True when the toolbar is available in all documents of the same type
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		MsgBox myToolbar.HasGlobalScope

	HasGlobalScope = _PropertyGet(&quot;HasGlobalScope&quot;)

End Property	&apos;	SFWidgets.SF_Toolbar.HasGlobalScope (get)

REM -----------------------------------------------------------------------------
Property Get Name() As String
&apos;&apos;&apos;	Returns the name of the toolbar
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		MsgBox myToolbar.Name

	Name = _PropertyGet(&quot;Name&quot;)

End Property	&apos;	SFWidgets.SF_Toolbar.Name (get)

REM -----------------------------------------------------------------------------
Property Get ResourceURL() As String
&apos;&apos;&apos;	Returns URL of the toolbar, in the form private:toolbar/xxx
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		MsgBox myToolbar.ResourceURL

	ResourceURL = _PropertyGet(&quot;ResourceURL&quot;)

End Property	&apos;	SFWidgets.SF_Toolbar.ResourceURL (get)

REM -----------------------------------------------------------------------------
Property Get Visible() As Variant
&apos;&apos;&apos;	Returns True when the toolbar is active in the window and visible.
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		MsgBox myToolbar.Visible

	Visible = _PropertyGet(&quot;Visible&quot;)

End Property	&apos;	SFWidgets.SF_Toolbar.Visible (get)

REM -----------------------------------------------------------------------------
Property Let Visible(ByVal pvVisible As Variant)
&apos;&apos;&apos;	Sets the visible status of the toolbar.
&apos;&apos;&apos;	When the toolbar is not yet active i the window, it is first created.
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		myToolbar.Visible = True

	_PropertySet(&quot;Visible&quot;, pvVisible)

End Property	&apos;	SFWidgets.SF_Toolbar.Visible (let)

REM -----------------------------------------------------------------------------
Property Get XUIElement() As Variant
&apos;&apos;&apos;	Returns the com.sun.star.ui.XUIElement UNO object corresponding with the toolbar
&apos;&apos;&apos;	Example:
&apos;&apos;&apos;		MsgBox myToolbar.XUIElement

	XUIElement = _PropertyGet(&quot;XUIElement&quot;)

End Property	&apos;	SFWidgets.SF_Toolbar.XUIElement (get)

REM ===================================================================== METHODS

REM -----------------------------------------------------------------------------
Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
&apos;&apos;&apos;	Return the actual value of the given property
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		PropertyName: the name of the property as a string
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		The actual value of the property
&apos;&apos;&apos;		If the property does not exist, returns Null
&apos;&apos;&apos;	Exceptions:
&apos;&apos;&apos;		see the exceptions of the individual properties
&apos;&apos;&apos;	Examples:
&apos;&apos;&apos;		myToolbar.GetProperty(&quot;Visible&quot;)

Const cstThisSub = &quot;SFWidgets.Toolbar.GetProperty&quot;
Const cstSubArgs = &quot;&quot;

	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
	GetProperty = Null

Check:
	If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
		If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
	End If

Try:
	GetProperty = _PropertyGet(PropertyName)

Finally:
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	GoTo Finally
End Function	&apos;	SFWidgets.SF_Toolbar.GetProperty

REM -----------------------------------------------------------------------------
Public Function Methods() As Variant
&apos;&apos;&apos;	Return the list of public methods of the Model service as an array

	Methods = Array( _
					&quot;ToolbarButtons&quot; _
					)

End Function	&apos;	SFWidgets.SF_Toolbar.Methods

REM -----------------------------------------------------------------------------
Public Function Properties() As Variant
&apos;&apos;&apos;	Return the list or properties of the Timer a.AddItem(&quot;B&gt;B1&quot;)class as an array

	Properties = Array( _
					&quot;BuiltIn&quot; _
					, &quot;Docked&quot; _
					, &quot;HasGlobalScope&quot; _
					, &quot;Name&quot; _
					, &quot;ResourceURL&quot; _
					, &quot;Visible&quot; _
					, &quot;XUIElement&quot; _
					)

End Function	&apos;	SFWidgets.SF_Toolbar.Properties

REM -----------------------------------------------------------------------------
Public Function SetProperty(Optional ByVal PropertyName As Variant _
								, Optional ByRef Value As Variant _
								) As Boolean
&apos;&apos;&apos;	Set a new value to the given property
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		PropertyName: the name of the property as a string
&apos;&apos;&apos;		Value: its new value
&apos;&apos;&apos;	Exceptions
&apos;&apos;&apos;		ARGUMENTERROR		The property does not exist

Const cstThisSub = &quot;SFWidgets.Toolbar.SetProperty&quot;
Const cstSubArgs = &quot;PropertyName, Value&quot;

	If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
	SetProperty = False

Check:
	If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
		If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
	End If

Try:
	SetProperty = _PropertySet(PropertyName, Value)

Finally:
	SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	GoTo Finally
End Function	&apos;	SFWidgets.SF_Toolbar.SetProperty

REM -----------------------------------------------------------------------------
Public Function ToolbarButtons(Optional ByVal ButtonName As Variant) As Variant
&apos;&apos;&apos;	Returns either a list of the available toolbar button names in the actual toolbar
&apos;&apos;&apos;	or a ToolbarButton object instance.
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		ButtonName: the usual name of one of the available buttons in the actual toolbar
&apos;&apos;&apos;	Returns:
&apos;&apos;&apos;		A zero-based array of button names when the argument is absent,
&apos;&apos;&apos;		or a new ToolbarButton object instance.
&apos;&apos;&apos;		An inactive toolbar has no buttons =&gt; the actual method forces the toolbar to be made visible first.

Const cstThisSub = &quot;SFWidgets.Toolbar.ToolbarButtons&quot;
Const cstSubArgs = &quot;[ButtonName=&quot;&quot;&quot;&quot;]&quot;

	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch

Check:
	If IsMissing(ButtonName) Or IsEmpty(ButtonName) Then ButtonName = &quot;&quot;
	&apos;	Store button descriptions in cache
	_CollectAllButtons()
	If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
		If VarType(ButtonName) = V_STRING Then
			If Len(ButtonName) &gt; 0 Then
				If Not ScriptForge.SF_Utils._Validate(ButtonName, &quot;ButtonName&quot;, V_STRING, _ToolbarButtons.Keys()) Then GoTo Finally
			End If
		Else
			If Not ScriptForge.SF_Utils._Validate(ButtonName, &quot;ButtonName&quot;, V_STRING) Then GoTo Finally	&apos;	Manage here the VarType error
		End If
	End If

Try:
	If Len(ButtonName) = 0 Then
		ToolbarButtons = _ToolbarButtons.Keys()
	Else
		ToolbarButtons = CreateScriptService(&quot;SFWidgets.ToolbarButton&quot;, _ToolbarButtons.Item(ButtonName))
	End If

Finally:
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	GoTo Finally
End Function	&apos;	SFWidgets.SF_Toolbar.ToolbarButtons

REM =========================================================== PRIVATE FUNCTIONS

REM -----------------------------------------------------------------------------
Private Sub _CollectAllButtons()
&apos;&apos;&apos;	Stores a SF_Dictionary object instance, with
&apos;&apos;&apos;	- key = name of the button
&apos;&apos;&apos;	- item = a _ButtonDesc object type
&apos;&apos;&apos;	into _ToolbarButtons, a cache for all buttons.
&apos;&apos;&apos;	The toolbar is made visible before collecting the buttons.
&apos;&apos;&apos;
&apos;&apos;&apos;	The name of the buttons is derived either from:
&apos;&apos;&apos;		- the Label property of the static toolbar and toolbar buttons  definitions
&apos;&apos;&apos;		- or the AccessibleName property of the AccessibleContext of the button
&apos;&apos;&apos;	whichever is found first.
&apos;&apos;&apos;	Separators are skipped.
&apos;&apos;&apos;	If there are homonyms (&gt;= 2 buttons having the same name), only the 1st one is retained.

Dim oElement As Object				&apos;	com.sun.star.ui.XUIElement
Dim oSettings As Object				&apos;	com.sun.star.container.XIndexAccess
Dim vProperties() As Variant		&apos;	Array of property values
Dim iType As Integer				&apos;	Separators have type = 1, others have Type = 0
Dim oAccessible As Object			&apos;	com.sun.star.accessibility.XAccessible
Dim sLabel As String				&apos;	Label in static description
Dim sAccessibleName As String		&apos;	Name in AccessibleContext
Dim sButtonName As String			&apos;	Key part in dictionary entry
Dim oButton As Object				&apos;	Item part in dictionary entry
Dim i As Long

	On Local Error GoTo Catch
	If Not IsNull(_ToolbarButtons) Then GoTo Finally		&apos;	Do not redo the job if already done

Try:
	&apos;	Force the visibility of the toolbar
	Visible = True

	Set _ToolbarButtons = ScriptForge.SF_Services.CreateScriptService(&quot;ScriptForge.Dictionary&quot;)
	Set oElement = _LayoutManager.getElement(_ResourceURL)
	Set oSettings = oElement.getSettings(True)

	With oSettings
		For i = 0 To .Count - 1
			vProperties = .getByIndex(i)
			iType = ScriptForge.SF_Utils._GetPropertyValue(vProperties, &quot;Type&quot;)
			If iType = 0 Then		&apos;	Usual button
				sLabel = ScriptForge.SF_Utils._GetPropertyValue(vProperties, &quot;Label&quot;)
				If Len(sLabel) = 0 Then
					Set oAccessible = oElement.RealInterface.AccessibleContext.getAccessibleChild(i)
					sAccessibleName = oAccessible.AccessibleName
				Else
					sAccessibleName = &quot;&quot;
				End If
				&apos;	Store in dictionary
				sButtonName = sLabel &amp; sAccessibleName		&apos;	At least 1 of them is blank
				If Len(sButtonName) &gt; 0 Then
					Set oButton = New _ToolbarButton
					With oButton
						Set .Toolbar = [Me]
						.Index = i
						.Label = sLabel
						.AccessibleName = sAccessibleName
						Set .Element = oElement
					End With
					With _ToolbarButtons
						If Not .Exists(sButtonName) Then .Add(sButtonName, oButton)
					End With
				End If
			End If
		Next i
	End With

Finally:
	Exit Sub
Catch:
	&apos;	_ToolbarButtons is left unchanged
	GoTo Finally
End Sub			&apos;	SFWidgets.SF_Toolbar._CollectAllButtons

REM -----------------------------------------------------------------------------
Public Sub _Initialize(ByRef poToolbar As Object)
&apos;&apos;&apos;	Complete the object creation process:
&apos;&apos;&apos;		- Initialize the toolbar descriptioner use
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		poToolbar: the toolbar description as a ui._Toolbr object

Try:
	&apos;	Store the static description
	With poToolbar
		_Component = .Component
		_ResourceURL = .ResourceURL
		_UIName = .UIName
		_UIConfigurationManager = .UIConfigurationManager
		_ElementsInfoIndex = .ElementsInfoIndex
		_Storage = .Storage
	End With

	&apos;	Complement
	If Len(_UIName) = 0 Then _UIName = Split(_ResourceURL, &quot;/&quot;)(2)
	Set _LayoutManager = _Component.CurrentController.Frame.LayoutManager

Finally:
	Exit Sub
End Sub			&apos;	SFWidgets.SF_Toolbar._Initialize

REM -----------------------------------------------------------------------------
Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
&apos;&apos;&apos;	Return the value of the named property
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		psProperty: the name of the property

Dim vGet As Variant							&apos;	Return value
Dim oElement As Object						&apos;	com.sun.star.ui.XUIElement
Dim cstThisSub As String
Const cstSubArgs = &quot;&quot;

	cstThisSub = &quot;SFWidgets.Toolbar.get&quot; &amp; psProperty
	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch

	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
	_PropertyGet = Null

	Select Case UCase(psProperty)
		Case UCase(&quot;BuiltIn&quot;)
			_PropertyGet = ( _Storage = cstBUILTINTOOLBAR )
		Case UCase(&quot;Docked&quot;)
			Set oElement = _LayoutManager.getElement(_ResourceURL)
			If Not IsNull(oElement) Then _PropertyGet = _LayoutManager.isElementDocked(_ResourceURL) Else _PropertyGet = False
		Case UCase(&quot;HasGlobalScope&quot;)
			_PropertyGet = ( _Storage = cstBUILTINTOOLBAR Or _Storage = cstCUSTOMTOOLBAR )
		Case UCase(&quot;Name&quot;)
			_PropertyGet = _UIName
		Case UCase(&quot;ResourceURL&quot;)
			_PropertyGet = _ResourceURL
		Case UCase(&quot;Visible&quot;)
			Set oElement = _LayoutManager.getElement(_ResourceURL)
			If Not IsNull(oElement) Then _PropertyGet = _LayoutManager.isElementVisible(_ResourceURL) Else _PropertyGet = False
		Case UCase(&quot;XUIElement&quot;)
			_PropertyGet = _LayoutManager.getElement(_ResourceURL)
		Case Else
			_PropertyGet = Null
	End Select

Finally:
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	GoTo Finally
End Function	&apos;	SFWidgets.SF_Toolbar._PropertyGet

REM -----------------------------------------------------------------------------
Private Function _PropertySet(Optional ByVal psProperty As String _
								, Optional ByVal pvValue As Variant _
								) As Boolean
&apos;&apos;&apos;	Set the new value of the named property
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;		psProperty: the name of the property
&apos;&apos;&apos;		pvValue: the new value of the given property

Dim bSet As Boolean							&apos;	Return value
Dim oElement As Object						&apos;	com.sun.star.ui.XUIElement
Dim bVisible As Boolean						&apos;	Actual Visible state

Dim cstThisSub As String
Const cstSubArgs = &quot;Value&quot;

	If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
	bSet = False

	cstThisSub = &quot;SFWidgets.Toolbar.set&quot; &amp; psProperty
	ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)

	bSet = True
	Select Case UCase(psProperty)
		Case UCase(&quot;Visible&quot;)
			If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_BOOLEAN) Then GoTo Catch
			With _LayoutManager
				Set oElement = .getElement(_ResourceURL)
				If Not IsNull(oElement) Then bVisible = .isElementVisible(_ResourceURL) Else bVisible = False
				&apos;	If there is no change, do nothing
				If Not bVisible = pvValue Then
					If IsNull(oElement) And pvValue Then .createElement(_ResourceURL)
					If pvValue Then .showElement(_ResourceURL) Else .hideElement(_ResourceURL)
				End If
			End With
		Case Else
			bSet = False
	End Select

Finally:
	_PropertySet = bSet
	ScriptForge.SF_Utils._ExitFunction(cstThisSub)
	Exit Function
Catch:
	bSet = False
	GoTo Finally
End Function	&apos;	SFWidgets.SF_Toolbar._PropertySet

REM -----------------------------------------------------------------------------
Private Function _Repr() As String
&apos;&apos;&apos;	Convert the SF_Toolbar instance to a readable string, typically for debugging purposes (DebugPrint ...)
&apos;&apos;&apos;	Args:
&apos;&apos;&apos;	Return:
&apos;&apos;&apos;		&quot;[Toolbar]: Name, Type (dialogname)
	_Repr = &quot;[Toolbar]: &quot; &amp; _UIName &amp; &quot; - &quot; &amp; _ResourceURL

End Function	&apos;	SFWidgets.SF_Toolbar._Repr

REM ============================================ END OF SFWIDGETS.SF_TOOLBAR
</script:module>