calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / wizards / source / sfdocuments / SF_Form.xba
blob2879536efb6f88f22b4c85a2b239864766f96112
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:
27 &apos;&apos;&apos; For usual documents, there is only 1 form document. It is in fact the document itself.
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 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 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 not-Base document (Calc, Writer)
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 one of the FormDocuments of a Base document
54 &apos;&apos;&apos; Dim oDoc As Object, myForm As Object, mySubForm As Object
55 &apos;&apos;&apos; Set oDoc = CreateScriptService(&quot;SFDocuments.Document&quot;, ThisDatabaseDocument)
56 &apos;&apos;&apos; oDoc.OpenFormDocument(&quot;thisFormDocument&quot;)
57 &apos;&apos;&apos; Set myForm = oDoc.Forms(&quot;thisFormDocument&quot;, &quot;MainForm&quot;)
58 &apos;&apos;&apos; &apos; or, alternatively, when there is only 1 form
59 &apos;&apos;&apos; Set myForm = oDoc.Forms(&quot;thisFormDocument&quot;, 0)
60 &apos;&apos;&apos; &apos; To access a subform: myForm and mySubForm become distinct instances of the current class
61 &apos;&apos;&apos; Set mySubForm = myForm.SubForms(&quot;mySubForm&quot;)
62 &apos;&apos;&apos;
63 &apos;&apos;&apos; REM the form is the subject of an event
64 &apos;&apos;&apos; Sub OnEvent(ByRef poEvent As Object)
65 &apos;&apos;&apos; Dim myForm As Object
66 &apos;&apos;&apos; Set myForm = CreateScriptService(&quot;SFDocuments.FormEvent&quot;, poEvent)
67 &apos;&apos;&apos;
68 &apos;&apos;&apos; Detailed user documentation:
69 &apos;&apos;&apos; https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03/sf_form.html?DbPAR=BASIC
70 &apos;&apos;&apos;
71 &apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;&apos;
73 REM ================================================================== EXCEPTIONS
75 Private Const FORMDEADERROR = &quot;FORMDEADERROR&quot;
76 Private Const SUBFORMNOTFOUNDERROR = &quot;SUBFORMNOTFOUNDERROR&quot;
78 REM ============================================================= PRIVATE MEMBERS
80 Private [Me] As Object
81 Private [_Parent] As Object
82 Private ObjectType As String &apos; Must be Form
83 Private ServiceName As String
85 &apos; Form location
86 Private _Name As String &apos; Internal name of the form
87 Private _FormType As Integer &apos; One of the ISxxxFORM constants
88 Private _SheetName As String &apos; Name as the sheet containing the form (Calc only)
89 Private _FormDocumentName As String &apos; The hierarchical name of the containing form document (Base only)
90 Private _FormDocument As Object &apos; com.sun.star.comp.sdb.Content - the containing form document
91 &apos; The form topmost container
92 Private _Component As Object &apos; com.sun.star.lang.XComponent or com.sun.star.comp.dba.ODatabaseDocument
94 &apos; Events management
95 Private _CacheIndex As Long &apos; Index in central cache storage
97 &apos; Form UNO references
98 &apos; The entry to the interactions with the form. Validity checked by the _IsStillAlive() method
99 &apos; Each method or property requiring that the form is opened should first invoke that method
100 Private _Form As Object &apos; com.sun.star.form.XForm or com.sun.star.comp.forms.ODatabaseForm
101 Private _Database As Object &apos; Database class instance
103 &apos; Form attributes
105 &apos; Cache storage for controls
106 Private _ControlNames As Variant &apos; Array of control names
107 Private _ControlCache As Variant &apos; Array of control objects sorted like ElementNames of XForm
109 REM ============================================================ MODULE CONSTANTS
111 Const ISDOCFORM = 1 &apos; Form is stored in a Writer document
112 Const ISCALCFORM = 2 &apos; Form is stored in a Calc document
113 Const ISBASEFORM = 3 &apos; Form is stored in a Base document
114 Const ISSUBFORM = 4 &apos; Form is a subform of a form or of another subform
115 Const ISUNDEFINED = -1 &apos; Undefined form type
117 REM ====================================================== CONSTRUCTOR/DESTRUCTOR
119 REM -----------------------------------------------------------------------------
120 Private Sub Class_Initialize()
121 Set [Me] = Nothing
122 Set [_Parent] = Nothing
123 ObjectType = &quot;FORM&quot;
124 ServiceName = &quot;SFDocuments.Form&quot;
125 _Name = &quot;&quot;
126 _SheetName = &quot;&quot;
127 _FormDocumentName = &quot;&quot;
128 Set _FormDocument = Nothing
129 _FormType = ISUNDEFINED
130 _CacheIndex = -1
131 Set _Form = Nothing
132 Set _Database = Nothing
133 _ControlNames = Array()
134 _ControlCache = Array()
135 End Sub &apos; SFDocuments.SF_Form Constructor
137 REM -----------------------------------------------------------------------------
138 Private Sub Class_Terminate()
139 Call Class_Initialize()
140 End Sub &apos; SFDocuments.SF_Form Destructor
142 REM -----------------------------------------------------------------------------
143 Public Function Dispose() As Variant
144 If Not IsNull(_Database) And (_FormType = ISDOCFORM Or _FormType = ISCALCFORM) Then
145 Set _Database = _Database.Dispose()
146 End If
147 SF_Register._CleanCacheEntry(_CacheIndex)
148 Call Class_Terminate()
149 Set Dispose = Nothing
150 End Function &apos; SFDocuments.SF_Form Explicit Destructor
152 REM ================================================================== PROPERTIES
154 REM -----------------------------------------------------------------------------
155 Property Get AllowDeletes() As Variant
156 &apos;&apos;&apos; The AllowDeletes property specifies if the form allows to delete records
157 AllowDeletes = _PropertyGet(&quot;AllowDeletes&quot;)
158 End Property &apos; SFDocuments.SF_Form.AllowDeletes (get)
160 REM -----------------------------------------------------------------------------
161 Property Let AllowDeletes(Optional ByVal pvAllowDeletes As Variant)
162 &apos;&apos;&apos; Set the updatable property AllowDeletes
163 _PropertySet(&quot;AllowDeletes&quot;, pvAllowDeletes)
164 End Property &apos; SFDocuments.SF_Form.AllowDeletes (let)
166 REM -----------------------------------------------------------------------------
167 Property Get AllowInserts() As Variant
168 &apos;&apos;&apos; The AllowInserts property specifies if the form allows to add records
169 AllowInserts = _PropertyGet(&quot;AllowInserts&quot;)
170 End Property &apos; SFDocuments.SF_Form.AllowInserts (get)
172 REM -----------------------------------------------------------------------------
173 Property Let AllowInserts(Optional ByVal pvAllowInserts As Variant)
174 &apos;&apos;&apos; Set the updatable property AllowInserts
175 _PropertySet(&quot;AllowInserts&quot;, pvAllowInserts)
176 End Property &apos; SFDocuments.SF_Form.AllowInserts (let)
178 REM -----------------------------------------------------------------------------
179 Property Get AllowUpdates() As Variant
180 &apos;&apos;&apos; The AllowUpdates property specifies if the form allows to update records
181 AllowUpdates = _PropertyGet(&quot;AllowUpdates&quot;)
182 End Property &apos; SFDocuments.SF_Form.AllowUpdates (get)
184 REM -----------------------------------------------------------------------------
185 Property Let AllowUpdates(Optional ByVal pvAllowUpdates As Variant)
186 &apos;&apos;&apos; Set the updatable property AllowUpdates
187 _PropertySet(&quot;AllowUpdates&quot;, pvAllowUpdates)
188 End Property &apos; SFDocuments.SF_Form.AllowUpdates (let)
190 REM -----------------------------------------------------------------------------
191 Property Get BaseForm() As String
192 &apos;&apos;&apos; The BaseForm property specifies the hierarchical name of the Base form containing the actual form
193 BaseForm = _PropertyGet(&quot;BaseForm&quot;)
194 End Property &apos; SFDocuments.SF_Form.BaseForm (get)
196 REM -----------------------------------------------------------------------------
197 Property Get Bookmark() As Variant
198 &apos;&apos;&apos; The Bookmark property specifies uniquely the current record of the form&apos;s underlying table, query or SQL statement.
199 Bookmark = _PropertyGet(&quot;Bookmark&quot;)
200 End Property &apos; SFDocuments.SF_Form.Bookmark (get)
202 REM -----------------------------------------------------------------------------
203 Property Let Bookmark(Optional ByVal pvBookmark As Variant)
204 &apos;&apos;&apos; Set the updatable property Bookmark
205 _PropertySet(&quot;Bookmark&quot;, pvBookmark)
206 End Property &apos; SFDocuments.SF_Form.Bookmark (let)
208 REM -----------------------------------------------------------------------------
209 Property Get CurrentRecord() As Variant
210 &apos;&apos;&apos; The CurrentRecord property identifies the current record in the recordset being viewed on a form
211 CurrentRecord = _PropertyGet(&quot;CurrentRecord&quot;)
212 End Property &apos; SFDocuments.SF_Form.CurrentRecord (get)
214 REM -----------------------------------------------------------------------------
215 Property Let CurrentRecord(Optional ByVal pvCurrentRecord As Variant)
216 &apos;&apos;&apos; Set the updatable property CurrentRecord
217 &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.
218 &apos;&apos;&apos; The first row is row 1, the second is row 2, and so on.
219 &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.
220 &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
221 _PropertySet(&quot;CurrentRecord&quot;, pvCurrentRecord)
222 End Property &apos; SFDocuments.SF_Form.CurrentRecord (let)
224 REM -----------------------------------------------------------------------------
225 Property Get Filter() As Variant
226 &apos;&apos;&apos; The Filter property specifies a subset of records to be displayed.
227 Filter = _PropertyGet(&quot;Filter&quot;)
228 End Property &apos; SFDocuments.SF_Form.Filter (get)
230 REM -----------------------------------------------------------------------------
231 Property Let Filter(Optional ByVal pvFilter As Variant)
232 &apos;&apos;&apos; Set the updatable property Filter
233 _PropertySet(&quot;Filter&quot;, pvFilter)
234 End Property &apos; SFDocuments.SF_Form.Filter (let)
236 REM -----------------------------------------------------------------------------
237 Property Get LinkChildFields() As Variant
238 &apos;&apos;&apos; The LinkChildFields property specifies how records in a subform (child) are linked to records in its parent form
239 &apos;&apos;&apos; It returns an array of strings
240 LinkChildFields = _PropertyGet(&quot;LinkChildFields&quot;)
241 End Property &apos; SFDocuments.SF_Form.LinkChildFields (get)
243 REM -----------------------------------------------------------------------------
244 Property Get LinkParentFields() As Variant
245 &apos;&apos;&apos; The LinkParentFields property specifies how records in a subform (Child) are linked to records in its parent form
246 &apos;&apos;&apos; It returns an array of strings
247 LinkParentFields = _PropertyGet(&quot;LinkParentFields&quot;)
248 End Property &apos; SFDocuments.SF_Form.LinkParentFields (get)
250 REM -----------------------------------------------------------------------------
251 Property Get Name() As String
252 &apos;&apos;&apos; Return the name of the actual Form
253 Name = _PropertyGet(&quot;Name&quot;)
254 End Property &apos; SFDocuments.SF_Form.Name
256 REM -----------------------------------------------------------------------------
257 Property Get OnApproveCursorMove() As Variant
258 &apos;&apos;&apos; The OnApproveCursorMove property specifies the script to trigger when this event occurs
259 OnApproveCursorMove = _PropertyGet(&quot;OnApproveCursorMove&quot;)
260 End Property &apos; SFDocuments.SF_Form.OnApproveCursorMove (get)
262 REM -----------------------------------------------------------------------------
263 Property Let OnApproveCursorMove(Optional ByVal pvOnApproveCursorMove As Variant)
264 &apos;&apos;&apos; Set the updatable property OnApproveCursorMove
265 _PropertySet(&quot;OnApproveCursorMove&quot;, pvOnApproveCursorMove)
266 End Property &apos; SFDocuments.SF_Form.OnApproveCursorMove (let)
268 REM -----------------------------------------------------------------------------
269 Property Get OnApproveReset() As Variant
270 &apos;&apos;&apos; The OnApproveReset property specifies the script to trigger when this event occurs
271 OnApproveReset = _PropertyGet(&quot;OnApproveReset&quot;)
272 End Property &apos; SFDocuments.SF_Form.OnApproveReset (get)
274 REM -----------------------------------------------------------------------------
275 Property Let OnApproveReset(Optional ByVal pvOnApproveReset As Variant)
276 &apos;&apos;&apos; Set the updatable property OnApproveReset
277 _PropertySet(&quot;OnApproveReset&quot;, pvOnApproveReset)
278 End Property &apos; SFDocuments.SF_Form.OnApproveReset (let)
280 REM -----------------------------------------------------------------------------
281 Property Get OnApproveRowChange() As Variant
282 &apos;&apos;&apos; The OnApproveRowChange property specifies the script to trigger when this event occurs
283 OnApproveRowChange = _PropertyGet(&quot;OnApproveRowChange&quot;)
284 End Property &apos; SFDocuments.SF_Form.OnApproveRowChange (get)
286 REM -----------------------------------------------------------------------------
287 Property Let OnApproveRowChange(Optional ByVal pvOnApproveRowChange As Variant)
288 &apos;&apos;&apos; Set the updatable property OnApproveRowChange
289 _PropertySet(&quot;OnApproveRowChange&quot;, pvOnApproveRowChange)
290 End Property &apos; SFDocuments.SF_Form.OnApproveRowChange (let)
292 REM -----------------------------------------------------------------------------
293 Property Get OnApproveSubmit() As Variant
294 &apos;&apos;&apos; The OnApproveSubmit property specifies the script to trigger when this event occurs
295 OnApproveSubmit = _PropertyGet(&quot;OnApproveSubmit&quot;)
296 End Property &apos; SFDocuments.SF_Form.OnApproveSubmit (get)
298 REM -----------------------------------------------------------------------------
299 Property Let OnApproveSubmit(Optional ByVal pvOnApproveSubmit As Variant)
300 &apos;&apos;&apos; Set the updatable property OnApproveSubmit
301 _PropertySet(&quot;OnApproveSubmit&quot;, pvOnApproveSubmit)
302 End Property &apos; SFDocuments.SF_Form.OnApproveSubmit (let)
304 REM -----------------------------------------------------------------------------
305 Property Get OnConfirmDelete() As Variant
306 &apos;&apos;&apos; The OnConfirmDelete property specifies the script to trigger when this event occurs
307 OnConfirmDelete = _PropertyGet(&quot;OnConfirmDelete&quot;)
308 End Property &apos; SFDocuments.SF_Form.OnConfirmDelete (get)
310 REM -----------------------------------------------------------------------------
311 Property Let OnConfirmDelete(Optional ByVal pvOnConfirmDelete As Variant)
312 &apos;&apos;&apos; Set the updatable property OnConfirmDelete
313 _PropertySet(&quot;OnConfirmDelete&quot;, pvOnConfirmDelete)
314 End Property &apos; SFDocuments.SF_Form.OnConfirmDelete (let)
316 REM -----------------------------------------------------------------------------
317 Property Get OnCursorMoved() As Variant
318 &apos;&apos;&apos; The OnCursorMoved property specifies the script to trigger when this event occurs
319 OnCursorMoved = _PropertyGet(&quot;OnCursorMoved&quot;)
320 End Property &apos; SFDocuments.SF_Form.OnCursorMoved (get)
322 REM -----------------------------------------------------------------------------
323 Property Let OnCursorMoved(Optional ByVal pvOnCursorMoved As Variant)
324 &apos;&apos;&apos; Set the updatable property OnCursorMoved
325 _PropertySet(&quot;OnCursorMoved&quot;, pvOnCursorMoved)
326 End Property &apos; SFDocuments.SF_Form.OnCursorMoved (let)
328 REM -----------------------------------------------------------------------------
329 Property Get OnErrorOccurred() As Variant
330 &apos;&apos;&apos; The OnErrorOccurred property specifies the script to trigger when this event occurs
331 OnErrorOccurred = _PropertyGet(&quot;OnErrorOccurred&quot;)
332 End Property &apos; SFDocuments.SF_Form.OnErrorOccurred (get)
334 REM -----------------------------------------------------------------------------
335 Property Let OnErrorOccurred(Optional ByVal pvOnErrorOccurred As Variant)
336 &apos;&apos;&apos; Set the updatable property OnErrorOccurred
337 _PropertySet(&quot;OnErrorOccurred&quot;, pvOnErrorOccurred)
338 End Property &apos; SFDocuments.SF_Form.OnErrorOccurred (let)
340 REM -----------------------------------------------------------------------------
341 Property Get OnLoaded() As Variant
342 &apos;&apos;&apos; The OnLoaded property specifies the script to trigger when this event occurs
343 OnLoaded = _PropertyGet(&quot;OnLoaded&quot;)
344 End Property &apos; SFDocuments.SF_Form.OnLoaded (get)
346 REM -----------------------------------------------------------------------------
347 Property Let OnLoaded(Optional ByVal pvOnLoaded As Variant)
348 &apos;&apos;&apos; Set the updatable property OnLoaded
349 _PropertySet(&quot;OnLoaded&quot;, pvOnLoaded)
350 End Property &apos; SFDocuments.SF_Form.OnLoaded (let)
352 REM -----------------------------------------------------------------------------
353 Property Get OnReloaded() As Variant
354 &apos;&apos;&apos; The OnReloaded property specifies the script to trigger when this event occurs
355 OnReloaded = _PropertyGet(&quot;OnReloaded&quot;)
356 End Property &apos; SFDocuments.SF_Form.OnReloaded (get)
358 REM -----------------------------------------------------------------------------
359 Property Let OnReloaded(Optional ByVal pvOnReloaded As Variant)
360 &apos;&apos;&apos; Set the updatable property OnReloaded
361 _PropertySet(&quot;OnReloaded&quot;, pvOnReloaded)
362 End Property &apos; SFDocuments.SF_Form.OnReloaded (let)
364 REM -----------------------------------------------------------------------------
365 Property Get OnReloading() As Variant
366 &apos;&apos;&apos; The OnReloading property specifies the script to trigger when this event occurs
367 OnReloading = _PropertyGet(&quot;OnReloading&quot;)
368 End Property &apos; SFDocuments.SF_Form.OnReloading (get)
370 REM -----------------------------------------------------------------------------
371 Property Let OnReloading(Optional ByVal pvOnReloading As Variant)
372 &apos;&apos;&apos; Set the updatable property OnReloading
373 _PropertySet(&quot;OnReloading&quot;, pvOnReloading)
374 End Property &apos; SFDocuments.SF_Form.OnReloading (let)
376 REM -----------------------------------------------------------------------------
377 Property Get OnResetted() As Variant
378 &apos;&apos;&apos; The OnResetted property specifies the script to trigger when this event occurs
379 OnResetted = _PropertyGet(&quot;OnResetted&quot;)
380 End Property &apos; SFDocuments.SF_Form.OnResetted (get)
382 REM -----------------------------------------------------------------------------
383 Property Let OnResetted(Optional ByVal pvOnResetted As Variant)
384 &apos;&apos;&apos; Set the updatable property OnResetted
385 _PropertySet(&quot;OnResetted&quot;, pvOnResetted)
386 End Property &apos; SFDocuments.SF_Form.OnResetted (let)
388 REM -----------------------------------------------------------------------------
389 Property Get OnRowChanged() As Variant
390 &apos;&apos;&apos; The OnRowChanged property specifies the script to trigger when this event occurs
391 OnRowChanged = _PropertyGet(&quot;OnRowChanged&quot;)
392 End Property &apos; SFDocuments.SF_Form.OnRowChanged (get)
394 REM -----------------------------------------------------------------------------
395 Property Let OnRowChanged(Optional ByVal pvOnRowChanged As Variant)
396 &apos;&apos;&apos; Set the updatable property OnRowChanged
397 _PropertySet(&quot;OnRowChanged&quot;, pvOnRowChanged)
398 End Property &apos; SFDocuments.SF_Form.OnRowChanged (let)
400 REM -----------------------------------------------------------------------------
401 Property Get OnUnloaded() As Variant
402 &apos;&apos;&apos; The OnUnloaded property specifies the script to trigger when this event occurs
403 OnUnloaded = _PropertyGet(&quot;OnUnloaded&quot;)
404 End Property &apos; SFDocuments.SF_Form.OnUnloaded (get)
406 REM -----------------------------------------------------------------------------
407 Property Let OnUnloaded(Optional ByVal pvOnUnloaded As Variant)
408 &apos;&apos;&apos; Set the updatable property OnUnloaded
409 _PropertySet(&quot;OnUnloaded&quot;, pvOnUnloaded)
410 End Property &apos; SFDocuments.SF_Form.OnUnloaded (let)
412 REM -----------------------------------------------------------------------------
413 Property Get OnUnloading() As Variant
414 &apos;&apos;&apos; The OnUnloading property specifies the script to trigger when this event occurs
415 OnUnloading = _PropertyGet(&quot;OnUnloading&quot;)
416 End Property &apos; SFDocuments.SF_Form.OnUnloading (get)
418 REM -----------------------------------------------------------------------------
419 Property Let OnUnloading(Optional ByVal pvOnUnloading As Variant)
420 &apos;&apos;&apos; Set the updatable property OnUnloading
421 _PropertySet(&quot;OnUnloading&quot;, pvOnUnloading)
422 End Property &apos; SFDocuments.SF_Form.OnUnloading (let)
424 REM -----------------------------------------------------------------------------
425 Property Get OrderBy() As Variant
426 &apos;&apos;&apos; The OrderBy property specifies in which order the records should be displayed.
427 OrderBy = _PropertyGet(&quot;OrderBy&quot;)
428 End Property &apos; SFDocuments.SF_Form.OrderBy (get)
430 REM -----------------------------------------------------------------------------
431 Property Let OrderBy(Optional ByVal pvOrderBy As Variant)
432 &apos;&apos;&apos; Set the updatable property OrderBy
433 _PropertySet(&quot;OrderBy&quot;, pvOrderBy)
434 End Property &apos; SFDocuments.SF_Form.OrderBy (let)
436 REM -----------------------------------------------------------------------------
437 Property Get Parent() As Object
438 &apos;&apos;&apos; Return the Parent of the actual Form
439 Parent = _PropertyGet(&quot;Parent&quot;)
440 End Property &apos; SFDocuments.SF_Form.Parent
442 REM -----------------------------------------------------------------------------
443 Property Get RecordSource() As Variant
444 &apos;&apos;&apos; The RecordSource property specifies the source of the data,
445 &apos;&apos;&apos; a table name, a query name or a SQL statement
446 RecordSource = _PropertyGet(&quot;RecordSource&quot;)
447 End Property &apos; SFDocuments.SF_Form.RecordSource (get)
449 REM -----------------------------------------------------------------------------
450 Property Let RecordSource(Optional ByVal pvRecordSource As Variant)
451 &apos;&apos;&apos; Set the updatable property RecordSource
452 _PropertySet(&quot;RecordSource&quot;, pvRecordSource)
453 End Property &apos; SFDocuments.SF_Form.RecordSource (let)
455 REM -----------------------------------------------------------------------------
456 Property Get XForm() As Object
457 &apos;&apos;&apos; The XForm property returns the XForm UNO object of the Form
458 XForm = _PropertyGet(&quot;XForm&quot;)
459 End Property &apos; SFDocuments.SF_Form.XForm (get)
461 REM ===================================================================== METHODS
463 REM -----------------------------------------------------------------------------
464 Public Function Activate() As Boolean
465 &apos;&apos;&apos; Set the focus on the current Form instance
466 &apos;&apos;&apos; Probably called from after an event occurrence or to focus on an open Base form document
467 &apos;&apos;&apos; If the parent document is ...
468 &apos;&apos;&apos; Calc Activate the corresponding sheet
469 &apos;&apos;&apos; Writer Activate the parent document
470 &apos;&apos;&apos; Base Activate the parent form document
471 &apos;&apos;&apos; Args:
472 &apos;&apos;&apos; Returns:
473 &apos;&apos;&apos; True if focusing is successful
474 &apos;&apos;&apos; Example:
475 &apos;&apos;&apos; myForm.Activate()
477 Dim bActivate As Boolean &apos; Return value
478 Dim oContainer As Object &apos; com.sun.star.awt.XWindow
479 Const cstThisSub = &quot;SFDocuments.Form.Activate&quot;
480 Const cstSubArgs = &quot;&quot;
482 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
483 bActivate = False
485 Check:
486 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
487 If Not _IsStillAlive() Then GoTo Finally
488 End If
489 Try:
490 Select Case _FormType
491 Case ISDOCFORM : bActivate = [_Parent].Activate()
492 Case ISCALCFORM : bActivate = [_Parent].Activate(_SheetName)
493 Case ISBASEFORM
494 Set oContainer = _FormDocument.Component.CurrentController.Frame.ContainerWindow
495 With oContainer
496 If .isVisible() = False Then .setVisible(True)
497 .IsMinimized = False
498 .setFocus()
499 .toFront() &apos; Force window change in Linux
500 Wait 1 &apos; Bypass desynchro issue in Linux
501 End With
502 bActivate = True
503 End Select
505 Finally:
506 Activate = bActivate
507 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
508 Exit Function
509 Catch:
510 GoTo Finally
511 End Function &apos; SFDocuments.SF_Form.Activate
513 REM -----------------------------------------------------------------------------
514 Public Function CloseFormDocument() As Boolean
515 &apos;&apos;&apos; Close the form document containing the actual form instance
516 &apos;&apos;&apos; The form instance is disposed
517 &apos;&apos;&apos; The method does nothing if the actual form is not located in a Base form document
518 &apos;&apos;&apos; Args:
519 &apos;&apos;&apos; Returns:
520 &apos;&apos;&apos; True if closure is successful
521 &apos;&apos;&apos; Example:
522 &apos;&apos;&apos; myForm.CloseFormDocument()
524 Dim bClose As Boolean &apos; Return value
525 Dim oContainer As Object &apos; com.sun.star.awt.XWindow
526 Const cstThisSub = &quot;SFDocuments.Form.CloseFormDocument&quot;
527 Const cstSubArgs = &quot;&quot;
529 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
530 bClose = False
532 Check:
533 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
534 If Not _IsStillAlive() Then GoTo Finally
535 End If
536 Try:
537 Select Case _FormType
538 Case ISDOCFORM, ISCALCFORM, ISSUBFORM
539 Case ISBASEFORM
540 _FormDocument.close()
541 Dispose()
542 bClose = True
543 End Select
545 Finally:
546 CloseFormDocument = bClose
547 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
548 Exit Function
549 Catch:
550 GoTo Finally
551 End Function &apos; SFDocuments.SF_Form.CloseFormDocument
553 REM -----------------------------------------------------------------------------
554 Public Function Controls(Optional ByVal ControlName As Variant) As Variant
555 &apos;&apos;&apos; Return either
556 &apos;&apos;&apos; - the list of the controls contained in the Form
557 &apos;&apos;&apos; - a Form control object based on its name
558 &apos;&apos;&apos; Args:
559 &apos;&apos;&apos; ControlName: a valid control name as a case-sensitive string. If absent the list is returned
560 &apos;&apos;&apos; Returns:
561 &apos;&apos;&apos; A zero-base array of strings if ControlName is absent
562 &apos;&apos;&apos; An instance of the SF_FormControl class if ControlName exists
563 &apos;&apos;&apos; Exceptions:
564 &apos;&apos;&apos; ControlName is invalid
565 &apos;&apos;&apos; Example:
566 &apos;&apos;&apos; Dim myForm As Object, myList As Variant, myControl As Object
567 &apos;&apos;&apos; Set myForm = myDoc.Forms(&quot;myForm&quot;)
568 &apos;&apos;&apos; myList = myForm.Controls()
569 &apos;&apos;&apos; Set myControl = myForm.Controls(&quot;myTextBox&quot;)
571 Dim oControl As Object &apos; The new control class instance
572 Dim lIndexOfNames As Long &apos; Index in ElementNames array. Used to access _ControlCache
573 Dim vControl As Variant &apos; Alias of _ControlCache entry
574 Dim i As Long
575 Const cstThisSub = &quot;SFDocuments.Form.Controls&quot;
576 Const cstSubArgs = &quot;[ControlName]&quot;
578 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
580 Check:
581 If IsMissing(ControlName) Or IsEmpty(ControlName) Then ControlName = &quot;&quot;
582 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
583 If Not _IsStillAlive() Then GoTo Finally
584 If Not ScriptForge.SF_Utils._Validate(ControlName, &quot;ControlName&quot;, V_STRING) Then GoTo Finally
585 End If
587 Try:
588 &apos; Collect all control names if not yet done
589 If UBound(_ControlNames) &lt; 0 Then
590 _ControlNames = _Form.getElementNames()
591 &apos; Remove all subforms from the list
592 For i = 0 To UBound(_ControlNames)
593 &apos; Subforms have no ClassId property
594 If Not ScriptForge.SF_Session.HasUnoProperty(_Form.getByName(_ControlNames(i)), &quot;ClassId&quot;) Then _ControlNames(i) = &quot;&quot;
595 Next i
596 _ControlNames = ScriptForge.SF_Array.TrimArray(_ControlNames)
597 &apos; Size the cache accordingly
598 If UBound(_ControlNames) &gt;= 0 Then
599 ReDim _ControlCache(0 To UBound(_ControlNames))
600 End If
601 End If
603 &apos; Return the list of controls or a FormControl instance
604 If Len(ControlName) = 0 Then
605 Controls = _ControlNames
607 Else
609 If Not _Form.hasByName(ControlName) Then GoTo CatchNotFound
610 lIndexOfNames = ScriptForge.SF_Array.IndexOf(_ControlNames, ControlName, CaseSensitive := True)
611 &apos; Reuse cache when relevant
612 vControl = _ControlCache(lIndexOfNames)
614 If IsEmpty(vControl) Then
615 &apos; Create the new form control class instance
616 Set oControl = New SF_FormControl
617 With oControl
618 ._Name = ControlName
619 Set .[Me] = oControl
620 Set .[_Parent] = [Me]
621 Set ._ParentForm = [Me]
622 ._IndexOfNames = lIndexOfNames
623 ._FormName = _Name
624 &apos; Get model and view of the current control
625 Set ._ControlModel = _Form.getByName(ControlName)
626 ._Initialize()
627 End With
628 Else
629 Set oControl = vControl
630 End If
632 Set Controls = oControl
633 End If
635 Finally:
636 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
637 Exit Function
638 Catch:
639 GoTo Finally
640 CatchNotFound:
641 ScriptForge.SF_Utils._Validate(ControlName, &quot;ControlName&quot;, V_STRING, _Form.getElementNames())
642 GoTo Finally
643 End Function &apos; SFDocuments.SF_Form.Controls
645 REM -----------------------------------------------------------------------------
646 Public Function GetDatabase(Optional ByVal User As Variant _
647 , Optional ByVal Password As Variant _
648 ) As Object
649 &apos;&apos;&apos; Returns a Database instance (service = SFDatabases.Database) giving access
650 &apos;&apos;&apos; to the execution of SQL commands on the database defined and/or stored in
651 &apos;&apos;&apos; the actual Base document
652 &apos;&apos;&apos; Each main form has its own database connection, except within Base documents where
653 &apos;&apos;&apos; they all share the same connection
654 &apos;&apos;&apos; Args:
655 &apos;&apos;&apos; User, Password: the login parameters as strings. Defaults = &quot;&quot;
656 &apos;&apos;&apos; Returns:
657 &apos;&apos;&apos; A SFDatabases.Database instance or Nothing
658 &apos;&apos;&apos; Example:
659 &apos;&apos;&apos; Dim myDb As Object
660 &apos;&apos;&apos; Set myDb = oForm.GetDatabase()
662 Dim FSO As Object &apos; Alias for SF_FileSystem
663 Dim sDataSource As String &apos; Database file name in FileNaming format
664 Dim sUser As String &apos; Alias for User
665 Dim sPassword As String &apos; Alias for Password
666 Const cstThisSub = &quot;SFDocuments.Form.GetDatabase&quot;
667 Const cstSubArgs = &quot;[User=&quot;&quot;&quot;&quot;], [Password=&quot;&quot;&quot;&quot;]&quot;
669 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
670 Set GetDatabase = Nothing
672 Check:
673 If IsMissing(User) Or IsEmpty(User) Then User = &quot;&quot;
674 If IsMissing(Password) Or IsEmpty(Password) Then Password = &quot;&quot;
675 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
676 If Not [_Parent]._IsStillAlive(True) Then GoTo Finally
677 If Not ScriptForge.SF_Utils._Validate(User, &quot;User&quot;, V_STRING) Then GoTo Finally
678 If Not ScriptForge.SF_Utils._Validate(Password, &quot;Password&quot;, V_STRING) Then GoTo Finally
679 End If
681 Try:
682 &apos; Adjust connection arguments
683 If Len(User) = 0 Then
684 If ScriptForge.SF_Session.HasUnoProperty(_Form, &quot;User&quot;) Then sUser = _Form.User Else sUser = &quot;&quot;
685 Else
686 sUser = User
687 End If
688 If Len(sUser) + Len(Password) = 0 Then
689 If ScriptForge.SF_Session.HasUnoProperty(_Form, &quot;Password&quot;) Then sPassword = _Form.Password Else sPassword = Password
690 End If
692 &apos; Connect to database, avoiding multiple requests
693 If IsNull(_Database) Then &apos; 1st connection request from the current form instance
694 If _FormType = ISBASEFORM Then
695 &apos; Fetch the shared connection
696 Set _Database = [_Parent].GetDatabase(User, Password)
697 ElseIf _FormType = ISSUBFORM Then
698 Set _Database = [_Parent].GetDatabase() &apos; Recursive call, climb the tree
699 ElseIf Len(_Form.DataSourceName) = 0 Then &apos; There is no database linked with the form
700 &apos; Return Nothing
701 Else
702 &apos; Check if DataSourceName is a file or a registered name and create database instance accordingly
703 Set FSO = ScriptForge.SF_FileSystem
704 sDataSource = FSO._ConvertFromUrl(_Form.DataSourceName)
705 If FSO.FileExists(sDataSource) Then
706 Set _Database = ScriptForge.SF_Services.CreateScriptService(&quot;SFDatabases.Database&quot; _
707 , sDataSource, , , sUser, sPassword)
708 Else
709 Set _Database = ScriptForge.SF_Services.CreateScriptService(&quot;SFDatabases.Database&quot; _
710 , , _Form.DataSourceName, , sUser, sPassword)
711 End If
712 If IsNull(_Database) Then GoTo CatchConnect
713 End If
714 Else
715 EndIf
717 Finally:
718 Set GetDatabase = _Database
719 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
720 Exit Function
721 Catch:
722 GoTo Finally
723 CatchConnect:
724 ScriptForge.SF_Exception.RaiseFatal(DBCONNECTERROR, &quot;User&quot;, User, &quot;Password&quot;, Password, [_Super]._FileIdent())
725 GoTo Finally
726 End Function &apos; SFDocuments.SF_Form.GetDatabase
728 REM -----------------------------------------------------------------------------
729 Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
730 &apos;&apos;&apos; Return the actual value of the given property
731 &apos;&apos;&apos; Args:
732 &apos;&apos;&apos; PropertyName: the name of the property as a string
733 &apos;&apos;&apos; Returns:
734 &apos;&apos;&apos; The actual value of the property
735 &apos;&apos;&apos; Exceptions:
736 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
737 &apos;&apos;&apos; Examples:
738 &apos;&apos;&apos; oDlg.GetProperty(&quot;Caption&quot;)
740 Const cstThisSub = &quot;SFDocuments.Form.GetProperty&quot;
741 Const cstSubArgs = &quot;&quot;
743 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
744 GetProperty = Null
746 Check:
747 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
748 If Not ScriptForge.SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
749 End If
751 Try:
752 GetProperty = _PropertyGet(PropertyName)
754 Finally:
755 SF_Utils._ExitFunction(cstThisSub)
756 Exit Function
757 Catch:
758 GoTo Finally
759 End Function &apos; SFDocuments.SF_Form.GetProperty
761 REM -----------------------------------------------------------------------------
762 Public Function Methods() As Variant
763 &apos;&apos;&apos; Return the list of public methods of the Form service as an array
765 Methods = Array( _
766 &quot;Activate&quot; _
767 , &quot;CloseForm&quot; _
768 , &quot;Controls&quot; _
769 , &quot;GetDatabase&quot; _
770 , &quot;MoveFirst&quot; _
771 , &quot;MoveLast&quot; _
772 , &quot;MoveNew&quot; _
773 , &quot;MoveNext&quot; _
774 , &quot;MovePrevious&quot; _
775 , &quot;Requery&quot; _
776 , &quot;SubForms&quot; _
779 End Function &apos; SFDocuments.SF_Form.Methods
781 REM -----------------------------------------------------------------------------
782 Public Function MoveFirst() As Boolean
783 &apos;&apos;&apos; The cursor is (re)positioned on the first row
784 &apos;&apos;&apos; Args:
785 &apos;&apos;&apos; Returns:
786 &apos;&apos;&apos; True if cursor move is successful
787 &apos;&apos;&apos; Example:
788 &apos;&apos;&apos; myForm.MoveFirst()
790 Dim bMoveFirst As Boolean &apos; Return value
791 Const cstThisSub = &quot;SFDocuments.Form.MoveFirst&quot;
792 Const cstSubArgs = &quot;&quot;
794 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
795 bMoveFirst = False
797 Check:
798 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
799 If Not _IsStillAlive() Then GoTo Finally
800 End If
801 Try:
802 With _Form
803 bMoveFirst = .first()
804 End With
806 Finally:
807 MoveFirst = bMoveFirst
808 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
809 Exit Function
810 Catch:
811 GoTo Finally
812 End Function &apos; SFDocuments.SF_Form.MoveFirst
814 REM -----------------------------------------------------------------------------
815 Public Function MoveLast() As Boolean
816 &apos;&apos;&apos; The cursor is (re)positioned on the last row
817 &apos;&apos;&apos; Args:
818 &apos;&apos;&apos; Returns:
819 &apos;&apos;&apos; True if cursor move is successful
820 &apos;&apos;&apos; Example:
821 &apos;&apos;&apos; myForm.MoveLast()
823 Dim bMoveLast As Boolean &apos; Return value
824 Const cstThisSub = &quot;SFDocuments.Form.MoveLast&quot;
825 Const cstSubArgs = &quot;&quot;
827 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
828 bMoveLast = False
830 Check:
831 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
832 If Not _IsStillAlive() Then GoTo Finally
833 End If
834 Try:
835 With _Form
836 bMoveLast = .last()
837 End With
839 Finally:
840 MoveLast = bMoveLast
841 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
842 Exit Function
843 Catch:
844 GoTo Finally
845 End Function &apos; SFDocuments.SF_Form.MoveLast
847 REM -----------------------------------------------------------------------------
848 Public Function MoveNew() As Boolean
849 &apos;&apos;&apos; The cursor is (re)positioned in the new record area
850 &apos;&apos;&apos; Args:
851 &apos;&apos;&apos; Returns:
852 &apos;&apos;&apos; True if cursor move is successful
853 &apos;&apos;&apos; Example:
854 &apos;&apos;&apos; myForm.MoveNew()
856 Dim bMoveNew As Boolean &apos; Return value
857 Const cstThisSub = &quot;SFDocuments.Form.MoveNew&quot;
858 Const cstSubArgs = &quot;&quot;
860 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
861 bMoveNew = False
863 Check:
864 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
865 If Not _IsStillAlive() Then GoTo Finally
866 End If
867 Try:
868 With _Form
869 .last() &apos; To simulate the behaviour in the UI
870 .moveToInsertRow()
871 End With
872 bMoveNew = True
874 Finally:
875 MoveNew = bMoveNew
876 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
877 Exit Function
878 Catch:
879 GoTo Finally
880 End Function &apos; SFDocuments.SF_Form.MoveNew
882 REM -----------------------------------------------------------------------------
883 Public Function MoveNext(Optional ByVal Offset As Variant) As Boolean
884 &apos;&apos;&apos; The cursor is (re)positioned on the next row
885 &apos;&apos;&apos; Args:
886 &apos;&apos;&apos; Offset: The number of records to go forward (default = 1)
887 &apos;&apos;&apos; Returns:
888 &apos;&apos;&apos; True if cursor move is successful
889 &apos;&apos;&apos; Example:
890 &apos;&apos;&apos; myForm.MoveNext()
892 Dim bMoveNext As Boolean &apos; Return value
893 Dim lOffset As Long &apos; Alias of Offset
894 Const cstThisSub = &quot;SFDocuments.Form.MoveNext&quot;
895 Const cstSubArgs = &quot;&quot;
897 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
898 bMoveNext = False
900 Check:
901 If IsMissing(Offset) Or IsEmpty(Offset) Then Offset = 1
902 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
903 If Not _IsStillAlive() Then GoTo Finally
904 If Not ScriptForge.SF_Utils._Validate(Offset, &quot;Offset&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
905 End If
906 Try:
907 lOffset = CLng(Offset) &apos; To be sure to have the right argument type
908 With _Form
909 If lOffset = 1 Then bMoveNext = .next() Else bMoveNext = .relative(lOffset)
910 End With
912 Finally:
913 MoveNext = bMoveNext
914 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
915 Exit Function
916 Catch:
917 GoTo Finally
918 End Function &apos; SFDocuments.SF_Form.MoveNext
920 REM -----------------------------------------------------------------------------
921 Public Function MovePrevious(Optional ByVal Offset As Variant) As Boolean
922 &apos;&apos;&apos; The cursor is (re)positioned on the previous row
923 &apos;&apos;&apos; Args:
924 &apos;&apos;&apos; Offset: The number of records to go backward (default = 1)
925 &apos;&apos;&apos; Returns:
926 &apos;&apos;&apos; True if cursor move is successful
927 &apos;&apos;&apos; Example:
928 &apos;&apos;&apos; myForm.MovePrevious()
930 Dim bMovePrevious As Boolean &apos; Return value
931 Dim lOffset As Long &apos; Alias of Offset
932 Const cstThisSub = &quot;SFDocuments.Form.MovePrevious&quot;
933 Const cstSubArgs = &quot;&quot;
935 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
936 bMovePrevious = False
938 Check:
939 If IsMissing(Offset) Or IsEmpty(Offset) Then Offset = 1
940 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
941 If Not _IsStillAlive() Then GoTo Finally
942 If Not ScriptForge.SF_Utils._Validate(Offset, &quot;Offset&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
943 End If
944 Try:
945 lOffset = CLng(Offset) &apos; To be sure to have the right argument type
946 With _Form
947 If lOffset = 1 Then bMovePrevious = .previous() Else bMovePrevious = .relative(-lOffset)
948 End With
950 Finally:
951 MovePrevious = bMovePrevious
952 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
953 Exit Function
954 Catch:
955 GoTo Finally
956 End Function &apos; SFDocuments.SF_Form.MovePrevious
958 REM -----------------------------------------------------------------------------
959 Public Function Properties() As Variant
960 &apos;&apos;&apos; Return the list or properties of the Form class as an array
962 Properties = Array( _
963 &quot;AllowDeletes&quot; _
964 , &quot;AllowInserts&quot; _
965 , &quot;AllowUpdates&quot; _
966 , &quot;BaseForm&quot; _
967 , &quot;Bookmark&quot; _
968 , &quot;CurrentRecord&quot; _
969 , &quot;Filter&quot; _
970 , &quot;LinkChildFields&quot; _
971 , &quot;LinkParentFields&quot; _
972 , &quot;Name&quot; _
973 , &quot;OnApproveCursorMove&quot; _
974 , &quot;OnApproveParameter&quot; _
975 , &quot;OnApproveReset&quot; _
976 , &quot;OnApproveRowChange&quot; _
977 , &quot;OnApproveSubmit&quot; _
978 , &quot;OnConfirmDelete&quot; _
979 , &quot;OnCursorMoved&quot; _
980 , &quot;OnErrorOccurred&quot; _
981 , &quot;OnLoaded&quot; _
982 , &quot;OnReloaded&quot; _
983 , &quot;OnReloading&quot; _
984 , &quot;OnResetted&quot; _
985 , &quot;OnRowChanged&quot; _
986 , &quot;OnUnloaded&quot; _
987 , &quot;OnUnloading&quot; _
988 , &quot;OrderBy&quot; _
989 , &quot;Parent&quot; _
990 , &quot;RecordSource&quot; _
991 , &quot;XForm&quot; _
994 End Function &apos; SFDocuments.SF_Form.Properties
996 REM -----------------------------------------------------------------------------
997 Public Function Requery() As Boolean
998 &apos;&apos;&apos; Reload from the database the actual data into the form
999 &apos;&apos;&apos; The cursor is (re)positioned on the first row
1000 &apos;&apos;&apos; Args:
1001 &apos;&apos;&apos; Returns:
1002 &apos;&apos;&apos; True if requery is successful
1003 &apos;&apos;&apos; Example:
1004 &apos;&apos;&apos; myForm.Requery()
1006 Dim bRequery As Boolean &apos; Return value
1007 Const cstThisSub = &quot;SFDocuments.Form.Requery&quot;
1008 Const cstSubArgs = &quot;&quot;
1010 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1011 bRequery = False
1013 Check:
1014 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1015 If Not _IsStillAlive() Then GoTo Finally
1016 End If
1017 Try:
1018 With _Form
1019 If .isLoaded() Then .reload() Else .load()
1020 End With
1021 bRequery = True
1023 Finally:
1024 Requery = bRequery
1025 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1026 Exit Function
1027 Catch:
1028 GoTo Finally
1029 End Function &apos; SFDocuments.SF_Form.Requery
1031 REM -----------------------------------------------------------------------------
1032 Public Function SetProperty(Optional ByVal PropertyName As Variant _
1033 , Optional ByRef Value As Variant _
1034 ) As Boolean
1035 &apos;&apos;&apos; Set a new value to the given property
1036 &apos;&apos;&apos; Args:
1037 &apos;&apos;&apos; PropertyName: the name of the property as a string
1038 &apos;&apos;&apos; Value: its new value
1039 &apos;&apos;&apos; Exceptions
1040 &apos;&apos;&apos; ARGUMENTERROR The property does not exist
1042 Const cstThisSub = &quot;SFDocuments.Form.SetProperty&quot;
1043 Const cstSubArgs = &quot;PropertyName, Value&quot;
1045 If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1046 SetProperty = False
1048 Check:
1049 If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1050 If Not SF_Utils._Validate(PropertyName, &quot;PropertyName&quot;, V_STRING, Properties()) Then GoTo Catch
1051 End If
1053 Try:
1054 SetProperty = _PropertySet(PropertyName, Value)
1056 Finally:
1057 SF_Utils._ExitFunction(cstThisSub)
1058 Exit Function
1059 Catch:
1060 GoTo Finally
1061 End Function &apos; SFDocuments.SF_Form.SetProperty
1063 REM -----------------------------------------------------------------------------
1064 Public Function Subforms(Optional ByVal Subform As Variant) As Variant
1065 &apos;&apos;&apos; Return either
1066 &apos;&apos;&apos; - the list of the subforms contained in the actual form or subform instance
1067 &apos;&apos;&apos; - a SFDocuments.Form object based on its name or its index in the alphabetic list of subforms
1068 &apos;&apos;&apos; Args:
1069 &apos;&apos;&apos; Subform: a subform stored in the parent form given by its name or its index
1070 &apos;&apos;&apos; When absent, the list of available subforms is returned
1071 &apos;&apos;&apos; To get the first (unique ?) subform stored in the parent form, set Subform = 0
1072 &apos;&apos;&apos; Exceptions:
1073 &apos;&apos;&apos; SUBFORMNOTFOUNDERROR Subform not found
1074 &apos;&apos;&apos; Returns:
1075 &apos;&apos;&apos; A zero-based array of strings if Subform is absent
1076 &apos;&apos;&apos; An instance of the SF_Form class if Subform exists
1077 &apos;&apos;&apos; Example:
1078 &apos;&apos;&apos; Dim myForm As Object, myList As Variant, mySubform As Object
1079 &apos;&apos;&apos; myList = myForm.Subforms()
1080 &apos;&apos;&apos; Set mySubform = myForm.Subforms(&quot;mySubform&quot;)
1082 Dim oSubform As Object &apos; The new Form class instance
1083 Dim oXSubform As Object &apos; com.sun.star.form.XForm
1084 Dim vSubformNames As Variant &apos; Array of subform names
1085 Dim i As Long
1086 Const cstDrawPage = 0 &apos; Only 1 drawpage in a Writer document
1088 Const cstThisSub = &quot;SFDocuments.Form.Subforms&quot;
1089 Const cstSubArgs = &quot;[Subform=&quot;&quot;&quot;&quot;]&quot;
1091 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1093 Check:
1094 If IsMissing(Subform) Or IsEmpty(Subform) Then Subform = &quot;&quot;
1095 If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
1096 If Not _IsStillAlive() Then GoTo Finally
1097 If Not ScriptForge.SF_Utils._Validate(Subform, &quot;Subform&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
1098 End If
1100 Try:
1101 &apos; Collect all control names and retain only the subforms
1102 vSubformNames = _Form.getElementNames()
1103 For i = 0 To UBound(vSubformNames)
1104 Set oSubform = _Form.getByName(vSubformNames(i))
1105 &apos; Subforms are the only control types having no ClassId property
1106 If ScriptForge.SF_Session.HasUnoProperty(oSubform, &quot;ClassId&quot;) Then vSubformNames(i) = &quot;&quot;
1107 Next i
1108 vSubformNames = ScriptForge.SF_Array.TrimArray(vSubformNames)
1110 If Len(Subform) = 0 Then &apos; Return the list of valid subform names
1111 Subforms = vSubformNames
1112 Else
1113 If VarType(Subform) = V_STRING Then &apos; Find the form by name
1114 If Not ScriptForge.SF_Array.Contains(vSubformNames, Subform, CaseSensitive := True) Then GoTo CatchNotFound
1115 Set oXSubform = _Form.getByName(Subform)
1116 Else &apos; Find the form by index
1117 If Subform &lt; 0 Or Subform &gt; UBound(vSubformNames) Then GoTo CatchNotFound
1118 Set oXSubform = _Form.getByName(vSubformNames(Subform))
1119 End If
1120 &apos; Create the new Form class instance
1121 Set oSubform = SF_Register._NewForm(oXSubform)
1122 With oSubform
1123 Set .[_Parent] = [Me]
1124 ._FormType = ISSUBFORM
1125 Set ._Component = _Component
1126 Set ._FormDocument = _FormDocument
1127 ._SheetName = _SheetName
1128 ._FormDocumentName = _FormDocumentName
1129 Set ._Database = _Database
1130 ._Initialize()
1131 End With
1132 Set Subforms = oSubform
1133 End If
1135 Finally:
1136 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1137 Exit Function
1138 Catch:
1139 GoTo Finally
1140 CatchNotFound:
1141 ScriptForge.SF_Exception.RaiseFatal(SUBFORMNOTFOUNDERROR, Subform, _Name)
1142 GoTo Finally
1143 End Function &apos; SFDocuments.SF_Form.Subforms
1145 REM =========================================================== PRIVATE FUNCTIONS
1147 REM -----------------------------------------------------------------------------
1148 Public Function _GetEventName(ByVal psProperty As String) As String
1149 &apos;&apos;&apos; Return the LO internal event name derived from the SF property name
1150 &apos;&apos;&apos; The SF property name is not case sensitive, while the LO name is case-sensitive
1151 &apos; Corrects the typo on ErrorOccur(r?)ed, if necessary
1153 Dim vProperties As Variant &apos; Array of class properties
1154 Dim sProperty As String &apos; Correctly cased property name
1156 vProperties = Properties()
1157 sProperty = vProperties(ScriptForge.SF_Array.IndexOf(vProperties, psProperty, SortOrder := &quot;ASC&quot;))
1159 _GetEventName = LCase(Mid(sProperty, 3, 1)) &amp; Right(sProperty, Len(sProperty) - 3)
1161 End Function &apos; SFDocuments.SF_Form._GetEventName
1163 REM -----------------------------------------------------------------------------
1164 Private Function _GetListener(ByVal psEventName As String) As String
1165 &apos;&apos;&apos; Getting/Setting macros triggered by events requires a Listener-EventName pair
1166 &apos;&apos;&apos; Return the X...Listener corresponding with the event name in argument
1168 Select Case UCase(psEventName)
1169 Case UCase(&quot;OnApproveCursorMove&quot;)
1170 _GetListener = &quot;XRowSetApproveListener&quot;
1171 Case UCase(&quot;OnApproveParameter&quot;)
1172 _GetListener = &quot;XDatabaseParameterListener&quot;
1173 Case UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnResetted&quot;)
1174 _GetListener = &quot;XResetListener&quot;
1175 Case UCase(&quot;OnApproveRowChange&quot;)
1176 _GetListener = &quot;XRowSetApproveListener&quot;
1177 Case UCase(&quot;OnApproveSubmit&quot;)
1178 _GetListener = &quot;XSubmitListener&quot;
1179 Case UCase(&quot;OnConfirmDelete&quot;)
1180 _GetListener = &quot;XConfirmDeleteListener&quot;
1181 Case UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnRowChanged&quot;)
1182 _GetListener = &quot;XRowSetListener&quot;
1183 Case UCase(&quot;OnErrorOccurred&quot;)
1184 _GetListener = &quot;XSQLErrorListener&quot;
1185 Case UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
1186 _GetListener = &quot;XLoadListener&quot;
1187 End Select
1189 End Function &apos; SFDocuments.SF_Form._GetListener
1191 REM -----------------------------------------------------------------------------
1192 Private Sub _GetParents()
1193 &apos;&apos;&apos; When the current instance is created top-down, the parents are completely defined
1194 &apos;&apos;&apos; and nothing should be done in this method
1195 &apos;&apos;&apos; When the a class instance is created in a (form/control) event, it is the opposite
1196 &apos;&apos;&apos; The current method rebuilds the missing members in the instance from the bottom
1197 &apos;&apos;&apos; Members potentially to collect are:
1198 &apos;&apos;&apos; - _FormType
1199 &apos;&apos;&apos; - [_Parent], the immediate parent: a form or a document instance
1200 &apos;&apos;&apos; + Only when the _FormType is a main form
1201 &apos;&apos;&apos; - _SheetName (Calc only)
1202 &apos;&apos;&apos; - _FormDocumentName (Base only)
1203 &apos;&apos;&apos; - _FormDocument, the topmost form collection
1204 &apos;&apos;&apos; - _Component, the containing document
1205 &apos;&apos;&apos; They must be identified only starting from the _Form UNO object
1206 &apos;&apos;&apos;
1207 &apos;&apos;&apos; The method is called from the _Initialize() method at instance creation
1209 Dim oParent As Object &apos; Successive bottom-up parents
1210 Dim sType As String &apos; UNO object type
1211 Dim sPersistentName As String &apos; The Obj... name of a Base form
1212 Dim iLevel As Integer &apos; When = 1 =&gt; first parent
1213 Dim oSession As Object : Set oSession = ScriptForge.SF_Session
1215 On Local Error GoTo Finally &apos; Being probably called from events, this method should avoid failures
1216 &apos; When the form type is known, the upper part of the branch is not scanned
1217 If _FormType &lt;&gt; ISUNDEFINED Then GoTo Finally
1219 Try:
1220 &apos; The whole branch is scanned bottom-up
1221 If oSession.HasUnoProperty(_Form, &quot;Parent&quot;) Then Set oParent = _Form.Parent Else Set oParent = Nothing
1222 _FormType = ISUNDEFINED
1223 iLevel = 1
1225 Do While Not IsNull(oParent)
1226 sType = SF_Session.UnoObjectType(oParent)
1227 Select Case sType
1228 &apos; Collect at each level the needed info
1229 Case &quot;com.sun.star.comp.forms.ODatabaseForm&quot; &apos; The parent _Form of a subform
1230 If iLevel = 1 Then
1231 _FormType = ISSUBFORM
1232 Set [_Parent] = SF_Register._NewForm(oParent)
1233 &apos; Everything is in the parent, copy items and stop scan
1234 [_Parent]._Initialize() &apos; Current method is called recursively here
1235 With [_Parent]
1236 _SheetName = ._SheetName
1237 _FormDocumentName = ._FormDocumentName
1238 Set _FormDocument = ._FormDocument
1239 Set _Component = ._Component
1240 End With
1241 Exit Sub
1242 End If
1243 Case &quot;com.sun.star.form.OFormsCollection&quot; &apos; The collection of forms inside a drawpage
1244 Case &quot;SwXTextDocument&quot; &apos; The parent document: a Writer document or a Base form document
1245 If oParent.Identifier = &quot;com.sun.star.sdb.FormDesign&quot; Then
1246 sPersistentName = ScriptForge._GetPropertyValue(oParent.Args, &quot;HierarchicalDocumentName&quot;)
1247 ElseIf oParent.Identifier = &quot;com.sun.star.text.TextDocument&quot; Then
1248 _FormType = ISDOCFORM
1249 Set [_Parent] = ScriptForge.SF_Services.CreateScriptService(&quot;SFDocuments.Document&quot;, oParent)
1250 Set _Component = [_Parent]._Component
1251 End If
1252 Case &quot;ScModelObj&quot; &apos; The parent document: a Calc document
1253 _FormType = ISCALCFORM
1254 Set [_Parent] = ScriptForge.SF_Services.CreateScriptService(&quot;SFDocuments.Document&quot;, oParent)
1255 Set _Component = oParent
1256 &apos; The triggered form event is presumed to be located in the (drawpage of the) active sheet
1257 _SheetName = [_Parent].XSpreadsheet(&quot;~&quot;)
1258 Case &quot;com.sun.star.comp.dba.ODatabaseDocument&quot; &apos; The Base document
1259 _FormType = ISBASEFORM
1260 Set [_Parent] = ScriptForge.SF_Services.CreateScriptService(&quot;SFDocuments.Document&quot;, oParent)
1261 Set _Component = oParent
1262 If IsNull([_Parent]._FormDocuments) Then Set [_Parent]._FormDocuments = _Component.getFormDocuments()
1263 Set _FormDocument = [_Parent]._FindByPersistentName([_Parent]._FormDocuments, sPersistentName)
1264 _FormDocumentName = _FormDocument.HierarchicalName
1265 Case Else
1266 End Select
1267 If oSession.HasUnoProperty(oParent, &quot;Parent&quot;) Then Set oParent = oParent.Parent Else Set oParent = Nothing
1268 iLevel = iLevel + 1
1269 Loop
1271 Finally:
1272 Exit Sub
1273 End Sub &apos; SFDocuments.SF_Form._GetParents
1275 REM -----------------------------------------------------------------------------
1276 Public Sub _Initialize()
1277 &apos;&apos;&apos; Achieve the creation of a SF_Form instance
1278 &apos;&apos;&apos; - complete the missing private members
1279 &apos;&apos;&apos; - store the new instance in the cache
1281 _GetParents()
1282 _CacheIndex = SF_Register._AddFormToCache(_Form, [Me])
1284 End Sub &apos; SFDocuments.SF_Form._Initialize
1286 REM -----------------------------------------------------------------------------
1287 Private Function _IsStillAlive(Optional ByVal pbError As Boolean) As Boolean
1288 &apos;&apos;&apos; Return True if the Form is still open
1289 &apos;&apos;&apos; If dead the actual instance is disposed
1290 &apos;&apos;&apos; and the execution is cancelled when pbError = True (default)
1291 &apos;&apos;&apos; Args:
1292 &apos;&apos;&apos; pbError: if True (default), raise a fatal error
1294 Dim bAlive As Boolean &apos; Return value
1295 Dim sName As String &apos; Alias of _Name
1296 Dim sId As String &apos; Alias of FileIdent
1298 Check:
1299 On Local Error GoTo Catch &apos; Anticipate DisposedException errors or alike
1300 If IsMissing(pbError) Then pbError = True
1302 Try:
1303 &apos; At main form termination, all database connections are lost
1304 bAlive = Not IsNull(_Form)
1305 If Not bAlive Then GoTo Catch
1307 Finally:
1308 _IsStillAlive = bAlive
1309 Exit Function
1310 Catch:
1311 bAlive = False
1312 On Error GoTo 0
1313 &apos; Keep error message elements before disposing the instance
1314 sName = _SheetName &amp; _FormDocumentName &apos; At least one of them is a zero-length string
1315 sName = Iif(Len(sName) &gt; 0, &quot;[&quot; &amp; sName &amp; &quot;].&quot;, &quot;&quot;) &amp; _Name
1316 If Not IsNull(_Component) Then sId = _Component.Location Else sId = &quot;&quot;
1317 &apos; Dispose the actual forms instance
1318 Dispose()
1319 &apos; Display error message
1320 If pbError Then ScriptForge.SF_Exception.RaiseFatal(FORMDEADERROR, sName, sId)
1321 GoTo Finally
1322 End Function &apos; SFDocuments.SF_Form._IsStillAlive
1324 REM -----------------------------------------------------------------------------
1325 Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
1326 &apos;&apos;&apos; Return the value of the named property
1327 &apos;&apos;&apos; Args:
1328 &apos;&apos;&apos; psProperty: the name of the property
1330 Static oSession As Object &apos; Alias of SF_Session
1331 Dim vBookmark As Variant &apos; Form bookmark
1332 Dim cstThisSub As String
1333 Const cstSubArgs = &quot;&quot;
1335 cstThisSub = &quot;SFDocuments.Form.get&quot; &amp; psProperty
1336 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1338 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
1339 _PropertyGet = Empty
1340 If Not _IsStillAlive() Then GoTo Finally
1342 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
1343 Select Case UCase(psProperty)
1344 Case UCase(&quot;AllowDeletes&quot;)
1345 If Not IsNull(_Form) Then _PropertyGet = _Form.AllowDeletes
1346 Case UCase(&quot;AllowInserts&quot;)
1347 If Not IsNull(_Form) Then _PropertyGet = _Form.AllowInserts
1348 Case UCase(&quot;AllowUpdates&quot;)
1349 If Not IsNull(_Form) Then _PropertyGet = _Form.AllowUpdates
1350 Case UCase(&quot;BaseForm&quot;)
1351 _PropertyGet = _FormDocumentName
1352 Case UCase(&quot;Bookmark&quot;)
1353 If IsNull(_Form) Then
1354 _PropertyGet = 0
1355 Else
1356 On Local Error Resume Next &apos; Disable error handler because bookmarking does not always react well in events ...
1357 If _Form.IsBookmarkable Then vBookmark = _Form.getBookmark() Else vBookmark = Nothing
1358 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error Goto Catch Else On Local Error Goto 0
1359 If IsNull(vBookmark) Then Goto Catch
1360 _PropertyGet = vBookmark
1361 End If
1362 Case UCase(&quot;CurrentRecord&quot;)
1363 If IsNull(_Form) Then _PropertyGet = 0 Else _PropertyGet = _Form.Row
1364 Case UCase(&quot;Filter&quot;)
1365 If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Filter
1366 Case UCase(&quot;LinkChildFields&quot;)
1367 If IsNull(_Form) Or _FormType &lt;&gt; ISSUBFORM Then _PropertyGet = Array() Else _PropertyGet = _Form.DetailFields
1368 Case UCase(&quot;LinkParentFields&quot;)
1369 If IsNull(_Form) Or _FormType &lt;&gt; ISSUBFORM Then _PropertyGet = Array() Else _PropertyGet = _Form.MasterFields
1370 Case UCase(&quot;Name&quot;)
1371 _PropertyGet = _Name
1372 Case UCase(&quot;OnApproveCursorMove&quot;), UCase(&quot;OnApproveParameter&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveRowChange&quot;) _
1373 , UCase(&quot;OnApproveSubmit&quot;), UCase(&quot;OnConfirmDelete&quot;), UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnErrorOccurred&quot;) _
1374 , UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnResetted&quot;), UCase(&quot;OnRowChanged&quot;) _
1375 , UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
1376 If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = SF_Register._GetEventScriptCode(_Form, psProperty, _Name)
1377 Case UCase(&quot;OrderBy&quot;)
1378 If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Order
1379 Case UCase(&quot;Parent&quot;)
1380 _PropertyGet = [_Parent]
1381 Case UCase(&quot;RecordSource&quot;)
1382 If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Command
1383 Case UCase(&quot;XForm&quot;)
1384 Set _PropertyGet = _Form
1385 Case Else
1386 _PropertyGet = Null
1387 End Select
1389 Finally:
1390 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1391 Exit Function
1392 Catch:
1393 GoTo Finally
1394 End Function &apos; SFDocuments.SF_Form._PropertyGet
1396 REM -----------------------------------------------------------------------------
1397 Private Function _PropertySet(Optional ByVal psProperty As String _
1398 , Optional ByVal pvValue As Variant _
1399 ) As Boolean
1400 &apos;&apos;&apos; Set the new value of the named property
1401 &apos;&apos;&apos; Args:
1402 &apos;&apos;&apos; psProperty: the name of the property
1403 &apos;&apos;&apos; pvValue: the new value of the given property
1404 &apos;&apos;&apos; Returns:
1405 &apos;&apos;&apos; True if successful
1407 Dim bSet As Boolean &apos; Return value
1408 Dim oDatabase As Object &apos; Database class instance
1409 Dim lCommandType As Long &apos; Record source type: 0 = Table, 1 = Query, 2 = SELECT
1410 Dim sCommand As String &apos; Record source
1411 Static oSession As Object &apos; Alias of SF_Session
1412 Dim cstThisSub As String
1413 Const cstSubArgs = &quot;Value&quot;
1415 If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
1416 bSet = False
1418 cstThisSub = &quot;SFDocuments.Form.set&quot; &amp; psProperty
1419 ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
1420 If Not _IsStillAlive() Then GoTo Finally
1422 If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
1423 bSet = True
1424 Select Case UCase(psProperty)
1425 Case UCase(&quot;AllowDeletes&quot;)
1426 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowDeletes&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1427 If Not IsNull(_Form) Then
1428 _Form.AllowDeletes = pvValue
1429 _Form.reload()
1430 End If
1431 Case UCase(&quot;AllowInserts&quot;)
1432 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowInserts&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1433 If Not IsNull(_Form) Then
1434 _Form.AllowInserts = pvValue
1435 _Form.reload()
1436 End If
1437 Case UCase(&quot;AllowUpdates&quot;)
1438 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowUpdates&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
1439 If Not IsNull(_Form) Then
1440 _Form.AllowUpdates = pvValue
1441 _Form.reload()
1442 End If
1443 Case UCase(&quot;Bookmark&quot;)
1444 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Bookmark&quot;, Array(ScriptForge.V_NUMERIC, ScriptForge.V_OBJECT)) Then GoTo Finally
1445 If Not IsNull(pvValue) And Not IsNull(_Form) Then bSet = _Form.moveToBookmark(pvValue)
1446 Case UCase(&quot;CurrentRecord&quot;)
1447 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;CurrentRecord&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
1448 If Not IsNull(_Form) Then bSet = _Form.absolute(pvValue)
1449 Case UCase(&quot;Filter&quot;)
1450 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Filter&quot;, V_STRING) Then GoTo Finally
1451 If Not IsNull(_Form) Then
1452 With _Form
1453 If Len(pvValue) &gt; 0 Then
1454 Set oDatabase = GetDatabase()
1455 If Not IsNull(oDatabase) Then .Filter = oDatabase._ReplaceSquareBrackets(pvValue) Else .Filter = pvValue
1456 Else
1457 .Filter = &quot;&quot;
1458 End If
1459 .ApplyFilter = True
1460 .reload()
1461 End With
1462 End If
1463 Case UCase(&quot;OnApproveCursorMove&quot;), UCase(&quot;OnApproveParameter&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveRowChange&quot;) _
1464 , UCase(&quot;OnApproveSubmit&quot;), UCase(&quot;OnConfirmDelete&quot;), UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnErrorOccurred&quot;) _
1465 , UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnResetted&quot;), UCase(&quot;OnRowChanged&quot;) _
1466 , UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
1467 If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then Goto Finally
1468 If Not IsNull(_Form) Then
1469 bSet = SF_Register._RegisterEventScript(_Form _
1470 , psProperty _
1471 , _GetListener(psProperty) _
1472 , pvValue _
1473 , _Name _
1475 End If
1476 Case UCase(&quot;OrderBy&quot;)
1477 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;OrderBy&quot;, V_STRING) Then GoTo Finally
1478 If Not IsNull(_Form) Then
1479 With _Form
1480 If Len(pvValue) &gt; 0 Then
1481 Set oDatabase = GetDatabase()
1482 If Not IsNull(oDatabase) Then .Order = oDatabase._ReplaceSquareBrackets(pvValue) Else .Order = pvValue
1483 Else
1484 .Order = &quot;&quot;
1485 End If
1486 .reload()
1487 End With
1488 End If
1489 Case UCase(&quot;RecordSource&quot;)
1490 If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;RecordSource&quot;, V_STRING) Then GoTo Finally
1491 If Not IsNull(_Form) And Len(pvValue) &gt; 0 Then
1492 Set oDatabase = GetDatabase()
1493 If Not IsNull(oDatabase) Then
1494 With oDatabase
1495 If ScriptForge.SF_Array.Contains(.Tables, pvValue, CaseSensitive := True) Then
1496 sCommand = pvValue
1497 lCommandType = com.sun.star.sdb.CommandType.TABLE
1498 ElseIf ScriptForge.SF_Array.Contains(.Queries, pvValue, CaseSensitive := True) Then
1499 sCommand = pvValue
1500 lCommandType = com.sun.star.sdb.CommandType.QUERY
1501 ElseIf ScriptForge.SF_String.StartsWith(pvValue, &quot;SELECT&quot;, CaseSensitive := False) Then
1502 sCommand = .ReplaceSquareBrackets(pvValue)
1503 lCommandType = com.sun.star.sdb.CommandType.COMMAND
1504 End If
1505 _Form.Command = sCommand
1506 _Form.CommandType = lCommandType
1507 End With
1508 End If
1509 End If
1510 Case Else
1511 bSet = False
1512 End Select
1514 Finally:
1515 _PropertySet = bSet
1516 ScriptForge.SF_Utils._ExitFunction(cstThisSub)
1517 Exit Function
1518 Catch:
1519 GoTo Finally
1520 End Function &apos; SFDocuments.SF_Form._PropertySet
1522 REM -----------------------------------------------------------------------------
1523 Private Function _Repr() As String
1524 &apos;&apos;&apos; Convert the Model instance to a readable string, typically for debugging purposes (DebugPrint ...)
1525 &apos;&apos;&apos; Args:
1526 &apos;&apos;&apos; Return:
1527 &apos;&apos;&apos; &quot;[Form]: Name&quot;
1529 Dim sParent As String &apos; To recognize the parent
1531 sParent = _SheetName &amp; _FormDocumentName &apos; At least one of them is a zero-length string
1532 _Repr = &quot;[Form]: &quot; &amp; Iif(Len(sParent) &gt; 0, sParent &amp; &quot;...&quot;, &quot;&quot;) &amp; _Name
1534 End Function &apos; SFDocuments.SF_Form._Repr
1536 REM ============================================ END OF SFDOCUMENTS.SF_FORM
1537 </script:module>