calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / wizards / source / sfdocuments / SF_FormControl.xba
bloba48c22b6c1c5b2360c433e4450e121009f4d0b05
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_FormControl" 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 SFDocuments 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_FormControl
16 &apos;&apos;&apos; ================
17 &apos;&apos;&apos; Manage the controls belonging to a form or subform stored in a document
18 &apos;&apos;&apos; Each instance of the current class represents a single control within a form, a subform or a tablecontrol
19 &apos;&apos;&apos; A prerequisite is that all controls within the same form, subform or tablecontrol must have
20 &apos;&apos;&apos; a unique name. This is also true for the individual radio buttons belonging to the same group.
21 &apos;&apos;&apos; A common group name must identify such a single group.
22 &apos;&apos;&apos;
23 &apos;&apos;&apos; The focus is clearly set on getting and setting the values displayed by the controls of the form,
24 &apos;&apos;&apos; not on their formatting. The latter is easily accessible via the XControlModel and XControlView
25 &apos;&apos;&apos; UNO objects.
26 &apos;&apos;&apos; Essentially a single property &quot;Value&quot; maps many alternative UNO properties depending each on
27 &apos;&apos;&apos; the control type.
28 &apos;&apos;&apos;
29 &apos;&apos;&apos; Service invocations:
30 &apos;&apos;&apos; Dim myForm As Object, myControl As Object
31 &apos;&apos;&apos; Set myForm = ... (read the comments in the SF_Form module)
32 &apos;&apos;&apos; Set myControl = myForm.Controls(&quot;myTextBox&quot;)
33 &apos;&apos;&apos; myControl.Value = &quot;Current time = &quot; &amp; Now()
34 &apos;&apos;&apos;
35 &apos;&apos;&apos; REM the control is the subject of an event
36 &apos;&apos;&apos; Sub OnEvent(ByRef poEvent As Object)
37 &apos;&apos;&apos; Dim myControl As Object
38 &apos;&apos;&apos; Set myControl = CreateScriptService(&quot;SFDocuments.FormEvent&quot;, poEvent)
39 &apos;&apos;&apos;
40 &apos;&apos;&apos; Detailed user documentation:
41 &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_formcontrol.html?DbPAR=BASIC
42 &apos;&apos;&apos;
43 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
45 REM ================================================================== EXCEPTIONS
47 Private Const FORMCONTROLTYPEERROR = &quot;FORMCONTROLTYPEERROR&quot;
49 REM ============================================================= PRIVATE MEMBERS
51 Private [Me] As Object
52 Private [_Parent] As Object
53 Private ObjectType As String &apos; Must be FORMCONTROL
54 Private ServiceName As String
56 &apos; Control naming and context
57 Private _Name As String
58 Private _IndexOfNames As Long &apos; Index in ElementNames array. Used to access SF_Form._ControlCache
59 Private _FormName As String &apos; Parent form name
60 Private _ParentForm As Object &apos; Parent form or subform instance
61 Private _ParentIsTable As Boolean &apos; True when parent is a table control
63 &apos; Control UNO references
64 Private _ControlModel As Object &apos; com.sun.star.awt.XControlModel
65 Private _ControlView As Object &apos; com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
67 &apos; Control attributes
68 Private _ImplementationName As String
69 Private _ControlType As String &apos; One of the CTLxxx constants
70 Private _ClassId As Integer &apos; Numerical type of control
72 &apos; Cache storage for table controls
73 Private _ControlNames As Variant &apos; Array of control names
74 Private _ControlCache As Variant &apos; Array of control objects sorted like ElementNames of XControlModel
76 REM ============================================================ MODULE CONSTANTS
78 &apos; ClassId
79 Private Const CTLBUTTON = &quot;Button&quot; &apos; 2
80 Private Const CTLCHECKBOX = &quot;CheckBox&quot; &apos; 5
81 Private Const CTLCOMBOBOX = &quot;ComboBox&quot; &apos; 7
82 Private Const CTLCURRENCYFIELD = &quot;CurrencyField&quot; &apos; 18
83 Private Const CTLDATEFIELD = &quot;DateField&quot; &apos; 15
84 Private Const CTLFILECONTROL = &quot;FileControl&quot; &apos; 12
85 Private Const CTLFIXEDTEXT = &quot;FixedText&quot; &apos; 10
86 Private Const CTLFORMATTEDFIELD = &quot;FormattedField&quot; &apos; Idem TextField
87 Private Const CTLGROUPBOX = &quot;GroupBox&quot; &apos; 8
88 Private Const CTLHIDDENCONTROL = &quot;HiddenControl&quot; &apos; 13
89 Private Const CTLIMAGEBUTTON = &quot;ImageButton&quot; &apos; 4
90 Private Const CTLIMAGECONTROL = &quot;ImageControl&quot; &apos; 14
91 Private Const CTLLISTBOX = &quot;ListBox&quot; &apos; 6
92 Private Const CTLNAVIGATIONBAR = &quot;NavigationBar&quot; &apos; 22
93 Private Const CTLNUMERICFIELD = &quot;NumericField&quot; &apos; 17
94 Private Const CTLPATTERNFIELD = &quot;PatternField&quot; &apos; 19
95 Private Const CTLRADIOBUTTON = &quot;RadioButton&quot; &apos; 3
96 Private Const CTLSCROLLBAR = &quot;ScrollBar&quot; &apos; 20
97 Private Const CTLSPINBUTTON = &quot;SpinButton&quot; &apos; 21
98 Private Const CTLTABLECONTROL = &quot;TableControl&quot; &apos; 11
99 Private Const CTLTEXTFIELD = &quot;TextField&quot; &apos; 9
100 Private Const CTLTIMEFIELD = &quot;TimeField&quot; &apos; 16
102 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
104 REM -----------------------------------------------------------------------------
105 Private Sub Class_Initialize()
106 Set [Me] = Nothing
107 Set [_Parent] = Nothing
108 ObjectType = &quot;FORMCONTROL&quot;
109 ServiceName = &quot;SFDocuments.FormControl&quot;
110 _Name = &quot;&quot;
111 _IndexOfNames = -1
112 _FormName = &quot;&quot;
113 _ParentIsTable = False
114 Set _ParentForm = Nothing
115 Set _ControlModel = Nothing
116 Set _ControlView = Nothing
117 _ImplementationName = &quot;&quot;
118 _ControlType = &quot;&quot;
119 _ClassId = 0
120 _ControlNames = Array()
121 _ControlCache = Array()
122 End Sub &apos; SFDocuments.SF_FormControl Constructor
124 REM -----------------------------------------------------------------------------
125 Private Sub Class_Terminate()
126 Call Class_Initialize()
127 End Sub &apos; SFDocuments.SF_FormControl Destructor
129 REM -----------------------------------------------------------------------------
130 Public Function Dispose() As Variant
131 If Not IsNull([_Parent]) And _IndexOfNames &gt;= 0 Then [_Parent]._ControlCache(_IndexOfNames) = Empty
132 Call Class_Terminate()
133 Set Dispose = Nothing
134 End Function &apos; SFDocuments.SF_FormControl Explicit Destructor
136 REM ================================================================== PROPERTIES
138 REM -----------------------------------------------------------------------------
139 Property Get Action() As Variant
140 &apos;&apos;&apos; The Action property specifies the action triggered when the button is clicked
141 &apos;&apos;&apos; Accepted values: none, submitForm, resetForm, refreshForm, moveToFirst, moveToLast,
142 &apos;&apos;&apos; moveToNext, moveToPrev, saveRecord, moveToNew, deleteRecord, undoRecord
143 Action = _PropertyGet(&quot;Action&quot;, &quot;&quot;)
144 End Property &apos; SFDocuments.SF_FormControl.Action (get)
146 REM -----------------------------------------------------------------------------
147 Property Let Action(Optional ByVal pvAction As Variant)
148 &apos;&apos;&apos; Set the updatable property Action
149 _PropertySet(&quot;Action&quot;, pvAction)
150 End Property &apos; SFDocuments.SF_FormControl.Action (let)
152 REM -----------------------------------------------------------------------------
153 Property Get Caption() As Variant
154 &apos;&apos;&apos; The Caption property refers to the text associated with the control
155 Caption = _PropertyGet(&quot;Caption&quot;, &quot;&quot;)
156 End Property &apos; SFDocuments.SF_FormControl.Caption (get)
158 REM -----------------------------------------------------------------------------
159 Property Let Caption(Optional ByVal pvCaption As Variant)
160 &apos;&apos;&apos; Set the updatable property Caption
161 _PropertySet(&quot;Caption&quot;, pvCaption)
162 End Property &apos; SFDocuments.SF_FormControl.Caption (let)
164 REM -----------------------------------------------------------------------------
165 Property Get ControlSource() As Variant
166 &apos;&apos;&apos; The ControlSource property specifies the rowset field mapped onto the actual control
167 ControlSource = _PropertyGet(&quot;ControlSource&quot;, &quot;&quot;)
168 End Property &apos; SFDocuments.SF_FormControl.ControlSource (get)
170 REM -----------------------------------------------------------------------------
171 Property Get ControlType() As String
172 &apos;&apos;&apos; Return the type of the actual control: &quot;CheckBox&quot;, &quot;TextField&quot;, &quot;DateField&quot;, ...
173 ControlType = _PropertyGet(&quot;ControlType&quot;)
174 End Property &apos; SFDocuments.SF_FormControl.ControlType
176 REM -----------------------------------------------------------------------------
177 Property Get Default() As Variant
178 &apos;&apos;&apos; The Default property specifies whether a command button is the default (OK) button.
179 Default = _PropertyGet(&quot;Default&quot;, False)
180 End Property &apos; SFDocuments.SF_FormControl.Default (get)
182 REM -----------------------------------------------------------------------------
183 Property Let Default(Optional ByVal pvDefault As Variant)
184 &apos;&apos;&apos; Set the updatable property Default
185 _PropertySet(&quot;Default&quot;, pvDefault)
186 End Property &apos; SFDocuments.SF_FormControl.Default (let)
188 REM -----------------------------------------------------------------------------
189 Property Get DefaultValue() As Variant
190 &apos;&apos;&apos; The DefaultValue property specifies how the control is initialized in a new record
191 DefaultValue = _PropertyGet(&quot;DefaultValue&quot;, Null)
192 End Property &apos; SFDocuments.SF_FormControl.DefaultValue (get)
194 REM -----------------------------------------------------------------------------
195 Property Let DefaultValue(Optional ByVal pvDefaultValue As Variant)
196 &apos;&apos;&apos; Set the updatable property DefaultValue
197 _PropertySet(&quot;DefaultValue&quot;, pvDefaultValue)
198 End Property &apos; SFDocuments.SF_FormControl.DefaultValue (let)
200 REM -----------------------------------------------------------------------------
201 Property Get Enabled() As Variant
202 &apos;&apos;&apos; The Enabled property specifies if the control is accessible with the cursor.
203 Enabled = _PropertyGet(&quot;Enabled&quot;, False)
204 End Property &apos; SFDocuments.SF_FormControl.Enabled (get)
206 REM -----------------------------------------------------------------------------
207 Property Let Enabled(Optional ByVal pvEnabled As Variant)
208 &apos;&apos;&apos; Set the updatable property Enabled
209 _PropertySet(&quot;Enabled&quot;, pvEnabled)
210 End Property &apos; SFDocuments.SF_FormControl.Enabled (let)
212 REM -----------------------------------------------------------------------------
213 Property Get Format() As Variant
214 &apos;&apos;&apos; The Format property specifies the format in which to display dates and times.
215 Format = _PropertyGet(&quot;Format&quot;, &quot;&quot;)
216 End Property &apos; SFDocuments.SF_FormControl.Format (get)
218 REM -----------------------------------------------------------------------------
219 Property Let Format(Optional ByVal pvFormat As Variant)
220 &apos;&apos;&apos; Set the updatable property Format
221 &apos;&apos;&apos; NB: Format is read-only for formatted field controls
222 _PropertySet(&quot;Format&quot;, pvFormat)
223 End Property &apos; SFDocuments.SF_FormControl.Format (let)
225 REM -----------------------------------------------------------------------------
226 Property Get ListCount() As Long
227 &apos;&apos;&apos; The ListCount property specifies the number of rows in a list box or a combo box
228 ListCount = _PropertyGet(&quot;ListCount&quot;, 0)
229 End Property &apos; SFDocuments.SF_FormControl.ListCount (get)
231 REM -----------------------------------------------------------------------------
232 Property Get ListIndex() As Variant
233 &apos;&apos;&apos; The ListIndex property specifies which item is selected in a list box or combo box.
234 &apos;&apos;&apos; In case of multiple selection, the index of the first one is returned or only one is set
235 ListIndex = _PropertyGet(&quot;ListIndex&quot;, -1)
236 End Property &apos; SFDocuments.SF_FormControl.ListIndex (get)
238 REM -----------------------------------------------------------------------------
239 Property Let ListIndex(Optional ByVal pvListIndex As Variant)
240 &apos;&apos;&apos; Set the updatable property ListIndex
241 _PropertySet(&quot;ListIndex&quot;, pvListIndex)
242 End Property &apos; SFDocuments.SF_FormControl.ListIndex (let)
244 REM -----------------------------------------------------------------------------
245 Property Get ListSource() As Variant
246 &apos;&apos;&apos; The ListSource property specifies the data contained in a combobox or a listbox
247 &apos;&apos;&apos; as a zero-based array of string values
248 ListSource = _PropertyGet(&quot;ListSource&quot;, &quot;&quot;)
249 End Property &apos; SFDocuments.SF_FormControl.ListSource (get)
251 REM -----------------------------------------------------------------------------
252 Property Let ListSource(Optional ByVal pvListSource As Variant)
253 &apos;&apos;&apos; Set the updatable property ListSource
254 _PropertySet(&quot;ListSource&quot;, pvListSource)
255 End Property &apos; SFDocuments.SF_FormControl.ListSource (let)
257 REM -----------------------------------------------------------------------------
258 Property Get ListSourceType() As Variant
259 &apos;&apos;&apos; The ListSourceType property specifies the kind of data source used to fill the list data of a listbox or a combobox
260 ListSourceType = _PropertyGet(&quot;ListSourceType&quot;, &quot;&quot;)
261 End Property &apos; SFDocuments.SF_FormControl.ListSourceType (get)
263 REM -----------------------------------------------------------------------------
264 Property Let ListSourceType(Optional ByVal pvListSourceType As Variant)
265 &apos;&apos;&apos; Set the updatable property ListSourceType
266 _PropertySet(&quot;ListSourceType&quot;, pvListSourceType)
267 End Property &apos; SFDocuments.SF_FormControl.ListSourceType (let)
269 REM -----------------------------------------------------------------------------
270 Property Get Locked() As Variant
271 &apos;&apos;&apos; The Locked property specifies if a control is read-only
272 Locked = _PropertyGet(&quot;Locked&quot;, False)
273 End Property &apos; SFDocuments.SF_FormControl.Locked (get)
275 REM -----------------------------------------------------------------------------
276 Property Let Locked(Optional ByVal pvLocked As Variant)
277 &apos;&apos;&apos; Set the updatable property Locked
278 _PropertySet(&quot;Locked&quot;, pvLocked)
279 End Property &apos; SFDocuments.SF_FormControl.Locked (let)
281 REM -----------------------------------------------------------------------------
282 Property Get MultiSelect() As Variant
283 &apos;&apos;&apos; The MultiSelect property specifies whether a user can make multiple selections in a listbox
284 MultiSelect = _PropertyGet(&quot;MultiSelect&quot;, False)
285 End Property &apos; SFDocuments.SF_FormControl.MultiSelect (get)
287 REM -----------------------------------------------------------------------------
288 Property Let MultiSelect(Optional ByVal pvMultiSelect As Variant)
289 &apos;&apos;&apos; Set the updatable property MultiSelect
290 _PropertySet(&quot;MultiSelect&quot;, pvMultiSelect)
291 End Property &apos; SFDocuments.SF_FormControl.MultiSelect (let)
293 REM -----------------------------------------------------------------------------
294 Property Get Name() As String
295 &apos;&apos;&apos; Return the name of the actual control
296 Name = _PropertyGet(&quot;Name&quot;)
297 End Property &apos; SFDocuments.SF_FormControl.Name
299 REM -----------------------------------------------------------------------------
300 Property Get OnActionPerformed() As Variant
301 &apos;&apos;&apos; Get the script associated with the OnActionPerformed event
302 OnActionPerformed = _PropertyGet(&quot;OnActionPerformed&quot;, &quot;&quot;)
303 End Property &apos; SFDocuments.SF_FormControl.OnActionPerformed (get)
305 REM -----------------------------------------------------------------------------
306 Property Let OnActionPerformed(Optional ByVal pvOnActionPerformed As Variant)
307 &apos;&apos;&apos; Set the updatable property OnActionPerformed
308 _PropertySet(&quot;OnActionPerformed&quot;, pvOnActionPerformed)
309 End Property &apos; SFDocuments.SF_FormControl.OnActionPerformed (let)
311 REM -----------------------------------------------------------------------------
312 Property Get OnAdjustmentValueChanged() As Variant
313 &apos;&apos;&apos; Get the script associated with the OnAdjustmentValueChanged event
314 OnAdjustmentValueChanged = _PropertyGet(&quot;OnAdjustmentValueChanged&quot;, &quot;&quot;)
315 End Property &apos; SFDocuments.SF_FormControl.OnAdjustmentValueChanged (get)
317 REM -----------------------------------------------------------------------------
318 Property Let OnAdjustmentValueChanged(Optional ByVal pvOnAdjustmentValueChanged As Variant)
319 &apos;&apos;&apos; Set the updatable property OnAdjustmentValueChanged
320 _PropertySet(&quot;OnAdjustmentValueChanged&quot;, pvOnAdjustmentValueChanged)
321 End Property &apos; SFDocuments.SF_FormControl.OnAdjustmentValueChanged (let)
323 REM -----------------------------------------------------------------------------
324 Property Get OnApproveAction() As Variant
325 &apos;&apos;&apos; Get the script associated with the OnApproveAction event
326 OnApproveAction = _PropertyGet(&quot;OnApproveAction&quot;, &quot;&quot;)
327 End Property &apos; SFDocuments.SF_FormControl.OnApproveAction (get)
329 REM -----------------------------------------------------------------------------
330 Property Let OnApproveAction(Optional ByVal pvOnApproveAction As Variant)
331 &apos;&apos;&apos; Set the updatable property OnApproveAction
332 _PropertySet(&quot;OnApproveAction&quot;, pvOnApproveAction)
333 End Property &apos; SFDocuments.SF_FormControl.OnApproveAction (let)
335 REM -----------------------------------------------------------------------------
336 Property Get OnApproveReset() As Variant
337 &apos;&apos;&apos; Get the script associated with the OnApproveReset event
338 OnApproveReset = _PropertyGet(&quot;OnApproveReset&quot;, &quot;&quot;)
339 End Property &apos; SFDocuments.SF_FormControl.OnApproveReset (get)
341 REM -----------------------------------------------------------------------------
342 Property Let OnApproveReset(Optional ByVal pvOnApproveReset As Variant)
343 &apos;&apos;&apos; Set the updatable property OnApproveReset
344 _PropertySet(&quot;OnApproveReset&quot;, pvOnApproveReset)
345 End Property &apos; SFDocuments.SF_FormControl.OnApproveReset (let)
347 REM -----------------------------------------------------------------------------
348 Property Get OnApproveUpdate() As Variant
349 &apos;&apos;&apos; Get the script associated with the OnApproveUpdate event
350 OnApproveUpdate = _PropertyGet(&quot;OnApproveUpdate&quot;, &quot;&quot;)
351 End Property &apos; SFDocuments.SF_FormControl.OnApproveUpdate (get)
353 REM -----------------------------------------------------------------------------
354 Property Let OnApproveUpdate(Optional ByVal pvOnApproveUpdate As Variant)
355 &apos;&apos;&apos; Set the updatable property OnApproveUpdate
356 _PropertySet(&quot;OnApproveUpdate&quot;, pvOnApproveUpdate)
357 End Property &apos; SFDocuments.SF_FormControl.OnApproveUpdate (let)
359 REM -----------------------------------------------------------------------------
360 Property Get OnChanged() As Variant
361 &apos;&apos;&apos; Get the script associated with the OnChanged event
362 OnChanged = _PropertyGet(&quot;OnChanged&quot;, &quot;&quot;)
363 End Property &apos; SFDocuments.SF_FormControl.OnChanged (get)
365 REM -----------------------------------------------------------------------------
366 Property Let OnChanged(Optional ByVal pvOnChanged As Variant)
367 &apos;&apos;&apos; Set the updatable property OnChanged
368 _PropertySet(&quot;OnChanged&quot;, pvOnChanged)
369 End Property &apos; SFDocuments.SF_FormControl.OnChanged (let)
371 REM -----------------------------------------------------------------------------
372 Property Get OnErrorOccurred() As Variant
373 &apos;&apos;&apos; Get the script associated with the OnErrorOccurred event
374 OnErrorOccurred = _PropertyGet(&quot;OnErrorOccurred&quot;, &quot;&quot;)
375 End Property &apos; SFDocuments.SF_FormControl.OnErrorOccurred (get)
377 REM -----------------------------------------------------------------------------
378 Property Let OnErrorOccurred(Optional ByVal pvOnErrorOccurred As Variant)
379 &apos;&apos;&apos; Set the updatable property OnErrorOccurred
380 _PropertySet(&quot;OnErrorOccurred&quot;, pvOnErrorOccurred)
381 End Property &apos; SFDocuments.SF_FormControl.OnErrorOccurred (let)
383 REM -----------------------------------------------------------------------------
384 Property Get OnFocusGained() As Variant
385 &apos;&apos;&apos; Get the script associated with the OnFocusGained event
386 OnFocusGained = _PropertyGet(&quot;OnFocusGained&quot;, &quot;&quot;)
387 End Property &apos; SFDocuments.SF_FormControl.OnFocusGained (get)
389 REM -----------------------------------------------------------------------------
390 Property Let OnFocusGained(Optional ByVal pvOnFocusGained As Variant)
391 &apos;&apos;&apos; Set the updatable property OnFocusGained
392 _PropertySet(&quot;OnFocusGained&quot;, pvOnFocusGained)
393 End Property &apos; SFDocuments.SF_FormControl.OnFocusGained (let)
395 REM -----------------------------------------------------------------------------
396 Property Get OnFocusLost() As Variant
397 &apos;&apos;&apos; Get the script associated with the OnFocusLost event
398 OnFocusLost = _PropertyGet(&quot;OnFocusLost&quot;, &quot;&quot;)
399 End Property &apos; SFDocuments.SF_FormControl.OnFocusLost (get)
401 REM -----------------------------------------------------------------------------
402 Property Let OnFocusLost(Optional ByVal pvOnFocusLost As Variant)
403 &apos;&apos;&apos; Set the updatable property OnFocusLost
404 _PropertySet(&quot;OnFocusLost&quot;, pvOnFocusLost)
405 End Property &apos; SFDocuments.SF_FormControl.OnFocusLost (let)
407 REM -----------------------------------------------------------------------------
408 Property Get OnItemStateChanged() As Variant
409 &apos;&apos;&apos; Get the script associated with the OnItemStateChanged event
410 OnItemStateChanged = _PropertyGet(&quot;OnItemStateChanged&quot;, &quot;&quot;)
411 End Property &apos; SFDocuments.SF_FormControl.OnItemStateChanged (get)
413 REM -----------------------------------------------------------------------------
414 Property Let OnItemStateChanged(Optional ByVal pvOnItemStateChanged As Variant)
415 &apos;&apos;&apos; Set the updatable property OnItemStateChanged
416 _PropertySet(&quot;OnItemStateChanged&quot;, pvOnItemStateChanged)
417 End Property &apos; SFDocuments.SF_FormControl.OnItemStateChanged (let)
419 REM -----------------------------------------------------------------------------
420 Property Get OnKeyPressed() As Variant
421 &apos;&apos;&apos; Get the script associated with the OnKeyPressed event
422 OnKeyPressed = _PropertyGet(&quot;OnKeyPressed&quot;, &quot;&quot;)
423 End Property &apos; SFDocuments.SF_FormControl.OnKeyPressed (get)
425 REM -----------------------------------------------------------------------------
426 Property Let OnKeyPressed(Optional ByVal pvOnKeyPressed As Variant)
427 &apos;&apos;&apos; Set the updatable property OnKeyPressed
428 _PropertySet(&quot;OnKeyPressed&quot;, pvOnKeyPressed)
429 End Property &apos; SFDocuments.SF_FormControl.OnKeyPressed (let)
431 REM -----------------------------------------------------------------------------
432 Property Get OnKeyReleased() As Variant
433 &apos;&apos;&apos; Get the script associated with the OnKeyReleased event
434 OnKeyReleased = _PropertyGet(&quot;OnKeyReleased&quot;, &quot;&quot;)
435 End Property &apos; SFDocuments.SF_FormControl.OnKeyReleased (get)
437 REM -----------------------------------------------------------------------------
438 Property Let OnKeyReleased(Optional ByVal pvOnKeyReleased As Variant)
439 &apos;&apos;&apos; Set the updatable property OnKeyReleased
440 _PropertySet(&quot;OnKeyReleased&quot;, pvOnKeyReleased)
441 End Property &apos; SFDocuments.SF_FormControl.OnKeyReleased (let)
443 REM -----------------------------------------------------------------------------
444 Property Get OnMouseDragged() As Variant
445 &apos;&apos;&apos; Get the script associated with the OnMouseDragged event
446 OnMouseDragged = _PropertyGet(&quot;OnMouseDragged&quot;, &quot;&quot;)
447 End Property &apos; SFDocuments.SF_FormControl.OnMouseDragged (get)
449 REM -----------------------------------------------------------------------------
450 Property Let OnMouseDragged(Optional ByVal pvOnMouseDragged As Variant)
451 &apos;&apos;&apos; Set the updatable property OnMouseDragged
452 _PropertySet(&quot;OnMouseDragged&quot;, pvOnMouseDragged)
453 End Property &apos; SFDocuments.SF_FormControl.OnMouseDragged (let)
455 REM -----------------------------------------------------------------------------
456 Property Get OnMouseEntered() As Variant
457 &apos;&apos;&apos; Get the script associated with the OnMouseEntered event
458 OnMouseEntered = _PropertyGet(&quot;OnMouseEntered&quot;, &quot;&quot;)
459 End Property &apos; SFDocuments.SF_FormControl.OnMouseEntered (get)
461 REM -----------------------------------------------------------------------------
462 Property Let OnMouseEntered(Optional ByVal pvOnMouseEntered As Variant)
463 &apos;&apos;&apos; Set the updatable property OnMouseEntered
464 _PropertySet(&quot;OnMouseEntered&quot;, pvOnMouseEntered)
465 End Property &apos; SFDocuments.SF_FormControl.OnMouseEntered (let)
467 REM -----------------------------------------------------------------------------
468 Property Get OnMouseExited() As Variant
469 &apos;&apos;&apos; Get the script associated with the OnMouseExited event
470 OnMouseExited = _PropertyGet(&quot;OnMouseExited&quot;, &quot;&quot;)
471 End Property &apos; SFDocuments.SF_FormControl.OnMouseExited (get)
473 REM -----------------------------------------------------------------------------
474 Property Let OnMouseExited(Optional ByVal pvOnMouseExited As Variant)
475 &apos;&apos;&apos; Set the updatable property OnMouseExited
476 _PropertySet(&quot;OnMouseExited&quot;, pvOnMouseExited)
477 End Property &apos; SFDocuments.SF_FormControl.OnMouseExited (let)
479 REM -----------------------------------------------------------------------------
480 Property Get OnMouseMoved() As Variant
481 &apos;&apos;&apos; Get the script associated with the OnMouseMoved event
482 OnMouseMoved = _PropertyGet(&quot;OnMouseMoved&quot;, &quot;&quot;)
483 End Property &apos; SFDocuments.SF_FormControl.OnMouseMoved (get)
485 REM -----------------------------------------------------------------------------
486 Property Let OnMouseMoved(Optional ByVal pvOnMouseMoved As Variant)
487 &apos;&apos;&apos; Set the updatable property OnMouseMoved
488 _PropertySet(&quot;OnMouseMoved&quot;, pvOnMouseMoved)
489 End Property &apos; SFDocuments.SF_FormControl.OnMouseMoved (let)
491 REM -----------------------------------------------------------------------------
492 Property Get OnMousePressed() As Variant
493 &apos;&apos;&apos; Get the script associated with the OnMousePressed event
494 OnMousePressed = _PropertyGet(&quot;OnMousePressed&quot;, &quot;&quot;)
495 End Property &apos; SFDocuments.SF_FormControl.OnMousePressed (get)
497 REM -----------------------------------------------------------------------------
498 Property Let OnMousePressed(Optional ByVal pvOnMousePressed As Variant)
499 &apos;&apos;&apos; Set the updatable property OnMousePressed
500 _PropertySet(&quot;OnMousePressed&quot;, pvOnMousePressed)
501 End Property &apos; SFDocuments.SF_FormControl.OnMousePressed (let)
503 REM -----------------------------------------------------------------------------
504 Property Get OnMouseReleased() As Variant
505 &apos;&apos;&apos; Get the script associated with the OnMouseReleased event
506 OnMouseReleased = _PropertyGet(&quot;OnMouseReleased&quot;, &quot;&quot;)
507 End Property &apos; SFDocuments.SF_FormControl.OnMouseReleased (get)
509 REM -----------------------------------------------------------------------------
510 Property Let OnMouseReleased(Optional ByVal pvOnMouseReleased As Variant)
511 &apos;&apos;&apos; Set the updatable property OnMouseReleased
512 _PropertySet(&quot;OnMouseReleased&quot;, pvOnMouseReleased)
513 End Property &apos; SFDocuments.SF_FormControl.OnMouseReleased (let)
515 REM -----------------------------------------------------------------------------
516 Property Get OnResetted() As Variant
517 &apos;&apos;&apos; Get the script associated with the OnResetted event
518 OnResetted = _PropertyGet(&quot;OnResetted&quot;, &quot;&quot;)
519 End Property &apos; SFDocuments.SF_FormControl.OnResetted (get)
521 REM -----------------------------------------------------------------------------
522 Property Let OnResetted(Optional ByVal pvOnResetted As Variant)
523 &apos;&apos;&apos; Set the updatable property OnResetted
524 _PropertySet(&quot;OnResetted&quot;, pvOnResetted)
525 End Property &apos; SFDocuments.SF_FormControl.OnResetted (let)
527 REM -----------------------------------------------------------------------------
528 Property Get OnTextChanged() As Variant
529 &apos;&apos;&apos; Get the script associated with the OnTextChanged event
530 OnTextChanged = _PropertyGet(&quot;OnTextChanged&quot;, &quot;&quot;)
531 End Property &apos; SFDocuments.SF_FormControl.OnTextChanged (get)
533 REM -----------------------------------------------------------------------------
534 Property Let OnTextChanged(Optional ByVal pvOnTextChanged As Variant)
535 &apos;&apos;&apos; Set the updatable property OnTextChanged
536 _PropertySet(&quot;OnTextChanged&quot;, pvOnTextChanged)
537 End Property &apos; SFDocuments.SF_FormControl.OnTextChanged (let)
539 REM -----------------------------------------------------------------------------
540 Property Get OnUpdated() As Variant
541 &apos;&apos;&apos; Get the script associated with the OnUpdated event
542 OnUpdated = _PropertyGet(&quot;OnUpdated&quot;, &quot;&quot;)
543 End Property &apos; SFDocuments.SF_FormControl.OnUpdated (get)
545 REM -----------------------------------------------------------------------------
546 Property Let OnUpdated(Optional ByVal pvOnUpdated As Variant)
547 &apos;&apos;&apos; Set the updatable property OnUpdated
548 _PropertySet(&quot;OnUpdated&quot;, pvOnUpdated)
549 End Property &apos; SFDocuments.SF_FormControl.OnUpdated (let)
551 REM -----------------------------------------------------------------------------
552 Property Get Parent() As Object
553 &apos;&apos;&apos; Return the Parent form or [table]control object of the actual control
554 Parent = _PropertyGet(&quot;Parent&quot;, Nothing)
555 End Property &apos; SFDocuments.SF_FormControl.Parent
557 REM -----------------------------------------------------------------------------
558 Property Get Picture() As Variant
559 &apos;&apos;&apos; The Picture property specifies a bitmap or other type of graphic to be displayed on the specified control
560 Picture = _PropertyGet(&quot;Picture&quot;, &quot;&quot;)
561 End Property &apos; SFDocuments.SF_FormControl.Picture (get)
563 REM -----------------------------------------------------------------------------
564 Property Let Picture(Optional ByVal pvPicture As Variant)
565 &apos;&apos;&apos; Set the updatable property Picture
566 _PropertySet(&quot;Picture&quot;, pvPicture)
567 End Property &apos; SFDocuments.SF_FormControl.Picture (let)
569 REM -----------------------------------------------------------------------------
570 Property Get Required() As Variant
571 &apos;&apos;&apos; A control is said Required when it must not contain a null value
572 Required = _PropertyGet(&quot;Required&quot;, False)
573 End Property &apos; SFDocuments.SF_FormControl.Required (get)
575 REM -----------------------------------------------------------------------------
576 Property Let Required(Optional ByVal pvRequired As Variant)
577 &apos;&apos;&apos; Set the updatable property Required
578 _PropertySet(&quot;Required&quot;, pvRequired)
579 End Property &apos; SFDocuments.SF_FormControl.Required (let)
581 REM -----------------------------------------------------------------------------
582 Property Get Text() As Variant
583 &apos;&apos;&apos; The Text property specifies the actual content of the control like it is displayed on the screen
584 Text = _PropertyGet(&quot;Text&quot;, &quot;&quot;)
585 End Property &apos; SFDocuments.SF_FormControl.Text (get)
587 REM -----------------------------------------------------------------------------
588 Property Get TipText() As Variant
589 &apos;&apos;&apos; The TipText property specifies the text that appears in a screentip when you hold the mouse pointer over a control
590 TipText = _PropertyGet(&quot;TipText&quot;, &quot;&quot;)
591 End Property &apos; SFDocuments.SF_FormControl.TipText (get)
593 REM -----------------------------------------------------------------------------
594 Property Let TipText(Optional ByVal pvTipText As Variant)
595 &apos;&apos;&apos; Set the updatable property TipText
596 _PropertySet(&quot;TipText&quot;, pvTipText)
597 End Property &apos; SFDocuments.SF_FormControl.TipText (let)
599 REM -----------------------------------------------------------------------------
600 Property Get TripleState() As Variant
601 &apos;&apos;&apos; The TripleState property specifies how a check box will display Null values
602 &apos;&apos;&apos; When True, the control will cycle through states for Yes, No, and Null values. The control appears dimmed (grayed) when its Value property is set to Null.
603 &apos;&apos;&apos; When False, the control will cycle through states for Yes and No values. Null values display as if they were No values.
604 TripleState = _PropertyGet(&quot;TripleState&quot;, False)
605 End Property &apos; SFDocuments.SF_FormControl.TripleState (get)
607 REM -----------------------------------------------------------------------------
608 Property Let TripleState(Optional ByVal pvTripleState As Variant)
609 &apos;&apos;&apos; Set the updatable property TripleState
610 _PropertySet(&quot;TripleState&quot;, pvTripleState)
611 End Property &apos; SFDocuments.SF_FormControl.TripleState (let)
613 REM -----------------------------------------------------------------------------
614 Property Get Value() As Variant
615 &apos;&apos;&apos; The Value property specifies the data contained in the control
616 Value = _PropertyGet(&quot;Value&quot;, Empty)
617 End Property &apos; SFDocuments.SF_FormControl.Value (get)
619 REM -----------------------------------------------------------------------------
620 Property Let Value(Optional ByVal pvValue As Variant)
621 &apos;&apos;&apos; Set the updatable property Value
622 _PropertySet(&quot;Value&quot;, pvValue)
623 End Property &apos; SFDocuments.SF_FormControl.Value (let)
625 REM -----------------------------------------------------------------------------
626 Property Get Visible() As Variant
627 &apos;&apos;&apos; The Visible property specifies if the control is accessible with the cursor.
628 Visible = _PropertyGet(&quot;Visible&quot;, True)
629 End Property &apos; SFDocuments.SF_FormControl.Visible (get)
631 REM -----------------------------------------------------------------------------
632 Property Let Visible(Optional ByVal pvVisible As Variant)
633 &apos;&apos;&apos; Set the updatable property Visible
634 _PropertySet(&quot;Visible&quot;, pvVisible)
635 End Property &apos; SFDocuments.SF_FormControl.Visible (let)
637 REM -----------------------------------------------------------------------------
638 Property Get XControlModel() As Object
639 &apos;&apos;&apos; The XControlModel property returns the model UNO object of the control
640 XControlModel = _PropertyGet(&quot;XControlModel&quot;, Nothing)
641 End Property &apos; SFDocuments.SF_FormControl.XControlModel (get)
643 REM -----------------------------------------------------------------------------
644 Property Get XControlView() As Object
645 &apos;&apos;&apos; The XControlView property returns the view UNO object of the control
646 XControlView = _PropertyGet(&quot;XControlView&quot;, Nothing)
647 End Property &apos; SFDocuments.SF_FormControl.XControlView (get)
649 REM ===================================================================== METHODS
651 REM -----------------------------------------------------------------------------
652 Public Function Controls(Optional ByVal ControlName As Variant) As Variant
653 &apos;&apos;&apos; Return either
654 &apos;&apos;&apos; - the list of the controls contained in the actual table control
655 &apos;&apos;&apos; - a Form Control object based on its name
656 &apos;&apos;&apos; Args:
657 &apos;&apos;&apos; ControlName: a valid control name as a case-sensitive string. If absent the list is returned
658 &apos;&apos;&apos; Returns:
659 &apos;&apos;&apos; A zero-base array of strings if ControlName is absent
660 &apos;&apos;&apos; An instance of the SF_FormControl class if ControlName exists
661 &apos;&apos;&apos; Exceptions:
662 &apos;&apos;&apos; ControlName is invalid
663 &apos;&apos;&apos; Example:
664 &apos;&apos;&apos; Dim myGrid As Object, myList As Variant, myControl As Object
665 &apos;&apos;&apos; Set myGrid = myForm.Controls(&quot;myTableControl&quot;)
666 &apos;&apos;&apos; myList = myGrid.Controls()
667 &apos;&apos;&apos; Set myControl = myGrid.Controls(&quot;myCheckBox&quot;)
669 Dim oControl As Object &apos; The new control class instance
670 Dim lIndexOfNames As Long &apos; Index in ElementNames array. Used to access _ControlCache
671 Dim vControl As Variant &apos; Alias of _ControlCache entry
672 Dim oView As Object &apos; com.sun.star.awt.XControl - stardiv.Toolkit.UnoDialogControl
673 Dim i As Long
674 Const cstThisSub = &quot;SFDocuments.FormControl.Controls&quot;
675 Const cstSubArgs = &quot;[ControlName]&quot;
677 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
678 Set Controls = Nothing
680 Check:
681 If IsMissing(ControlName) Or IsEmpty(ControlName) Then ControlName = &quot;&quot;
682 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
683 If _ControlType &lt;&gt; CTLTABLECONTROL Then GoTo Catch
684 If Not [_Parent]._IsStillAlive() Then GoTo Finally
685 If Not ScriptForge.SF_Utils._Validate(ControlName, &quot;ControlName&quot;, V_STRING) Then GoTo Finally
686 End If
688 Try:
689 &apos; Collect all control names if not yet done
690 If UBound(_ControlNames) &lt; 0 Then
691 _ControlNames = _ControlModel.getElementNames()
692 If UBound(_ControlNames) &gt;= 0 Then
693 ReDim _ControlCache(0 To UBound(_ControlNames))
694 End If
695 End If
697 &apos; Return the list of controls or a FormControl instance
698 If Len(ControlName) = 0 Then
699 Controls = _ControlNames
701 Else
703 If Not _ControlModel.hasByName(ControlName) Then GoTo CatchNotFound
704 lIndexOfNames = ScriptForge.SF_Array.IndexOf(_ControlNames, ControlName, CaseSensitive := True)
705 &apos; Reuse cache when relevant
706 vControl = _ControlCache(lIndexOfNames)
708 If IsEmpty(vControl) Then
709 &apos; Not in cache =&gt; Create the new form control class instance
710 Set oControl = New SF_FormControl
711 With oControl
712 ._Name = ControlName
713 Set .[Me] = oControl
714 Set .[_Parent] = [Me]
715 ._ParentIsTable = True
716 ._IndexOfNames = lIndexOfNames
717 ._FormName = _FormName
718 Set ._ParentForm = _ParentForm
719 &apos; Get model and view of the current control
720 Set ._ControlModel = _ControlModel.getByName(ControlName)
721 ._ImplementationName = ._ControlModel.ColumnServiceName &apos; getImplementationName aborts for subcontrols !?
722 &apos; Bypass to find the control view: cannot be done from the top component
723 If Not IsNull(_ControlView) Then &apos; Anticipate absence of ControlView in table controls when edit mode
724 For i = 0 to _ControlView.getCount() - 1
725 Set oView = _ControlView.GetByIndex(i)
726 If Not IsNull(oView) Then
727 If oView.getModel.Name = ControlName Then
728 Set ._ControlView = oView
729 Exit For
730 End If
731 End If
732 Next i
733 End If
734 ._Initialize()
735 End With
736 Else
737 Set oControl = vControl
738 End If
740 Set Controls = oControl
741 End If
743 Finally:
744 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
745 Exit Function
746 Catch:
747 GoTo Finally
748 CatchNotFound:
749 ScriptForge.SF_Utils._Validate(ControlName, &quot;ControlName&quot;, V_STRING, _ControlModel.getElementNames())
750 GoTo Finally
751 End Function &apos; SFDocuments.SF_FormControl.Controls
753 REM -----------------------------------------------------------------------------
754 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
755 &apos;&apos;&apos; Return the actual value of the given property
756 &apos;&apos;&apos; Args:
757 &apos;&apos;&apos; PropertyName: the name of the property as a string
758 &apos;&apos;&apos; Returns:
759 &apos;&apos;&apos; The actual value of the property
760 &apos;&apos;&apos; If the property does not exist, returns Null
761 &apos;&apos;&apos; Exceptions:
762 &apos;&apos;&apos; see the exceptions of the individual properties
763 &apos;&apos;&apos; Examples:
764 &apos;&apos;&apos; myControl.GetProperty(&quot;MyProperty&quot;)
766 Dim vDefault As Variant &apos; Default value when property not applicable on control type
767 Const cstThisSub = &quot;SFDocuments.FormControl.GetProperty&quot;
768 Const cstSubArgs = &quot;&quot;
770 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
771 GetProperty = Null
773 Check:
774 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
775 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
776 End If
778 Try:
779 &apos; FormControl properties are far from applicable to all control types
780 &apos; Getting a property must never abort to not interfere with the Basic IDE watch function
781 &apos; Hence a default value must be provided
782 Select Case UCase(PropertyName)
783 Case UCase(&quot;Default&quot;) : vDefault = False
784 Case UCase(&quot;DefaultValue&quot;) : vDefault = Null
785 Case UCase(&quot;Enabled&quot;) : vDefault = False
786 Case UCase(&quot;ListCount&quot;) : vDefault = 0
787 Case UCase(&quot;ListIndex&quot;) : vDefault = -1
788 Case UCase(&quot;Locked&quot;) : vDefault = False
789 Case UCase(&quot;MultiSelect&quot;) : vDefault = False
790 Case UCase(&quot;Parent&quot;) : vDefault = Nothing
791 Case UCase(&quot;Required&quot;) : vDefault = False
792 Case UCase(&quot;TripleState&quot;) : vDefault = False
793 Case UCase(&quot;Value&quot;) : vDefault = Empty
794 Case UCase(&quot;Visible&quot;) : vDefault = True
795 Case UCase(&quot;XControlModel&quot;) : vDefault = Nothing
796 Case UCase(&quot;XControlView&quot;) : vDefault = Nothing
797 Case Else : vDefault = &quot;&quot;
798 End Select
800 GetProperty = _PropertyGet(PropertyName, vDefault)
802 Finally:
803 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
804 Exit Function
805 Catch:
806 GoTo Finally
807 End Function &apos; SFDocuments.SF_FormControl.GetProperty
809 REM -----------------------------------------------------------------------------
810 Public Function Methods() As Variant
811 &apos;&apos;&apos; Return the list of public methods of the FormControl service as an array
813 Methods = Array( _
814 &quot;AddSubNode&quot; _
815 , &quot;AddSubTree&quot; _
816 , &quot;CreateRoot&quot; _
817 , &quot;FindNode&quot; _
818 , &quot;SetFocus&quot; _
819 , &quot;WriteLine&quot; _
822 End Function &apos; SFDocuments.SF_FormControl.Methods
824 REM -----------------------------------------------------------------------------
825 Public Function Properties() As Variant
826 &apos;&apos;&apos; Return the list or properties of the FormControl class as an array
828 Properties = Array( _
829 &quot;Action&quot; _
830 , &quot;Cancel&quot; _
831 , &quot;Caption&quot; _
832 , &quot;ControlSource&quot; _
833 , &quot;ControlType&quot; _
834 , &quot;Default&quot; _
835 , &quot;DefaultValue&quot; _
836 , &quot;Enabled&quot; _
837 , &quot;Format&quot; _
838 , &quot;ListCount&quot; _
839 , &quot;ListIndex&quot; _
840 , &quot;ListSource&quot; _
841 , &quot;ListSourceType&quot; _
842 , &quot;Locked&quot; _
843 , &quot;MultiSelect&quot; _
844 , &quot;Name&quot; _
845 , &quot;OnActionPerformed&quot; _
846 , &quot;OnAdjustmentValueChanged&quot; _
847 , &quot;OnApproveAction&quot; _
848 , &quot;OnApproveReset&quot; _
849 , &quot;OnApproveUpdate&quot; _
850 , &quot;OnChanged&quot; _
851 , &quot;OnErrorOccurred&quot; _
852 , &quot;OnFocusGained&quot; _
853 , &quot;OnFocusLost&quot; _
854 , &quot;OnItemStateChanged&quot; _
855 , &quot;OnKeyPressed&quot; _
856 , &quot;OnKeyReleased&quot; _
857 , &quot;OnMouseDragged&quot; _
858 , &quot;OnMouseEntered&quot; _
859 , &quot;OnMouseExited&quot; _
860 , &quot;OnMouseMoved&quot; _
861 , &quot;OnMousePressed&quot; _
862 , &quot;OnMouseReleased&quot; _
863 , &quot;OnResetted&quot; _
864 , &quot;OnTextChanged&quot; _
865 , &quot;OnUpdated&quot; _
866 , &quot;Parent&quot; _
867 , &quot;Picture&quot; _
868 , &quot;Required&quot; _
869 , &quot;Text&quot; _
870 , &quot;TipText&quot; _
871 , &quot;TripleState&quot; _
872 , &quot;Value&quot; _
873 , &quot;Visible&quot; _
874 , &quot;XControlModel&quot; _
875 , &quot;XControlView&quot; _
878 End Function &apos; SFDocuments.SF_FormControl.Properties
880 REM -----------------------------------------------------------------------------
881 Public Function SetFocus() As Boolean
882 &apos;&apos;&apos; Set the focus on the current Control instance
883 &apos;&apos;&apos; Probably called from after an event occurrence
884 &apos;&apos;&apos; Args:
885 &apos;&apos;&apos; Returns:
886 &apos;&apos;&apos; True if focusing is successful
887 &apos;&apos;&apos; Example:
888 &apos;&apos;&apos; Dim oDoc As Object, oForm As Object, oControl As Object
889 &apos;&apos;&apos; Set oDoc = CreateScriptService(&quot;SFDocuments.Document&quot;, ThisComponent)
890 &apos;&apos;&apos; Set oForm = oDoc.Forms(0)
891 &apos;&apos;&apos; Set oControl = oForm.Controls(&quot;thisControl&quot;)
892 &apos;&apos;&apos; oControl.SetFocus()
894 Dim bSetFocus As Boolean &apos; Return value
895 Dim iColPosition As Integer &apos; Position of control in table
896 Dim oTableModel As Object &apos; XControlModel of parent table
897 Dim oControl As Object &apos; com.sun.star.awt.XControlModel
898 Dim i As Integer, j As Integer
899 Const cstThisSub = &quot;SFDocuments.FormControl.SetFocus&quot;
900 Const cstSubArgs = &quot;&quot;
902 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
903 bSetFocus = False
905 Check:
906 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
907 If Not _ParentForm._IsStillAlive() Then GoTo Finally
908 End If
910 Try:
911 If Not IsNull(_ControlView) Then
912 If _ParentIsTable Then &apos; setFocus() method does not work on controlviews in table control ?!?
913 &apos; Find the column position of the current instance in the parent table control
914 iColPosition = -1
915 Set oTableModel = [_Parent]._ControlModel
916 j = -1
917 For i = 0 To oTableModel.Count - 1
918 Set oControl = oTableModel.getByIndex(i)
919 If Not oControl.Hidden Then j = j + 1 &apos; Skip hidden columns
920 If oControl.Name = _Name Then
921 iColPosition = j
922 Exit For
923 End If
924 Next i
925 If iColPosition &gt;= 0 Then
926 [_Parent]._ControlView.setFocus() &apos;Set first focus on table control itself
927 [_Parent]._ControlView.setCurrentColumnPosition(iColPosition) &apos;Deprecated but no alternative found
928 End If
929 Else
930 _ControlView.setFocus()
931 End If
932 bSetFocus = True
933 End If
934 bSetFocus = True
936 Finally:
937 SetFocus = bSetFocus
938 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
939 Exit Function
940 Catch:
941 GoTo Finally
942 End Function &apos; SFControls.SF_FormControl.SetFocus
944 REM -----------------------------------------------------------------------------
945 Public Function SetProperty(Optional ByVal PropertyName As Variant _
946 , Optional ByRef Value As Variant _
947 ) As Boolean
948 &apos;&apos;&apos; Set a new value to the given property
949 &apos;&apos;&apos; Args:
950 &apos;&apos;&apos; PropertyName: the name of the property as a string
951 &apos;&apos;&apos; Value: its new value
952 &apos;&apos;&apos; Exceptions
953 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
955 Const cstThisSub = &quot;SFDocuments.FormControl.SetProperty&quot;
956 Const cstSubArgs = &quot;PropertyName, Value&quot;
958 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
959 SetProperty = False
961 Check:
962 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
963 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
964 End If
966 Try:
967 SetProperty = _PropertySet(PropertyName, Value)
969 Finally:
970 SF_Utils._ExitFunction(cstThisSub)
971 Exit Function
972 Catch:
973 GoTo Finally
974 End Function &apos; SFDocuments.SF_FormControl.SetProperty
976 REM =========================================================== PRIVATE FUNCTIONS
978 REM -----------------------------------------------------------------------------
979 Private Function _FormatsList() As Variant
980 &apos;&apos;&apos; Return the allowed format entries as a zero-based array for Date and Time control types
982 Dim vFormats() As Variant &apos; Return value
984 Select Case _ControlType
985 Case CTLDATEFIELD
986 vFormats = Array( _
987 &quot;Standard (short)&quot; _
988 , &quot;Standard (short YY)&quot; _
989 , &quot;Standard (short YYYY)&quot; _
990 , &quot;Standard (long)&quot; _
991 , &quot;DD/MM/YY&quot; _
992 , &quot;MM/DD/YY&quot; _
993 , &quot;YY/MM/DD&quot; _
994 , &quot;DD/MM/YYYY&quot; _
995 , &quot;MM/DD/YYYY&quot; _
996 , &quot;YYYY/MM/DD&quot; _
997 , &quot;YY-MM-DD&quot; _
998 , &quot;YYYY-MM-DD&quot; _
1000 Case CTLTIMEFIELD
1001 vFormats = Array( _
1002 &quot;24h short&quot; _
1003 , &quot;24h long&quot; _
1004 , &quot;12h short&quot; _
1005 , &quot;12h long&quot; _
1007 Case Else
1008 vFormats = Array()
1009 End Select
1011 _FormatsList = vFormats
1013 End Function &apos; SFDocuments.SF_FormControl._FormatsList
1015 REM -----------------------------------------------------------------------------
1016 Public Function _GetEventName(ByVal psProperty As String) As String
1017 &apos;&apos;&apos; Return the LO internal event name derived from the SF property name
1018 &apos;&apos;&apos; The SF property name is not case sensitive, while the LO name is case-sensitive
1019 &apos; Corrects the typo on ErrorOccur(r?)ed, if necessary
1021 Dim vProperties As Variant &apos; Array of class properties
1022 Dim sProperty As String &apos; Correctly cased property name
1024 vProperties = Properties()
1025 sProperty = vProperties(ScriptForge.SF_Array.IndexOf(vProperties, psProperty, SortOrder := &quot;ASC&quot;))
1027 _GetEventName = LCase(Mid(sProperty, 3, 1)) &amp; Right(sProperty, Len(sProperty) - 3)
1029 End Function &apos; SFDocuments.SF_FormControl._GetEventName
1031 REM -----------------------------------------------------------------------------
1032 Private Function _GetListener(ByVal psEventName As String) As String
1033 &apos;&apos;&apos; Getting/Setting macros triggered by events requires a Listener-EventName pair
1034 &apos;&apos;&apos; Return the X...Listener corresponding with the event name in argument
1036 Select Case UCase(psEventName)
1037 Case UCase(&quot;OnActionPerformed&quot;)
1038 _GetListener = &quot;XActionListener&quot;
1039 Case UCase(&quot;OnAdjustmentValueChanged&quot;)
1040 _GetListener = &quot;XAdjustmentListener&quot;
1041 Case UCase(&quot;OnApproveAction&quot;)
1042 _GetListener = &quot;XApproveActionListener&quot;
1043 Case UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnResetted&quot;)
1044 _GetListener = &quot;XResetListener&quot;
1045 Case UCase(&quot;OnApproveUpdate&quot;), UCase(&quot;OnUpdated&quot;)
1046 _GetListener = &quot;XUpdateListener&quot;
1047 Case UCase(&quot;OnChanged&quot;)
1048 _GetListener = &quot;XChangeListener&quot;
1049 Case UCase(&quot;OnErrorOccurred&quot;)
1050 _GetListener = &quot;XErrorListener&quot;
1051 Case UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;)
1052 _GetListener = &quot;XFocusListener&quot;
1053 Case UCase(&quot;OnItemStateChanged&quot;)
1054 _GetListener = &quot;XItemListener&quot;
1055 Case UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;)
1056 _GetListener = &quot;XKeyListener&quot;
1057 Case UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseMoved&quot;)
1058 _GetListener = &quot;XMouseMotionListener&quot;
1059 Case UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;)
1060 _GetListener = &quot;XMouseListener&quot;
1061 Case UCase(&quot;OnTextChanged&quot;)
1062 _GetListener = &quot;XTextListener&quot;
1063 End Select
1065 End Function &apos; SFDocuments.SF_FormControl._GetListener
1067 REM -----------------------------------------------------------------------------
1068 Public Sub _Initialize()
1069 &apos;&apos;&apos; Complete the object creation process:
1070 &apos;&apos;&apos; - Initialization of private members
1071 &apos;&apos;&apos; - Collection of specific attributes
1072 &apos;&apos;&apos; - Synchronization with parent form instance
1074 Dim vControlTypes As Variant &apos; Array of control types ordered by the ClassId property of XControlModel - 2
1075 Const acHiddenControl = 13 &apos; Class Id of an hidden control: has no ControlView
1077 vControlTypes = array( CTLBUTTON _
1078 , CTLRADIOBUTTON _
1079 , CTLIMAGEBUTTON _
1080 , CTLCHECKBOX _
1081 , CTLLISTBOX _
1082 , CTLCOMBOBOX _
1083 , CTLGROUPBOX _
1084 , CTLTEXTFIELD _
1085 , CTLFIXEDTEXT _
1086 , CTLTABLECONTROL _
1087 , CTLFILECONTROL _
1088 , CTLHIDDENCONTROL _
1089 , CTLIMAGECONTROL _
1090 , CTLDATEFIELD _
1091 , CTLTIMEFIELD _
1092 , CTLNUMERICFIELD _
1093 , CTLCURRENCYFIELD _
1094 , CTLPATTERNFIELD _
1095 , CTLSCROLLBAR _
1096 , CTLSPINBUTTON _
1097 , CTLNAVIGATIONBAR _
1100 Try:
1101 &apos; _implementationName is set elsewhere for controls in table control
1102 If Len(_ImplementationName) = 0 Then _ImplementationName = ScriptForge.SF_Session.UnoObjectType(_ControlModel)
1103 _ClassId = _ControlModel.ClassId
1105 &apos; Identify the control type, ignore subforms and pay attention to formatted fields
1106 If ScriptForge.SF_Session.HasUnoproperty(_ControlModel, &quot;ClassId&quot;) Then &apos; All control types have a ClassId property except subforms
1107 _ControlType = vControlTypes(_ClassId - 2)
1108 &apos; Formatted fields belong to the TextField family
1109 If _ControlType = CTLTEXTFIELD Then
1110 If _ImplementationName = &quot;com.sun.star.comp.forms.OFormattedFieldWrapper&quot; _
1111 Or _ImplementationName = &quot;com.sun.star.comp.forms.OFormattedFieldWrapper_ForcedFormatted&quot; _
1112 Or _ImplementationName = &quot;com.sun.star.form.component.FormattedField&quot; Then &apos; When in table control
1113 _ControlType = CTLFORMATTEDFIELD
1114 End If
1115 End If
1116 Else
1117 Exit Sub &apos; Ignore subforms, should not happen
1118 End If
1120 With [_Parent]
1121 &apos; Set control view if not set yet
1122 If IsNull(_ControlView) Then
1123 If _ClassId &gt; 0 And _ClassId &lt;&gt; acHiddenControl Then &apos; No view on hidden controls
1124 If IsNull(._FormDocument) Then &apos; Usual document
1125 Set _ControlView = ._Component.CurrentController.getControl(_ControlModel)
1126 Else &apos; Base form document
1127 Set _ControlView = ._FormDocument.Component.CurrentController.getControl(_ControlModel)
1128 End If
1129 End If
1130 End If
1131 End With
1133 &apos; Store the SF_FormControl object in the parent cache
1134 Set _Parent._ControlCache(_IndexOfNames) = [Me]
1136 Finally:
1137 Exit Sub
1138 End Sub &apos; SFDocuments.SF_FormControl._Initialize
1140 REM -----------------------------------------------------------------------------
1141 Private Function _ListboxBound() As Boolean
1142 &apos;&apos;&apos; Return True if the actual control, which is a listbox, has a bound column
1143 &apos;&apos;&apos; Called before setting the value of a listbox, i.e. the value to be rewritten in the underlying table data
1144 &apos;&apos;&apos; The existence of a bound column is derived from the comparison between StringItemList and ValueItemList
1145 &apos;&apos;&apos; String ... : the strings displayed in the list box
1146 &apos;&apos;&apos; Value ... : the database values
1147 &apos;&apos;&apos; If they are different, then there is a bound column
1149 Dim bListboxBound As Boolean &apos; Return value
1150 Dim vValue() As Variant &apos; Alias of the control model ValueItemList
1151 Dim vString() As Variant &apos; Alias of the control model StringItemList
1152 Dim i As Long
1154 bListboxBound = False
1156 With _ControlModel
1157 If Not IsNull(.ValueItemList) _
1158 And .DataField &lt;&gt; &quot;&quot; _
1159 And Not IsNull(.BoundField) _
1160 And ScriptForge.SF_Array.Contains(Array( _
1161 com.sun.star.form.ListSourceType.TABLE _
1162 , com.sun.star.form.ListSourceType.QUERY _
1163 , com.sun.star.form.ListSourceType.SQL _
1164 , com.sun.star.form.ListSourceType.SQLPASSTHROUGH _
1165 ), .ListSourceType) Then
1166 If IsArray(.ValueItemList) Then
1167 vValue = .ValueItemList
1168 vString = .StringItemList
1169 For i = 0 To UBound(vValue)
1170 If VarType(vValue(i)) &lt;&gt; VarType(vString(i)) Then
1171 bListboxBound = True
1172 ElseIf vValue(i) &lt;&gt; vString(i) Then
1173 bListboxBound = True
1174 End If
1175 If bListboxBound Then Exit For
1176 Next i
1177 End If
1178 End If
1179 End With
1181 _ListboxBound = bListboxBound
1183 End Function &apos; _ListboxBound V0.9.0
1185 REM -----------------------------------------------------------------------------
1186 Private Function _PropertyGet(Optional ByVal psProperty As String _
1187 , Optional ByVal pvDefault As Variant _
1188 ) As Variant
1189 &apos;&apos;&apos; Return the value of the named property
1190 &apos;&apos;&apos; Args:
1191 &apos;&apos;&apos; psProperty: the name of the property
1192 &apos;&apos;&apos; pvDefault: the value returned when the property is not applicable on the control&apos;s type
1193 &apos;&apos;&apos; Getting a non-existing property for a specific control type should
1194 &apos;&apos;&apos; not generate an error to not disrupt the Basic IDE debugger
1196 Dim vGet As Variant &apos; Return value
1197 Static oSession As Object &apos; Alias of SF_Session
1198 Dim vSelection As Variant &apos; Alias of Model.SelectedItems or Model.Selection
1199 Dim vList As Variant &apos; Alias of Model.StringItemList
1200 Dim lIndex As Long &apos; Index in StringItemList
1201 Dim sItem As String &apos; A single item
1202 Dim vDate As Variant &apos; Date after conversion from com.sun.star.util.Date or com.sun.star.util.Time
1203 Dim vValues As Variant &apos; Array of listbox values
1204 Dim oControlEvents As Object &apos; com.sun.star.container.XNameContainer
1205 Dim sEventName As String &apos; Internal event name
1206 Const cstUnoUrl = &quot;.uno:FormController/&quot;
1207 Dim i As Long
1208 Dim cstThisSub As String
1209 Const cstSubArgs = &quot;&quot;
1211 cstThisSub = &quot;SFDocuments.FormControl.get&quot; &amp; psProperty
1212 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1214 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
1215 If Not _ParentForm._IsStillAlive() Then GoTo Finally
1217 If IsMissing(pvDefault) Or IsEmpty(pvDefault) Then pvDefault = Null
1218 _PropertyGet = pvDefault
1220 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
1221 Select Case UCase(psProperty)
1222 Case UCase(&quot;Action&quot;)
1223 Select Case _ControlType
1224 Case CTLBUTTON
1225 If oSession.HasUNOProperty(_ControlModel, &quot;ButtonType&quot;) Then
1226 Select Case _ControlModel.ButtonType
1227 Case com.sun.star.form.FormButtonType.PUSH : _PropertyGet = &quot;none&quot;
1228 Case com.sun.star.form.FormButtonType.SUBMIT : _PropertyGet = &quot;submitForm&quot;
1229 Case com.sun.star.form.FormButtonType.RESET : _PropertyGet = &quot;resetForm&quot;
1230 Case com.sun.star.form.FormButtonType.URL
1231 &apos; &quot;.uno:FormController/moveToFirst&quot;
1232 If Left(_ControlModel.TargetURL, Len(cstUnoUrl)) = cstUnoUrl Then
1233 _PropertyGet = Mid(_ControlModel.TargetURL, Len(cstUnoUrl) + 1)
1234 ElseIf Left(_ControlModel.TargetURL, 4) = &quot;http&quot; Then
1235 _PropertyGet = &quot;openWebPage&quot;
1236 ElseIf Left(_ControlModel.TargetURL, 4) = &quot;file&quot; Then
1237 _PropertyGet =&quot;openDocument&quot;
1238 End If
1239 End Select
1240 End If
1241 Case Else : GoTo CatchType
1242 End Select
1243 Case UCase(&quot;Caption&quot;)
1244 Select Case _ControlType
1245 Case CTLBUTTON, CTLCHECKBOX, CTLFIXEDTEXT, CTLGROUPBOX, CTLRADIOBUTTON
1246 If oSession.HasUNOProperty(_ControlModel, &quot;Label&quot;) Then _PropertyGet = _ControlModel.Label
1247 Case Else : GoTo CatchType
1248 End Select
1249 Case UCase(&quot;ControlSource&quot;)
1250 Select Case _ControlType
1251 Case CTLCHECKBOX, CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLFORMATTEDFIELD, CTLIMAGECONTROL, CTLLISTBOX _
1252 , CTLNUMERICFIELD, CTLPATTERNFIELD, CTLRADIOBUTTON, CTLTEXTFIELD, CTLTIMEFIELD
1253 If oSession.HasUNOProperty(_ControlModel, &quot;DataField&quot;) Then _PropertyGet = _ControlModel.DataField
1254 Case Else : GoTo CatchType
1255 End Select
1256 Case UCase(&quot;ControlType&quot;)
1257 _PropertyGet = _ControlType
1258 Case UCase(&quot;Default&quot;)
1259 Select Case _ControlType
1260 Case CTLBUTTON
1261 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultButton&quot;) Then _PropertyGet = _ControlModel.DefaultButton
1262 Case Else : GoTo CatchType
1263 End Select
1264 Case UCase(&quot;DefaultValue&quot;)
1265 Select Case _ControlType
1266 Case CTLCHECKBOX, CTLRADIOBUTTON
1267 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultState&quot;) Then _PropertyGet = _ControlModel.DefaultState
1268 Case CTLCOMBOBOX, CTLFILECONTROL, CTLPATTERNFIELD, CTLTEXTFIELD
1269 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultText&quot;) Then _PropertyGet = _ControlModel.DefaultText
1270 Case CTLCURRENCYFIELD, CTLNUMERICFIELD
1271 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultValue&quot;) Then _PropertyGet = _ControlModel.DefaultValue
1272 Case CTLDATEFIELD
1273 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultDate&quot;) Then
1274 If Not IsEmpty(_ControlModel.DefaultDate) Then
1275 With _ControlModel.DefaultDate
1276 vDate = DateSerial(.Year, .Month, .Day)
1277 End With
1278 _PropertyGet = vDate
1279 End If
1280 End If
1281 Case CTLFORMATTEDFIELD
1282 If oSession.HasUNOProperty(_ControlModel, &quot;EffectiveDefault&quot;) Then _PropertyGet = _ControlModel.EffectiveDefault
1283 Case CTLLISTBOX
1284 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultSelection&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then
1285 vList = _ControlModel.DefaultSelection
1286 If IsArray(vList) Then
1287 If UBound(vList) &gt;= LBound(vList) Then &apos; Is array initialized ?
1288 lIndex = UBound(_ControlModel.StringItemList)
1289 If vList(0) &gt;= 0 And vList(0) &lt;= lIndex Then _PropertyGet = _ControlModel.StringItemList(vList(0))
1290 &apos; Only first default value is considered
1291 End If
1292 End If
1293 End If
1294 Case CTLSPINBUTTON
1295 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultSpinValue&quot;) Then _PropertyGet = _ControlModel.DefaultSpinValue
1296 Case CTLTIMEFIELD
1297 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultTime&quot;) Then
1298 If Not IsEmpty(_ControlModel.DefaultTime) Then
1299 With _ControlModel.DefaultTime
1300 vDate = TimeSerial(.Hours, .Minutes, .Seconds)
1301 End With
1302 _PropertyGet = vDate
1303 End If
1304 End If
1305 Case Else : GoTo CatchType
1306 End Select
1307 Case UCase(&quot;Enabled&quot;)
1308 Select Case _ControlType
1309 Case CTLHIDDENCONTROL : GoTo CatchType
1310 Case Else
1311 If oSession.HasUnoProperty(_ControlModel, &quot;Enabled&quot;) Then _PropertyGet = _ControlModel.Enabled
1312 End Select
1313 Case UCase(&quot;Format&quot;)
1314 Select Case _ControlType
1315 Case CTLDATEFIELD
1316 If oSession.HasUNOProperty(_ControlModel, &quot;DateFormat&quot;) Then _PropertyGet = _FormatsList()(_ControlModel.DateFormat)
1317 Case CTLTIMEFIELD
1318 If oSession.HasUNOProperty(_ControlModel, &quot;TimeFormat&quot;) Then _PropertyGet = _FormatsList()(_ControlModel.TimeFormat)
1319 Case CTLFORMATTEDFIELD
1320 If oSession.HasUNOProperty(_ControlModel, &quot;FormatsSupplier&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;FormatKey&quot;) Then
1321 _PropertyGet = _ControlModel.FormatsSupplier.getNumberFormats.getByKey(_ControlModel.FormatKey).FormatString
1322 End If
1323 Case Else : GoTo CatchType
1324 End Select
1325 Case UCase(&quot;ListCount&quot;)
1326 Select Case _ControlType
1327 Case CTLCOMBOBOX, CTLLISTBOX
1328 If oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then _PropertyGet = UBound(_ControlModel.StringItemList) + 1
1329 Case Else : GoTo CatchType
1330 End Select
1331 Case UCase(&quot;ListIndex&quot;)
1332 Select Case _ControlType
1333 Case CTLCOMBOBOX
1334 _PropertyGet = -1 &apos; Not found, multiselection
1335 If oSession.HasUNOProperty(_ControlModel, &quot;Text&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then
1336 _PropertyGet = ScriptForge.SF_Array.IndexOf(_ControlModel.StringItemList, _ControlModel.Text, CaseSensitive := True)
1337 End If
1338 Case CTLLISTBOX
1339 _PropertyGet = -1 &apos; Not found, multiselection
1340 If oSession.HasUNOProperty(_ControlModel, &quot;SelectedItems&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then
1341 vSelection = _ControlModel.SelectedItems
1342 If UBound(vSelection) &gt;= 0 Then _PropertyGet = vSelection(0)
1343 End If
1344 Case Else : GoTo CatchType
1345 End Select
1346 Case UCase(&quot;ListSource&quot;)
1347 Select Case _ControlType
1348 Case CTLCOMBOBOX, CTLLISTBOX
1349 If oSession.HasUNOProperty(_ControlModel, &quot;ListSource&quot;) Then
1350 With com.sun.star.form.ListSourceType
1351 Select Case _ControlModel.ListSourceType
1352 Case .VALUELIST _
1353 , .TABLEFIELDS
1354 If IsArray(_ControlModel.StringItemList) Then vValues = _ControlModel.StringItemList Else vValues = Array(_ControlModel.StringItemList)
1355 Case .TABLE _
1356 , .QUERY _
1357 , .SQL _
1358 , .SQLPASSTHROUGH
1359 If IsArray(_ControlModel.ListSource) Then vValues = _ControlModel.ListSource Else vValues = Array(_ControlModel.ListSource)
1360 End Select
1361 End With
1362 _PropertyGet = Join(vValues, &quot;;&quot;)
1363 End If
1364 Case Else : GoTo CatchType
1365 End Select
1366 Case UCase(&quot;ListSourceType&quot;)
1367 Select Case _ControlType
1368 Case CTLCOMBOBOX, CTLLISTBOX
1369 If oSession.HasUnoProperty(_ControlModel, &quot;ListSourceType&quot;) Then _PropertyGet = _ControlModel.ListSourceType
1370 Case Else : GoTo CatchType
1371 End Select
1372 Case UCase(&quot;Locked&quot;)
1373 Select Case _ControlType
1374 Case CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLIMAGECONTROL _
1375 , CTLLISTBOX, CTLNUMERICFIELD, CTLPATTERNFIELD, CTLTEXTFIELD, CTLTIMEFIELD
1376 If oSession.HasUnoProperty(_ControlModel, &quot;ReadOnly&quot;) Then _PropertyGet = _ControlModel.ReadOnly
1377 Case Else : GoTo CatchType
1378 End Select
1379 Case UCase(&quot;MultiSelect&quot;)
1380 Select Case _ControlType
1381 Case CTLLISTBOX
1382 If oSession.HasUnoProperty(_ControlModel, &quot;MultiSelection&quot;) Then
1383 _PropertyGet = _ControlModel.MultiSelection
1384 ElseIf oSession.HasUnoProperty(_ControlModel, &quot;MultiSelectionSimpleMode&quot;) Then &apos; Not documented: gridcontrols only TBC ??
1385 _PropertyGet = _ControlModel.MultiSelectionSimpleMode
1386 End If
1387 Case Else : GoTo CatchType
1388 End Select
1389 Case UCase(&quot;Name&quot;)
1390 _PropertyGet = _Name
1391 Case UCase(&quot;OnActionPerformed&quot;), UCase(&quot;OnAdjustmentValueChanged&quot;), UCase(&quot;OnApproveAction&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveUpdate&quot;) _
1392 , UCase(&quot;OnChanged&quot;), UCase(&quot;OnErrorOccurred&quot;), UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;) _
1393 , UCase(&quot;OnItemStateChanged&quot;), UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;) _
1394 , UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMouseMoved&quot;) _
1395 , UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;), UCase(&quot;OnResetted&quot;) _
1396 , UCase(&quot;OnTextChanged&quot;), UCase(&quot;OnUpdated&quot;)
1397 If IsNull(_ControlModel) Then _PropertyGet = &quot;&quot; Else _PropertyGet = SF_Register._GetEventScriptCode(_ControlModel, psProperty, _Name)
1398 Case UCase(&quot;Parent&quot;)
1399 Set _PropertyGet = [_Parent]
1400 Case UCase(&quot;Picture&quot;)
1401 Select Case _ControlType
1402 Case CTLBUTTON, CTLIMAGEBUTTON, CTLIMAGECONTROL
1403 If oSession.HasUnoProperty(_ControlModel, &quot;ImageURL&quot;) Then _PropertyGet = ScriptForge.SF_FileSystem._ConvertFromUrl(_ControlModel.ImageURL)
1404 Case Else : GoTo CatchType
1405 End Select
1406 Case UCase(&quot;Required&quot;)
1407 Select Case _ControlType
1408 Case CTLCHECKBOX, CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLIMAGECONTROL, CTLLISTBOX, CTLNUMERICFIELD _
1409 , CTLPATTERNFIELD, CTLRADIOBUTTON, CTLTEXTFIELD, CTLTIMEFIELD
1410 If oSession.HasUnoProperty(_ControlModel, &quot;InputRequired&quot;) Then _PropertyGet = _ControlModel.InputRequired
1411 Case Else : GoTo CatchType
1412 End Select
1413 Case UCase(&quot;Text&quot;)
1414 Select Case _ControlType
1415 Case CTLDATEFIELD
1416 If oSession.HasUNOProperty(_ControlModel, &quot;Date&quot;) _
1417 And oSession.HasUNOProperty(_ControlModel, &quot;FormatKey&quot;) _
1418 And oSession.HasUNOProperty(_ControlModel, &quot;FormatsSupplier&quot;) Then
1419 If Not IsEmpty(_ControlModel.Date) Then
1420 With _ControlModel.Date
1421 vDate = DateSerial(.Year, .Month, .Day)
1422 End With
1423 _PropertyGet = Format(vDate, _ControlModel.FormatsSupplier.getNumberFormats.getByKey(_ControlModel.FormatKey).FormatString)
1424 End If
1425 End If
1426 Case CTLTIMEFIELD
1427 If oSession.HasUNOProperty(_ControlModel, &quot;Text&quot;) Then
1428 If Not IsEmpty(_ControlModel.Time) Then
1429 With _ControlModel.Time
1430 vDate = TimeSerial(.Hours, .Minutes, .Seconds)
1431 End With
1432 _PropertyGet = Format(vDate, &quot;HH:MM:SS&quot;)
1433 End If
1434 End If
1435 Case CTLCOMBOBOX, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLPATTERNFIELD, CTLTEXTFIELD
1436 If oSession.HasUnoProperty(_ControlModel, &quot;Text&quot;) Then _PropertyGet = _ControlModel.Text
1437 Case Else : GoTo CatchType
1438 End Select
1439 Case UCase(&quot;TipText&quot;)
1440 Select Case _ControlType
1441 Case CTLHIDDENCONTROL : GoTo CatchType
1442 Case Else
1443 If oSession.HasUnoProperty(_ControlModel, &quot;HelpText&quot;) Then _PropertyGet = _ControlModel.HelpText
1444 End Select
1445 Case UCase(&quot;TripleState&quot;)
1446 Select Case _ControlType
1447 Case CTLCHECKBOX
1448 If oSession.HasUnoProperty(_ControlModel, &quot;TriState&quot;) Then _PropertyGet = _ControlModel.TriState
1449 Case Else : GoTo CatchType
1450 End Select
1451 Case UCase(&quot;Value&quot;) &apos; Default values are set here by control type, not in the 2nd argument (pvDefault)
1452 vGet = pvDefault
1453 Select Case _ControlType
1454 Case CTLBUTTON &apos;Boolean, toggle buttons only
1455 vGet = False
1456 If oSession.HasUnoProperty(_ControlModel, &quot;Toggle&quot;) Then
1457 If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then vGet = ( _ControlModel.State = 1 )
1458 End If
1459 Case CTLCHECKBOX &apos;0 = Not checked, 1 = Checked, 2 = Don&apos;t know
1460 If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then vGet = _ControlModel.State Else vGet = 2
1461 Case CTLCOMBOBOX, CTLFILECONTROL, CTLPATTERNFIELD, CTLTEXTFIELD &apos;String
1462 If oSession.HasUnoProperty(_ControlModel, &quot;Text&quot;) Then vGet = _ControlModel.Text Else vGet = &quot;&quot;
1463 Case CTLCURRENCYFIELD, CTLNUMERICFIELD &apos;Numeric
1464 If oSession.HasUnoProperty(_ControlModel, &quot;Value&quot;) Then vGet = _ControlModel.Value Else vGet = 0
1465 Case CTLDATEFIELD &apos;Date
1466 vGet = CDate(1)
1467 If oSession.HasUnoProperty(_ControlModel, &quot;Date&quot;) Then
1468 If VarType(_ControlModel.Date) = ScriptForge.V_OBJECT Then &apos; com.sun.star.util.Date
1469 With _ControlModel.Date
1470 vDate = DateSerial(.Year, .Month, .Day)
1471 End With
1472 vGet = vDate
1473 Else &apos; .Date = Empty
1474 End If
1475 End If
1476 Case CTLFORMATTEDFIELD &apos;String or numeric
1477 If oSession.HasUnoProperty(_ControlModel, &quot;EffectiveValue&quot;) Then vGet = _ControlModel.EffectiveValue Else vGet = &quot;&quot;
1478 Case CTLHIDDENCONTROL &apos;String
1479 If oSession.HasUnoProperty(_ControlModel, &quot;HiddenValue&quot;) Then vGet = _ControlModel.HiddenValue Else vGet = &quot;&quot;
1480 Case CTLLISTBOX &apos;String or array of strings depending on MultiSelection
1481 &apos; StringItemList is the list of the items displayed in the box
1482 &apos; ValueItemList is the list of the values in the underlying database field
1483 &apos; SelectedItems is the list of the indexes in StringItemList of the selected items
1484 &apos; It can go beyond the limits of StringItemList
1485 &apos; It can contain multiple values even if the listbox is not multiselect
1486 If oSession.HasUnoProperty(_ControlModel, &quot;StringItemList&quot;) And oSession.HasUnoProperty(_ControlModel, &quot;SelectedItems&quot;) _
1487 And oSession.HasUnoProperty(_ControlModel, &quot;MultiSelection&quot;) Then
1488 vSelection = _ControlModel.SelectedItems
1489 &apos; The list of allowed values depends on the existence of a bound column
1490 If _ListBoxBound() Then vList = _ControlModel.ValueItemList Else vList = _ControlModel.StringItemList
1491 If _ControlModel.MultiSelection Then vValues = Array()
1492 For i = 0 To UBound(vSelection)
1493 lIndex = vSelection(i)
1494 If lIndex &gt;= 0 And lIndex &lt;= UBound(vList) Then
1495 If Not _ControlModel.MultiSelection Then
1496 vValues = vList(lIndex)
1497 Exit For
1498 End If
1499 vValues = ScriptForge.SF_Array.Append(vValues, vList(lIndex))
1500 End If
1501 Next i
1502 vGet = vValues
1503 Else
1504 vGet = &quot;&quot;
1505 End If
1506 Case CTLRADIOBUTTON &apos;Boolean
1507 If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then vGet = ( _ControlModel.State = 1 ) Else vGet = False
1508 Case CTLSCROLLBAR &apos;Numeric
1509 vGet = 0
1510 If oSession.HasUnoProperty(_ControlModel, &quot;ScrollValue&quot;) Then
1511 If Not IsEmpty(_ControlModel.ScrollValue) Then vGet = _ControlModel.ScrollValue
1512 End If
1513 Case CTLSPINBUTTON
1514 If oSession.HasUnoProperty(_ControlModel, &quot;SpinValue&quot;) Then vGet = _ControlModel.SpinValue Else vGet = 0
1515 Case CTLTIMEFIELD
1516 vGet = CDate(0)
1517 If oSession.HasUnoProperty(_ControlModel, &quot;Time&quot;) Then
1518 If VarType(_ControlModel.Time) = ScriptForge.V_OBJECT Then &apos; com.sun.star.Util.Time
1519 With _ControlModel.Time
1520 vDate = TimeSerial(.Hours, .Minutes, .Seconds)
1521 End With
1522 vGet = vDate
1523 Else &apos; .Time = Empty
1524 End If
1525 End If
1526 Case Else : GoTo CatchType
1527 End Select
1528 _PropertyGet = vGet
1529 Case UCase(&quot;Visible&quot;)
1530 If oSession.HasUnoMethod(_ControlView, &quot;isVisible&quot;) Then _PropertyGet = CBool(_ControlView.isVisible())
1531 Case UCase(&quot;XControlModel&quot;)
1532 Set _PropertyGet = _ControlModel
1533 Case UCase(&quot;XControlView&quot;)
1534 Set _PropertyGet = _ControlView
1535 Case Else
1536 _PropertyGet = Null
1537 End Select
1539 Finally:
1540 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1541 Exit Function
1542 Catch:
1543 GoTo Finally
1544 CatchType:
1545 GoTo Finally
1546 End Function &apos; SFDocuments.SF_FormControl._PropertyGet
1548 REM -----------------------------------------------------------------------------
1549 Private Function _PropertySet(Optional ByVal psProperty As String _
1550 , Optional ByVal pvValue As Variant _
1551 ) As Boolean
1552 &apos;&apos;&apos; Set the new value of the named property
1553 &apos;&apos;&apos; Args:
1554 &apos;&apos;&apos; psProperty: the name of the property
1555 &apos;&apos;&apos; pvValue: the new value of the given property
1557 Dim bSet As Boolean &apos; Return value
1558 Static oSession As Object &apos; Alias of SF_Session
1559 Dim sFormName As String &apos; Full form identification for error messages
1560 Dim vSet As Variant &apos; Value to set in UNO model or view property
1561 Dim vActions As Variant &apos; Action property: list of available actions
1562 Dim sAction As String &apos; A single action
1563 Dim vFormats As Variant &apos; Format property: output of _FormatsList()
1564 Dim iFormat As Integer &apos; Format property: index in vFormats
1565 Dim vSelection As Variant &apos; Alias of Model.SelectedItems
1566 Dim vList As Variant &apos; Alias of Model.StringItemList
1567 Dim lIndex As Long &apos; Index in StringItemList
1568 Dim sItem As String &apos; A single item
1569 Dim oDatabase As Object &apos; The database object related to the parent form of the control instance
1570 Dim i As Long
1571 Dim cstThisSub As String
1572 Const cstSubArgs = &quot;Value&quot;
1574 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1575 bSet = False
1577 cstThisSub = &quot;SFDocuments.FormControl.set&quot; &amp; psProperty
1578 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
1579 If Not _ParentForm._IsStillAlive() Then GoTo Finally
1581 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
1582 bSet = True
1583 Select Case UCase(psProperty)
1584 Case UCase(&quot;Action&quot;)
1585 Select Case _ControlType
1586 Case CTLBUTTON
1587 vActions = Array(&quot;none&quot;, &quot;submitForm&quot;, &quot;resetForm&quot;, &quot;refreshForm&quot;, &quot;moveToFirst&quot;, &quot;moveToLast&quot;, &quot;moveToNext&quot;, &quot;moveToPrev&quot; _
1588 , &quot;saveRecord&quot;, &quot;moveToNew&quot;, &quot;deleteRecord&quot;, &quot;undoRecord&quot;)
1589 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Action&quot;, ScriptForge.V_STRING, vActions) Then GoTo Finally
1590 If oSession.HasUNOProperty(_ControlModel, &quot;ButtonType&quot;) Then
1591 sAction = vActions(ScriptForge.SF_Array.IndexOf(vActions, pvValue, CaseSensitive := False))
1592 _ControlModel.TargetURL = &quot;&quot;
1593 Select Case sAction
1594 Case &quot;none&quot; : vSet = com.sun.star.form.FormButtonType.PUSH
1595 Case &quot;submitForm&quot; : vSet = com.sun.star.form.FormButtonType.SUBMIT
1596 Case &quot;resetForm&quot; : vSet = com.sun.star.form.FormButtonType.RESET
1597 Case Else
1598 vSet = com.sun.star.form.FormButtonType.URL
1599 _ControlModel.TargetURL = &quot;.uno:FormController/&quot; &amp; sAction
1600 End Select
1601 _ControlModel.ButtonType = vSet
1602 End If
1603 Case Else : GoTo CatchType
1604 End Select
1605 Case UCase(&quot;Caption&quot;)
1606 Select Case _ControlType
1607 Case CTLBUTTON, CTLCHECKBOX, CTLFIXEDTEXT, CTLGROUPBOX, CTLRADIOBUTTON
1608 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Caption&quot;, V_STRING) Then GoTo Finally
1609 If oSession.HasUNOProperty(_ControlModel, &quot;Label&quot;) Then _ControlModel.Label = pvValue
1610 Case Else : GoTo CatchType
1611 End Select
1612 Case UCase(&quot;Default&quot;)
1613 Select Case _ControlType
1614 Case CTLBUTTON
1615 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Default&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1616 If oSession.HasUNOProperty(_ControlModel, &quot;DefaultButton&quot;) Then _ControlModel.DefaultButton = pvValue
1617 Case Else : GoTo CatchType
1618 End Select
1619 Case UCase(&quot;Enabled&quot;)
1620 Select Case _ControlType
1621 Case CTLHIDDENCONTROL : GoTo CatchType
1622 Case Else
1623 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Enabled&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1624 If oSession.HasUnoProperty(_ControlModel, &quot;Enabled&quot;) Then _ControlModel.Enabled = pvValue
1625 End Select
1626 Case UCase(&quot;Format&quot;)
1627 Select Case _ControlType
1628 Case CTLDATEFIELD, CTLTIMEFIELD
1629 vFormats = _FormatsList()
1630 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Format&quot;, V_STRING, vFormats) Then GoTo Finally
1631 iFormat = ScriptForge.SF_Array.IndexOf(vFormats, pvValue, CaseSensitive := False)
1632 If oSession.HasUNOProperty(_ControlModel, &quot;DateFormat&quot;) Then
1633 _ControlModel.DateFormat = iFormat
1634 ElseIf oSession.HasUNOProperty(_ControlModel, &quot;TimeFormat&quot;) Then
1635 _ControlModel.TimeFormat = iFormat
1636 End If
1637 Case Else : GoTo CatchType
1638 End Select
1639 Case UCase(&quot;ListIndex&quot;)
1640 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;ListIndex&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
1641 Select Case _ControlType
1642 Case CTLCOMBOBOX
1643 If oSession.HasUNOProperty(_ControlModel, &quot;Text&quot;) And oSession.HasUNOProperty(_ControlModel, &quot;StringItemList&quot;) Then
1644 If pvValue &gt;= 0 And pvValue &lt;= UBound(_ControlModel.StringItemList) Then _ControlModel.Text = _ControlModel.StringItemList(CInt(pvValue))
1645 End If
1646 Case CTLLISTBOX
1647 If oSession.HasUNOProperty(_ControlModel, &quot;SelectedItems&quot;) Then _ControlModel.SelectedItems = Array(CInt(pvValue))
1648 Case Else : GoTo CatchType
1649 End Select
1650 Case UCase(&quot;ListSource&quot;)
1651 Select Case _ControlType
1652 Case CTLCOMBOBOX, CTLLISTBOX
1653 If oSession.HasUNOProperty(_ControlModel, &quot;ListSource&quot;) Then
1654 If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then Goto Finally
1655 With com.sun.star.form.ListSourceType
1656 Select Case _ControlModel.ListSourceType
1657 Case .QUERY _
1658 , .TABLE _
1659 , .TABLEFIELDS
1660 Set oDatabase = _ParentForm.GetDatabase()
1661 If _ControlModel.ListSourceType = .QUERY Then vList = oDatabase.Queries Else vList = oDatabase.Tables
1662 If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING, vList) Then Goto Finally
1663 If _ControlType = CTLCOMBOBOX Then _ControlModel.ListSource = pvValue Else _ControlModel.ListSource = Array(pvValue)
1664 _ControlModel.refresh()
1665 Case .SQL
1666 Set oDatabase = _ParentForm.GetDatabase()
1667 If _ControlType = CTLCOMBOBOX Then _ControlModel.ListSource = oDatabase._ReplaceSquareBrackets(pvValue) Else _ControlModel.ListSource = Array(oDatabase._ReplaceSquareBrackets(pvValue))
1668 _ControlModel.refresh()
1669 Case .VALUELIST &apos; ListBox only !
1670 _ControlModel.ListSource = Split(pvValue, &quot;;&quot;)
1671 _ControlModel.StringItemList = _ControlModel.ListSource
1672 Case .SQLPASSTHROUGH
1673 If _ControlType = CTLCOMBOBOX Then _ControlModel.ListSource = pvValue Else _ControlModel.ListSource = Array(pvValue)
1674 _ControlModel.refresh()
1675 End Select
1676 End With
1677 End If
1678 Case Else : GoTo CatchType
1679 End Select
1680 Case UCase(&quot;ListSourceType&quot;)
1681 With com.sun.star.form.ListSourceType
1682 Select Case _ControlType
1683 Case CTLCOMBOBOX
1684 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;ListSourceType&quot;, ScriptForge.V_NUMERIC, Array( _
1685 .TABLE _
1686 , .QUERY _
1687 , .SQL _
1688 , .SQLPASSTHROUGH _
1689 , .TABLEFIELDS _
1690 )) Then GoTo Finally
1691 Case CTLLISTBOX
1692 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;ListSourceType&quot;, ScriptForge.V_NUMERIC, Array( _
1693 .VALUELIST _
1694 , .TABLE _
1695 , .QUERY _
1696 , .SQL _
1697 , .SQLPASSTHROUGH _
1698 , .TABLEFIELDS _
1699 )) Then GoTo Finally
1700 Case Else : GoTo CatchType
1701 End Select
1702 End With
1703 If oSession.HasUnoProperty(_ControlModel, &quot;ListSourceType&quot;) Then _ControlModel.ListSourceType = pvValue
1704 Case UCase(&quot;Locked&quot;)
1705 Select Case _ControlType
1706 Case CTLCOMBOBOX, CTLCURRENCYFIELD, CTLDATEFIELD, CTLFILECONTROL, CTLFORMATTEDFIELD, CTLIMAGECONTROL _
1707 , CTLLISTBOX, CTLNUMERICFIELD, CTLPATTERNFIELD, CTLTEXTFIELD, CTLTIMEFIELD
1708 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Locked&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1709 If oSession.HasUnoProperty(_ControlModel, &quot;ReadOnly&quot;) Then _ControlModel.ReadOnly = pvValue
1710 Case Else : GoTo CatchType
1711 End Select
1712 Case UCase(&quot;MultiSelect&quot;)
1713 Select Case _ControlType
1714 Case CTLLISTBOX
1715 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;MultiSelect&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1716 If oSession.HasUnoProperty(_ControlModel, &quot;MultiSelection&quot;) Then _ControlModel.MultiSelection = pvValue
1717 If oSession.HasUnoProperty(_ControlModel, &quot;MultiSelectionSimpleMode&quot;) Then _ControlModel.MultiSelectionSimpleMode = pvValue
1718 If oSession.HasUnoProperty(_ControlModel, &quot;SelectedItems&quot;) Then
1719 &apos; Cancel selections when MultiSelect becomes False
1720 If Not pvValue And UBound(_ControlModel.SelectedItems) &gt; 0 Then
1721 lIndex = _ControlModel.SelectedItems(0)
1722 _ControlModel.SelectedItems = Array(lIndex)
1723 End If
1724 End If
1725 Case Else : GoTo CatchType
1726 End Select
1727 Case UCase(&quot;OnActionPerformed&quot;), UCase(&quot;OnAdjustmentValueChanged&quot;), UCase(&quot;OnApproveAction&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveUpdate&quot;) _
1728 , UCase(&quot;OnChanged&quot;), UCase(&quot;OnErrorOccurred&quot;), UCase(&quot;OnFocusGained&quot;), UCase(&quot;OnFocusLost&quot;) _
1729 , UCase(&quot;OnItemStateChanged&quot;), UCase(&quot;OnKeyPressed&quot;), UCase(&quot;OnKeyReleased&quot;) _
1730 , UCase(&quot;OnMouseDragged&quot;), UCase(&quot;OnMouseEntered&quot;), UCase(&quot;OnMouseExited&quot;), UCase(&quot;OnMouseMoved&quot;) _
1731 , UCase(&quot;OnMousePressed&quot;), UCase(&quot;OnMouseReleased&quot;), UCase(&quot;OnResetted&quot;) _
1732 , UCase(&quot;OnTextChanged&quot;), UCase(&quot;OnUpdated&quot;)
1733 If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then Goto Finally
1734 If Not IsNull(_ControlModel) Then
1735 bSet = SF_Register._RegisterEventScript(_ControlModel _
1736 , psProperty _
1737 , _GetListener(psProperty) _
1738 , pvValue _
1739 , _Name _
1741 End If
1742 Case UCase(&quot;Picture&quot;)
1743 Select Case _ControlType
1744 Case CTLBUTTON, CTLIMAGEBUTTON, CTLIMAGECONTROL
1745 If Not ScriptForge.SF_Utils._ValidateFile(pvValue, &quot;Picture&quot;) Then GoTo Finally
1746 If oSession.HasUnoProperty(_ControlModel, &quot;ImageURL&quot;) Then _ControlModel.ImageURL = ScriptForge.SF_FileSystem._ConvertToUrl(pvValue)
1747 Case Else : GoTo CatchType
1748 End Select
1749 Case UCase(&quot;TipText&quot;)
1750 Select Case _ControlType
1751 Case CTLHIDDENCONTROL : GoTo CatchType
1752 Case Else
1753 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;TipText&quot;, V_STRING) Then GoTo Finally
1754 If oSession.HasUnoProperty(_ControlModel, &quot;HelpText&quot;) Then _ControlModel.HelpText = pvValue
1755 End Select
1756 Case UCase(&quot;TripleState&quot;)
1757 Select Case _ControlType
1758 Case CTLCHECKBOX
1759 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;TripleState&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1760 If oSession.HasUnoProperty(_ControlModel, &quot;TriState&quot;) Then _ControlModel.TriState = pvValue
1761 Case Else : GoTo CatchType
1762 End Select
1763 Case UCase(&quot;Value&quot;)
1764 Select Case _ControlType
1765 Case CTLBUTTON &apos;Boolean, toggle buttons only
1766 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1767 If oSession.HasUnoProperty(_ControlModel, &quot;Toggle&quot;) And oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then
1768 _ControlModel.State = Iif(pvValue, 1, 0)
1769 End If
1770 Case CTLCHECKBOX &apos;0 = Not checked, 1 = Checked, 2 = Don&apos;t know
1771 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, Array(ScriptForge.V_BOOLEAN, ScriptForge.V_NUMERIC), Array(0, 1, 2, True, False)) Then GoTo Finally
1772 If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then
1773 If VarType(pvValue) = ScriptForge.V_BOOLEAN Then pvValue = Iif(pvValue, 1, 0)
1774 _ControlModel.State = pvValue
1775 End If
1776 Case CTLCOMBOBOX
1777 If oSession.HasUnoProperty(_ControlModel, &quot;Text&quot;) And oSession.HasUnoProperty(_ControlModel, &quot;StringItemList&quot;) Then
1778 If pvValue &lt;&gt; &quot;&quot; Then
1779 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_STRING, _ControlModel.StringItemList) Then Goto Finally
1780 End If
1781 _ControlModel.Text = pvValue
1782 End If
1783 Case CTLCURRENCYFIELD, CTLNUMERICFIELD &apos;Numeric
1784 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
1785 If oSession.HasUnoProperty(_ControlModel, &quot;Value&quot;) Then _ControlModel.Value = pvValue
1786 Case CTLDATEFIELD &apos;Date
1787 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_DATE) Then GoTo Finally
1788 If oSession.HasUnoProperty(_ControlModel, &quot;Date&quot;) Then
1789 Set vSet = New com.sun.star.util.Date
1790 vSet.Year = Year(pvValue)
1791 vSet.Month = Month(pvValue)
1792 vSet.Day = Day(pvValue)
1793 _ControlModel.Date = vSet
1794 End If
1795 Case CTLFILECONTROL
1796 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_STRING) Then GoTo Finally
1797 If oSession.HasUnoProperty(_ControlModel, &quot;Text&quot;) Then _ControlModel.Text = ScriptForge.SF_FileSystem._ConvertToUrl(pvValue)
1798 Case CTLFORMATTEDFIELD &apos;String or numeric
1799 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
1800 If oSession.HasUnoProperty(_ControlModel, &quot;EffectiveValue&quot;) Then _ControlModel.EffectiveValue = pvValue
1801 Case CTLHIDDENCONTROL &apos;String
1802 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_STRING) Then GoTo Finally
1803 If oSession.HasUnoProperty(_ControlModel, &quot;HiddenValue&quot;) Then _ControlModel.HiddenValue = pvValue
1804 Case CTLLISTBOX &apos;String or number - Only a single value may be set
1805 &apos; StringItemList is the list of the items displayed in the box
1806 &apos; ValueItemList is the list of the values in the underlying database field
1807 &apos; SelectedItems is the list of the indexes in StringItemList of the selected items
1808 If oSession.HasUnoProperty(_ControlModel, &quot;StringItemList&quot;) And oSession.HasUnoProperty(_ControlModel, &quot;SelectedItems&quot;) Then
1809 &apos; Setting the value on a listbox is allowed only if single value and value in the list
1810 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
1811 &apos; The list of allowed values depends on the existence of a bound column
1812 If _ListboxBound() Then vList = _ControlModel.ValueItemList Else vList = _ControlModel.StringItemList
1813 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, , vList) Then GoTo Finally
1814 _ControlModel.SelectedItems = Array(ScriptForge.SF_Array.IndexOf(vList, pvValue, CaseSensitive := True))
1815 End If
1816 Case CTLPATTERNFIELD, CTLTEXTFIELD &apos;String
1817 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_STRING) Then GoTo Finally
1818 If oSession.HasUnoProperty(_ControlModel, &quot;Text&quot;) Then _ControlModel.Text = pvValue
1819 Case CTLRADIOBUTTON &apos;Boolean
1820 &apos; A group of radio buttons is presumed sharing the same GroupName
1821 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1822 If oSession.HasUnoProperty(_ControlModel, &quot;State&quot;) Then _ControlModel.State = Iif(pvValue, 1, 0)
1823 Case CTLSCROLLBAR &apos;Numeric
1824 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
1825 If oSession.HasUnoProperty(_ControlModel, &quot;ScrollValueMin&quot;) Then
1826 If pvValue &lt; _ControlModel.ScrollValueMin Then pvValue = _ControlModel.ScrollValueMin
1827 End If
1828 If oSession.HasUnoProperty(_ControlModel, &quot;ScrollValueMax&quot;) Then
1829 If pvValue &gt; _ControlModel.ScrollValueMax Then pvValue = _ControlModel.ScrollValueMax
1830 End If
1831 If oSession.HasUnoProperty(_ControlModel, &quot;ScrollValue&quot;) Then _ControlModel.ScrollValue = pvValue
1832 Case CTLSPINBUTTON &apos;Numeric
1833 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
1834 If oSession.HasUnoProperty(_ControlModel, &quot;SpinValueMin&quot;) Then
1835 If pvValue &lt; _ControlModel.SpinValueMin Then pvValue = _ControlModel.SpinValueMin
1836 End If
1837 If oSession.HasUnoProperty(_ControlModel, &quot;SpinValueMax&quot;) Then
1838 If pvValue &gt; _ControlModel.SpinValueMax Then pvValue = _ControlModel.SpinValueMax
1839 End If
1840 If oSession.HasUnoProperty(_ControlModel, &quot;SpinValue&quot;) Then _ControlModel.SpinValue = pvValue
1841 Case CTLTIMEFIELD
1842 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Value&quot;, V_DATE) Then GoTo Finally
1843 If oSession.HasUnoProperty(_ControlModel, &quot;Time&quot;) Then
1844 Set vSet = New com.sun.star.util.Time
1845 vSet.Hours = Hour(pvValue)
1846 vSet.Minutes = Minute(pvValue)
1847 vSet.Seconds = Second(pvValue)
1848 _ControlModel.Time = vSet
1849 End If
1850 Case Else : GoTo CatchType
1851 End Select
1852 &apos; FINAL COMMITMENT
1853 If oSession.HasUNOMethod(_ControlModel, &quot;commit&quot;) Then _ControlModel.commit() &apos; f.i. checkboxes have no commit method ??
1854 Case UCase(&quot;Visible&quot;)
1855 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Visible&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1856 If oSession.HasUnoMethod(_ControlView, &quot;setVisible&quot;) Then
1857 If pvValue Then _ControlModel.EnableVisible = True
1858 _ControlView.setVisible(pvValue)
1859 End If
1860 Case Else
1861 bSet = False
1862 End Select
1864 Finally:
1865 _PropertySet = bSet
1866 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1867 Exit Function
1868 Catch:
1869 bSet = False
1870 GoTo Finally
1871 CatchType:
1872 If Len(_ParentForm._FormDocumentName) &gt; 0 Then sFormName = _ParentForm._FormDocumentName &amp; &quot;.&quot; Else sFormName = &quot;&quot;
1873 ScriptForge.SF_Exception.RaiseFatal(FORMCONTROLTYPEERROR, _Name, sFormName &amp; _FormName, _ControlType, psProperty)
1874 GoTo Finally
1875 End Function &apos; SFDocuments.SF_FormControl._PropertySet
1877 REM -----------------------------------------------------------------------------
1878 Private Function _Repr() As String
1879 &apos;&apos;&apos; Convert the Model instance to a readable string, typically for debugging purposes (DebugPrint ...)
1880 &apos;&apos;&apos; Args:
1881 &apos;&apos;&apos; Return:
1882 &apos;&apos;&apos; &quot;[FORMCONTROL]: Name, Type (formname)
1883 _Repr = &quot;[FORMCONTROL]: &quot; &amp; _Name &amp; &quot;, &quot; &amp; _ControlType &amp; &quot; (&quot; &amp; _FormName &amp; &quot;)&quot;
1885 End Function &apos; SFDocuments.SF_FormControl._Repr
1887 REM ============================================ END OF SFDOCUMENTS.SF_FORMCONTROL
1888 </script:module>