Update git submodules
[LibreOffice.git] / wizards / source / access2base / Form.xba
blobdf18feb34678c345da456ed961299cd0beb4b251
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="Form" script:language="StarBasic">
4 REM =======================================================================================================================
5 REM === The Access2Base library is a part of the LibreOffice project. ===
6 REM === Full documentation is available on http://www.access2base.com ===
7 REM =======================================================================================================================
9 Option Compatible
10 Option ClassModule
12 Option Explicit
14 REM -----------------------------------------------------------------------------------------------------------------------
15 REM --- CLASS ROOT FIELDS ---
16 REM -----------------------------------------------------------------------------------------------------------------------
18 Private _Type As String &apos; Must be FORM
19 Private _This As Object &apos; Workaround for absence of This builtin function
20 Private _Parent As Object
21 Private _Shortcut As String
22 Private _Name As String
23 Private _DocEntry As Integer &apos; Doc- and DbContainer entries in Root structure
24 Private _DbEntry As Integer
25 Private _MainForms As Variant
26 Private _PersistentName As String
27 Private _IsLoaded As Boolean
28 Private _OpenArgs As Variant
29 Private _OrderBy As String
30 Public Component As Object &apos; com.sun.star.text.TextDocument
31 Public ContainerWindow As Object &apos; (No name)
32 Public FormsCollection As Object &apos; com.sun.star.form.OFormsCollection
33 Public DatabaseForm As Object &apos; com.sun.star.form.component.DataForm and com.sun.star.sdb.ResultSet (a.o.)
35 REM -----------------------------------------------------------------------------------------------------------------------
36 REM --- CONSTRUCTORS / DESTRUCTORS ---
37 REM -----------------------------------------------------------------------------------------------------------------------
38 Private Sub Class_Initialize()
39 _Type = OBJFORM
40 Set _This = Nothing
41 Set _Parent = Nothing
42 _Shortcut = &quot;&quot;
43 _Name = &quot;&quot;
44 _DocEntry = -1
45 _DbEntry = -1
46 _MainForms = Array()
47 _PersistentName = &quot;&quot;
48 _IsLoaded = False
49 _OpenArgs = &quot;&quot;
50 _OrderBy = &quot;&quot;
51 Set Component = Nothing
52 Set ContainerWindow = Nothing
53 Set FormsCollection = Nothing
54 Set DatabaseForm = Nothing
55 End Sub &apos; Constructor
57 REM -----------------------------------------------------------------------------------------------------------------------
58 Private Sub Class_Terminate()
59 On Local Error Resume Next
60 Call Class_Initialize()
61 End Sub &apos; Destructor
63 REM -----------------------------------------------------------------------------------------------------------------------
64 Public Sub Dispose()
65 Dim ofForm As Object
66 If Not IsLoaded(True) Then
67 If Not IsNull(DatabaseForm) Then DatabaseForm.Dispose()
68 End If
69 Call Class_Terminate()
70 End Sub &apos; Explicit destructor
72 REM -----------------------------------------------------------------------------------------------------------------------
73 REM --- CLASS GET/LET/SET PROPERTIES ---
74 REM -----------------------------------------------------------------------------------------------------------------------
75 Property Get AllowAdditions() As Variant
76 AllowAdditions = _PropertyGet(&quot;AllowAdditions&quot;)
77 End Property &apos; AllowAdditions (get)
79 Property Let AllowAdditions(ByVal pvValue As Variant)
80 Call _PropertySet(&quot;AllowAdditions&quot;, pvValue)
81 End Property &apos; AllowAdditions (set)
83 REM -----------------------------------------------------------------------------------------------------------------------
84 Property Get AllowDeletions() As Variant
85 AllowDeletions = _PropertyGet(&quot;AllowDeletions&quot;)
86 End Property &apos; AllowDeletions (get)
88 Property Let AllowDeletions(ByVal pvValue As Variant)
89 Call _PropertySet(&quot;AllowDeletions&quot;, pvValue)
90 End Property &apos; AllowDeletions (set)
92 REM -----------------------------------------------------------------------------------------------------------------------
93 Property Get AllowEdits() As Variant
94 AllowEdits = _PropertyGet(&quot;AllowEdits&quot;)
95 End Property &apos; AllowEdits (get)
97 Property Let AllowEdits(ByVal pvValue As Variant)
98 Call _PropertySet(&quot;AllowEdits&quot;, pvValue)
99 End Property &apos; AllowEdits (set)
101 REM -----------------------------------------------------------------------------------------------------------------------
102 Property Get Bookmark() As Variant
103 Bookmark = _PropertyGet(&quot;Bookmark&quot;)
104 End Property &apos; Bookmark (get)
106 Property Let Bookmark(ByVal pvValue As Variant)
107 Call _PropertySet(&quot;Bookmark&quot;, pvValue)
108 End Property &apos; Bookmark (set)
110 REM -----------------------------------------------------------------------------------------------------------------------
111 Property Get Caption() As Variant
112 Caption = _PropertyGet(&quot;Caption&quot;)
113 End Property &apos; Caption (get)
115 Property Let Caption(ByVal pvValue As Variant)
116 Call _PropertySet(&quot;Caption&quot;, pvValue)
117 End Property &apos; Caption (set)
119 REM -----------------------------------------------------------------------------------------------------------------------
120 Property Get CurrentRecord() As Variant
121 CurrentRecord = _PropertyGet(&quot;CurrentRecord&quot;)
122 End Property &apos; CurrentRecord (get)
124 Property Let CurrentRecord(ByVal pvValue As Variant)
125 Call _PropertySet(&quot;CurrentRecord&quot;, pvValue)
126 End Property &apos; CurrentRecord (set)
128 REM -----------------------------------------------------------------------------------------------------------------------
129 Property Get Filter() As Variant
130 Filter = _PropertyGet(&quot;Filter&quot;)
131 End Property &apos; Filter (get)
133 Property Let Filter(ByVal pvValue As Variant)
134 Call _PropertySet(&quot;Filter&quot;, pvValue)
135 End Property &apos; Filter (set)
137 REM -----------------------------------------------------------------------------------------------------------------------
138 Property Get FilterOn() As Variant
139 FilterOn = _PropertyGet(&quot;FilterOn&quot;)
140 End Property &apos; FilterOn (get)
142 Property Let FilterOn(ByVal pvValue As Variant)
143 Call _PropertySet(&quot;FilterOn&quot;, pvValue)
144 End Property &apos; FilterOn (set)
146 REM -----------------------------------------------------------------------------------------------------------------------
147 Property Get Height() As Variant
148 Height = _PropertyGet(&quot;Height&quot;)
149 End Property &apos; Height (get)
151 Property Let Height(ByVal pvValue As Variant)
152 Call _PropertySet(&quot;Height&quot;, pvValue)
153 End Property &apos; Height (set)
155 REM -----------------------------------------------------------------------------------------------------------------------
156 Function IsLoaded(ByVal Optional pbForce As Boolean) As Boolean
157 &apos;Return True if form open
158 &apos;pbForce = True forbids bypass on value of _IsLoaded
160 If _ErrorHandler() Then On Local Error Goto Error_Function
161 Utils._SetCalledSub(&quot;Form.getIsLoaded&quot;)
162 If IsMissing(pbForce) Then pbForce = False
163 If ( Not pbForce ) And _IsLoaded Then &apos; For performance reasons, a form object, once detected as loaded, is presumed remaining loaded. Except if pbForce = True
164 IsLoaded = True
165 Goto Exit_Function
166 End If
167 IsLoaded = False
169 Dim oDoc As Object, oDatabase As Object, oEnum As Object, oDesk As Object, oComp As Object, vPersistent As Variant
170 Dim i As Integer
171 Set oDoc = _A2B_.CurrentDocument()
172 Select Case oDoc.DbConnect
173 Case DBCONNECTBASE
174 Set oDesk = CreateUnoService(&quot;com.sun.star.frame.Desktop&quot;)
175 Set oEnum = oDesk.Components().createEnumeration
176 Do While oEnum.hasMoreElements &apos; Search in all open components if one corresponds with current form
177 oComp = oEnum.nextElement
178 If _hasUNOProperty(oComp, &quot;Identifier&quot;) Then
179 If oComp.Identifier = &quot;com.sun.star.sdb.FormDesign&quot; Then
180 vPersistent = Split(oComp.StringValue, &quot;/&quot;)
181 If vPersistent(UBound(vPersistent) - 1) = _PersistentName Then
182 _IsLoaded = True
183 Set Component = oComp
184 Exit Do
185 End If
186 End If
187 End If
188 Loop
189 Case DBCONNECTFORM
190 Set Component = oDoc.Document &apos; Form
191 _IsLoaded = True &apos; Interactive form always loaded by design
192 End Select
193 Set oComp = Nothing
194 IsLoaded = _IsLoaded
196 Exit_Function:
197 Utils._ResetCalledSub(&quot;Form.getIsLoaded&quot;)
198 Exit Function
199 Error_Function:
200 TraceError(TRACEABORT, Err, &quot;Form.getIsLoaded&quot;, Erl)
201 GoTo Exit_Function
202 End Function &apos; IsLoaded V1.1.0
204 REM -----------------------------------------------------------------------------------------------------------------------
205 Property Get Name() As String
206 Name = _PropertyGet(&quot;Name&quot;)
207 End Property &apos; Name (get)
209 Public Function pName() As String &apos; For compatibility with &lt; V0.9.0
210 pName = _PropertyGet(&quot;Name&quot;)
211 End Function &apos; pName (get)
213 REM -----------------------------------------------------------------------------------------------------------------------
214 Property Get ObjectType() As String
215 ObjectType = _PropertyGet(&quot;ObjectType&quot;)
216 End Property &apos; ObjectType (get)
218 REM -----------------------------------------------------------------------------------------------------------------------
219 Property Get OnApproveCursorMove() As Variant
220 OnApproveCursorMove = _PropertyGet(&quot;OnApproveCursorMove&quot;)
221 End Property &apos; OnApproveCursorMove (get)
223 Property Let OnApproveCursorMove(ByVal pvValue As Variant)
224 Call _PropertySet(&quot;OnApproveCursorMove&quot;, pvValue)
225 End Property &apos; OnApproveCursorMove (set)
227 REM -----------------------------------------------------------------------------------------------------------------------
228 Property Get OnApproveParameter() As Variant
229 OnApproveParameter = _PropertyGet(&quot;OnApproveParameter&quot;)
230 End Property &apos; OnApproveParameter (get)
232 Property Let OnApproveParameter(ByVal pvValue As Variant)
233 Call _PropertySet(&quot;OnApproveParameter&quot;, pvValue)
235 End Property &apos; OnApproveParameter (set)
237 REM -----------------------------------------------------------------------------------------------------------------------
238 Property Get OnApproveReset() As Variant
239 OnApproveReset = _PropertyGet(&quot;OnApproveReset&quot;)
240 End Property &apos; OnApproveReset (get)
242 Property Let OnApproveReset(ByVal pvValue As Variant)
243 Call _PropertySet(&quot;OnApproveReset&quot;, pvValue)
244 End Property &apos; OnApproveReset (set)
246 REM -----------------------------------------------------------------------------------------------------------------------
247 Property Get OnApproveRowChange() As Variant
248 OnApproveRowChange = _PropertyGet(&quot;OnApproveRowChange&quot;)
249 End Property &apos; OnApproveRowChange (get)
251 Property Let OnApproveRowChange(ByVal pvValue As Variant)
252 Call _PropertySet(&quot;OnApproveRowChange&quot;, pvValue)
253 End Property &apos; OnApproveRowChange (set)
255 REM -----------------------------------------------------------------------------------------------------------------------
256 Property Get OnApproveSubmit() As Variant
257 OnApproveSubmit = _PropertyGet(&quot;OnApproveSubmit&quot;)
258 End Property &apos; OnApproveSubmit (get)
260 Property Let OnApproveSubmit(ByVal pvValue As Variant)
261 Call _PropertySet(&quot;OnApproveSubmit&quot;, pvValue)
262 End Property &apos; OnApproveSubmit (set)
264 REM -----------------------------------------------------------------------------------------------------------------------
265 Property Get OnConfirmDelete() As Variant
266 OnConfirmDelete = _PropertyGet(&quot;OnConfirmDelete&quot;)
267 End Property &apos; OnConfirmDelete (get)
269 Property Let OnConfirmDelete(ByVal pvValue As Variant)
270 Call _PropertySet(&quot;OnConfirmDelete&quot;, pvValue)
271 End Property &apos; OnConfirmDelete (set)
273 REM -----------------------------------------------------------------------------------------------------------------------
274 Property Get OnCursorMoved() As Variant
275 OnCursorMoved = _PropertyGet(&quot;OnCursorMoved&quot;)
276 End Property &apos; OnCursorMoved (get)
278 Property Let OnCursorMoved(ByVal pvValue As Variant)
279 Call _PropertySet(&quot;OnCursorMoved&quot;, pvValue)
280 End Property &apos; OnCursorMoved (set)
282 REM -----------------------------------------------------------------------------------------------------------------------
283 Property Get OnErrorOccurred() As Variant
284 OnErrorOccurred = _PropertyGet(&quot;OnErrorOccurred&quot;)
285 End Property &apos; OnErrorOccurred (get)
287 Property Let OnErrorOccurred(ByVal pvValue As Variant)
288 Call _PropertySet(&quot;OnErrorOccurred&quot;, pvValue)
289 End Property &apos; OnErrorOccurred (set)
291 REM -----------------------------------------------------------------------------------------------------------------------
292 Property Get OnLoaded() As Variant
293 OnLoaded = _PropertyGet(&quot;OnLoaded&quot;)
294 End Property &apos; OnLoaded (get)
296 Property Let OnLoaded(ByVal pvValue As Variant)
297 Call _PropertySet(&quot;OnLoaded&quot;, pvValue)
298 End Property &apos; OnLoaded (set)
300 REM -----------------------------------------------------------------------------------------------------------------------
301 Property Get OnReloaded() As Variant
302 OnReloaded = _PropertyGet(&quot;OnReloaded&quot;)
303 End Property &apos; OnReloaded (get)
305 Property Let OnReloaded(ByVal pvValue As Variant)
306 Call _PropertySet(&quot;OnReloaded&quot;, pvValue)
307 End Property &apos; OnReloaded (set)
309 REM -----------------------------------------------------------------------------------------------------------------------
310 Property Get OnReloading() As Variant
311 OnReloading = _PropertyGet(&quot;OnReloading&quot;)
312 End Property &apos; OnReloading (get)
314 Property Let OnReloading(ByVal pvValue As Variant)
315 Call _PropertySet(&quot;OnReloading&quot;, pvValue)
316 End Property &apos; OnReloading (set)
318 REM -----------------------------------------------------------------------------------------------------------------------
319 Property Get OnResetted() As Variant
320 OnResetted = _PropertyGet(&quot;OnResetted&quot;)
321 End Property &apos; OnResetted (get)
323 Property Let OnResetted(ByVal pvValue As Variant)
324 Call _PropertySet(&quot;OnResetted&quot;, pvValue)
325 End Property &apos; OnResetted (set)
327 REM -----------------------------------------------------------------------------------------------------------------------
328 Property Get OnRowChanged() As Variant
329 OnRowChanged = _PropertyGet(&quot;OnRowChanged&quot;)
330 End Property &apos; OnRowChanged (get)
332 Property Let OnRowChanged(ByVal pvValue As Variant)
333 Call _PropertySet(&quot;OnRowChanged&quot;, pvValue)
334 End Property &apos; OnRowChanged (set)
336 REM -----------------------------------------------------------------------------------------------------------------------
337 Property Get OnUnloaded() As Variant
338 OnUnloaded = _PropertyGet(&quot;OnUnloaded&quot;)
339 End Property &apos; OnUnloaded (get)
341 Property Let OnUnloaded(ByVal pvValue As Variant)
342 Call _PropertySet(&quot;OnUnloaded&quot;, pvValue)
343 End Property &apos; OnUnloaded (set)
345 REM -----------------------------------------------------------------------------------------------------------------------
346 Property Get OnUnloading() As Variant
347 OnUnloading = _PropertyGet(&quot;OnUnloading&quot;)
348 End Property &apos; OnUnloading (get)
350 Property Let OnUnloading(ByVal pvValue As Variant)
351 Call _PropertySet(&quot;OnUnloading&quot;, pvValue)
352 End Property &apos; OnUnloading (set)
354 REM -----------------------------------------------------------------------------------------------------------------------
355 Property Get OpenArgs() As Variant
356 OpenArgs = _PropertyGet(&quot;OpenArgs&quot;)
357 End Property &apos; OpenArgs (get)
359 REM -----------------------------------------------------------------------------------------------------------------------
360 Property Get OrderBy() As Variant
361 OrderBy = _PropertyGet(&quot;OrderBy&quot;)
362 End Property &apos; OrderBy (get) V1.2.0
364 Property Let OrderBy(ByVal pvValue As Variant)
365 Call _PropertySet(&quot;OrderBy&quot;, pvValue)
366 End Property &apos; OrderBy (set)
368 REM -----------------------------------------------------------------------------------------------------------------------
369 Property Get OrderByOn() As Variant
370 OrderByOn = _PropertyGet(&quot;OrderByOn&quot;)
371 End Property &apos; OrderByOn (get) V1.2.0
373 Property Let OrderByOn(ByVal pvValue As Variant)
374 Call _PropertySet(&quot;OrderByOn&quot;, pvValue)
375 End Property &apos; OrderByOn (set)
377 REM -----------------------------------------------------------------------------------------------------------------------
378 Public Function OptionGroup(ByVal Optional pvGroupName As Variant) As Variant
379 &apos; Return either an error or an object of type OPTIONGROUP based on its name
381 Const cstThisSub = &quot;Form.OptionGroup&quot;
382 Dim ogGroup As Object
383 Utils._SetCalledSub(cstThisSub)
384 If IsMissing(pvGroupName) Then Call _TraceArguments()
385 If _ErrorHandler() Then On Local Error Goto Error_Function
387 Set ogGroup = _OptionGroup(pvGroupName, CTLPARENTISFORM, Component, FormsCollection)
388 If Not IsNull(ogGroup) Then
389 ogGroup._DocEntry = _DocEntry
390 ogGroup._DbEntry = _DbEntry
391 End If
392 Set OptionGroup = ogGroup
394 Exit_Function:
395 Utils._ResetCalledSub(cstThisSub)
396 Exit Function
397 Error_Function:
398 TraceError(TRACEABORT, Err, Form.OptionGroup, Erl)
399 GoTo Exit_Function
400 End Function &apos; OptionGroup V1.1.0
402 REM -----------------------------------------------------------------------------------------------------------------------
403 Public Function Parent() As Object
404 Parent = _Parent
405 End Function &apos; Parent (get) V6.4.0
407 REM -----------------------------------------------------------------------------------------------------------------------
408 Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
409 &apos; Return
410 &apos; a Collection object if pvIndex absent
411 &apos; a Property object otherwise
413 Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String
414 vPropertiesList = _PropertiesList()
415 sObject = Utils._PCase(_Type)
416 If IsMissing(pvIndex) Then
417 vProperty = PropertiesGet._Properties(sObject, _This, vPropertiesList)
418 Else
419 vProperty = PropertiesGet._Properties(sObject, _This, vPropertiesList, pvIndex)
420 vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
421 End If
423 Exit_Function:
424 Set Properties = vProperty
425 Exit Function
426 End Function &apos; Properties
428 REM -----------------------------------------------------------------------------------------------------------------------
429 Property Get Recordset() As Object
430 Recordset = _PropertyGet(&quot;Recordset&quot;)
431 End Property &apos; Recordset (get) V0.9.5
433 REM -----------------------------------------------------------------------------------------------------------------------
434 Property Get RecordSource() As Variant
435 RecordSource = _PropertyGet(&quot;RecordSource&quot;)
436 End Property &apos; RecordSource (get)
438 Property Let RecordSource(ByVal pvValue As Variant)
439 Call _PropertySet(&quot;RecordSource&quot;, pvValue)
440 End Property &apos; RecordSource (set)
442 REM -----------------------------------------------------------------------------------------------------------------------
443 Property Get Visible() As Variant
444 Visible = _PropertyGet(&quot;Visible&quot;)
445 End Property &apos; Visible (get)
447 Property Let Visible(ByVal pvValue As Variant)
448 Call _PropertySet(&quot;Visible&quot;, pvValue)
449 End Property &apos; Visible (set)
451 REM -----------------------------------------------------------------------------------------------------------------------
452 Property Get Width() As Variant
453 Width = _PropertyGet(&quot;Width&quot;)
454 End Property &apos; Width (get)
456 Property Let Width(ByVal pvValue As Variant)
457 Call _PropertySet(&quot;Width&quot;, pvValue)
458 End Property &apos; Width (set)
460 REM -----------------------------------------------------------------------------------------------------------------------
461 REM --- CLASS METHODS ---
462 REM -----------------------------------------------------------------------------------------------------------------------
464 Public Function mClose() As Variant
465 &apos; Close the form
467 If _ErrorHandler() Then On Local Error Goto Error_Function
468 Utils._SetCalledSub(&quot;Form.Close&quot;)
469 mClose = False
470 Dim oDatabase As Object, oController As Object
471 Set oDatabase = Application._CurrentDb()
472 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
474 Set oController = oDatabase.Document.getFormDocuments.getByHierarchicalName(_Name)
475 oController.close()
476 Dispose()
477 mClose = True
479 Exit_Function:
480 Utils._ResetCalledSub(&quot;Form.Close&quot;)
481 Exit Function
482 Error_NotApplicable:
483 TraceError(TRACEFATAL, ERRMETHOD, Utils._CalledSub(), 0, 1, cstThisSub)
484 Goto Exit_Function
485 Error_Function:
486 TraceError(TRACEABORT, Err, &quot;Form.Close&quot;, Erl)
487 GoTo Exit_Function
488 End Function &apos; Close
490 REM -----------------------------------------------------------------------------------------------------------------------
491 Public Function Controls(Optional ByVal pvIndex As Variant) As Variant
492 &apos; Return a Control object with name or index = pvIndex
494 If _ErrorHandler() Then On Local Error Goto Error_Function
495 Utils._SetCalledSub(&quot;Form.Controls&quot;)
497 Dim ocControl As Variant, iControlCount As Integer
498 Dim oCounter As Variant, sControls() As Variant, i As Integer, bFound As Boolean, sIndex As String
499 Dim j As Integer, iCount As Integer, sName As String, iAddCount As Integer
500 Dim oDatabaseForm As Object, iCtlCount As Integer
502 Set ocControl = Nothing
503 If Not IsLoaded Then Goto Trace_Error_NotOpen
504 &apos;Count number of controls thru the forms collection
505 iControlCount = 0
507 iCount = FormsCollection.Count
508 For i = 0 To iCount - 1
509 If i = 0 Then Set oDatabaseForm = DatabaseForm Else Set oDatabaseForm = FormsCollection.getByIndex(i)
510 If Not IsNull(oDatabaseForm) Then iControlCount = iControlCount + oDatabaseForm.getCount()
511 Next i
513 If IsMissing(pvIndex) Then &apos; No argument, return Collection pseudo-object
514 Set oCounter = New Collect
515 Set oCounter._This = oCounter
516 oCounter._CollType = COLLCONTROLS
517 Set oCounter._Parent = _This
518 oCounter._Count = iControlCount
519 Set Controls = oCounter
520 Goto Exit_Function
521 End If
523 If Not Utils._CheckArgument(pvIndex, 1, Utils._AddNumeric(vbString)) Then Goto Exit_Function
525 &apos; Start building the ocControl object
526 &apos; Determine exact name
528 sName = &quot;&quot;
529 Select Case VarType(pvIndex)
530 Case vbInteger, vbLong, vbSingle, vbDouble, vbCurrency, vbBigint, vbDecimal
531 If pvIndex &lt; 0 Or pvIndex &gt; iControlCount - 1 Then Goto Trace_Error_Index
532 iAddCount = 0
533 For i = 0 To iCount - 1
534 If i = 0 Then Set oDatabaseForm = DatabaseForm Else Set oDatabaseForm = FormsCollection.getByIndex(i)
535 If Not IsNull(oDatabaseForm) Then
536 iCtlCount = oDatabaseForm.getCount()
537 If pvIndex &gt;= iAddCount And pvIndex &lt;= iAddcount + iCtlCount - 1 Then
538 sName = oDatabaseForm.ElementNames(pvIndex - iAddCount)
539 Exit For
540 End If
541 iAddCount = iAddcount +iCtlCount
542 End If
543 Next i
544 Case vbString &apos; Check control name validity (non case sensitive)
545 sIndex = UCase(Utils._Trim(pvIndex))
546 bFound = False
547 For i = 0 To iCount - 1
548 If i = 0 Then Set oDatabaseForm = DatabaseForm Else Set oDatabaseForm = FormsCollection.getByIndex(i)
549 If Not IsNull(oDatabaseForm) Then
550 sControls() = oDatabaseForm.getElementNames()
551 For j = 0 To UBound(sControls)
552 If UCase(sControls(j)) = sIndex Then
553 sName = sControls(j)
554 bFound = True
555 Exit For
556 End If
557 Next j
558 If bFound Then Exit For
559 End If
560 Next i
561 If Not bFound Then Goto Trace_NotFound
562 End Select
564 &apos;Initialize a new Control object
565 Set ocControl = New Control
566 With ocControl
567 Set ._This = ocControl
568 Set ._Parent = _This
569 ._ParentType = CTLPARENTISFORM
570 ._Name = sName
571 ._Shortcut = _Shortcut &amp; &quot;!&quot; &amp; Utils._Surround(sName)
572 If IsNull(oDatabaseForm) Then ._MainForm = &quot;&quot; Else ._MainForm = oDatabaseForm.Name
573 Set .ControlModel = oDatabaseForm.getByName(sName)
574 ._ImplementationName = .ControlModel.getImplementationName()
575 ._FormComponent = Component
576 If Utils._hasUNOProperty(.ControlModel, &quot;ClassId&quot;) Then ._ClassId = .ControlModel.ClassId
577 If ._ClassId &gt; 0 And ._ClassId &lt;&gt; acHiddenControl Then
578 Set .ControlView = Component.CurrentController.getControl(.ControlModel)
579 End If
581 ._Initialize()
582 ._DocEntry = _DocEntry
583 ._DbEntry = _DbEntry
584 End With
585 Set Controls = ocControl
587 Exit_Function:
588 Utils._ResetCalledSub(&quot;Form.Controls&quot;)
589 Exit Function
590 Trace_Error_NotOpen:
591 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(), 0, , _Name)
592 Set Controls = Nothing
593 Goto Exit_Function
594 Trace_Error_Index:
595 TraceError(TRACEFATAL, ERRCOLLECTION, Utils._CalledSub(), 0, 1)
596 Set Controls = Nothing
597 Goto Exit_Function
598 Trace_NotFound:
599 TraceError(TRACEFATAL, ERRCONTROLNOTFOUND, Utils._CalledSub(), 0, , Array(pvIndex, pvIndex))
600 Set Controls = Nothing
601 Goto Exit_Function
602 Error_Function:
603 TraceError(TRACEABORT, Err, &quot;Form.Controls&quot;, Erl)
604 Set Controls = Nothing
605 GoTo Exit_Function
606 End Function &apos; Controls
608 REM -----------------------------------------------------------------------------------------------------------------------
609 Public Function CurrentDb() As Object
610 &apos; Returns Database object related to current form
612 Const cstThisSub = &quot;Form.CurrentDb&quot;
613 Utils._SetCalledSub(cstThisSub)
615 Set CurrentDb = Application._CurrentDb(_DocEntry, _DbEntry)
617 Exit_Function:
618 Utils._ResetCalledSub(cstThisSub)
619 Exit Function
620 End Function &apos; CurrentDb V1.1.0
622 REM -----------------------------------------------------------------------------------------------------------------------
623 Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
624 &apos; Return property value of psProperty property name
626 Utils._SetCalledSub(&quot;Form.getProperty&quot;)
627 If IsMissing(pvProperty) Then Call _TraceArguments()
628 getProperty = _PropertyGet(pvProperty)
629 Utils._ResetCalledSub(&quot;Form.getProperty&quot;)
631 End Function &apos; getProperty
633 REM -----------------------------------------------------------------------------------------------------------------------
634 Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
635 &apos; Return True if object has a valid property called pvProperty (case-insensitive comparison !)
637 If IsMissing(pvProperty) Then hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList()) Else hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList(), pvProperty)
638 Exit Function
640 End Function &apos; hasProperty
642 REM -----------------------------------------------------------------------------------------------------------------------
643 Public Function Move( ByVal Optional pvLeft As Variant _
644 , ByVal Optional pvTop As Variant _
645 , ByVal Optional pvWidth As Variant _
646 , ByVal Optional pvHeight As Variant _
647 ) As Variant
648 &apos; Execute Move method
649 Utils._SetCalledSub(&quot;Form.Move&quot;)
650 If _ErrorHandler() Then On Local Error Goto Error_Function
651 Move = False
652 Dim iArgNr As Integer
653 Select Case UCase(_A2B_.CalledSub)
654 Case UCase(&quot;Move&quot;) : iArgNr = 1
655 Case UCase(&quot;Form.Move&quot;) : iArgNr = 0
656 End Select
657 If IsMissing(pvLeft) Then pvLeft = -1
658 If IsMissing(pvTop) Then pvTop = -1
659 If IsMissing(pvWidth) Then pvWidth = -1
660 If IsMissing(pvHeight) Then pvHeight = -1
661 If Not Utils._CheckArgument(pvLeft, iArgNr + 1, Utils._AddNumeric()) Then Goto Exit_Function
662 If Not Utils._CheckArgument(pvTop, iArgNr + 2, Utils._AddNumeric()) Then Goto Exit_Function
663 If Not Utils._CheckArgument(pvWidth, iArgNr + 3, Utils._AddNumeric()) Then Goto Exit_Function
664 If Not Utils._CheckArgument(pvHeight, iArgNr + 4, Utils._AddNumeric()) Then Goto Exit_Function
666 Dim iArg As Integer, iWrong As Integer &apos; Check arguments values
667 iArg = 0
668 If pvHeight &lt; -1 Then
669 iArg = 4 : iWrong = pvHeight
670 ElseIf pvWidth &lt; -1 Then
671 iArg = 3 : iWrong = pvWidth
672 ElseIf pvTop &lt; -1 Then
673 iArg = 2 : iWrong = pvTop
674 ElseIf pvLeft &lt; -1 Then
675 iArg = 1 : iWrong = pvLeft
676 End If
677 If iArg &gt; 0 Then
678 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, 1, Array(iArgNr + iArg, iWrong))
679 Goto Exit_Function
680 End If
682 Dim iPosSize As Integer
683 iPosSize = 0
684 If pvLeft &gt;= 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.X
685 If pvTop &gt;= 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.Y
686 If pvWidth &gt; 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.WIDTH
687 If pvHeight &gt; 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.HEIGHT
688 If iPosSize &gt; 0 Then
689 If Utils._hasUNOProperty(ContainerWindow, &quot;IsMaximized&quot;) Then &apos; Ignored when &lt;= OO3.2
690 ContainerWindow.IsMaximized = False
691 ContainerWindow.IsMinimized = False
692 End If
693 ContainerWindow.setPosSize(pvLeft, pvTop, pvWidth, pvHeight, iPosSize)
694 End If
695 Move = True
697 Exit_Function:
698 Utils._ResetCalledSub(&quot;Form.Move&quot;)
699 Exit Function
700 Error_Function:
701 TraceError(TRACEABORT, Err, &quot;Form.Move&quot;, Erl)
702 GoTo Exit_Function
703 End Function &apos; Move
705 REM -----------------------------------------------------------------------------------------------------------------------
706 Public Function Refresh() As Boolean
707 &apos; Refresh data with its most recent value in the database in a form or subform
708 Utils._SetCalledSub(&quot;Form.Refresh&quot;)
709 If _ErrorHandler() Then On Local Error Goto Error_Function
710 Refresh = False
712 Dim oSet As Object
713 Set oSet = DatabaseForm.createResultSet()
714 If Not IsNull(oSet) Then
715 oSet.refreshRow()
716 Refresh = True
717 End If
719 Exit_Function:
720 Set oSet = Nothing
721 Utils._ResetCalledSub(&quot;Form.Refresh&quot;)
722 Exit Function
723 Error_Function:
724 TraceError(TRACEABORT, Err, &quot;SubForm.Refresh&quot;, Erl)
725 GoTo Exit_Function
726 End Function &apos; Refresh
728 REM -----------------------------------------------------------------------------------------------------------------------
729 Public Function Requery() As Boolean
730 &apos; Refresh data displayed in a form, subform, combobox or listbox
731 Utils._SetCalledSub(&quot;Form.Requery&quot;)
732 If _ErrorHandler() Then On Local Error Goto Error_Function
733 Requery = False
735 DatabaseForm.reload()
736 Requery = True
738 Exit_Function:
739 Utils._ResetCalledSub(&quot;Form.Requery&quot;)
740 Exit Function
741 Error_Function:
742 TraceError(TRACEABORT, Err, &quot;Form.Requery&quot;, Erl)
743 GoTo Exit_Function
744 End Function &apos; Requery
746 REM -----------------------------------------------------------------------------------------------------------------------
747 Public Function setFocus() As Boolean
748 &apos; Execute setFocus method
749 Const cstThisSub = &quot;Form.setFocus&quot;
750 Utils._SetCalledSub(cstThisSub)
751 If _ErrorHandler() Then On Local Error Goto Error_Function
752 setFocus = False
754 With ContainerWindow
755 If .isVisible() = False Then .setVisible(True)
756 .IsMinimized = False
757 .setFocus()
758 .setEnable(True) &apos; Added to try to bypass desynchro issue in Linux
759 .toFront() &apos; Added to force window change in Linux
760 End With
761 setFocus = True
763 Exit_Function:
764 Utils._ResetCalledSub(cstThisSub)
765 Exit Function
766 Error_Function:
767 TraceError(TRACEABORT, Err, cstThisSub, Erl)
768 Goto Exit_Function
769 End Function &apos; setFocus V1.1.0
771 REM -----------------------------------------------------------------------------------------------------------------------
772 Public Function setProperty(ByVal Optional psProperty As String, ByVal Optional pvValue As Variant) As Boolean
773 &apos; Return True if property setting OK
774 Utils._SetCalledSub(&quot;Form.setProperty&quot;)
775 setProperty = _PropertySet(psProperty, pvValue)
776 Utils._ResetCalledSub(&quot;Form.setProperty&quot;)
777 End Function
779 REM -----------------------------------------------------------------------------------------------------------------------
780 REM --- PRIVATE FUNCTIONS ---
781 REM -----------------------------------------------------------------------------------------------------------------------
783 REM -----------------------------------------------------------------------------------------------------------------------
784 Private Function _GetListener(ByVal psProperty As String) As String
785 &apos; Return the X...Listener corresponding with the property in argument
787 Select Case UCase(psProperty)
788 Case UCase(&quot;OnApproveCursorMove&quot;)
789 _GetListener = &quot;XRowSetApproveListener&quot;
790 Case UCase(&quot;OnApproveParameter&quot;)
791 _GetListener = &quot;XDatabaseParameterListener&quot;
792 Case UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnResetted&quot;)
793 _GetListener = &quot;XResetListener&quot;
794 Case UCase(&quot;OnApproveRowChange&quot;)
795 _GetListener = &quot;XRowSetApproveListener&quot;
796 Case UCase(&quot;OnApproveSubmit&quot;)
797 _GetListener = &quot;XSubmitListener&quot;
798 Case UCase(&quot;OnConfirmDelete&quot;)
799 _GetListener = &quot;XConfirmDeleteListener&quot;
800 Case UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnRowChanged&quot;)
801 _GetListener = &quot;XRowSetListener&quot;
802 Case UCase(&quot;OnErrorOccurred&quot;)
803 _GetListener = &quot;XSQLErrorListener&quot;
804 Case UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
805 _GetListener = &quot;XLoadListener&quot;
806 End Select
808 End Function &apos; _GetListener V1.7.0
810 REM -----------------------------------------------------------------------------------------------------------------------
811 Public Sub _Initialize(psName As String)
812 &apos; Set pointers to UNO objects
814 Dim oDoc As Object, oDatabase As Object
815 If _ErrorHandler() Then On Local Error Goto Trace_Error
816 _Name = psName
817 _Shortcut = &quot;Forms!&quot; &amp; Utils._Surround(psName)
818 Set oDoc = _A2B_.CurrentDocument()
819 If oDoc.DbConnect = DBCONNECTBASE Then _PersistentName = oDoc.Document.getFormDocuments().getByHierarchicalName(psName).PersistentName
820 If IsLoaded Then
821 Select Case oDoc.DbConnect
822 Case DBCONNECTBASE
823 If Not IsNull(Component.CurrentController) Then &apos; A form opened then closed afterwards keeps a Component attribute
824 Set ContainerWindow = Component.CurrentController.Frame.ContainerWindow
825 Set FormsCollection = Component.getDrawPage.Forms
826 If FormsCollection.Count = 0 Then
827 Set DatabaseForm = Nothing
828 Else
829 &apos;Only first member of the collection can be reached with A2B
830 &apos;Compliant with MSAccess which has 1 datasource by form, while LO might have many
831 _MainForms = FormsCollection.ElementNames()
832 Set DatabaseForm = FormsCollection.getByIndex(0)
833 End If
834 End If
835 Case DBCONNECTFORM
836 Set ContainerWindow = oDoc.Document.CurrentController.Frame.ContainerWindow
837 Set FormsCollection = oDoc.Document.getDrawPage.Forms
838 Set oDatabase = Application._CurrentDb(_DocEntry, _DbEntry)
839 With oDatabase
840 Set DatabaseForm = .Form
841 If IsNull(.Connection) Then
842 Set .Connection = DatabaseForm.ActiveConnection
843 If Not IsNull(.Connection) Then
844 Set .MetaData = .Connection.MetaData
845 oDatabase._ReadOnly = .Connection.isReadOnly()
846 End If
847 End If
848 End With
849 End Select
850 If IsNull(DatabaseForm) Then _OrderBy = &quot;&quot; Else _OrderBy = DatabaseForm.Order
851 Else
852 Set Component = Nothing
853 Set ContainerWindow = Nothing
854 Set DatabaseForm = Nothing
855 End If
857 Exit_Sub:
858 Exit Sub
859 Trace_Error:
860 TraceError(TRACEABORT, Err, &quot;Form.Initialize&quot;, Erl)
861 Goto Exit_Sub
862 Trace_Internal_Error:
863 TraceError(TRACEABORT, ERRFORMNOTIDENTIFIED, Utils._CalledSub(), 0, , _Name)
864 Goto Exit_Sub
865 End Sub &apos; _Initialize V1.1.0
867 REM -----------------------------------------------------------------------------------------------------------------------
868 Private Function _PropertiesList() As Variant
870 If _IsLoaded Then
871 _PropertiesList = Array(&quot;AllowAdditions&quot;, &quot;AllowDeletions&quot;, &quot;AllowEdits&quot;, &quot;Bookmark&quot; _
872 , &quot;Caption&quot;, &quot;CurrentRecord&quot;, &quot;Filter&quot;, &quot;FilterOn&quot;, &quot;Height&quot;, &quot;IsLoaded&quot; _
873 , &quot;Name&quot;, &quot;ObjectType&quot;, &quot;OnApproveCursorMove&quot;, &quot;OnApproveParameter&quot; _
874 , &quot;OnApproveReset&quot;, &quot;OnApproveRowChange&quot;, &quot;OnApproveSubmit&quot;, &quot;OnConfirmDelete&quot; _
875 , &quot;OnCursorMoved&quot;, &quot;OnErrorOccurred&quot;, &quot;OnLoaded&quot;, &quot;OnReloaded&quot;, &quot;OnReloading&quot; _
876 , &quot;OnResetted&quot;, &quot;OnRowChanged&quot;, &quot;OnUnloaded&quot;, &quot;OnUnloading&quot;, &quot;OpenArgs&quot; _
877 , &quot;OrderBy&quot;, &quot;OrderByOn&quot;, &quot;RecordSource&quot;, &quot;Visible&quot;, &quot;Width&quot; _
878 ) &apos; Recordset removed
879 Else
880 _PropertiesList = Array(&quot;IsLoaded&quot;, &quot;Name&quot; _
882 End If
884 End Function &apos; _PropertiesList
886 REM -----------------------------------------------------------------------------------------------------------------------
887 Private Function _PropertyGet(ByVal psProperty As String) As Variant
888 &apos; Return property value of the psProperty property name
890 If _ErrorHandler() Then On Local Error Goto Error_Function
891 Utils._SetCalledSub(&quot;Form.get&quot; &amp; psProperty)
893 &apos;Execute
894 Dim oDatabase As Object, vBookmark As Variant
895 Dim i As Integer, oObject As Object
897 _PropertyGet = EMPTY
899 Select Case UCase(psProperty)
900 Case UCase(&quot;Name&quot;), UCase(&quot;IsLoaded&quot;)
901 Case Else : If Not IsLoaded Then Goto Trace_Error_Form
902 End Select
904 Select Case UCase(psProperty)
905 Case UCase(&quot;AllowAdditions&quot;)
906 If IsNull(DatabaseForm) Then _PropertyGet = False Else _PropertyGet = DatabaseForm.AllowInserts
907 Case UCase(&quot;AllowDeletions&quot;)
908 If IsNull(DatabaseForm) Then _PropertyGet = False Else _PropertyGet = DatabaseForm.AllowDeletes
909 Case UCase(&quot;AllowEdits&quot;)
910 If IsNull(DatabaseForm) Then _PropertyGet = False Else _PropertyGet = DatabaseForm.AllowUpdates
911 Case UCase(&quot;Bookmark&quot;)
912 If IsNull(DatabaseForm) Then
913 _PropertyGet = 0
914 Else
915 On Local Error Resume Next &apos; Disable error handler because bookmarking does not always react well in events ...
916 If DatabaseForm.IsBookmarkable Then vBookmark = DatabaseForm.getBookmark() Else vBookmark = Nothing
917 If _ErrorHandler() Then On Local Error Goto Error_Function Else On Local Error Goto 0
918 If IsNull(vBookmark) Then Goto Trace_Error
919 _PropertyGet = vBookmark
920 End If
921 Case UCase(&quot;Caption&quot;)
922 Set odatabase = Application._CurrentDb(_DocEntry, _DbEntry)
923 Select Case oDatabase._DbConnect
924 Case DBCONNECTFORM : _PropertyGet = oDatabase.Document.CurrentController.Frame.Title
925 Case DBCONNECTBASE : _PropertyGet = Component.CurrentController.Frame.Title
926 End Select
927 Case UCase(&quot;CurrentRecord&quot;)
928 If IsNull(DatabaseForm) Then _PropertyGet = 0 Else _PropertyGet = DatabaseForm.Row
929 Case UCase(&quot;Filter&quot;)
930 If IsNull(DatabaseForm) Then _PropertyGet = &quot;&quot; Else _PropertyGet = DatabaseForm.Filter
931 Case UCase(&quot;FilterOn&quot;)
932 If IsNull(DatabaseForm) Then _PropertyGet = False Else _PropertyGet = DatabaseForm.ApplyFilter
933 Case UCase(&quot;Height&quot;)
934 _PropertyGet = ContainerWindow.getPosSize().Height
935 Case UCase(&quot;IsLoaded&quot;) &apos; Only for indirect access from property object
936 _PropertyGet = IsLoaded
937 Case UCase(&quot;Name&quot;)
938 _PropertyGet = _Name
939 Case UCase(&quot;ObjectType&quot;)
940 _PropertyGet = _Type
941 Case UCase(&quot;OnApproveCursorMove&quot;), UCase(&quot;OnApproveParameter&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveRowChange&quot;) _
942 , UCase(&quot;OnApproveSubmit&quot;), UCase(&quot;OnConfirmDelete&quot;), UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnErrorOccurred&quot;) _
943 , UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnResetted&quot;), UCase(&quot;OnRowChanged&quot;) _
944 , UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
945 If IsNull(DatabaseForm) Then _PropertyGet = &quot;&quot; Else _PropertyGet = Utils._GetEventScriptCode(DatabaseForm, psProperty, _Name, True)
946 Case UCase(&quot;OpenArgs&quot;)
947 _PropertyGet = _OpenArgs
948 Case UCase(&quot;OrderBy&quot;)
949 _PropertyGet = _OrderBy
950 Case UCase(&quot;OrderByOn&quot;)
951 If IsNull(DatabaseForm) Then _PropertyGet = False Else _PropertyGet = ( DatabaseForm.Order &lt;&gt; &quot;&quot; )
952 Case UCase(&quot;Recordset&quot;)
953 If IsNull(DatabaseForm) Then Goto Trace_Error
954 If DatabaseForm.Command = &quot;&quot; Then Goto Trace_Error &apos; No underlying data ??
955 Set oObject = New Recordset
956 With DatabaseForm
957 oObject._This = oObject
958 oObject._CommandType = .CommandType
959 oObject._Command = .Command
960 oObject._ParentName = _Name
961 oObject._ParentType = _Type
962 Set oDatabase = Application._CurrentDb(_DocEntry, _DbEntry)
963 Set oObject._ParentDatabase = oDatabase
964 Set oObject._ParentDatabase.Connection = .ActiveConnection
965 oObject._ForwardOnly = ( .ResultSetType = com.sun.star.sdbc.ResultSetType.FORWARD_ONLY )
966 oObject._PassThrough = ( .EscapeProcessing = False )
967 oObject._ReadOnly = ( .ResultSetConcurrency = com.sun.star.sdbc.ResultSetConcurrency.READ_ONLY )
968 Call oObject._Initialize()
969 End With
970 With oDatabase
971 .RecordsetMax = .RecordsetMax + 1
972 oObject._Name = Format(.RecordsetMax, &quot;0000000&quot;)
973 .RecordsetsColl.Add(oObject, UCase(oObject._Name))
974 End With
975 If Not ( oObject._BOF And oObject._EOF ) Then oObject.MoveFirst() &apos; Do nothing if resultset empty
976 Set _PropertyGet = oObject
977 Case UCase(&quot;RecordSource&quot;)
978 If IsNull(DatabaseForm) Then _PropertyGet = &quot;&quot; Else _PropertyGet = DatabaseForm.Command
979 Case UCase(&quot;Visible&quot;)
980 _PropertyGet = ContainerWindow.IsVisible()
981 Case UCase(&quot;Width&quot;)
982 _PropertyGet = ContainerWindow.getPosSize().Width
983 Case Else
984 Goto Trace_Error
985 End Select
987 Exit_Function:
988 Utils._ResetCalledSub(&quot;Form.get&quot; &amp; psProperty)
989 Exit Function
990 Trace_Error:
991 TraceError(TRACEWARNING, ERRPROPERTY, Utils._CalledSub(), 0, 1, psProperty)
992 _PropertyGet = EMPTY
993 Goto Exit_Function
994 Trace_Error_Form:
995 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(), 0, 1, _Name)
996 _PropertyGet = EMPTY
997 Goto Exit_Function
998 Error_Function:
999 TraceError(TRACEABORT, Err, &quot;Form._PropertyGet&quot;, Erl)
1000 _PropertyGet = EMPTY
1001 GoTo Exit_Function
1002 End Function &apos; _PropertyGet
1004 REM -----------------------------------------------------------------------------------------------------------------------
1005 Private Function _PropertySet(ByVal psProperty As String, ByVal pvValue As Variant) As Boolean
1007 Utils._SetCalledSub(&quot;Form.set&quot; &amp; psProperty)
1008 If _ErrorHandler() Then On Local Error Goto Error_Function
1009 _PropertySet = True
1011 &apos;Execute
1012 Dim iArgNr As Integer, i As Integer
1013 Dim oDatabase As Object
1015 If _Isleft(_A2B_.CalledSub, &quot;Form.&quot;) Then iArgNr = 1 Else iArgNr = 2
1016 If Not IsLoaded Then Goto Trace_Error_Form
1018 Select Case UCase(psProperty)
1019 Case UCase(&quot;AllowAdditions&quot;)
1020 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
1021 If IsNull(DatabaseForm) Then Goto Trace_Error
1022 DatabaseForm.AllowInserts = pvValue
1023 DatabaseForm.reload()
1024 Case UCase(&quot;AllowDeletions&quot;)
1025 If Not Utils._CheckArgument(pvValue,iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
1026 If IsNull(DatabaseForm) Then Goto Trace_Error
1027 DatabaseForm.AllowDeletes = pvValue
1028 DatabaseForm.reload()
1029 Case UCase(&quot;AllowEdits&quot;)
1030 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
1031 If IsNull(DatabaseForm) Then Goto Trace_Error
1032 DatabaseForm.AllowUpdates = pvValue
1033 DatabaseForm.reload()
1034 Case UCase(&quot;Bookmark&quot;)
1035 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(vbObject), , False) Then Goto Trace_Error_Value
1036 If IsNull(pvValue) Then Goto Trace_Error_Value
1037 If IsNull(DatabaseForm) Then Goto Trace_Error
1038 DatabaseForm.MoveToBookmark(pvValue)
1039 Case UCase(&quot;Caption&quot;)
1040 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
1041 Set oDatabase = Application._CurrentDb(_DocEntry, _DbEntry)
1042 Select Case oDatabase._DbConnect
1043 Case DBCONNECTFORM : oDatabase.Document.CurrentController.Frame.Title = pvValue
1044 Case DBCONNECTBASE : Component.CurrentController.Frame.Title = pvValue
1045 End Select
1046 Case UCase(&quot;CurrentRecord&quot;)
1047 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
1048 If pvValue &lt; 1 Then Goto Trace_Error_Value
1049 If IsNull(DatabaseForm) Then Goto Trace_Error
1050 DatabaseForm.absolute(pvValue)
1051 Case UCase(&quot;Filter&quot;)
1052 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
1053 If IsNull(DatabaseForm) Then Goto Trace_Error
1054 DatabaseForm.Filter = Application._CurrentDb(_DocEntry, _DbEntry)._ReplaceSquareBrackets(pvValue)
1055 Case UCase(&quot;FilterOn&quot;)
1056 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
1057 If IsNull(DatabaseForm) Then Goto Trace_Error
1058 DatabaseForm.ApplyFilter = pvValue
1059 DatabaseForm.reload()
1060 Case UCase(&quot;Height&quot;)
1061 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
1062 If Utils._hasUNOProperty(ContainerWindow, &quot;IsMaximized&quot;) Then &apos; Ignored when &lt;= OO3.2
1063 ContainerWindow.IsMaximized = False
1064 ContainerWindow.IsMinimized = False
1065 End If
1066 ContainerWindow.setPosSize(0, 0, 0, pvValue, com.sun.star.awt.PosSize.HEIGHT)
1067 Case UCase(&quot;OnApproveCursorMove&quot;), UCase(&quot;OnApproveParameter&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveRowChange&quot;) _
1068 , UCase(&quot;OnApproveSubmit&quot;), UCase(&quot;OnConfirmDelete&quot;), UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnErrorOccurred&quot;) _
1069 , UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnResetted&quot;), UCase(&quot;OnRowChanged&quot;) _
1070 , UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
1071 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
1072 If IsNull(DatabaseForm) Then Goto Trace_Error
1073 If Not Utils._RegisterEventScript(DatabaseForm _
1074 , psProperty _
1075 , _GetListener(psProperty) _
1076 , pvValue, _Name, True _
1077 ) Then GoTo Trace_Error
1078 Case UCase(&quot;OrderBy&quot;)
1079 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
1080 If IsNull(DatabaseForm) Then Goto Trace_Error
1081 _OrderBy = Application._CurrentDb(_DocEntry, _DbEntry)._ReplaceSquareBrackets(pvValue)
1082 Case UCase(&quot;OrderByOn&quot;)
1083 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
1084 If IsNull(DatabaseForm) Then Goto Trace_Error
1085 If pvValue Then DatabaseForm.Order = _OrderBy Else DatabaseForm.Order = &quot;&quot;
1086 DatabaseForm.reload()
1087 Case UCase(&quot;RecordSource&quot;)
1088 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
1089 If IsNull(DatabaseForm) Then Goto Trace_Error
1090 DatabaseForm.Command = Application._CurrentDb(_DocEntry, _DbEntry)._ReplaceSquareBrackets(pvValue)
1091 DatabaseForm.CommandType = com.sun.star.sdb.CommandType.COMMAND
1092 DatabaseForm.Filter = &quot;&quot;
1093 DatabaseForm.reload()
1094 Case UCase(&quot;Visible&quot;)
1095 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
1096 ContainerWindow.setVisible(pvValue)
1097 Case UCase(&quot;Width&quot;)
1098 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric()) Then Goto Trace_Error_Value
1099 If Utils._hasUNOProperty(ContainerWindow, &quot;IsMaximized&quot;) Then &apos; Ignored when &lt;= OO3.2
1100 ContainerWindow.IsMaximized = False
1101 ContainerWindow.IsMinimized = False
1102 End If
1103 ContainerWindow.setPosSize(0, 0, pvValue, 0, com.sun.star.awt.PosSize.WIDTH)
1104 Case Else
1105 Goto Trace_Error
1106 End Select
1108 Exit_Function:
1109 Utils._ResetCalledSub(&quot;Form.set&quot; &amp; psProperty)
1110 Exit Function
1111 Trace_Error_Form:
1112 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(), 0, 1, _Name)
1113 _PropertySet = False
1114 Goto Exit_Function
1115 Trace_Error:
1116 TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(), 0, 1, psProperty)
1117 _PropertySet = False
1118 Goto Exit_Function
1119 Trace_Error_Value:
1120 TraceError(TRACEFATAL, ERRPROPERTYVALUE, Utils._CalledSub(), 0, 1, Array(pvValue, psProperty))
1121 _PropertySet = False
1122 Goto Exit_Function
1123 Error_Function:
1124 TraceError(TRACEABORT, Err, &quot;Form._PropertySet&quot;, Erl)
1125 _PropertySet = False
1126 GoTo Exit_Function
1127 End Function &apos; _PropertySet
1129 </script:module>