Form.xba 48 KB

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