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