tdf#164434 Correct SvgSymbolNode SVG import
[LibreOffice.git] / wizards / source / sfdocuments / SF_Form.xba
blobef5907a8d723b1b353e2dd9f1e8c7c7640b66193
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_Form" 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_Form
16 &apos;&apos;&apos; =======
17 &apos;&apos;&apos; Management of forms defined in LibreOffice documents. Supported types are Base, Calc and Writer documents.
18 &apos;&apos;&apos; It includes the management of subforms
19 &apos;&apos;&apos; Each instance of the current class represents a single form or a single subform
20 &apos;&apos;&apos;
21 &apos;&apos;&apos; A form may optionally be (understand &quot;is often&quot;) linked to a data source manageable with the SFDatabases.Database service
22 &apos;&apos;&apos; The current service offers a rapid access to that service
23 &apos;&apos;&apos;
24 &apos;&apos;&apos; Definitions:
25 &apos;&apos;&apos;
26 &apos;&apos;&apos; FormDocument: BASE DOCUMENTS ONLY
27 &apos;&apos;&apos; For usual documents, there is only 1 forms container. It is either the document itself or one of its sheets (Calc)
28 &apos;&apos;&apos; A Base document may contain an unlimited number of form documents.
29 &apos;&apos;&apos; In the Base terminology they are called &quot;forms&quot; or &quot;Base forms&quot;. This could create some confusion.
30 &apos;&apos;&apos; They can be organized in folders. Their name is then always the full path of folders + form
31 &apos;&apos;&apos; with the slash (&quot;/&quot;) as path separator
32 &apos;&apos;&apos; A FormDocument is a set of Forms. Form names are visible in the user interface thanks to the form navigator
33 &apos;&apos;&apos; Often there is only 1 Form present in a FormDocument. Having more, however, might improve
34 &apos;&apos;&apos; the user experience significantly
35 &apos;&apos;&apos;
36 &apos;&apos;&apos; Form: WHERE IT IS ABOUT IN THE CURRENT &quot;Form&quot; SERVICE
37 &apos;&apos;&apos; Is an abstract set of Controls in an OPEN Document or FormDocument
38 &apos;&apos;&apos; Each form is usually linked to one single dataset (table, query or Select statement),
39 &apos;&apos;&apos; located in any database (provided the user may access it)
40 &apos;&apos;&apos; A usual document may contain several forms. Each of which may have its own data source (database + dataset)
41 &apos;&apos;&apos; A Base form document may contain several forms. Each of which may address its own dataset. The database however is unique
42 &apos;&apos;&apos; A form is defined by its owning Document or FormDocument and its FormName or FormIndex
43 &apos;&apos;&apos;
44 &apos;&apos;&apos; Service invocations:
45 &apos;&apos;&apos;
46 &apos;&apos;&apos; REM the form is stored in a Writer document
47 &apos;&apos;&apos; Dim oDoc As Object, myForm As Object
48 &apos;&apos;&apos; Set oDoc = CreateScriptService(&quot;SFDocuments.Document&quot;, ThisComponent)
49 &apos;&apos;&apos; Set myForm = oDoc.Forms(&quot;Form1&quot;)
50 &apos;&apos;&apos; &apos; or, alternatively, when there is only 1 form
51 &apos;&apos;&apos; Set myForm = oDoc.Forms(0)
52 &apos;&apos;&apos;
53 &apos;&apos;&apos; REM the form is stored in a Calc document
54 &apos;&apos;&apos; Dim oCalc As Object, myForm As Object
55 &apos;&apos;&apos; Set oCalc = CreateScriptService(&quot;SFDocuments.Document&quot;, ThisComponent)
56 &apos;&apos;&apos; Set myForm = oCalc.Forms(&quot;Sheet1&quot;, &quot;Form1&quot;)
57 &apos;&apos;&apos; &apos; or, alternatively, when there is only 1 form
58 &apos;&apos;&apos; Set myForm = oCalc.Forms(&quot;Sheet1&quot;, 0)
59 &apos;&apos;&apos;
60 &apos;&apos;&apos; REM the form is stored in one of the FormDocuments of a Base document
61 &apos;&apos;&apos; Dim oBase As Object, myFormDoc As Object, myForm As Object, mySubForm As Object
62 &apos;&apos;&apos; Set oBase = CreateScriptService(&quot;SFDocuments.Document&quot;, ThisDatabaseDocument)
63 &apos;&apos;&apos; Set oFormDoc = oBase.OpenFormDocument(&quot;thisFormDocument&quot;)
64 &apos;&apos;&apos; Set myForm = oFormDoc.Forms(&quot;MainForm&quot;)
65 &apos;&apos;&apos; &apos; or, alternatively, when there is only 1 form
66 &apos;&apos;&apos; Set myForm = oFormDoc.Forms(0)
67 &apos;&apos;&apos; &apos; To access a subform: myForm and mySubForm become distinct instances of the current class
68 &apos;&apos;&apos; Set mySubForm = myForm.SubForms(&quot;mySubForm&quot;)
69 &apos;&apos;&apos;
70 &apos;&apos;&apos; REM the form is the subject of an event
71 &apos;&apos;&apos; Sub OnEvent(ByRef poEvent As Object)
72 &apos;&apos;&apos; Dim myForm As Object
73 &apos;&apos;&apos; Set myForm = CreateScriptService(&quot;SFDocuments.FormEvent&quot;, poEvent)
74 &apos;&apos;&apos;
75 &apos;&apos;&apos; Detailed user documentation:
76 &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_form.html?DbPAR=BASIC
77 &apos;&apos;&apos;
78 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
80 REM ================================================================== EXCEPTIONS
82 Private Const FORMDEADERROR = &quot;FORMDEADERROR&quot;
83 Private Const SUBFORMNOTFOUNDERROR = &quot;SUBFORMNOTFOUNDERROR&quot;
84 Private Const DBCONNECTERROR = &quot;DBCONNECTERROR&quot;
86 REM ============================================================= PRIVATE MEMBERS
88 Private [Me] As Object
89 Private [_Parent] As Object
90 Private ObjectType As String &apos; Must be Form
91 Private ServiceName As String
93 &apos; Form location
94 Private _Name As String &apos; Internal name of the form
95 Private _FormType As Integer &apos; One of the ISxxxFORM constants
96 Private _SheetName As String &apos; Name as the sheet containing the form (Calc only)
97 Private _FormDocumentName As String &apos; The hierarchical name of the containing form document (Base only)
98 Private _FormDocument As Object &apos; com.sun.star.comp.sdb.Content - the form document container
99 &apos; The form topmost containers
100 Private _Component As Object &apos; com.sun.star.lang.XComponent
101 Private _BaseComponent As Object &apos; com.sun.star.comp.dba.ODatabaseDocument
103 &apos; Events management
104 Private _CacheIndex As Long &apos; Index in central cache storage
106 &apos; Form UNO references
107 &apos; The entry to the interactions with the form. Validity checked by the _IsStillAlive() method
108 &apos; Each method or property requiring that the form is opened should first invoke that method
109 Private _Form As Object &apos; com.sun.star.form.XForm or com.sun.star.comp.forms.ODatabaseForm
111 &apos; Form attributes
112 Private _Database As Object &apos; Database class instance
114 &apos; Cache storage for controls
115 Private _ControlNames As Variant &apos; Array of control names
116 Private _ControlCache As Variant &apos; Array of control objects sorted like ElementNames of XForm
118 REM ============================================================ MODULE CONSTANTS
120 Const ISDOCFORM = 1 &apos; Form is stored in a Writer document
121 Const ISCALCFORM = 2 &apos; Form is stored in a Calc document
122 Const ISBASEFORM = 3 &apos; Form is stored in a Base form document
123 Const ISSUBFORM = 4 &apos; Form is a subform of a form or of another subform
124 Const ISUNDEFINED = -1 &apos; Undefined form type
126 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
128 REM -----------------------------------------------------------------------------
129 Private Sub Class_Initialize()
130 Set [Me] = Nothing
131 Set [_Parent] = Nothing
132 ObjectType = &quot;FORM&quot;
133 ServiceName = &quot;SFDocuments.Form&quot;
134 _Name = &quot;&quot;
135 _SheetName = &quot;&quot;
136 _FormDocumentName = &quot;&quot;
137 Set _FormDocument = Nothing
138 Set _Component = Nothing
139 Set _BaseComponent = Nothing
140 _FormType = ISUNDEFINED
141 _CacheIndex = -1
142 Set _Form = Nothing
143 Set _Database = Nothing
144 _ControlNames = Array()
145 _ControlCache = Array()
146 End Sub &apos; SFDocuments.SF_Form Constructor
148 REM -----------------------------------------------------------------------------
149 Private Sub Class_Terminate()
150 Call Class_Initialize()
151 End Sub &apos; SFDocuments.SF_Form Destructor
153 REM -----------------------------------------------------------------------------
154 Public Function Dispose() As Variant
155 If Not IsNull(_Database) And (_FormType = ISDOCFORM Or _FormType = ISCALCFORM) Then
156 Set _Database = _Database.Dispose()
157 End If
158 SF_Register._CleanCacheEntry(_CacheIndex)
159 Call Class_Terminate()
160 Set Dispose = Nothing
161 End Function &apos; SFDocuments.SF_Form Explicit Destructor
163 REM ================================================================== PROPERTIES
165 REM -----------------------------------------------------------------------------
166 Property Get AllowDeletes() As Variant
167 &apos;&apos;&apos; The AllowDeletes property specifies if the form allows to delete records
168 AllowDeletes = _PropertyGet(&quot;AllowDeletes&quot;)
169 End Property &apos; SFDocuments.SF_Form.AllowDeletes (get)
171 REM -----------------------------------------------------------------------------
172 Property Let AllowDeletes(Optional ByVal pvAllowDeletes As Variant)
173 &apos;&apos;&apos; Set the updatable property AllowDeletes
174 _PropertySet(&quot;AllowDeletes&quot;, pvAllowDeletes)
175 End Property &apos; SFDocuments.SF_Form.AllowDeletes (let)
177 REM -----------------------------------------------------------------------------
178 Property Get AllowInserts() As Variant
179 &apos;&apos;&apos; The AllowInserts property specifies if the form allows to add records
180 AllowInserts = _PropertyGet(&quot;AllowInserts&quot;)
181 End Property &apos; SFDocuments.SF_Form.AllowInserts (get)
183 REM -----------------------------------------------------------------------------
184 Property Let AllowInserts(Optional ByVal pvAllowInserts As Variant)
185 &apos;&apos;&apos; Set the updatable property AllowInserts
186 _PropertySet(&quot;AllowInserts&quot;, pvAllowInserts)
187 End Property &apos; SFDocuments.SF_Form.AllowInserts (let)
189 REM -----------------------------------------------------------------------------
190 Property Get AllowUpdates() As Variant
191 &apos;&apos;&apos; The AllowUpdates property specifies if the form allows to update records
192 AllowUpdates = _PropertyGet(&quot;AllowUpdates&quot;)
193 End Property &apos; SFDocuments.SF_Form.AllowUpdates (get)
195 REM -----------------------------------------------------------------------------
196 Property Let AllowUpdates(Optional ByVal pvAllowUpdates As Variant)
197 &apos;&apos;&apos; Set the updatable property AllowUpdates
198 _PropertySet(&quot;AllowUpdates&quot;, pvAllowUpdates)
199 End Property &apos; SFDocuments.SF_Form.AllowUpdates (let)
201 REM -----------------------------------------------------------------------------
202 Property Get BaseForm() As String
203 &apos;&apos;&apos; The BaseForm property specifies the hierarchical name of the Base form containing the actual form
204 BaseForm = _PropertyGet(&quot;BaseForm&quot;)
205 End Property &apos; SFDocuments.SF_Form.BaseForm (get)
207 REM -----------------------------------------------------------------------------
208 Property Get Bookmark() As Variant
209 &apos;&apos;&apos; The Bookmark property specifies uniquely the current record of the form&apos;s underlying table, query or SQL statement.
210 Bookmark = _PropertyGet(&quot;Bookmark&quot;)
211 End Property &apos; SFDocuments.SF_Form.Bookmark (get)
213 REM -----------------------------------------------------------------------------
214 Property Let Bookmark(Optional ByVal pvBookmark As Variant)
215 &apos;&apos;&apos; Set the updatable property Bookmark
216 _PropertySet(&quot;Bookmark&quot;, pvBookmark)
217 End Property &apos; SFDocuments.SF_Form.Bookmark (let)
219 REM -----------------------------------------------------------------------------
220 Property Get CurrentRecord() As Variant
221 &apos;&apos;&apos; The CurrentRecord property identifies the current record in the recordset being viewed on a form
222 CurrentRecord = _PropertyGet(&quot;CurrentRecord&quot;)
223 End Property &apos; SFDocuments.SF_Form.CurrentRecord (get)
225 REM -----------------------------------------------------------------------------
226 Property Let CurrentRecord(Optional ByVal pvCurrentRecord As Variant)
227 &apos;&apos;&apos; Set the updatable property CurrentRecord
228 &apos;&apos;&apos; If the row number is positive, the cursor moves to the given row number with respect to the beginning of the result set.
229 &apos;&apos;&apos; The first row is row 1, the second is row 2, and so on.
230 &apos;&apos;&apos; If the given row number is negative, the cursor moves to an absolute row position with respect to the end of the result set.
231 &apos;&apos;&apos; For example, setting CurrentRecord = -1 positions the cursor on the last row, -2 indicates the next-to-last row, and so on
232 _PropertySet(&quot;CurrentRecord&quot;, pvCurrentRecord)
233 End Property &apos; SFDocuments.SF_Form.CurrentRecord (let)
235 REM -----------------------------------------------------------------------------
236 Property Get Filter() As Variant
237 &apos;&apos;&apos; The Filter property specifies a subset of records to be displayed.
238 Filter = _PropertyGet(&quot;Filter&quot;)
239 End Property &apos; SFDocuments.SF_Form.Filter (get)
241 REM -----------------------------------------------------------------------------
242 Property Let Filter(Optional ByVal pvFilter As Variant)
243 &apos;&apos;&apos; Set the updatable property Filter
244 _PropertySet(&quot;Filter&quot;, pvFilter)
245 End Property &apos; SFDocuments.SF_Form.Filter (let)
247 REM -----------------------------------------------------------------------------
248 Property Get LinkChildFields() As Variant
249 &apos;&apos;&apos; The LinkChildFields property specifies how records in a subform (child) are linked to records in its parent form
250 &apos;&apos;&apos; It returns an array of strings
251 LinkChildFields = _PropertyGet(&quot;LinkChildFields&quot;)
252 End Property &apos; SFDocuments.SF_Form.LinkChildFields (get)
254 REM -----------------------------------------------------------------------------
255 Property Get LinkParentFields() As Variant
256 &apos;&apos;&apos; The LinkParentFields property specifies how records in a subform (Child) are linked to records in its parent form
257 &apos;&apos;&apos; It returns an array of strings
258 LinkParentFields = _PropertyGet(&quot;LinkParentFields&quot;)
259 End Property &apos; SFDocuments.SF_Form.LinkParentFields (get)
261 REM -----------------------------------------------------------------------------
262 Property Get Name() As String
263 &apos;&apos;&apos; Return the name of the actual Form
264 Name = _PropertyGet(&quot;Name&quot;)
265 End Property &apos; SFDocuments.SF_Form.Name
267 REM -----------------------------------------------------------------------------
268 Property Get OnApproveCursorMove() As Variant
269 &apos;&apos;&apos; The OnApproveCursorMove property specifies the script to trigger when this event occurs
270 OnApproveCursorMove = _PropertyGet(&quot;OnApproveCursorMove&quot;)
271 End Property &apos; SFDocuments.SF_Form.OnApproveCursorMove (get)
273 REM -----------------------------------------------------------------------------
274 Property Let OnApproveCursorMove(Optional ByVal pvOnApproveCursorMove As Variant)
275 &apos;&apos;&apos; Set the updatable property OnApproveCursorMove
276 _PropertySet(&quot;OnApproveCursorMove&quot;, pvOnApproveCursorMove)
277 End Property &apos; SFDocuments.SF_Form.OnApproveCursorMove (let)
279 REM -----------------------------------------------------------------------------
280 Property Get OnApproveReset() As Variant
281 &apos;&apos;&apos; The OnApproveReset property specifies the script to trigger when this event occurs
282 OnApproveReset = _PropertyGet(&quot;OnApproveReset&quot;)
283 End Property &apos; SFDocuments.SF_Form.OnApproveReset (get)
285 REM -----------------------------------------------------------------------------
286 Property Let OnApproveReset(Optional ByVal pvOnApproveReset As Variant)
287 &apos;&apos;&apos; Set the updatable property OnApproveReset
288 _PropertySet(&quot;OnApproveReset&quot;, pvOnApproveReset)
289 End Property &apos; SFDocuments.SF_Form.OnApproveReset (let)
291 REM -----------------------------------------------------------------------------
292 Property Get OnApproveRowChange() As Variant
293 &apos;&apos;&apos; The OnApproveRowChange property specifies the script to trigger when this event occurs
294 OnApproveRowChange = _PropertyGet(&quot;OnApproveRowChange&quot;)
295 End Property &apos; SFDocuments.SF_Form.OnApproveRowChange (get)
297 REM -----------------------------------------------------------------------------
298 Property Let OnApproveRowChange(Optional ByVal pvOnApproveRowChange As Variant)
299 &apos;&apos;&apos; Set the updatable property OnApproveRowChange
300 _PropertySet(&quot;OnApproveRowChange&quot;, pvOnApproveRowChange)
301 End Property &apos; SFDocuments.SF_Form.OnApproveRowChange (let)
303 REM -----------------------------------------------------------------------------
304 Property Get OnApproveSubmit() As Variant
305 &apos;&apos;&apos; The OnApproveSubmit property specifies the script to trigger when this event occurs
306 OnApproveSubmit = _PropertyGet(&quot;OnApproveSubmit&quot;)
307 End Property &apos; SFDocuments.SF_Form.OnApproveSubmit (get)
309 REM -----------------------------------------------------------------------------
310 Property Let OnApproveSubmit(Optional ByVal pvOnApproveSubmit As Variant)
311 &apos;&apos;&apos; Set the updatable property OnApproveSubmit
312 _PropertySet(&quot;OnApproveSubmit&quot;, pvOnApproveSubmit)
313 End Property &apos; SFDocuments.SF_Form.OnApproveSubmit (let)
315 REM -----------------------------------------------------------------------------
316 Property Get OnConfirmDelete() As Variant
317 &apos;&apos;&apos; The OnConfirmDelete property specifies the script to trigger when this event occurs
318 OnConfirmDelete = _PropertyGet(&quot;OnConfirmDelete&quot;)
319 End Property &apos; SFDocuments.SF_Form.OnConfirmDelete (get)
321 REM -----------------------------------------------------------------------------
322 Property Let OnConfirmDelete(Optional ByVal pvOnConfirmDelete As Variant)
323 &apos;&apos;&apos; Set the updatable property OnConfirmDelete
324 _PropertySet(&quot;OnConfirmDelete&quot;, pvOnConfirmDelete)
325 End Property &apos; SFDocuments.SF_Form.OnConfirmDelete (let)
327 REM -----------------------------------------------------------------------------
328 Property Get OnCursorMoved() As Variant
329 &apos;&apos;&apos; The OnCursorMoved property specifies the script to trigger when this event occurs
330 OnCursorMoved = _PropertyGet(&quot;OnCursorMoved&quot;)
331 End Property &apos; SFDocuments.SF_Form.OnCursorMoved (get)
333 REM -----------------------------------------------------------------------------
334 Property Let OnCursorMoved(Optional ByVal pvOnCursorMoved As Variant)
335 &apos;&apos;&apos; Set the updatable property OnCursorMoved
336 _PropertySet(&quot;OnCursorMoved&quot;, pvOnCursorMoved)
337 End Property &apos; SFDocuments.SF_Form.OnCursorMoved (let)
339 REM -----------------------------------------------------------------------------
340 Property Get OnErrorOccurred() As Variant
341 &apos;&apos;&apos; The OnErrorOccurred property specifies the script to trigger when this event occurs
342 OnErrorOccurred = _PropertyGet(&quot;OnErrorOccurred&quot;)
343 End Property &apos; SFDocuments.SF_Form.OnErrorOccurred (get)
345 REM -----------------------------------------------------------------------------
346 Property Let OnErrorOccurred(Optional ByVal pvOnErrorOccurred As Variant)
347 &apos;&apos;&apos; Set the updatable property OnErrorOccurred
348 _PropertySet(&quot;OnErrorOccurred&quot;, pvOnErrorOccurred)
349 End Property &apos; SFDocuments.SF_Form.OnErrorOccurred (let)
351 REM -----------------------------------------------------------------------------
352 Property Get OnLoaded() As Variant
353 &apos;&apos;&apos; The OnLoaded property specifies the script to trigger when this event occurs
354 OnLoaded = _PropertyGet(&quot;OnLoaded&quot;)
355 End Property &apos; SFDocuments.SF_Form.OnLoaded (get)
357 REM -----------------------------------------------------------------------------
358 Property Let OnLoaded(Optional ByVal pvOnLoaded As Variant)
359 &apos;&apos;&apos; Set the updatable property OnLoaded
360 _PropertySet(&quot;OnLoaded&quot;, pvOnLoaded)
361 End Property &apos; SFDocuments.SF_Form.OnLoaded (let)
363 REM -----------------------------------------------------------------------------
364 Property Get OnReloaded() As Variant
365 &apos;&apos;&apos; The OnReloaded property specifies the script to trigger when this event occurs
366 OnReloaded = _PropertyGet(&quot;OnReloaded&quot;)
367 End Property &apos; SFDocuments.SF_Form.OnReloaded (get)
369 REM -----------------------------------------------------------------------------
370 Property Let OnReloaded(Optional ByVal pvOnReloaded As Variant)
371 &apos;&apos;&apos; Set the updatable property OnReloaded
372 _PropertySet(&quot;OnReloaded&quot;, pvOnReloaded)
373 End Property &apos; SFDocuments.SF_Form.OnReloaded (let)
375 REM -----------------------------------------------------------------------------
376 Property Get OnReloading() As Variant
377 &apos;&apos;&apos; The OnReloading property specifies the script to trigger when this event occurs
378 OnReloading = _PropertyGet(&quot;OnReloading&quot;)
379 End Property &apos; SFDocuments.SF_Form.OnReloading (get)
381 REM -----------------------------------------------------------------------------
382 Property Let OnReloading(Optional ByVal pvOnReloading As Variant)
383 &apos;&apos;&apos; Set the updatable property OnReloading
384 _PropertySet(&quot;OnReloading&quot;, pvOnReloading)
385 End Property &apos; SFDocuments.SF_Form.OnReloading (let)
387 REM -----------------------------------------------------------------------------
388 Property Get OnResetted() As Variant
389 &apos;&apos;&apos; The OnResetted property specifies the script to trigger when this event occurs
390 OnResetted = _PropertyGet(&quot;OnResetted&quot;)
391 End Property &apos; SFDocuments.SF_Form.OnResetted (get)
393 REM -----------------------------------------------------------------------------
394 Property Let OnResetted(Optional ByVal pvOnResetted As Variant)
395 &apos;&apos;&apos; Set the updatable property OnResetted
396 _PropertySet(&quot;OnResetted&quot;, pvOnResetted)
397 End Property &apos; SFDocuments.SF_Form.OnResetted (let)
399 REM -----------------------------------------------------------------------------
400 Property Get OnRowChanged() As Variant
401 &apos;&apos;&apos; The OnRowChanged property specifies the script to trigger when this event occurs
402 OnRowChanged = _PropertyGet(&quot;OnRowChanged&quot;)
403 End Property &apos; SFDocuments.SF_Form.OnRowChanged (get)
405 REM -----------------------------------------------------------------------------
406 Property Let OnRowChanged(Optional ByVal pvOnRowChanged As Variant)
407 &apos;&apos;&apos; Set the updatable property OnRowChanged
408 _PropertySet(&quot;OnRowChanged&quot;, pvOnRowChanged)
409 End Property &apos; SFDocuments.SF_Form.OnRowChanged (let)
411 REM -----------------------------------------------------------------------------
412 Property Get OnUnloaded() As Variant
413 &apos;&apos;&apos; The OnUnloaded property specifies the script to trigger when this event occurs
414 OnUnloaded = _PropertyGet(&quot;OnUnloaded&quot;)
415 End Property &apos; SFDocuments.SF_Form.OnUnloaded (get)
417 REM -----------------------------------------------------------------------------
418 Property Let OnUnloaded(Optional ByVal pvOnUnloaded As Variant)
419 &apos;&apos;&apos; Set the updatable property OnUnloaded
420 _PropertySet(&quot;OnUnloaded&quot;, pvOnUnloaded)
421 End Property &apos; SFDocuments.SF_Form.OnUnloaded (let)
423 REM -----------------------------------------------------------------------------
424 Property Get OnUnloading() As Variant
425 &apos;&apos;&apos; The OnUnloading property specifies the script to trigger when this event occurs
426 OnUnloading = _PropertyGet(&quot;OnUnloading&quot;)
427 End Property &apos; SFDocuments.SF_Form.OnUnloading (get)
429 REM -----------------------------------------------------------------------------
430 Property Let OnUnloading(Optional ByVal pvOnUnloading As Variant)
431 &apos;&apos;&apos; Set the updatable property OnUnloading
432 _PropertySet(&quot;OnUnloading&quot;, pvOnUnloading)
433 End Property &apos; SFDocuments.SF_Form.OnUnloading (let)
435 REM -----------------------------------------------------------------------------
436 Property Get OrderBy() As Variant
437 &apos;&apos;&apos; The OrderBy property specifies in which order the records should be displayed.
438 OrderBy = _PropertyGet(&quot;OrderBy&quot;)
439 End Property &apos; SFDocuments.SF_Form.OrderBy (get)
441 REM -----------------------------------------------------------------------------
442 Property Let OrderBy(Optional ByVal pvOrderBy As Variant)
443 &apos;&apos;&apos; Set the updatable property OrderBy
444 _PropertySet(&quot;OrderBy&quot;, pvOrderBy)
445 End Property &apos; SFDocuments.SF_Form.OrderBy (let)
447 REM -----------------------------------------------------------------------------
448 Property Get Parent() As Object
449 &apos;&apos;&apos; Return the Parent of the actual Form
450 Parent = _PropertyGet(&quot;Parent&quot;)
451 End Property &apos; SFDocuments.SF_Form.Parent
453 REM -----------------------------------------------------------------------------
454 Property Get RecordSource() As Variant
455 &apos;&apos;&apos; The RecordSource property specifies the source of the data,
456 &apos;&apos;&apos; a table name, a query name or a SQL statement
457 RecordSource = _PropertyGet(&quot;RecordSource&quot;)
458 End Property &apos; SFDocuments.SF_Form.RecordSource (get)
460 REM -----------------------------------------------------------------------------
461 Property Let RecordSource(Optional ByVal pvRecordSource As Variant)
462 &apos;&apos;&apos; Set the updatable property RecordSource
463 _PropertySet(&quot;RecordSource&quot;, pvRecordSource)
464 End Property &apos; SFDocuments.SF_Form.RecordSource (let)
466 REM -----------------------------------------------------------------------------
467 Property Get XForm() As Object
468 &apos;&apos;&apos; The XForm property returns the XForm UNO object of the Form
469 XForm = _PropertyGet(&quot;XForm&quot;)
470 End Property &apos; SFDocuments.SF_Form.XForm (get)
472 REM ===================================================================== METHODS
474 REM -----------------------------------------------------------------------------
475 Public Function Activate() As Boolean
476 &apos;&apos;&apos; Set the focus on the current Form instance
477 &apos;&apos;&apos; Probably called from after an event occurrence or to focus on an open Base form document
478 &apos;&apos;&apos; If the parent document is ...
479 &apos;&apos;&apos; Calc Activate the corresponding sheet
480 &apos;&apos;&apos; Writer Activate the parent document
481 &apos;&apos;&apos; Base Activate the parent form document
482 &apos;&apos;&apos; Args:
483 &apos;&apos;&apos; Returns:
484 &apos;&apos;&apos; True if focusing is successful
485 &apos;&apos;&apos; Example:
486 &apos;&apos;&apos; myForm.Activate()
488 Dim bActivate As Boolean &apos; Return value
489 Dim oContainer As Object &apos; com.sun.star.awt.XWindow
490 Const cstThisSub = &quot;SFDocuments.Form.Activate&quot;
491 Const cstSubArgs = &quot;&quot;
493 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
494 bActivate = False
496 Check:
497 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
498 If Not _IsStillAlive() Then GoTo Finally
499 End If
500 Try:
501 Select Case _FormType
502 Case ISDOCFORM : bActivate = [_Parent].Activate()
503 Case ISCALCFORM : bActivate = [_Parent].Activate(_SheetName)
504 Case ISBASEFORM
505 Set oContainer = _FormDocument.Component.CurrentController.Frame.ContainerWindow
506 With oContainer
507 If .isVisible() = False Then .setVisible(True)
508 .IsMinimized = False
509 .setFocus()
510 .toFront() &apos; Force window change in Linux
511 Wait 1 &apos; Bypass desynchro issue in Linux
512 End With
513 bActivate = True
514 End Select
516 Finally:
517 Activate = bActivate
518 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
519 Exit Function
520 Catch:
521 GoTo Finally
522 End Function &apos; SFDocuments.SF_Form.Activate
524 REM -----------------------------------------------------------------------------
525 Public Function CloseFormDocument() As Boolean
526 &apos;&apos;&apos; Close the form document containing the actual form instance
527 &apos;&apos;&apos; The form instance is disposed
528 &apos;&apos;&apos; The method does nothing if the actual form is not located in a Base form document
529 &apos;&apos;&apos; Args:
530 &apos;&apos;&apos; Returns:
531 &apos;&apos;&apos; True if closure is successful
532 &apos;&apos;&apos; Example:
533 &apos;&apos;&apos; myForm.CloseFormDocument()
535 Dim bClose As Boolean &apos; Return value
536 Dim oContainer As Object &apos; com.sun.star.awt.XWindow
537 Const cstThisSub = &quot;SFDocuments.Form.CloseFormDocument&quot;
538 Const cstSubArgs = &quot;&quot;
540 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
541 bClose = False
543 Check:
544 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
545 If Not _IsStillAlive() Then GoTo Finally
546 End If
547 Try:
548 Select Case _FormType
549 Case ISDOCFORM, ISCALCFORM
550 Case ISBASEFORM, ISSUBFORM
551 If Not IsNull(_FormDocument) Then
552 _FormDocument.close()
553 Dispose()
554 bClose = True
555 End If
556 Case Else
557 End Select
559 Finally:
560 CloseFormDocument = bClose
561 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
562 Exit Function
563 Catch:
564 GoTo Finally
565 End Function &apos; SFDocuments.SF_Form.CloseFormDocument
567 REM -----------------------------------------------------------------------------
568 Public Function Controls(Optional ByVal ControlName As Variant) As Variant
569 &apos;&apos;&apos; Return either
570 &apos;&apos;&apos; - the list of the controls contained in the Form
571 &apos;&apos;&apos; - a Form control object based on its name
572 &apos;&apos;&apos; Args:
573 &apos;&apos;&apos; ControlName: a valid control name as a case-sensitive string. If absent the list is returned
574 &apos;&apos;&apos; Returns:
575 &apos;&apos;&apos; A zero-base array of strings if ControlName is absent
576 &apos;&apos;&apos; An instance of the SF_FormControl class if ControlName exists
577 &apos;&apos;&apos; Exceptions:
578 &apos;&apos;&apos; ControlName is invalid
579 &apos;&apos;&apos; Example:
580 &apos;&apos;&apos; Dim myForm As Object, myList As Variant, myControl As Object
581 &apos;&apos;&apos; Set myForm = myDoc.Forms(&quot;myForm&quot;)
582 &apos;&apos;&apos; myList = myForm.Controls()
583 &apos;&apos;&apos; Set myControl = myForm.Controls(&quot;myTextBox&quot;)
585 Dim oControl As Object &apos; The new control class instance
586 Dim lIndexOfNames As Long &apos; Index in ElementNames array. Used to access _ControlCache
587 Dim vControl As Variant &apos; Alias of _ControlCache entry
588 Dim i As Long
589 Const cstThisSub = &quot;SFDocuments.Form.Controls&quot;
590 Const cstSubArgs = &quot;[ControlName]&quot;
592 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
594 Check:
595 If IsMissing(ControlName) Or IsEmpty(ControlName) Then ControlName = &quot;&quot;
596 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
597 If Not _IsStillAlive() Then GoTo Finally
598 If Not ScriptForge.SF_Utils._Validate(ControlName, &quot;ControlName&quot;, V_STRING) Then GoTo Finally
599 End If
601 Try:
602 &apos; Collect all control names if not yet done
603 If UBound(_ControlNames) &lt; 0 Then
604 _ControlNames = _Form.getElementNames()
605 &apos; Remove all subforms from the list
606 For i = 0 To UBound(_ControlNames)
607 &apos; Subforms have no ClassId property
608 If Not ScriptForge.SF_Session.HasUnoProperty(_Form.getByName(_ControlNames(i)), &quot;ClassId&quot;) Then _ControlNames(i) = &quot;&quot;
609 Next i
610 _ControlNames = ScriptForge.SF_Array.TrimArray(_ControlNames)
611 &apos; Size the cache accordingly
612 If UBound(_ControlNames) &gt;= 0 Then
613 ReDim _ControlCache(0 To UBound(_ControlNames))
614 End If
615 End If
617 &apos; Return the list of controls or a FormControl instance
618 If Len(ControlName) = 0 Then
619 Controls = _ControlNames
621 Else
623 If Not _Form.hasByName(ControlName) Then GoTo CatchNotFound
624 lIndexOfNames = ScriptForge.SF_Array.IndexOf(_ControlNames, ControlName, CaseSensitive := True)
625 &apos; Reuse cache when relevant
626 vControl = _ControlCache(lIndexOfNames)
628 If IsEmpty(vControl) Then
629 &apos; Create the new form control class instance
630 Set oControl = New SF_FormControl
631 With oControl
632 ._Name = ControlName
633 Set .[Me] = oControl
634 Set .[_Parent] = [Me]
635 Set ._ParentForm = [Me]
636 ._IndexOfNames = lIndexOfNames
637 ._FormName = _Name
638 &apos; Get model and view of the current control
639 Set ._ControlModel = _Form.getByName(ControlName)
640 ._Initialize()
641 End With
642 Else
643 Set oControl = vControl
644 End If
646 Set Controls = oControl
647 End If
649 Finally:
650 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
651 Exit Function
652 Catch:
653 GoTo Finally
654 CatchNotFound:
655 ScriptForge.SF_Utils._Validate(ControlName, &quot;ControlName&quot;, V_STRING, _Form.getElementNames(), True)
656 GoTo Finally
657 End Function &apos; SFDocuments.SF_Form.Controls
659 REM -----------------------------------------------------------------------------
660 Public Function GetDatabase(Optional ByVal User As Variant _
661 , Optional ByVal Password As Variant _
662 ) As Object
663 &apos;&apos;&apos; Returns a Database instance (service = SFDatabases.Database) giving access
664 &apos;&apos;&apos; to the execution of SQL commands on the database defined and/or stored in
665 &apos;&apos;&apos; the actual Base document
666 &apos;&apos;&apos; Each main form has its own database connection, except within Base documents where
667 &apos;&apos;&apos; they all share the same connection
668 &apos;&apos;&apos; Args:
669 &apos;&apos;&apos; User, Password: the login parameters as strings. Defaults = &quot;&quot;
670 &apos;&apos;&apos; Returns:
671 &apos;&apos;&apos; A SFDatabases.Database instance or Nothing
672 &apos;&apos;&apos; Exceptions:
673 &apos;&apos;&apos; DBCONNECTERROR The database could not be connected, credentials are probably wrong
674 &apos;&apos;&apos; Example:
675 &apos;&apos;&apos; Dim myDb As Object
676 &apos;&apos;&apos; Set myDb = oForm.GetDatabase()
678 Dim FSO As Object &apos; Alias for SF_FileSystem
679 Dim sDataSource As String &apos; Database file name in FileNaming format
680 Dim sUser As String &apos; Alias for User
681 Dim sPassword As String &apos; Alias for Password
682 Const cstThisSub = &quot;SFDocuments.Form.GetDatabase&quot;
683 Const cstSubArgs = &quot;[User=&quot;&quot;&quot;&quot;], [Password=&quot;&quot;&quot;&quot;]&quot;
685 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
686 Set GetDatabase = Nothing
688 Check:
689 If IsMissing(User) Or IsEmpty(User) Then User = &quot;&quot;
690 If IsMissing(Password) Or IsEmpty(Password) Then Password = &quot;&quot;
691 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
692 If Not [_Parent]._IsStillAlive(False) Then GoTo Finally
693 If Not ScriptForge.SF_Utils._Validate(User, &quot;User&quot;, V_STRING) Then GoTo Finally
694 If Not ScriptForge.SF_Utils._Validate(Password, &quot;Password&quot;, V_STRING) Then GoTo Finally
695 End If
697 Try:
698 &apos; Adjust connection arguments
699 If Len(User) = 0 Then
700 If ScriptForge.SF_Session.HasUnoProperty(_Form, &quot;User&quot;) Then sUser = _Form.User Else sUser = &quot;&quot;
701 Else
702 sUser = User
703 End If
704 If Len(sUser) + Len(Password) = 0 Then
705 If ScriptForge.SF_Session.HasUnoProperty(_Form, &quot;Password&quot;) Then sPassword = _Form.Password Else sPassword = Password
706 End If
708 &apos; Connect to database, avoiding multiple requests
709 If IsNull(_Database) Then &apos; 1st connection request from the current form instance
710 If _FormType = ISBASEFORM And Not IsNull(_BaseComponent) Then
711 &apos; Fetch the shared connection
712 Set _Database = [_Parent].GetDatabase(User, Password)
713 ElseIf _FormType = ISSUBFORM Then
714 Set _Database = [_Parent].GetDatabase() &apos; Recursive call, climb the tree
715 ElseIf Len(_Form.DataSourceName) = 0 Then &apos; There is no database linked with the form
716 &apos; Return Nothing
717 Else
718 &apos; Check if DataSourceName is a file or a registered name and create database instance accordingly
719 Set FSO = ScriptForge.SF_FileSystem
720 sDataSource = FSO._ConvertFromUrl(_Form.DataSourceName)
721 If FSO.FileExists(sDataSource) Then
722 Set _Database = ScriptForge.SF_Services.CreateScriptService(&quot;SFDatabases.Database&quot; _
723 , sDataSource, , , sUser, sPassword)
724 Else
725 Set _Database = ScriptForge.SF_Services.CreateScriptService(&quot;SFDatabases.Database&quot; _
726 , , _Form.DataSourceName, , sUser, sPassword)
727 End If
728 If IsNull(_Database) Then GoTo CatchConnect
729 End If
730 Else
731 EndIf
733 Finally:
734 Set GetDatabase = _Database
735 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
736 Exit Function
737 Catch:
738 GoTo Finally
739 CatchConnect:
740 ScriptForge.SF_Exception.RaiseFatal(DBCONNECTERROR, &quot;User&quot;, User, &quot;Password&quot;, Password, [_Super]._FileIdent())
741 GoTo Finally
742 End Function &apos; SFDocuments.SF_Form.GetDatabase
744 REM -----------------------------------------------------------------------------
745 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
746 &apos;&apos;&apos; Return the actual value of the given property
747 &apos;&apos;&apos; Args:
748 &apos;&apos;&apos; PropertyName: the name of the property as a string
749 &apos;&apos;&apos; Returns:
750 &apos;&apos;&apos; The actual value of the property
751 &apos;&apos;&apos; Exceptions:
752 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
753 &apos;&apos;&apos; Examples:
754 &apos;&apos;&apos; oDlg.GetProperty(&quot;Caption&quot;)
756 Const cstThisSub = &quot;SFDocuments.Form.GetProperty&quot;
757 Const cstSubArgs = &quot;&quot;
759 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
760 GetProperty = Null
762 Check:
763 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
764 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
765 End If
767 Try:
768 GetProperty = _PropertyGet(PropertyName)
770 Finally:
771 SF_Utils._ExitFunction(cstThisSub)
772 Exit Function
773 Catch:
774 GoTo Finally
775 End Function &apos; SFDocuments.SF_Form.GetProperty
777 REM -----------------------------------------------------------------------------
778 Public Function Methods() As Variant
779 &apos;&apos;&apos; Return the list of public methods of the Form service as an array
781 Methods = Array( _
782 &quot;Activate&quot; _
783 , &quot;CloseForm&quot; _
784 , &quot;Controls&quot; _
785 , &quot;GetDatabase&quot; _
786 , &quot;MoveFirst&quot; _
787 , &quot;MoveLast&quot; _
788 , &quot;MoveNew&quot; _
789 , &quot;MoveNext&quot; _
790 , &quot;MovePrevious&quot; _
791 , &quot;Requery&quot; _
792 , &quot;SubForms&quot; _
795 End Function &apos; SFDocuments.SF_Form.Methods
797 REM -----------------------------------------------------------------------------
798 Public Function MoveFirst() As Boolean
799 &apos;&apos;&apos; The cursor is (re)positioned on the first row
800 &apos;&apos;&apos; Args:
801 &apos;&apos;&apos; Returns:
802 &apos;&apos;&apos; True if cursor move is successful
803 &apos;&apos;&apos; Example:
804 &apos;&apos;&apos; myForm.MoveFirst()
806 Dim bMoveFirst As Boolean &apos; Return value
807 Const cstThisSub = &quot;SFDocuments.Form.MoveFirst&quot;
808 Const cstSubArgs = &quot;&quot;
810 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
811 bMoveFirst = False
813 Check:
814 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
815 If Not _IsStillAlive() Then GoTo Finally
816 End If
817 Try:
818 With _Form
819 bMoveFirst = .first()
820 End With
822 Finally:
823 MoveFirst = bMoveFirst
824 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
825 Exit Function
826 Catch:
827 GoTo Finally
828 End Function &apos; SFDocuments.SF_Form.MoveFirst
830 REM -----------------------------------------------------------------------------
831 Public Function MoveLast() As Boolean
832 &apos;&apos;&apos; The cursor is (re)positioned on the last row
833 &apos;&apos;&apos; Args:
834 &apos;&apos;&apos; Returns:
835 &apos;&apos;&apos; True if cursor move is successful
836 &apos;&apos;&apos; Example:
837 &apos;&apos;&apos; myForm.MoveLast()
839 Dim bMoveLast As Boolean &apos; Return value
840 Const cstThisSub = &quot;SFDocuments.Form.MoveLast&quot;
841 Const cstSubArgs = &quot;&quot;
843 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
844 bMoveLast = False
846 Check:
847 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
848 If Not _IsStillAlive() Then GoTo Finally
849 End If
850 Try:
851 With _Form
852 bMoveLast = .last()
853 End With
855 Finally:
856 MoveLast = bMoveLast
857 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
858 Exit Function
859 Catch:
860 GoTo Finally
861 End Function &apos; SFDocuments.SF_Form.MoveLast
863 REM -----------------------------------------------------------------------------
864 Public Function MoveNew() As Boolean
865 &apos;&apos;&apos; The cursor is (re)positioned in the new record area
866 &apos;&apos;&apos; Args:
867 &apos;&apos;&apos; Returns:
868 &apos;&apos;&apos; True if cursor move is successful
869 &apos;&apos;&apos; Example:
870 &apos;&apos;&apos; myForm.MoveNew()
872 Dim bMoveNew As Boolean &apos; Return value
873 Const cstThisSub = &quot;SFDocuments.Form.MoveNew&quot;
874 Const cstSubArgs = &quot;&quot;
876 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
877 bMoveNew = False
879 Check:
880 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
881 If Not _IsStillAlive() Then GoTo Finally
882 End If
883 Try:
884 With _Form
885 .last() &apos; To simulate the behaviour in the UI
886 .moveToInsertRow()
887 End With
888 bMoveNew = True
890 Finally:
891 MoveNew = bMoveNew
892 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
893 Exit Function
894 Catch:
895 GoTo Finally
896 End Function &apos; SFDocuments.SF_Form.MoveNew
898 REM -----------------------------------------------------------------------------
899 Public Function MoveNext(Optional ByVal Offset As Variant) As Boolean
900 &apos;&apos;&apos; The cursor is (re)positioned on the next row
901 &apos;&apos;&apos; Args:
902 &apos;&apos;&apos; Offset: The number of records to go forward (default = 1)
903 &apos;&apos;&apos; Returns:
904 &apos;&apos;&apos; True if cursor move is successful
905 &apos;&apos;&apos; Example:
906 &apos;&apos;&apos; myForm.MoveNext()
908 Dim bMoveNext As Boolean &apos; Return value
909 Dim lOffset As Long &apos; Alias of Offset
910 Const cstThisSub = &quot;SFDocuments.Form.MoveNext&quot;
911 Const cstSubArgs = &quot;&quot;
913 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
914 bMoveNext = False
916 Check:
917 If IsMissing(Offset) Or IsEmpty(Offset) Then Offset = 1
918 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
919 If Not _IsStillAlive() Then GoTo Finally
920 If Not ScriptForge.SF_Utils._Validate(Offset, &quot;Offset&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
921 End If
922 Try:
923 lOffset = CLng(Offset) &apos; To be sure to have the right argument type
924 With _Form
925 If lOffset = 1 Then bMoveNext = .next() Else bMoveNext = .relative(lOffset)
926 End With
928 Finally:
929 MoveNext = bMoveNext
930 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
931 Exit Function
932 Catch:
933 GoTo Finally
934 End Function &apos; SFDocuments.SF_Form.MoveNext
936 REM -----------------------------------------------------------------------------
937 Public Function MovePrevious(Optional ByVal Offset As Variant) As Boolean
938 &apos;&apos;&apos; The cursor is (re)positioned on the previous row
939 &apos;&apos;&apos; Args:
940 &apos;&apos;&apos; Offset: The number of records to go backward (default = 1)
941 &apos;&apos;&apos; Returns:
942 &apos;&apos;&apos; True if cursor move is successful
943 &apos;&apos;&apos; Example:
944 &apos;&apos;&apos; myForm.MovePrevious()
946 Dim bMovePrevious As Boolean &apos; Return value
947 Dim lOffset As Long &apos; Alias of Offset
948 Const cstThisSub = &quot;SFDocuments.Form.MovePrevious&quot;
949 Const cstSubArgs = &quot;&quot;
951 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
952 bMovePrevious = False
954 Check:
955 If IsMissing(Offset) Or IsEmpty(Offset) Then Offset = 1
956 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
957 If Not _IsStillAlive() Then GoTo Finally
958 If Not ScriptForge.SF_Utils._Validate(Offset, &quot;Offset&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
959 End If
960 Try:
961 lOffset = CLng(Offset) &apos; To be sure to have the right argument type
962 With _Form
963 If lOffset = 1 Then bMovePrevious = .previous() Else bMovePrevious = .relative(-lOffset)
964 End With
966 Finally:
967 MovePrevious = bMovePrevious
968 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
969 Exit Function
970 Catch:
971 GoTo Finally
972 End Function &apos; SFDocuments.SF_Form.MovePrevious
974 REM -----------------------------------------------------------------------------
975 Public Function Properties() As Variant
976 &apos;&apos;&apos; Return the list or properties of the Form class as an array
978 Properties = Array( _
979 &quot;AllowDeletes&quot; _
980 , &quot;AllowInserts&quot; _
981 , &quot;AllowUpdates&quot; _
982 , &quot;BaseForm&quot; _
983 , &quot;Bookmark&quot; _
984 , &quot;CurrentRecord&quot; _
985 , &quot;Filter&quot; _
986 , &quot;LinkChildFields&quot; _
987 , &quot;LinkParentFields&quot; _
988 , &quot;Name&quot; _
989 , &quot;OnApproveCursorMove&quot; _
990 , &quot;OnApproveParameter&quot; _
991 , &quot;OnApproveReset&quot; _
992 , &quot;OnApproveRowChange&quot; _
993 , &quot;OnApproveSubmit&quot; _
994 , &quot;OnConfirmDelete&quot; _
995 , &quot;OnCursorMoved&quot; _
996 , &quot;OnErrorOccurred&quot; _
997 , &quot;OnLoaded&quot; _
998 , &quot;OnReloaded&quot; _
999 , &quot;OnReloading&quot; _
1000 , &quot;OnResetted&quot; _
1001 , &quot;OnRowChanged&quot; _
1002 , &quot;OnUnloaded&quot; _
1003 , &quot;OnUnloading&quot; _
1004 , &quot;OrderBy&quot; _
1005 , &quot;Parent&quot; _
1006 , &quot;RecordSource&quot; _
1007 , &quot;XForm&quot; _
1010 End Function &apos; SFDocuments.SF_Form.Properties
1012 REM -----------------------------------------------------------------------------
1013 Public Function Requery() As Boolean
1014 &apos;&apos;&apos; Reload from the database the actual data into the form
1015 &apos;&apos;&apos; The cursor is (re)positioned on the first row
1016 &apos;&apos;&apos; Args:
1017 &apos;&apos;&apos; Returns:
1018 &apos;&apos;&apos; True if requery is successful
1019 &apos;&apos;&apos; Example:
1020 &apos;&apos;&apos; myForm.Requery()
1022 Dim bRequery As Boolean &apos; Return value
1023 Const cstThisSub = &quot;SFDocuments.Form.Requery&quot;
1024 Const cstSubArgs = &quot;&quot;
1026 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1027 bRequery = False
1029 Check:
1030 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1031 If Not _IsStillAlive() Then GoTo Finally
1032 End If
1033 Try:
1034 With _Form
1035 If .isLoaded() Then .reload() Else .load()
1036 End With
1037 bRequery = True
1039 Finally:
1040 Requery = bRequery
1041 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1042 Exit Function
1043 Catch:
1044 GoTo Finally
1045 End Function &apos; SFDocuments.SF_Form.Requery
1047 REM -----------------------------------------------------------------------------
1048 Public Function SetProperty(Optional ByVal PropertyName As Variant _
1049 , Optional ByRef Value As Variant _
1050 ) As Boolean
1051 &apos;&apos;&apos; Set a new value to the given property
1052 &apos;&apos;&apos; Args:
1053 &apos;&apos;&apos; PropertyName: the name of the property as a string
1054 &apos;&apos;&apos; Value: its new value
1055 &apos;&apos;&apos; Exceptions
1056 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
1058 Const cstThisSub = &quot;SFDocuments.Form.SetProperty&quot;
1059 Const cstSubArgs = &quot;PropertyName, Value&quot;
1061 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1062 SetProperty = False
1064 Check:
1065 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1066 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
1067 End If
1069 Try:
1070 SetProperty = _PropertySet(PropertyName, Value)
1072 Finally:
1073 SF_Utils._ExitFunction(cstThisSub)
1074 Exit Function
1075 Catch:
1076 GoTo Finally
1077 End Function &apos; SFDocuments.SF_Form.SetProperty
1079 REM -----------------------------------------------------------------------------
1080 Public Function Subforms(Optional ByVal Subform As Variant) As Variant
1081 &apos;&apos;&apos; Return either
1082 &apos;&apos;&apos; - the list of the subforms contained in the actual form or subform instance
1083 &apos;&apos;&apos; - a SFDocuments.Form object based on its name or its index in the alphabetic list of subforms
1084 &apos;&apos;&apos; Args:
1085 &apos;&apos;&apos; Subform: a subform stored in the parent form given by its name or its index
1086 &apos;&apos;&apos; When absent, the list of available subforms is returned
1087 &apos;&apos;&apos; To get the first (unique ?) subform stored in the parent form, set Subform = 0
1088 &apos;&apos;&apos; Exceptions:
1089 &apos;&apos;&apos; SUBFORMNOTFOUNDERROR Subform not found
1090 &apos;&apos;&apos; Returns:
1091 &apos;&apos;&apos; A zero-based array of strings if Subform is absent
1092 &apos;&apos;&apos; An instance of the SF_Form class if Subform exists
1093 &apos;&apos;&apos; Example:
1094 &apos;&apos;&apos; Dim myForm As Object, myList As Variant, mySubform As Object
1095 &apos;&apos;&apos; myList = myForm.Subforms()
1096 &apos;&apos;&apos; Set mySubform = myForm.Subforms(&quot;mySubform&quot;)
1098 Dim oSubform As Object &apos; The new Form class instance
1099 Dim oXSubform As Object &apos; com.sun.star.form.XForm
1100 Dim vSubformNames As Variant &apos; Array of subform names
1101 Dim i As Long
1102 Const cstDrawPage = 0 &apos; Only 1 drawpage in a Writer document
1104 Const cstThisSub = &quot;SFDocuments.Form.Subforms&quot;
1105 Const cstSubArgs = &quot;[Subform=&quot;&quot;&quot;&quot;]&quot;
1107 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1109 Check:
1110 If IsMissing(Subform) Or IsEmpty(Subform) Then Subform = &quot;&quot;
1111 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1112 If Not _IsStillAlive() Then GoTo Finally
1113 If Not ScriptForge.SF_Utils._Validate(Subform, &quot;Subform&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
1114 End If
1116 Try:
1117 &apos; Collect all control names and retain only the subforms
1118 vSubformNames = _Form.getElementNames()
1119 For i = 0 To UBound(vSubformNames)
1120 Set oSubform = _Form.getByName(vSubformNames(i))
1121 &apos; Subforms are the only control types having no ClassId property
1122 If ScriptForge.SF_Session.HasUnoProperty(oSubform, &quot;ClassId&quot;) Then vSubformNames(i) = &quot;&quot;
1123 Next i
1124 vSubformNames = ScriptForge.SF_Array.TrimArray(vSubformNames)
1126 If Len(Subform) = 0 Then &apos; Return the list of valid subform names
1127 Subforms = vSubformNames
1128 Else
1129 If VarType(Subform) = V_STRING Then &apos; Find the form by name
1130 If Not ScriptForge.SF_Array.Contains(vSubformNames, Subform, CaseSensitive := True) Then GoTo CatchNotFound
1131 Set oXSubform = _Form.getByName(Subform)
1132 Else &apos; Find the form by index
1133 If Subform &lt; 0 Or Subform &gt; UBound(vSubformNames) Then GoTo CatchNotFound
1134 Set oXSubform = _Form.getByName(vSubformNames(Subform))
1135 End If
1136 &apos; Create the new Form class instance
1137 Set oSubform = SF_Register._NewForm(oXSubform)
1138 With oSubform
1139 Set .[_Parent] = [Me]
1140 ._FormType = ISSUBFORM
1141 Set ._Component = _Component
1142 Set ._BaseComponent = _BaseComponent
1143 Set ._FormDocument = _FormDocument
1144 ._SheetName = _SheetName
1145 ._FormDocumentName = _FormDocumentName
1146 Set ._Database = _Database
1147 ._Initialize()
1148 End With
1149 Set Subforms = oSubform
1150 End If
1152 Finally:
1153 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1154 Exit Function
1155 Catch:
1156 GoTo Finally
1157 CatchNotFound:
1158 ScriptForge.SF_Exception.RaiseFatal(SUBFORMNOTFOUNDERROR, Subform, _Name)
1159 GoTo Finally
1160 End Function &apos; SFDocuments.SF_Form.Subforms
1162 REM =========================================================== PRIVATE FUNCTIONS
1164 REM -----------------------------------------------------------------------------
1165 Public Function _GetEventName(ByVal psProperty As String) As String
1166 &apos;&apos;&apos; Return the LO internal event name derived from the SF property name
1167 &apos;&apos;&apos; The SF property name is not case sensitive, while the LO name is case-sensitive
1168 &apos; Corrects the typo on ErrorOccur(r?)ed, if necessary
1170 Dim vProperties As Variant &apos; Array of class properties
1171 Dim sProperty As String &apos; Correctly cased property name
1173 vProperties = Properties()
1174 sProperty = vProperties(ScriptForge.SF_Array.IndexOf(vProperties, psProperty, SortOrder := &quot;ASC&quot;))
1176 _GetEventName = LCase(Mid(sProperty, 3, 1)) &amp; Right(sProperty, Len(sProperty) - 3)
1178 End Function &apos; SFDocuments.SF_Form._GetEventName
1180 REM -----------------------------------------------------------------------------
1181 Private Function _GetListener(ByVal psEventName As String) As String
1182 &apos;&apos;&apos; Getting/Setting macros triggered by events requires a Listener-EventName pair
1183 &apos;&apos;&apos; Return the X...Listener corresponding with the event name in argument
1185 Select Case UCase(psEventName)
1186 Case UCase(&quot;OnApproveCursorMove&quot;)
1187 _GetListener = &quot;XRowSetApproveListener&quot;
1188 Case UCase(&quot;OnApproveParameter&quot;)
1189 _GetListener = &quot;XDatabaseParameterListener&quot;
1190 Case UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnResetted&quot;)
1191 _GetListener = &quot;XResetListener&quot;
1192 Case UCase(&quot;OnApproveRowChange&quot;)
1193 _GetListener = &quot;XRowSetApproveListener&quot;
1194 Case UCase(&quot;OnApproveSubmit&quot;)
1195 _GetListener = &quot;XSubmitListener&quot;
1196 Case UCase(&quot;OnConfirmDelete&quot;)
1197 _GetListener = &quot;XConfirmDeleteListener&quot;
1198 Case UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnRowChanged&quot;)
1199 _GetListener = &quot;XRowSetListener&quot;
1200 Case UCase(&quot;OnErrorOccurred&quot;)
1201 _GetListener = &quot;XSQLErrorListener&quot;
1202 Case UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
1203 _GetListener = &quot;XLoadListener&quot;
1204 End Select
1206 End Function &apos; SFDocuments.SF_Form._GetListener
1208 REM -----------------------------------------------------------------------------
1209 Private Sub _GetParents()
1210 &apos;&apos;&apos; When the current instance is created top-down, the parents are completely defined
1211 &apos;&apos;&apos; and nothing should be done in this method
1212 &apos;&apos;&apos; When the a class instance is created in a (form/control) event, it is the opposite
1213 &apos;&apos;&apos; The current method rebuilds the missing members in the instance from the bottom
1214 &apos;&apos;&apos; Members potentially to collect are:
1215 &apos;&apos;&apos; - _FormType
1216 &apos;&apos;&apos; - [_Parent], the immediate parent: a form or a document instance
1217 &apos;&apos;&apos; + Only when the _FormType is a main form
1218 &apos;&apos;&apos; - _SheetName (Calc only)
1219 &apos;&apos;&apos; - _FormDocumentName (Base only)
1220 &apos;&apos;&apos; - _FormDocument, the topmost form collection
1221 &apos;&apos;&apos; - _Component, the containing document
1222 &apos;&apos;&apos; They must be identified only starting from the _Form UNO object
1223 &apos;&apos;&apos;
1224 &apos;&apos;&apos; The method is called from the _Initialize() method at instance creation
1226 Dim oParent As Object &apos; Successive bottom-up parents
1227 Dim sType As String &apos; UNO object type
1228 Dim iLevel As Integer &apos; When = 1 =&gt; first parent
1229 Dim oBase As Object &apos; Empty Base instance
1230 Dim oSession As Object : Set oSession = ScriptForge.SF_Session
1232 On Local Error GoTo Finally &apos; Being probably called from events, this method should avoid failures
1233 &apos; When the form type is known, the upper part of the branch is not scanned
1234 If _FormType &lt;&gt; ISUNDEFINED Then GoTo Finally
1236 Try:
1237 &apos; The whole branch is scanned bottom-up
1238 If oSession.HasUnoProperty(_Form, &quot;Parent&quot;) Then Set oParent = _Form.Parent Else Set oParent = Nothing
1239 _FormType = ISUNDEFINED
1240 iLevel = 1
1242 Do While Not IsNull(oParent)
1243 sType = SF_Session.UnoObjectType(oParent)
1244 Select Case sType
1245 &apos; Collect at each level the needed info
1246 Case &quot;com.sun.star.comp.forms.ODatabaseForm&quot; &apos; The parent _Form of a subform
1247 If iLevel = 1 Then
1248 _FormType = ISSUBFORM
1249 Set [_Parent] = SF_Register._NewForm(oParent)
1250 &apos; Everything is in the parent, copy items and stop scan
1251 [_Parent]._Initialize() &apos; Current method is called recursively here
1252 With [_Parent]
1253 _SheetName = ._SheetName
1254 _FormDocumentName = ._FormDocumentName
1255 Set _FormDocument = ._FormDocument
1256 Set _Component = ._Component
1257 End With
1258 Exit Sub
1259 End If
1260 Case &quot;com.sun.star.form.OFormsCollection&quot; &apos; The collection of forms inside a drawpage
1261 Case &quot;SwXTextDocument&quot; &apos; The parent document: a Writer document or a Base form document
1262 If oParent.Identifier = &quot;com.sun.star.sdb.FormDesign&quot; Then
1263 _FormType = ISBASEFORM
1264 &apos; Make a new SF_FormDocument instance
1265 Set [_Parent] = ScriptForge.SF_Services.CreateScriptService(&quot;SFDocuments.FormDocument&quot;, oParent)
1266 Set _FormDocument = [_Parent]._FormDocument
1267 ElseIf oParent.Identifier = &quot;com.sun.star.text.TextDocument&quot; Then
1268 _FormType = ISDOCFORM
1269 Set [_Parent] = ScriptForge.SF_Services.CreateScriptService(&quot;SFDocuments.Document&quot;, oParent)
1270 End If
1271 Set _Component = oParent
1272 Case &quot;ScModelObj&quot; &apos; The parent document: a Calc document
1273 _FormType = ISCALCFORM
1274 Set [_Parent] = ScriptForge.SF_Services.CreateScriptService(&quot;SFDocuments.Document&quot;, oParent)
1275 Set _Component = oParent
1276 &apos; The triggered form event is presumed to be located in the (drawpage of the) active sheet
1277 _SheetName = [_Parent].XSpreadsheet(&quot;~&quot;)
1278 Case &quot;com.sun.star.comp.dba.ODatabaseDocument&quot; &apos; The Base document
1279 Case Else
1280 End Select
1281 If oSession.HasUnoProperty(oParent, &quot;Parent&quot;) Then Set oParent = oParent.Parent Else Set oParent = Nothing
1282 iLevel = iLevel + 1
1283 Loop
1285 Finally:
1286 Exit Sub
1287 End Sub &apos; SFDocuments.SF_Form._GetParents
1289 REM -----------------------------------------------------------------------------
1290 Public Sub _Initialize()
1291 &apos;&apos;&apos; Achieve the creation of a SF_Form instance
1292 &apos;&apos;&apos; - complete the missing private members
1293 &apos;&apos;&apos; - store the new instance in the cache
1295 _GetParents()
1296 _CacheIndex = SF_Register._AddFormToCache(_Form, [Me])
1298 End Sub &apos; SFDocuments.SF_Form._Initialize
1300 REM -----------------------------------------------------------------------------
1301 Private Function _IsStillAlive(Optional ByVal pbError As Boolean) As Boolean
1302 &apos;&apos;&apos; Return True if the Form is still open
1303 &apos;&apos;&apos; If dead the actual instance is disposed
1304 &apos;&apos;&apos; and the execution is cancelled when pbError = True (default)
1305 &apos;&apos;&apos; Args:
1306 &apos;&apos;&apos; pbError: if True (default), raise a fatal error
1308 Dim bAlive As Boolean &apos; Return value
1309 Dim sName As String &apos; Alias of _Name
1310 Dim sId As String &apos; Alias of FileIdent
1312 Check:
1313 On Local Error GoTo Catch &apos; Anticipate DisposedException errors or alike
1314 If IsMissing(pbError) Then pbError = True
1316 Try:
1317 &apos; At main form termination, all database connections are lost
1318 bAlive = Not IsNull(_Form)
1319 If Not bAlive Then GoTo Catch
1321 Finally:
1322 _IsStillAlive = bAlive
1323 Exit Function
1324 Catch:
1325 bAlive = False
1326 On Error GoTo 0
1327 &apos; Keep error message elements before disposing the instance
1328 sName = _SheetName &amp; _FormDocumentName &apos; At least one of them is a zero-length string
1329 sName = Iif(Len(sName) &gt; 0, &quot;[&quot; &amp; sName &amp; &quot;].&quot;, &quot;&quot;) &amp; _Name
1330 If Not IsNull(_Component) Then sId = _Component.Location Else sId = &quot;&quot;
1331 &apos; Dispose the actual forms instance
1332 Dispose()
1333 &apos; Display error message
1334 If pbError Then ScriptForge.SF_Exception.RaiseFatal(FORMDEADERROR, sName, sId)
1335 GoTo Finally
1336 End Function &apos; SFDocuments.SF_Form._IsStillAlive
1338 REM -----------------------------------------------------------------------------
1339 Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
1340 &apos;&apos;&apos; Return the value of the named property
1341 &apos;&apos;&apos; Args:
1342 &apos;&apos;&apos; psProperty: the name of the property
1344 Static oSession As Object &apos; Alias of SF_Session
1345 Dim vBookmark As Variant &apos; Form bookmark
1346 Dim cstThisSub As String
1347 Const cstSubArgs = &quot;&quot;
1349 cstThisSub = &quot;SFDocuments.Form.get&quot; &amp; psProperty
1350 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1352 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
1353 _PropertyGet = Empty
1354 If Not _IsStillAlive() Then GoTo Finally
1356 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
1357 Select Case UCase(psProperty)
1358 Case UCase(&quot;AllowDeletes&quot;)
1359 If Not IsNull(_Form) Then _PropertyGet = _Form.AllowDeletes
1360 Case UCase(&quot;AllowInserts&quot;)
1361 If Not IsNull(_Form) Then _PropertyGet = _Form.AllowInserts
1362 Case UCase(&quot;AllowUpdates&quot;)
1363 If Not IsNull(_Form) Then _PropertyGet = _Form.AllowUpdates
1364 Case UCase(&quot;BaseForm&quot;)
1365 _PropertyGet = _FormDocumentName
1366 Case UCase(&quot;Bookmark&quot;)
1367 If IsNull(_Form) Then
1368 _PropertyGet = 0
1369 Else
1370 On Local Error Resume Next &apos; Disable error handler because bookmarking does not always react well in events ...
1371 If _Form.IsBookmarkable Then vBookmark = _Form.getBookmark() Else vBookmark = Nothing
1372 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error Goto Catch Else On Local Error Goto 0
1373 If IsNull(vBookmark) Then Goto Catch
1374 _PropertyGet = vBookmark
1375 End If
1376 Case UCase(&quot;CurrentRecord&quot;)
1377 If IsNull(_Form) Then _PropertyGet = 0 Else _PropertyGet = _Form.Row
1378 Case UCase(&quot;Filter&quot;)
1379 If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Filter
1380 Case UCase(&quot;LinkChildFields&quot;)
1381 If IsNull(_Form) Or _FormType &lt;&gt; ISSUBFORM Then _PropertyGet = Array() Else _PropertyGet = _Form.DetailFields
1382 Case UCase(&quot;LinkParentFields&quot;)
1383 If IsNull(_Form) Or _FormType &lt;&gt; ISSUBFORM Then _PropertyGet = Array() Else _PropertyGet = _Form.MasterFields
1384 Case UCase(&quot;Name&quot;)
1385 _PropertyGet = _Name
1386 Case UCase(&quot;OnApproveCursorMove&quot;), UCase(&quot;OnApproveParameter&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveRowChange&quot;) _
1387 , UCase(&quot;OnApproveSubmit&quot;), UCase(&quot;OnConfirmDelete&quot;), UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnErrorOccurred&quot;) _
1388 , UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnResetted&quot;), UCase(&quot;OnRowChanged&quot;) _
1389 , UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
1390 If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = SF_Register._GetEventScriptCode(_Form, psProperty, _Name)
1391 Case UCase(&quot;OrderBy&quot;)
1392 If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Order
1393 Case UCase(&quot;Parent&quot;)
1394 _PropertyGet = [_Parent]
1395 Case UCase(&quot;RecordSource&quot;)
1396 If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Command
1397 Case UCase(&quot;XForm&quot;)
1398 Set _PropertyGet = _Form
1399 Case Else
1400 _PropertyGet = Null
1401 End Select
1403 Finally:
1404 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1405 Exit Function
1406 Catch:
1407 GoTo Finally
1408 End Function &apos; SFDocuments.SF_Form._PropertyGet
1410 REM -----------------------------------------------------------------------------
1411 Private Function _PropertySet(Optional ByVal psProperty As String _
1412 , Optional ByVal pvValue As Variant _
1413 ) As Boolean
1414 &apos;&apos;&apos; Set the new value of the named property
1415 &apos;&apos;&apos; Args:
1416 &apos;&apos;&apos; psProperty: the name of the property
1417 &apos;&apos;&apos; pvValue: the new value of the given property
1418 &apos;&apos;&apos; Returns:
1419 &apos;&apos;&apos; True if successful
1421 Dim bSet As Boolean &apos; Return value
1422 Dim oDatabase As Object &apos; Database class instance
1423 Dim lCommandType As Long &apos; Record source type: 0 = Table, 1 = Query, 2 = SELECT
1424 Dim sCommand As String &apos; Record source
1425 Static oSession As Object &apos; Alias of SF_Session
1426 Dim cstThisSub As String
1427 Const cstSubArgs = &quot;Value&quot;
1429 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1430 bSet = False
1432 cstThisSub = &quot;SFDocuments.Form.set&quot; &amp; psProperty
1433 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
1434 If Not _IsStillAlive() Then GoTo Finally
1436 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
1437 bSet = True
1438 Select Case UCase(psProperty)
1439 Case UCase(&quot;AllowDeletes&quot;)
1440 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowDeletes&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1441 If Not IsNull(_Form) Then
1442 _Form.AllowDeletes = pvValue
1443 _Form.reload()
1444 End If
1445 Case UCase(&quot;AllowInserts&quot;)
1446 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowInserts&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1447 If Not IsNull(_Form) Then
1448 _Form.AllowInserts = pvValue
1449 _Form.reload()
1450 End If
1451 Case UCase(&quot;AllowUpdates&quot;)
1452 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowUpdates&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1453 If Not IsNull(_Form) Then
1454 _Form.AllowUpdates = pvValue
1455 _Form.reload()
1456 End If
1457 Case UCase(&quot;Bookmark&quot;)
1458 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Bookmark&quot;, Array(ScriptForge.V_NUMERIC, ScriptForge.V_OBJECT)) Then GoTo Finally
1459 If Not IsNull(pvValue) And Not IsNull(_Form) Then bSet = _Form.moveToBookmark(pvValue)
1460 Case UCase(&quot;CurrentRecord&quot;)
1461 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;CurrentRecord&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
1462 If Not IsNull(_Form) Then bSet = _Form.absolute(pvValue)
1463 Case UCase(&quot;Filter&quot;)
1464 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Filter&quot;, V_STRING) Then GoTo Finally
1465 If Not IsNull(_Form) Then
1466 With _Form
1467 If Len(pvValue) &gt; 0 Then
1468 Set oDatabase = GetDatabase()
1469 If Not IsNull(oDatabase) Then .Filter = oDatabase._ReplaceSquareBrackets(pvValue) Else .Filter = pvValue
1470 Else
1471 .Filter = &quot;&quot;
1472 End If
1473 .ApplyFilter = True
1474 .reload()
1475 End With
1476 End If
1477 Case UCase(&quot;OnApproveCursorMove&quot;), UCase(&quot;OnApproveParameter&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveRowChange&quot;) _
1478 , UCase(&quot;OnApproveSubmit&quot;), UCase(&quot;OnConfirmDelete&quot;), UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnErrorOccurred&quot;) _
1479 , UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnResetted&quot;), UCase(&quot;OnRowChanged&quot;) _
1480 , UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
1481 If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then Goto Finally
1482 If Not IsNull(_Form) Then
1483 bSet = SF_Register._RegisterEventScript(_Form _
1484 , psProperty _
1485 , _GetListener(psProperty) _
1486 , pvValue _
1487 , _Name _
1489 End If
1490 Case UCase(&quot;OrderBy&quot;)
1491 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;OrderBy&quot;, V_STRING) Then GoTo Finally
1492 If Not IsNull(_Form) Then
1493 With _Form
1494 If Len(pvValue) &gt; 0 Then
1495 Set oDatabase = GetDatabase()
1496 If Not IsNull(oDatabase) Then .Order = oDatabase._ReplaceSquareBrackets(pvValue) Else .Order = pvValue
1497 Else
1498 .Order = &quot;&quot;
1499 End If
1500 .reload()
1501 End With
1502 End If
1503 Case UCase(&quot;RecordSource&quot;)
1504 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;RecordSource&quot;, V_STRING) Then GoTo Finally
1505 If Not IsNull(_Form) And Len(pvValue) &gt; 0 Then
1506 Set oDatabase = GetDatabase()
1507 If Not IsNull(oDatabase) Then
1508 With oDatabase
1509 If ScriptForge.SF_Array.Contains(.Tables, pvValue, CaseSensitive := True) Then
1510 sCommand = pvValue
1511 lCommandType = com.sun.star.sdb.CommandType.TABLE
1512 ElseIf ScriptForge.SF_Array.Contains(.Queries, pvValue, CaseSensitive := True) Then
1513 sCommand = pvValue
1514 lCommandType = com.sun.star.sdb.CommandType.QUERY
1515 ElseIf ScriptForge.SF_String.StartsWith(pvValue, &quot;SELECT&quot;, CaseSensitive := False) Then
1516 sCommand = .ReplaceSquareBrackets(pvValue)
1517 lCommandType = com.sun.star.sdb.CommandType.COMMAND
1518 End If
1519 _Form.Command = sCommand
1520 _Form.CommandType = lCommandType
1521 End With
1522 End If
1523 End If
1524 Case Else
1525 bSet = False
1526 End Select
1528 Finally:
1529 _PropertySet = bSet
1530 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1531 Exit Function
1532 Catch:
1533 GoTo Finally
1534 End Function &apos; SFDocuments.SF_Form._PropertySet
1536 REM -----------------------------------------------------------------------------
1537 Private Function _Repr() As String
1538 &apos;&apos;&apos; Convert the Model instance to a readable string, typically for debugging purposes (DebugPrint ...)
1539 &apos;&apos;&apos; Args:
1540 &apos;&apos;&apos; Return:
1541 &apos;&apos;&apos; &quot;[Form]: Name&quot;
1543 Dim sParent As String &apos; To recognize the parent
1545 sParent = _SheetName &amp; _FormDocumentName &apos; At least one of them is a zero-length string
1546 _Repr = &quot;[Form]: &quot; &amp; Iif(Len(sParent) &gt; 0, sParent &amp; &quot;...&quot;, &quot;&quot;) &amp; _Name
1548 End Function &apos; SFDocuments.SF_Form._Repr
1550 REM ============================================ END OF SFDOCUMENTS.SF_FORM
1551 </script:module>