bump product version to 5.0.4.1
[LibreOffice.git] / wizards / source / access2base / Form.xba
blobbf0ab31d87f0460e370950f7872c4cae660489e1
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">REM =======================================================================================================================
4 REM === The Access2Base library is a part of the LibreOffice project. ===
5 REM === Full documentation is available on http://www.access2base.com ===
6 REM =======================================================================================================================
8 Option Compatible
9 Option ClassModule
11 Option Explicit
13 REM -----------------------------------------------------------------------------------------------------------------------
14 REM --- CLASS ROOT FIELDS ---
15 REM -----------------------------------------------------------------------------------------------------------------------
17 Private _Type As String &apos; Must be FORM
18 Private _Shortcut As String
19 Private _Name As String
20 Private _DocEntry As Integer &apos; Doc- and DbContainer entries in Root structure
21 Private _DbEntry As Integer
22 Private _IsLoaded As Boolean
23 Private _OpenArgs As Variant
24 Private _OrderBy As String
25 Public Component As Object &apos; com.sun.star.text.TextDocument
26 Public ContainerWindow As Object &apos; (No name)
27 Public DatabaseForm As Object &apos; com.sun.star.form.component.DataForm and com.sun.star.sdb.ResultSet (a.o.)
29 REM -----------------------------------------------------------------------------------------------------------------------
30 REM --- CONSTRUCTORS / DESTRUCTORS ---
31 REM -----------------------------------------------------------------------------------------------------------------------
32 Private Sub Class_Initialize()
33 _Type = OBJFORM
34 _Shortcut = &quot;&quot;
35 _Name = &quot;&quot;
36 _DocEntry = -1
37 _DbEntry = -1
38 _IsLoaded = False
39 _OpenArgs = &quot;&quot;
40 _OrderBy = &quot;&quot;
41 Set Component = Nothing
42 Set ContainerWindow = Nothing
43 Set DatabaseForm = Nothing
44 End Sub &apos; Constructor
46 REM -----------------------------------------------------------------------------------------------------------------------
47 Private Sub Class_Terminate()
48 On Local Error Resume Next
49 Call Class_Initialize()
50 End Sub &apos; Destructor
52 REM -----------------------------------------------------------------------------------------------------------------------
53 Public Sub Dispose()
54 Dim ofForm As Object
55 If Not IsLoaded(True) Then
56 If Not IsNull(DatabaseForm) Then DatabaseForm.Dispose()
57 End If
58 Call Class_Terminate()
59 End Sub &apos; Explicit destructor
61 REM -----------------------------------------------------------------------------------------------------------------------
62 REM --- CLASS GET/LET/SET PROPERTIES ---
63 REM -----------------------------------------------------------------------------------------------------------------------
64 Property Get AllowAdditions() As Variant
65 AllowAdditions = _PropertyGet(&quot;AllowAdditions&quot;)
66 End Property &apos; AllowAdditions (get)
68 Property Let AllowAdditions(ByVal pvValue As Variant)
69 Call _PropertySet(&quot;AllowAdditions&quot;, pvValue)
70 End Property &apos; AllowAdditions (set)
72 REM -----------------------------------------------------------------------------------------------------------------------
73 Property Get AllowDeletions() As Variant
74 AllowDeletions = _PropertyGet(&quot;AllowDeletions&quot;)
75 End Property &apos; AllowDeletions (get)
77 Property Let AllowDeletions(ByVal pvValue As Variant)
78 Call _PropertySet(&quot;AllowDeletions&quot;, pvValue)
79 End Property &apos; AllowDeletions (set)
81 REM -----------------------------------------------------------------------------------------------------------------------
82 Property Get AllowEdits() As Variant
83 AllowEdits = _PropertyGet(&quot;AllowEdits&quot;)
84 End Property &apos; AllowEdits (get)
86 Property Let AllowEdits(ByVal pvValue As Variant)
87 Call _PropertySet(&quot;AllowEdits&quot;, pvValue)
88 End Property &apos; AllowEdits (set)
90 REM -----------------------------------------------------------------------------------------------------------------------
91 Property Get Bookmark() As Variant
92 Bookmark = _PropertyGet(&quot;Bookmark&quot;)
93 End Property &apos; Bookmark (get)
95 Property Let Bookmark(ByVal pvValue As Variant)
96 Call _PropertySet(&quot;Bookmark&quot;, pvValue)
97 End Property &apos; Bookmark (set)
99 REM -----------------------------------------------------------------------------------------------------------------------
100 Property Get Caption() As Variant
101 Caption = _PropertyGet(&quot;Caption&quot;)
102 End Property &apos; Caption (get)
104 Property Let Caption(ByVal pvValue As Variant)
105 Call _PropertySet(&quot;Caption&quot;, pvValue)
106 End Property &apos; Caption (set)
108 REM -----------------------------------------------------------------------------------------------------------------------
109 Property Get CurrentRecord() As Variant
110 CurrentRecord = _PropertyGet(&quot;CurrentRecord&quot;)
111 End Property &apos; CurrentRecord (get)
113 Property Let CurrentRecord(ByVal pvValue As Variant)
114 Call _PropertySet(&quot;CurrentRecord&quot;, pvValue)
115 End Property &apos; CurrentRecord (set)
117 REM -----------------------------------------------------------------------------------------------------------------------
118 Property Get Filter() As Variant
119 Filter = _PropertyGet(&quot;Filter&quot;)
120 End Property &apos; Filter (get)
122 Property Let Filter(ByVal pvValue As Variant)
123 Call _PropertySet(&quot;Filter&quot;, pvValue)
124 End Property &apos; Filter (set)
126 REM -----------------------------------------------------------------------------------------------------------------------
127 Property Get FilterOn() As Variant
128 FilterOn = _PropertyGet(&quot;FilterOn&quot;)
129 End Property &apos; FilterOn (get)
131 Property Let FilterOn(ByVal pvValue As Variant)
132 Call _PropertySet(&quot;FilterOn&quot;, pvValue)
133 End Property &apos; FilterOn (set)
135 REM -----------------------------------------------------------------------------------------------------------------------
136 Property Get Height() As Variant
137 Height = _PropertyGet(&quot;Height&quot;)
138 End Property &apos; Height (get)
140 Property Let Height(ByVal pvValue As Variant)
141 Call _PropertySet(&quot;Height&quot;, pvValue)
142 End Property &apos; Height (set)
144 REM -----------------------------------------------------------------------------------------------------------------------
145 Function IsLoaded(ByVal Optional pbForce As Boolean) As Boolean
146 &apos;Return True if form open
147 &apos;pbForce = True forbids bypass on value of _IsLoaded
149 If _ErrorHandler() Then On Local Error Goto Error_Function
150 Utils._SetCalledSub(&quot;Form.getIsLoaded&quot;)
151 If IsMissing(pbForce) Then pbForce = False
152 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
153 IsLoaded = True
154 Goto Exit_Function
155 End If
156 IsLoaded = False
158 Dim oDoc As Object, oDatabase As Object, oEnum As Object, oDesk As Object, oComp As Object, bFound As Boolean
159 Dim i As Integer
160 Set oDoc = _A2B_.CurrentDocument()
161 Select Case oDoc.DbConnect
162 Case DBCONNECTBASE
163 Set oDesk = CreateUnoService(&quot;com.sun.star.frame.Desktop&quot;)
164 Set oEnum = oDesk.Components().createEnumeration
165 bFound = False
166 Do While oEnum.hasMoreElements And Not bFound &apos; Search in all open components if one corresponds with current form
167 oComp = oEnum.nextElement
168 If HasUnoInterfaces(oComp, &quot;com.sun.star.frame.XModule&quot;) Then
169 If oComp.Identifier = &quot;com.sun.star.sdb.FormDesign&quot; Then
170 For i = 0 To UBound(oComp.Args())
171 If oComp.Args(i).Name = &quot;DocumentTitle&quot; Then
172 bFound = ( oComp.Args(i).Value = _Name )
173 If bFound Then
174 _IsLoaded = True
175 Set Component = oComp
176 Exit For
177 End If
178 End If
179 Next i
180 End If
181 End If
182 Loop
183 Case DBCONNECTFORM
184 Set Component = oDoc.Document &apos; Form
185 _IsLoaded = True &apos; Interactive form always loaded by design
186 End Select
187 Set oComp = Nothing
188 IsLoaded = _IsLoaded
190 Exit_Function:
191 Utils._ResetCalledSub(&quot;Form.getIsLoaded&quot;)
192 Exit Function
193 Error_Function:
194 TraceError(TRACEABORT, Err, &quot;Form.getIsLoaded&quot;, Erl)
195 GoTo Exit_Function
196 End Function &apos; IsLoaded V1.1.0
198 REM -----------------------------------------------------------------------------------------------------------------------
199 Property Get Name() As String
200 Name = _PropertyGet(&quot;Name&quot;)
201 End Property &apos; Name (get)
203 Public Function pName() As String &apos; For compatibility with &lt; V0.9.0
204 pName = _PropertyGet(&quot;Name&quot;)
205 End Function &apos; pName (get)
207 REM -----------------------------------------------------------------------------------------------------------------------
208 Property Get ObjectType() As String
209 ObjectType = _PropertyGet(&quot;ObjectType&quot;)
210 End Property &apos; ObjectType (get)
212 REM -----------------------------------------------------------------------------------------------------------------------
213 Property Get OpenArgs() As Variant
214 OpenArgs = _PropertyGet(&quot;OpenArgs&quot;)
215 End Property &apos; OpenArgs (get)
217 REM -----------------------------------------------------------------------------------------------------------------------
218 Property Get OrderBy() As Variant
219 OrderBy = _PropertyGet(&quot;OrderBy&quot;)
220 End Property &apos; OrderBy (get) V1.2.0
222 Property Let OrderBy(ByVal pvValue As Variant)
223 Call _PropertySet(&quot;OrderBy&quot;, pvValue)
224 End Property &apos; OrderBy (set)
226 REM -----------------------------------------------------------------------------------------------------------------------
227 Property Get OrderByOn() As Variant
228 OrderByOn = _PropertyGet(&quot;OrderByOn&quot;)
229 End Property &apos; OrderByOn (get) V1.2.0
231 Property Let OrderByOn(ByVal pvValue As Variant)
232 Call _PropertySet(&quot;OrderByOn&quot;, pvValue)
233 End Property &apos; OrderByOn (set)
235 REM -----------------------------------------------------------------------------------------------------------------------
236 Public Function OptionGroup(ByVal Optional pvGroupName As Variant) As Variant
237 &apos; Return either an error or an object of type OPTIONGROUP based on its name
239 Const cstThisSub = &quot;Form.OptionGroup&quot;
240 Dim ogGroup As Object
241 Utils._SetCalledSub(cstThisSub)
242 If IsMissing(pvGroupName) Then Call _TraceArguments()
243 If _ErrorHandler() Then On Local Error Goto Error_Function
245 Set ogGroup = _OptionGroup(pvGroupName, CTLPARENTISFORM, Component, DatabaseForm)
246 If Not IsNull(ogGroup) Then
247 ogGroup._DocEntry = _DocEntry
248 ogGroup._DbEntry = _DbEntry
249 End If
250 Set OptionGroup = ogGroup
252 Exit_Function:
253 Utils._ResetCalledSub(cstThisSub)
254 Exit Function
255 Error_Function:
256 TraceError(TRACEABORT, Err, Form.OptionGroup, Erl)
257 GoTo Exit_Function
258 End Function &apos; OptionGroup V1.1.0
260 REM -----------------------------------------------------------------------------------------------------------------------
261 Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
262 &apos; Return
263 &apos; a Collection object if pvIndex absent
264 &apos; a Property object otherwise
266 Dim vProperty As Variant, vPropertiesList() As Variant, sObject As String
267 vPropertiesList = _PropertiesList()
268 sObject = Utils._PCase(_Type)
269 If IsMissing(pvIndex) Then
270 vProperty = PropertiesGet._Properties(sObject, _Name, vPropertiesList)
271 Else
272 vProperty = PropertiesGet._Properties(sObject, _Name, vPropertiesList, pvIndex)
273 vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
274 End If
276 Exit_Function:
277 Set Properties = vProperty
278 Exit Function
279 End Function &apos; Properties
281 REM -----------------------------------------------------------------------------------------------------------------------
282 Property Get Recordset() As Object
283 Recordset = _PropertyGet(&quot;Recordset&quot;)
284 End Property &apos; Recordset (get) V0.9.5
286 REM -----------------------------------------------------------------------------------------------------------------------
287 Property Get RecordSource() As Variant
288 RecordSource = _PropertyGet(&quot;RecordSource&quot;)
289 End Property &apos; RecordSource (get)
291 Property Let RecordSource(ByVal pvValue As Variant)
292 Call _PropertySet(&quot;RecordSource&quot;, pvValue)
293 End Property &apos; RecordSource (set)
295 REM -----------------------------------------------------------------------------------------------------------------------
296 Property Get Visible() As Variant
297 Visible = _PropertyGet(&quot;Visible&quot;)
298 End Property &apos; Visible (get)
300 Property Let Visible(ByVal pvValue As Variant)
301 Call _PropertySet(&quot;Visible&quot;, pvValue)
302 End Property &apos; Visible (set)
304 REM -----------------------------------------------------------------------------------------------------------------------
305 Property Get Width() As Variant
306 Width = _PropertyGet(&quot;Width&quot;)
307 End Property &apos; Width (get)
309 Property Let Width(ByVal pvValue As Variant)
310 Call _PropertySet(&quot;Width&quot;, pvValue)
311 End Property &apos; Width (set)
313 REM -----------------------------------------------------------------------------------------------------------------------
314 REM --- CLASS METHODS ---
315 REM -----------------------------------------------------------------------------------------------------------------------
317 Public Function mClose() As Variant
318 &apos; Close the form
320 If _ErrorHandler() Then On Local Error Goto Error_Function
321 Utils._SetCalledSub(&quot;Form.Close&quot;)
322 mClose = False
323 Dim oDatabase As Object, oController As Object
324 Set oDatabase = Application._CurrentDb()
325 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
327 Set oController = oDatabase.Document.getFormDocuments.getByName(_Name)
328 oController.close()
329 Dispose()
330 mClose = True
332 Exit_Function:
333 Utils._ResetCalledSub(&quot;Form.Close&quot;)
334 Exit Function
335 Error_NotApplicable:
336 TraceError(TRACEFATAL, ERRMETHOD, Utils._CalledSub(), 0, 1, cstThisSub)
337 Goto Exit_Function
338 Error_Function:
339 TraceError(TRACEABORT, Err, &quot;Form.Close&quot;, Erl)
340 GoTo Exit_Function
341 End Function
343 REM -----------------------------------------------------------------------------------------------------------------------
344 Public Function Controls(Optional ByVal pvIndex As Variant) As Variant
345 &apos; Return a Control object with name or index = pvIndex
347 If _ErrorHandler() Then On Local Error Goto Error_Function
348 Utils._SetCalledSub(&quot;Form.Controls&quot;)
350 Dim ocControl As Variant, sParentShortcut As String, iControlCount As Integer
351 Dim oCounter As Variant, sControls() As Variant, i As Integer, bFound As Boolean, sIndex As String
352 Dim j As Integer
354 Set ocControl = Nothing
355 If Not IsLoaded Then Goto Trace_Error_NotOpen
356 Set ocControl = New Control
357 ocControl._ParentType = CTLPARENTISFORM
358 sParentShortcut = _Shortcut
359 iControlCount = DatabaseForm.getCount()
361 If IsMissing(pvIndex) Then &apos; No argument, return Collection pseudo-object
362 Set oCounter = New Collect
363 oCounter._CollType = COLLCONTROLS
364 oCounter._ParentType = OBJFORM
365 oCounter._ParentName = _Name
366 oCounter._Count = iControlCount
367 Set Controls = oCounter
368 Goto Exit_Function
369 End If
371 If Not Utils._CheckArgument(pvIndex, 1, Utils._AddNumeric(vbString)) Then Goto Exit_Function
373 &apos; Start building the ocControl object
374 &apos; Determine exact name
375 sControls() = DatabaseForm.getElementNames()
377 Select Case VarType(pvIndex)
378 Case vbInteger, vbLong, vbSingle, vbDouble, vbCurrency, vbBigint, vbDecimal
379 If pvIndex &lt; 0 Or pvIndex &gt; iControlCount - 1 Then Goto Trace_Error_Index
380 ocControl._Name = sControls(pvIndex)
381 Case vbString &apos; Check control name validity (non case sensitive)
382 bFound = False
383 sIndex = UCase(Utils._Trim(pvIndex))
384 For i = 0 To iControlCount - 1
385 If UCase(sControls(i)) = sIndex Then
386 bFound = True
387 Exit For
388 End If
389 Next i
390 If bFound Then ocControl._Name = sControls(i) Else Goto Trace_NotFound
391 End Select
393 ocControl._Shortcut = sParentShortcut &amp; &quot;!&quot; &amp; Utils._Surround(ocControl._Name)
394 Set ocControl.ControlModel = DatabaseForm.getByName(ocControl._Name)
395 ocControl._ImplementationName = ocControl.ControlModel.getImplementationName()
396 ocControl._FormComponent = Component
397 If Utils._hasUNOProperty(ocControl.ControlModel, &quot;ClassId&quot;) Then ocControl._ClassId = ocControl.ControlModel.ClassId
398 If ocControl._ClassId &gt; 0 And ocControl._ClassId &lt;&gt; acHiddenControl Then
399 Set ocControl.ControlView = Component.CurrentController.getControl(ocControl.ControlModel)
400 End If
402 ocControl._Initialize()
403 ocControl._DocEntry = _DocEntry
404 ocControl._DbEntry = _DbEntry
405 Set Controls = ocControl
407 Exit_Function:
408 Utils._ResetCalledSub(&quot;Form.Controls&quot;)
409 Exit Function
410 Trace_Error_NotOpen:
411 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(), 0, , _Name)
412 Set Controls = Nothing
413 Goto Exit_Function
414 Trace_Error_Index:
415 TraceError(TRACEFATAL, ERRCOLLECTION, Utils._CalledSub(), 0, 1)
416 Set Controls = Nothing
417 Goto Exit_Function
418 Trace_NotFound:
419 TraceError(TRACEFATAL, ERRCONTROLNOTFOUND, Utils._CalledSub(), 0, , Array(pvIndex, pvIndex))
420 Set Controls = Nothing
421 Goto Exit_Function
422 Error_Function:
423 TraceError(TRACEABORT, Err, &quot;Form.Controls&quot;, Erl)
424 Set Controls = Nothing
425 GoTo Exit_Function
426 End Function &apos; Controls
428 REM -----------------------------------------------------------------------------------------------------------------------
429 Public Function CurrentDb() As Object
430 &apos; Returns Database object related to current form
432 Const cstThisSub = &quot;Form.CurrentDb&quot;
433 Utils._SetCalledSub(cstThisSub)
435 Set CurrentDb = Application._CurrentDb(_DocEntry, _DbEntry)
437 Exit_Function:
438 Utils._ResetCalledSub(cstThisSub)
439 Exit Function
440 End Function &apos; CurrentDb V1.1.0
442 REM -----------------------------------------------------------------------------------------------------------------------
443 Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
444 &apos; Return property value of psProperty property name
446 Utils._SetCalledSub(&quot;Form.getProperty&quot;)
447 If IsMissing(pvProperty) Then Call _TraceArguments()
448 getProperty = _PropertyGet(pvProperty)
449 Utils._ResetCalledSub(&quot;Form.getProperty&quot;)
451 End Function &apos; getProperty
453 REM -----------------------------------------------------------------------------------------------------------------------
454 Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
455 &apos; Return True if object has a valid property called pvProperty (case-insensitive comparison !)
457 If IsMissing(pvProperty) Then hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList()) Else hasProperty = PropertiesGet._hasProperty(_Type, _PropertiesList(), pvProperty)
458 Exit Function
460 End Function &apos; hasProperty
462 REM -----------------------------------------------------------------------------------------------------------------------
463 Public Function Move( ByVal Optional pvLeft As Variant _
464 , ByVal Optional pvTop As Variant _
465 , ByVal Optional pvWidth As Variant _
466 , ByVal Optional pvHeight As Variant _
467 ) As Variant
468 &apos; Execute Move method
469 Utils._SetCalledSub(&quot;Form.Move&quot;)
470 If IsMissing(pvLeft) Then Call _TraceArguments()
471 If _ErrorHandler() Then On Local Error Goto Error_Function
472 Move = False
473 Dim iArgNr As Integer
474 Select Case UCase(_A2B_.CalledSub)
475 Case UCase(&quot;Move&quot;) : iArgNr = 1
476 Case UCase(&quot;Form.Move&quot;) : iArgNr = 0
477 End Select
478 If IsMissing(pvLeft) Then Call _TraceArguments()
479 If IsMissing(pvTop) Then pvTop = -1
480 If IsMissing(pvWidth) Then pvWidth = -1
481 If IsMissing(pvHeight) Then pvHeight = -1
482 If Not Utils._CheckArgument(pvLeft, iArgNr + 1, Utils._AddNumeric()) Then Goto Exit_Function
483 If Not Utils._CheckArgument(pvTop, iArgNr + 2, Utils._AddNumeric()) Then Goto Exit_Function
484 If Not Utils._CheckArgument(pvWidth, iArgNr + 3, Utils._AddNumeric()) Then Goto Exit_Function
485 If Not Utils._CheckArgument(pvHeight, iArgNr + 4, Utils._AddNumeric()) Then Goto Exit_Function
487 Dim iArg As Integer, iWrong As Integer &apos; Check arguments values
488 iArg = 0
489 If pvHeight &lt; -1 Then
490 iArg = 4 : iWrong = pvHeight
491 ElseIf pvWidth &lt; -1 Then
492 iArg = 3 : iWrong = pvWidth
493 ElseIf pvTop &lt; -1 Then
494 iArg = 2 : iWrong = pvTop
495 ElseIf pvLeft &lt; -1 Then
496 iArg = 1 : iWrong = pvLeft
497 End If
498 If iArg &gt; 0 Then
499 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, 1, Array(iArgNr + iArg, iWrong))
500 Goto Exit_Function
501 End If
503 Dim iPosSize As Integer
504 iPosSize = 0
505 If pvLeft &gt;= 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.X
506 If pvTop &gt;= 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.Y
507 If pvWidth &gt; 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.WIDTH
508 If pvHeight &gt; 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.HEIGHT
509 If iPosSize &gt; 0 Then
510 If Utils._hasUNOProperty(ContainerWindow, &quot;IsMaximized&quot;) Then &apos; Ignored when &lt;= OO3.2
511 ContainerWindow.IsMaximized = False
512 ContainerWindow.IsMinimized = False
513 End If
514 ContainerWindow.setPosSize(pvLeft, pvTop, pvWidth, pvHeight, iPosSize)
515 End If
516 Move = True
518 Exit_Function:
519 Utils._ResetCalledSub(&quot;Form.Move&quot;)
520 Exit Function
521 Error_Function:
522 TraceError(TRACEABORT, Err, &quot;Form.Move&quot;, Erl)
523 GoTo Exit_Function
524 End Function &apos; Move
526 REM -----------------------------------------------------------------------------------------------------------------------
527 Public Function Refresh() As Boolean
528 &apos; Refresh data with its most recent value in the database in a form or subform
529 Utils._SetCalledSub(&quot;Form.Refresh&quot;)
530 If _ErrorHandler() Then On Local Error Goto Error_Function
531 Refresh = False
533 Dim oSet As Object
534 Set oSet = DatabaseForm.createResultSet()
535 If Not IsNull(oSet) Then
536 oSet.refreshRow()
537 Refresh = True
538 End If
540 Exit_Function:
541 Set oSet = Nothing
542 Utils._ResetCalledSub(&quot;Form.Refresh&quot;)
543 Exit Function
544 Error_Function:
545 TraceError(TRACEABORT, Err, &quot;SubForm.Refresh&quot;, Erl)
546 GoTo Exit_Function
547 End Function &apos; Refresh
549 REM -----------------------------------------------------------------------------------------------------------------------
550 Public Function Requery() As Boolean
551 &apos; Refresh data displayed in a form, subform, combobox or listbox
552 Utils._SetCalledSub(&quot;Form.Requery&quot;)
553 If _ErrorHandler() Then On Local Error Goto Error_Function
554 Requery = False
556 DatabaseForm.reload()
557 Requery = True
559 Exit_Function:
560 Utils._ResetCalledSub(&quot;Form.Requery&quot;)
561 Exit Function
562 Error_Function:
563 TraceError(TRACEABORT, Err, &quot;Form.Requery&quot;, Erl)
564 GoTo Exit_Function
565 End Function &apos; Requery
567 REM -----------------------------------------------------------------------------------------------------------------------
568 Public Function setFocus() As Boolean
569 &apos; Execute setFocus method
570 Const cstThisSub = &quot;Form.setFocus&quot;
571 Utils._SetCalledSub(cstThisSub)
572 If _ErrorHandler() Then On Local Error Goto Error_Function
573 setFocus = False
575 With ContainerWindow
576 If .isVisible() = False Then .setVisible(True)
577 .IsMinimized = False
578 .setFocus()
579 .setEnable(True) &apos; Added to try to bypass desynchro issue in Linux
580 .toFront() &apos; Added to force window change in Linux
581 End With
582 setFocus = True
584 Exit_Function:
585 Utils._ResetCalledSub(cstThisSub)
586 Exit Function
587 Error_Function:
588 TraceError(TRACEABORT, Err, cstThisSub, Erl)
589 Goto Exit_Function
590 End Function &apos; setFocus V1.1.0
592 REM -----------------------------------------------------------------------------------------------------------------------
593 Public Function setProperty(ByVal Optional psProperty As String, ByVal Optional pvValue As Variant) As Boolean
594 &apos; Return True if property setting OK
595 Utils._SetCalledSub(&quot;Form.setProperty&quot;)
596 setProperty = _PropertySet(psProperty, pvValue)
597 Utils._ResetCalledSub(&quot;Form.setProperty&quot;)
598 End Function
600 REM -----------------------------------------------------------------------------------------------------------------------
601 REM --- PRIVATE FUNCTIONS ---
602 REM -----------------------------------------------------------------------------------------------------------------------
603 Public Sub _Initialize(psName As String)
604 &apos; Set pointers to UNO objects
606 Dim oDoc As Object, oFormsCollection As Object, oDatabase As Object
607 If _ErrorHandler() Then On Local Error Goto Trace_Error
608 _Name = psName
609 _Shortcut = &quot;Forms!&quot; &amp; Utils._Surround(psName)
610 If IsLoaded Then
611 Set oDoc = _A2B_.CurrentDocument()
612 Select Case oDoc.DbConnect
613 Case DBCONNECTBASE
614 If Not IsNull(Component.CurrentController) Then &apos; A form opened then closed afterwards keeps a Component attribute
615 Set ContainerWindow = Component.CurrentController.Frame.ContainerWindow
616 Set oFormsCollection = Component.getDrawPage.Forms
617 If oFormsCollection.hasByName(&quot;MainForm&quot;) Then
618 Set DatabaseForm = oFormsCollection.getByName(&quot;MainForm&quot;)
619 ElseIf oFormsCollection.hasByName(&quot;Form&quot;) Then
620 Set DatabaseForm = oFormsCollection.getByName(&quot;Form&quot;)
621 ElseIf oFormsCollection.hasByName(_Name) Then
622 Set DatabaseForm = oFormsCollection.getByName(_Name)
623 Else
624 Goto Trace_Internal_Error
625 End If
626 End If
627 Case DBCONNECTFORM
628 Set ContainerWindow = oDoc.Document.CurrentController.Frame.ContainerWindow
629 Set oDatabase = Application._CurrentDb(_DocEntry, _DbEntry)
630 With oDatabase
631 Set DatabaseForm = .Form
632 If IsNull(.Connection) Then
633 Set .Connection = DatabaseForm.ActiveConnection
634 If Not IsNull(.Connection) Then
635 Set .MetaData = .Connection.MetaData
636 oDatabase._ReadOnly = .Connection.isReadOnly()
637 End If
638 End If
639 End With
640 End Select
641 _OrderBy = DatabaseForm.Order
642 Else
643 Set Component = Nothing
644 Set ContainerWindow = Nothing
645 Set DatabaseForm = Nothing
646 End If
648 Exit_Sub:
649 Exit Sub
650 Trace_Error:
651 TraceError(TRACEABORT, Err, &quot;Form.Initialize&quot;, Erl)
652 Goto Exit_Sub
653 Trace_Internal_Error:
654 TraceError(TRACEABORT, ERRFORMNOTIDENTIFIED, Utils._CalledSub(), 0, , _Name)
655 Goto Exit_Sub
656 End Sub &apos; _Initialize V1.1.0
658 REM -----------------------------------------------------------------------------------------------------------------------
659 Private Function _PropertiesList() As Variant
661 If IsLoaded Then
662 _PropertiesList = Array(&quot;AllowAdditions&quot;, &quot;AllowDeletions&quot;, &quot;AllowEdits&quot;, &quot;Bookmark&quot; _
663 , &quot;Caption&quot;, &quot;CurrentRecord&quot;, &quot;Filter&quot;, &quot;FilterOn&quot;, &quot;Height&quot;, &quot;IsLoaded&quot; _
664 , &quot;Name&quot;, &quot;ObjectType&quot;, &quot;OpenArgs&quot;, &quot;OrderBy&quot;, &quot;OrderByOn&quot; _
665 , &quot;RecordSource&quot;, &quot;Visible&quot;, &quot;Width&quot; _
666 ) &apos; Recordset removed
667 Else
668 _PropertiesList = Array(&quot;IsLoaded&quot;, &quot;Name&quot; _
670 End If
672 End Function &apos; _PropertiesList
674 REM -----------------------------------------------------------------------------------------------------------------------
675 Private Function _PropertyGet(ByVal psProperty As String) As Variant
676 &apos; Return property value of the psProperty property name
678 If _ErrorHandler() Then On Local Error Goto Error_Function
679 Utils._SetCalledSub(&quot;Form.get&quot; &amp; psProperty)
681 &apos;Execute
682 Dim oDatabase As Object, vBookmark As Variant, vEMPTY As Variant
683 Dim oObject As Object
684 _PropertyGet = vEMPTY
686 Select Case UCase(psProperty)
687 Case UCase(&quot;Name&quot;), UCase(&quot;IsLoaded&quot;)
688 Case Else : If Not IsLoaded Then Goto Trace_Error_Form
689 End Select
690 Select Case UCase(psProperty)
691 Case UCase(&quot;AllowAdditions&quot;)
692 _PropertyGet = DatabaseForm.AllowInserts
693 Case UCase(&quot;AllowDeletions&quot;)
694 _PropertyGet = DatabaseForm.AllowDeletes
695 Case UCase(&quot;AllowEdits&quot;)
696 _PropertyGet = DatabaseForm.AllowUpdates
697 Case UCase(&quot;Bookmark&quot;)
698 On Local Error Resume Next &apos; Disable error handler because bookmarking does not always react well in events ...
699 If DatabaseForm.IsBookmarkable Then vBookmark = DatabaseForm.getBookmark() Else vBookmark = Nothing
700 If _ErrorHandler() Then On Local Error Goto Error_Function Else On Local Error Goto 0
701 If IsNull(vBookmark) Then Goto Trace_Error
702 _PropertyGet = vBookmark
703 Case UCase(&quot;Caption&quot;)
704 Set odatabase = Application._CurrentDb(_DocEntry, _DbEntry)
705 Select Case oDatabase._DbConnect
706 Case DBCONNECTFORM : _PropertyGet = oDatabase.Document.CurrentController.Frame.Title
707 Case DBCONNECTBASE : _PropertyGet = Component.CurrentController.Frame.Title
708 End Select
709 Case UCase(&quot;CurrentRecord&quot;)
710 _PropertyGet = DatabaseForm.Row
711 Case UCase(&quot;Filter&quot;)
712 _PropertyGet = DatabaseForm.Filter
713 Case UCase(&quot;FilterOn&quot;)
714 _PropertyGet = DatabaseForm.ApplyFilter
715 Case UCase(&quot;Height&quot;)
716 _PropertyGet = ContainerWindow.getPosSize().Height
717 Case UCase(&quot;IsLoaded&quot;) &apos; Only for indirect access from property object
718 _PropertyGet = IsLoaded
719 Case UCase(&quot;Name&quot;)
720 _PropertyGet = _Name
721 Case UCase(&quot;ObjectType&quot;)
722 _PropertyGet = _Type
723 Case UCase(&quot;OpenArgs&quot;)
724 _PropertyGet = _OpenArgs
725 Case UCase(&quot;OrderBy&quot;)
726 _PropertyGet = _OrderBy
727 Case UCase(&quot;OrderByOn&quot;)
728 If DatabaseForm.Order = &quot;&quot; Then _PropertyGet = False Else _PropertyGet = True
729 Case UCase(&quot;Recordset&quot;)
730 If DatabaseForm.Command = &quot;&quot; Then Goto Trace_Error &apos; No underlying data ??
731 Set oObject = New Recordset
732 With DatabaseForm
733 oObject._CommandType = .CommandType
734 oObject._Command = .Command
735 oObject._ParentName = _Name
736 oObject._ParentType = _Type
737 Set oDatabase = Application._CurrentDb(_DocEntry, _DbEntry)
738 Set oObject._ParentDatabase = oDatabase
739 Set oObject._ParentDatabase.Connection = .ActiveConnection
740 oObject._ForwardOnly = ( .ResultSetType = com.sun.star.sdbc.ResultSetType.FORWARD_ONLY )
741 oObject._PassThrough = ( .EscapeProcessing = False )
742 oObject._ReadOnly = ( .ResultSetConcurrency = com.sun.star.sdbc.ResultSetConcurrency.READ_ONLY )
743 Call oObject._Initialize()
744 End With
745 With oDatabase
746 .RecordsetMax = .RecordsetMax + 1
747 oObject._Name = Format(.RecordsetMax, &quot;0000000&quot;)
748 .RecordsetsColl.Add(oObject, UCase(oObject._Name))
749 End With
750 If Not ( oObject._BOF And oObject._EOF ) Then oObject.MoveFirst() &apos; Do nothing if resultset empty
751 Set _PropertyGet = oObject
752 Case UCase(&quot;RecordSource&quot;)
753 _PropertyGet = DatabaseForm.ActiveCommand
754 Case UCase(&quot;Visible&quot;)
755 _PropertyGet = ContainerWindow.IsVisible()
756 Case UCase(&quot;Width&quot;)
757 _PropertyGet = ContainerWindow.getPosSize().Width
758 Case Else
759 Goto Trace_Error
760 End Select
762 Exit_Function:
763 Utils._ResetCalledSub(&quot;Form.get&quot; &amp; psProperty)
764 Exit Function
765 Trace_Error:
766 TraceError(TRACEWARNING, ERRPROPERTY, Utils._CalledSub(), 0, 1, psProperty)
767 _PropertyGet = vEMPTY
768 Goto Exit_Function
769 Trace_Error_Form:
770 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(), 0, 1, _Name)
771 _PropertyGet = vEMPTY
772 Goto Exit_Function
773 Error_Function:
774 TraceError(TRACEABORT, Err, &quot;Form._PropertyGet&quot;, Erl)
775 _PropertyGet = vEMPTY
776 GoTo Exit_Function
777 End Function &apos; _PropertyGet
779 REM -----------------------------------------------------------------------------------------------------------------------
780 Private Function _PropertySet(ByVal psProperty As String, ByVal pvValue As Variant) As Boolean
782 Utils._SetCalledSub(&quot;Form.set&quot; &amp; psProperty)
783 If _ErrorHandler() Then On Local Error Goto Error_Function
784 _PropertySet = True
786 &apos;Execute
787 Dim iArgNr As Integer
788 Dim oDatabase As Object
790 If _Isleft(_A2B_.CalledSub, &quot;Form.&quot;) Then iArgNr = 1 Else iArgNr = 2
791 If Not IsLoaded Then Goto Trace_Error_Form
792 Select Case UCase(psProperty)
793 Case UCase(&quot;AllowAdditions&quot;)
794 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
795 DatabaseForm.AllowInserts = pvValue
796 DatabaseForm.reload()
797 Case UCase(&quot;AllowDeletions&quot;)
798 If Not Utils._CheckArgument(pvValue,iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
799 DatabaseForm.AllowDeletes = pvValue
800 DatabaseForm.reload()
801 Case UCase(&quot;AllowEdits&quot;)
802 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
803 DatabaseForm.AllowUpdates = pvValue
804 DatabaseForm.reload()
805 Case UCase(&quot;Bookmark&quot;)
806 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(vbObject), , False) Then Goto Trace_Error_Value
807 If IsNull(pvValue) Then Goto Trace_Error_Value
808 DatabaseForm.MoveToBookmark(pvValue)
809 Case UCase(&quot;Caption&quot;)
810 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
811 Set oDatabase = Application._CurrentDb(_DocEntry, _DbEntry)
812 Select Case oDatabase._DbConnect
813 Case DBCONNECTFORM : oDatabase.Document.CurrentController.Frame.Title = pvValue
814 Case DBCONNECTBASE : Component.CurrentController.Frame.Title = pvValue
815 End Select
816 Case UCase(&quot;CurrentRecord&quot;)
817 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
818 If pvValue &lt; 1 Then Goto Trace_Error_Value
819 DatabaseForm.absolute(pvValue)
820 Case UCase(&quot;Filter&quot;)
821 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
822 DatabaseForm.Filter = Application._CurrentDb(_DocEntry, _DbEntry)._ReplaceSquareBrackets(pvValue)
823 Case UCase(&quot;FilterOn&quot;)
824 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
825 DatabaseForm.ApplyFilter = pvValue
826 DatabaseForm.reload()
827 Case UCase(&quot;Height&quot;)
828 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
829 If Utils._hasUNOProperty(ContainerWindow, &quot;IsMaximized&quot;) Then &apos; Ignored when &lt;= OO3.2
830 ContainerWindow.IsMaximized = False
831 ContainerWindow.IsMinimized = False
832 End If
833 ContainerWindow.setPosSize(0, 0, 0, pvValue, com.sun.star.awt.PosSize.HEIGHT)
834 Case UCase(&quot;OrderBy&quot;)
835 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
836 _OrderBy = Application._CurrentDb(_DocEntry, _DbEntry)._ReplaceSquareBrackets(pvValue)
837 Case UCase(&quot;OrderByOn&quot;)
838 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
839 If pvValue Then DatabaseForm.Order = _OrderBy Else DatabaseForm.Order = &quot;&quot;
840 DatabaseForm.reload()
841 Case UCase(&quot;RecordSource&quot;)
842 If Not Utils._CheckArgument(pvValue, iArgNr, vbString, , False) Then Goto Trace_Error_Value
843 DatabaseForm.Command = Application._CurrentDb(_DocEntry, _DbEntry)._ReplaceSquareBrackets(pvValue)
844 DatabaseForm.CommandType = com.sun.star.sdb.CommandType.COMMAND
845 DatabaseForm.Filter = &quot;&quot;
846 DatabaseForm.reload()
847 Case UCase(&quot;Visible&quot;)
848 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
849 ContainerWindow.setVisible(pvValue)
850 Case UCase(&quot;Width&quot;)
851 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric()) Then Goto Trace_Error_Value
852 If Utils._hasUNOProperty(ContainerWindow, &quot;IsMaximized&quot;) Then &apos; Ignored when &lt;= OO3.2
853 ContainerWindow.IsMaximized = False
854 ContainerWindow.IsMinimized = False
855 End If
856 ContainerWindow.setPosSize(0, 0, pvValue, 0, com.sun.star.awt.PosSize.WIDTH)
857 Case Else
858 Goto Trace_Error
859 End Select
861 Exit_Function:
862 Utils._ResetCalledSub(&quot;Form.set&quot; &amp; psProperty)
863 Exit Function
864 Trace_Error_Form:
865 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(), 0, 1, _Name)
866 _PropertySet = False
867 Goto Exit_Function
868 Trace_Error:
869 TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(), 0, 1, psProperty)
870 _PropertySet = False
871 Goto Exit_Function
872 Trace_Error_Value:
873 TraceError(TRACEFATAL, ERRPROPERTYVALUE, Utils._CalledSub(), 0, 1, Array(pvValue, psProperty))
874 _PropertySet = False
875 Goto Exit_Function
876 Error_Function:
877 TraceError(TRACEABORT, Err, &quot;Form._PropertySet&quot;, Erl)
878 _PropertySet = False
879 GoTo Exit_Function
880 End Function &apos; _PropertySet
881 </script:module>