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 =======================================================================================================================
13 REM -----------------------------------------------------------------------------------------------------------------------
14 REM --- CLASS ROOT FIELDS ---
15 REM -----------------------------------------------------------------------------------------------------------------------
17 Private _Type As String
' Must be FORM
18 Private _Shortcut As String
19 Private _Name As String
20 Private _DocEntry As Integer
' 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
' com.sun.star.text.TextDocument
26 Public ContainerWindow As Object
' (No name)
27 Public DatabaseForm As Object
' 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()
34 _Shortcut =
""
39 _OpenArgs =
""
40 _OrderBy =
""
41 Set Component = Nothing
42 Set ContainerWindow = Nothing
43 Set DatabaseForm = Nothing
44 End Sub
' Constructor
46 REM -----------------------------------------------------------------------------------------------------------------------
47 Private Sub Class_Terminate()
48 On Local Error Resume Next
49 Call Class_Initialize()
50 End Sub
' Destructor
52 REM -----------------------------------------------------------------------------------------------------------------------
55 If Not IsLoaded(True) Then
56 If Not IsNull(DatabaseForm) Then DatabaseForm.Dispose()
58 Call Class_Terminate()
59 End Sub
' Explicit destructor
61 REM -----------------------------------------------------------------------------------------------------------------------
62 REM --- CLASS GET/LET/SET PROPERTIES ---
63 REM -----------------------------------------------------------------------------------------------------------------------
64 Property Get AllowAdditions() As Variant
65 AllowAdditions = _PropertyGet(
"AllowAdditions
")
66 End Property
' AllowAdditions (get)
68 Property Let AllowAdditions(ByVal pvValue As Variant)
69 Call _PropertySet(
"AllowAdditions
", pvValue)
70 End Property
' AllowAdditions (set)
72 REM -----------------------------------------------------------------------------------------------------------------------
73 Property Get AllowDeletions() As Variant
74 AllowDeletions = _PropertyGet(
"AllowDeletions
")
75 End Property
' AllowDeletions (get)
77 Property Let AllowDeletions(ByVal pvValue As Variant)
78 Call _PropertySet(
"AllowDeletions
", pvValue)
79 End Property
' AllowDeletions (set)
81 REM -----------------------------------------------------------------------------------------------------------------------
82 Property Get AllowEdits() As Variant
83 AllowEdits = _PropertyGet(
"AllowEdits
")
84 End Property
' AllowEdits (get)
86 Property Let AllowEdits(ByVal pvValue As Variant)
87 Call _PropertySet(
"AllowEdits
", pvValue)
88 End Property
' AllowEdits (set)
90 REM -----------------------------------------------------------------------------------------------------------------------
91 Property Get Bookmark() As Variant
92 Bookmark = _PropertyGet(
"Bookmark
")
93 End Property
' Bookmark (get)
95 Property Let Bookmark(ByVal pvValue As Variant)
96 Call _PropertySet(
"Bookmark
", pvValue)
97 End Property
' Bookmark (set)
99 REM -----------------------------------------------------------------------------------------------------------------------
100 Property Get Caption() As Variant
101 Caption = _PropertyGet(
"Caption
")
102 End Property
' Caption (get)
104 Property Let Caption(ByVal pvValue As Variant)
105 Call _PropertySet(
"Caption
", pvValue)
106 End Property
' Caption (set)
108 REM -----------------------------------------------------------------------------------------------------------------------
109 Property Get CurrentRecord() As Variant
110 CurrentRecord = _PropertyGet(
"CurrentRecord
")
111 End Property
' CurrentRecord (get)
113 Property Let CurrentRecord(ByVal pvValue As Variant)
114 Call _PropertySet(
"CurrentRecord
", pvValue)
115 End Property
' CurrentRecord (set)
117 REM -----------------------------------------------------------------------------------------------------------------------
118 Property Get Filter() As Variant
119 Filter = _PropertyGet(
"Filter
")
120 End Property
' Filter (get)
122 Property Let Filter(ByVal pvValue As Variant)
123 Call _PropertySet(
"Filter
", pvValue)
124 End Property
' Filter (set)
126 REM -----------------------------------------------------------------------------------------------------------------------
127 Property Get FilterOn() As Variant
128 FilterOn = _PropertyGet(
"FilterOn
")
129 End Property
' FilterOn (get)
131 Property Let FilterOn(ByVal pvValue As Variant)
132 Call _PropertySet(
"FilterOn
", pvValue)
133 End Property
' FilterOn (set)
135 REM -----------------------------------------------------------------------------------------------------------------------
136 Property Get Height() As Variant
137 Height = _PropertyGet(
"Height
")
138 End Property
' Height (get)
140 Property Let Height(ByVal pvValue As Variant)
141 Call _PropertySet(
"Height
", pvValue)
142 End Property
' Height (set)
144 REM -----------------------------------------------------------------------------------------------------------------------
145 Function IsLoaded(ByVal Optional pbForce As Boolean) As Boolean
146 'Return True if form open
147 'pbForce = True forbids bypass on value of _IsLoaded
149 If _ErrorHandler() Then On Local Error Goto Error_Function
150 Utils._SetCalledSub(
"Form.getIsLoaded
")
151 If IsMissing(pbForce) Then pbForce = False
152 If ( Not pbForce ) And _IsLoaded Then
' For performance reasons, a form object, once detected as loaded, is presumed remaining loaded. Except if pbForce = True
158 Dim oDoc As Object, oDatabase As Object, oEnum As Object, oDesk As Object, oComp As Object, bFound As Boolean
160 Set oDoc = _A2B_.CurrentDocument()
161 Select Case oDoc.DbConnect
163 Set oDesk = CreateUnoService(
"com.sun.star.frame.Desktop
")
164 Set oEnum = oDesk.Components().createEnumeration
166 Do While oEnum.hasMoreElements And Not bFound
' Search in all open components if one corresponds with current form
167 oComp = oEnum.nextElement
168 If HasUnoInterfaces(oComp,
"com.sun.star.frame.XModule
") Then
169 If oComp.Identifier =
"com.sun.star.sdb.FormDesign
" Then
170 For i =
0 To UBound(oComp.Args())
171 If oComp.Args(i).Name =
"DocumentTitle
" Then
172 bFound = ( oComp.Args(i).Value = _Name )
175 Set Component = oComp
184 Set Component = oDoc.Document
' Form
185 _IsLoaded = True
' Interactive form always loaded by design
191 Utils._ResetCalledSub(
"Form.getIsLoaded
")
194 TraceError(TRACEABORT, Err,
"Form.getIsLoaded
", Erl)
196 End Function
' IsLoaded V1.1
.0
198 REM -----------------------------------------------------------------------------------------------------------------------
199 Property Get Name() As String
200 Name = _PropertyGet(
"Name
")
201 End Property
' Name (get)
203 Public Function pName() As String
' For compatibility with
< V0.9
.0
204 pName = _PropertyGet(
"Name
")
205 End Function
' pName (get)
207 REM -----------------------------------------------------------------------------------------------------------------------
208 Property Get ObjectType() As String
209 ObjectType = _PropertyGet(
"ObjectType
")
210 End Property
' ObjectType (get)
212 REM -----------------------------------------------------------------------------------------------------------------------
213 Property Get OpenArgs() As Variant
214 OpenArgs = _PropertyGet(
"OpenArgs
")
215 End Property
' OpenArgs (get)
217 REM -----------------------------------------------------------------------------------------------------------------------
218 Property Get OrderBy() As Variant
219 OrderBy = _PropertyGet(
"OrderBy
")
220 End Property
' OrderBy (get) V1.2
.0
222 Property Let OrderBy(ByVal pvValue As Variant)
223 Call _PropertySet(
"OrderBy
", pvValue)
224 End Property
' OrderBy (set)
226 REM -----------------------------------------------------------------------------------------------------------------------
227 Property Get OrderByOn() As Variant
228 OrderByOn = _PropertyGet(
"OrderByOn
")
229 End Property
' OrderByOn (get) V1.2
.0
231 Property Let OrderByOn(ByVal pvValue As Variant)
232 Call _PropertySet(
"OrderByOn
", pvValue)
233 End Property
' OrderByOn (set)
235 REM -----------------------------------------------------------------------------------------------------------------------
236 Public Function OptionGroup(ByVal Optional pvGroupName As Variant) As Variant
237 ' Return either an error or an object of type OPTIONGROUP based on its name
239 Const cstThisSub =
"Form.OptionGroup
"
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
250 Set OptionGroup = ogGroup
253 Utils._ResetCalledSub(cstThisSub)
256 TraceError(TRACEABORT, Err, Form.OptionGroup, Erl)
258 End Function
' OptionGroup V1.1
.0
260 REM -----------------------------------------------------------------------------------------------------------------------
261 Public Function Properties(ByVal Optional pvIndex As Variant) As Variant
263 ' a Collection object if pvIndex absent
264 ' 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)
272 vProperty = PropertiesGet._Properties(sObject, _Name, vPropertiesList, pvIndex)
273 vProperty._Value = _PropertyGet(vPropertiesList(pvIndex))
277 Set Properties = vProperty
279 End Function
' Properties
281 REM -----------------------------------------------------------------------------------------------------------------------
282 Property Get Recordset() As Object
283 Recordset = _PropertyGet(
"Recordset
")
284 End Property
' Recordset (get) V0.9
.5
286 REM -----------------------------------------------------------------------------------------------------------------------
287 Property Get RecordSource() As Variant
288 RecordSource = _PropertyGet(
"RecordSource
")
289 End Property
' RecordSource (get)
291 Property Let RecordSource(ByVal pvValue As Variant)
292 Call _PropertySet(
"RecordSource
", pvValue)
293 End Property
' RecordSource (set)
295 REM -----------------------------------------------------------------------------------------------------------------------
296 Property Get Visible() As Variant
297 Visible = _PropertyGet(
"Visible
")
298 End Property
' Visible (get)
300 Property Let Visible(ByVal pvValue As Variant)
301 Call _PropertySet(
"Visible
", pvValue)
302 End Property
' Visible (set)
304 REM -----------------------------------------------------------------------------------------------------------------------
305 Property Get Width() As Variant
306 Width = _PropertyGet(
"Width
")
307 End Property
' Width (get)
309 Property Let Width(ByVal pvValue As Variant)
310 Call _PropertySet(
"Width
", pvValue)
311 End Property
' Width (set)
313 REM -----------------------------------------------------------------------------------------------------------------------
314 REM --- CLASS METHODS ---
315 REM -----------------------------------------------------------------------------------------------------------------------
317 Public Function mClose() As Variant
318 ' Close the form
320 If _ErrorHandler() Then On Local Error Goto Error_Function
321 Utils._SetCalledSub(
"Form.Close
")
323 Dim oDatabase As Object, oController As Object
324 Set oDatabase = Application._CurrentDb()
325 If oDatabase._DbConnect
<> DBCONNECTBASE Then Goto Error_NotApplicable
327 Set oController = oDatabase.Document.getFormDocuments.getByName(_Name)
333 Utils._ResetCalledSub(
"Form.Close
")
336 TraceError(TRACEFATAL, ERRMETHOD, Utils._CalledSub(),
0,
1, cstThisSub)
339 TraceError(TRACEABORT, Err,
"Form.Close
", Erl)
343 REM -----------------------------------------------------------------------------------------------------------------------
344 Public Function Controls(Optional ByVal pvIndex As Variant) As Variant
345 ' Return a Control object with name or index = pvIndex
347 If _ErrorHandler() Then On Local Error Goto Error_Function
348 Utils._SetCalledSub(
"Form.Controls
")
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
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
' 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
371 If Not Utils._CheckArgument(pvIndex,
1, Utils._AddNumeric(vbString)) Then Goto Exit_Function
373 ' Start building the ocControl object
374 ' Determine exact name
375 sControls() = DatabaseForm.getElementNames()
377 Select Case VarType(pvIndex)
378 Case vbInteger, vbLong, vbSingle, vbDouble, vbCurrency, vbBigint, vbDecimal
379 If pvIndex
< 0 Or pvIndex
> iControlCount -
1 Then Goto Trace_Error_Index
380 ocControl._Name = sControls(pvIndex)
381 Case vbString
' Check control name validity (non case sensitive)
383 sIndex = UCase(Utils._Trim(pvIndex))
384 For i =
0 To iControlCount -
1
385 If UCase(sControls(i)) = sIndex Then
390 If bFound Then ocControl._Name = sControls(i) Else Goto Trace_NotFound
393 ocControl._Shortcut = sParentShortcut
& "!
" & 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,
"ClassId
") Then ocControl._ClassId = ocControl.ControlModel.ClassId
398 If ocControl._ClassId
> 0 And ocControl._ClassId
<> acHiddenControl Then
399 Set ocControl.ControlView = Component.CurrentController.getControl(ocControl.ControlModel)
402 ocControl._Initialize()
403 ocControl._DocEntry = _DocEntry
404 ocControl._DbEntry = _DbEntry
405 Set Controls = ocControl
408 Utils._ResetCalledSub(
"Form.Controls
")
411 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(),
0, , _Name)
412 Set Controls = Nothing
415 TraceError(TRACEFATAL, ERRCOLLECTION, Utils._CalledSub(),
0,
1)
416 Set Controls = Nothing
419 TraceError(TRACEFATAL, ERRCONTROLNOTFOUND, Utils._CalledSub(),
0, , Array(pvIndex, pvIndex))
420 Set Controls = Nothing
423 TraceError(TRACEABORT, Err,
"Form.Controls
", Erl)
424 Set Controls = Nothing
426 End Function
' Controls
428 REM -----------------------------------------------------------------------------------------------------------------------
429 Public Function CurrentDb() As Object
430 ' Returns Database object related to current form
432 Const cstThisSub =
"Form.CurrentDb
"
433 Utils._SetCalledSub(cstThisSub)
435 Set CurrentDb = Application._CurrentDb(_DocEntry, _DbEntry)
438 Utils._ResetCalledSub(cstThisSub)
440 End Function
' CurrentDb V1.1
.0
442 REM -----------------------------------------------------------------------------------------------------------------------
443 Public Function getProperty(Optional ByVal pvProperty As Variant) As Variant
444 ' Return property value of psProperty property name
446 Utils._SetCalledSub(
"Form.getProperty
")
447 If IsMissing(pvProperty) Then Call _TraceArguments()
448 getProperty = _PropertyGet(pvProperty)
449 Utils._ResetCalledSub(
"Form.getProperty
")
451 End Function
' getProperty
453 REM -----------------------------------------------------------------------------------------------------------------------
454 Public Function hasProperty(ByVal Optional pvProperty As Variant) As Boolean
455 ' 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)
460 End Function
' 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 _
468 ' Execute Move method
469 Utils._SetCalledSub(
"Form.Move
")
470 If IsMissing(pvLeft) Then Call _TraceArguments()
471 If _ErrorHandler() Then On Local Error Goto Error_Function
473 Dim iArgNr As Integer
474 Select Case UCase(_A2B_.CalledSub)
475 Case UCase(
"Move
") : iArgNr =
1
476 Case UCase(
"Form.Move
") : iArgNr =
0
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
' Check arguments values
489 If pvHeight
< -
1 Then
490 iArg =
4 : iWrong = pvHeight
491 ElseIf pvWidth
< -
1 Then
492 iArg =
3 : iWrong = pvWidth
493 ElseIf pvTop
< -
1 Then
494 iArg =
2 : iWrong = pvTop
495 ElseIf pvLeft
< -
1 Then
496 iArg =
1 : iWrong = pvLeft
499 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(),
0,
1, Array(iArgNr + iArg, iWrong))
503 Dim iPosSize As Integer
505 If pvLeft
>=
0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.X
506 If pvTop
>=
0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.Y
507 If pvWidth
> 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.WIDTH
508 If pvHeight
> 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.HEIGHT
509 If iPosSize
> 0 Then
510 If Utils._hasUNOProperty(ContainerWindow,
"IsMaximized
") Then
' Ignored when
<= OO3.2
511 ContainerWindow.IsMaximized = False
512 ContainerWindow.IsMinimized = False
514 ContainerWindow.setPosSize(pvLeft, pvTop, pvWidth, pvHeight, iPosSize)
519 Utils._ResetCalledSub(
"Form.Move
")
522 TraceError(TRACEABORT, Err,
"Form.Move
", Erl)
524 End Function
' Move
526 REM -----------------------------------------------------------------------------------------------------------------------
527 Public Function Refresh() As Boolean
528 ' Refresh data with its most recent value in the database in a form or subform
529 Utils._SetCalledSub(
"Form.Refresh
")
530 If _ErrorHandler() Then On Local Error Goto Error_Function
534 Set oSet = DatabaseForm.createResultSet()
535 If Not IsNull(oSet) Then
542 Utils._ResetCalledSub(
"Form.Refresh
")
545 TraceError(TRACEABORT, Err,
"SubForm.Refresh
", Erl)
547 End Function
' Refresh
549 REM -----------------------------------------------------------------------------------------------------------------------
550 Public Function Requery() As Boolean
551 ' Refresh data displayed in a form, subform, combobox or listbox
552 Utils._SetCalledSub(
"Form.Requery
")
553 If _ErrorHandler() Then On Local Error Goto Error_Function
556 DatabaseForm.reload()
560 Utils._ResetCalledSub(
"Form.Requery
")
563 TraceError(TRACEABORT, Err,
"Form.Requery
", Erl)
565 End Function
' Requery
567 REM -----------------------------------------------------------------------------------------------------------------------
568 Public Function setFocus() As Boolean
569 ' Execute setFocus method
570 Const cstThisSub =
"Form.setFocus
"
571 Utils._SetCalledSub(cstThisSub)
572 If _ErrorHandler() Then On Local Error Goto Error_Function
576 If .isVisible() = False Then .setVisible(True)
579 .setEnable(True)
' Added to try to bypass desynchro issue in Linux
580 .toFront()
' Added to force window change in Linux
585 Utils._ResetCalledSub(cstThisSub)
588 TraceError(TRACEABORT, Err, cstThisSub, Erl)
590 End Function
' setFocus V1.1
.0
592 REM -----------------------------------------------------------------------------------------------------------------------
593 Public Function setProperty(ByVal Optional psProperty As String, ByVal Optional pvValue As Variant) As Boolean
594 ' Return True if property setting OK
595 Utils._SetCalledSub(
"Form.setProperty
")
596 setProperty = _PropertySet(psProperty, pvValue)
597 Utils._ResetCalledSub(
"Form.setProperty
")
600 REM -----------------------------------------------------------------------------------------------------------------------
601 REM --- PRIVATE FUNCTIONS ---
602 REM -----------------------------------------------------------------------------------------------------------------------
603 Public Sub _Initialize(psName As String)
604 ' 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
609 _Shortcut =
"Forms!
" & Utils._Surround(psName)
611 Set oDoc = _A2B_.CurrentDocument()
612 Select Case oDoc.DbConnect
614 If Not IsNull(Component.CurrentController) Then
' 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(
"MainForm
") Then
618 Set DatabaseForm = oFormsCollection.getByName(
"MainForm
")
619 ElseIf oFormsCollection.hasByName(
"Form
") Then
620 Set DatabaseForm = oFormsCollection.getByName(
"Form
")
621 ElseIf oFormsCollection.hasByName(_Name) Then
622 Set DatabaseForm = oFormsCollection.getByName(_Name)
624 Goto Trace_Internal_Error
628 Set ContainerWindow = oDoc.Document.CurrentController.Frame.ContainerWindow
629 Set oDatabase = Application._CurrentDb(_DocEntry, _DbEntry)
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()
641 _OrderBy = DatabaseForm.Order
643 Set Component = Nothing
644 Set ContainerWindow = Nothing
645 Set DatabaseForm = Nothing
651 TraceError(TRACEABORT, Err,
"Form.Initialize
", Erl)
653 Trace_Internal_Error:
654 TraceError(TRACEABORT, ERRFORMNOTIDENTIFIED, Utils._CalledSub(),
0, , _Name)
656 End Sub
' _Initialize V1.1
.0
658 REM -----------------------------------------------------------------------------------------------------------------------
659 Private Function _PropertiesList() As Variant
662 _PropertiesList = Array(
"AllowAdditions
",
"AllowDeletions
",
"AllowEdits
",
"Bookmark
" _
663 ,
"Caption
",
"CurrentRecord
",
"Filter
",
"FilterOn
",
"Height
",
"IsLoaded
" _
664 ,
"Name
",
"ObjectType
",
"OpenArgs
",
"OrderBy
",
"OrderByOn
" _
665 ,
"RecordSource
",
"Visible
",
"Width
" _
666 )
' Recordset removed
668 _PropertiesList = Array(
"IsLoaded
",
"Name
" _
672 End Function
' _PropertiesList
674 REM -----------------------------------------------------------------------------------------------------------------------
675 Private Function _PropertyGet(ByVal psProperty As String) As Variant
676 ' Return property value of the psProperty property name
678 If _ErrorHandler() Then On Local Error Goto Error_Function
679 Utils._SetCalledSub(
"Form.get
" & psProperty)
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(
"Name
"), UCase(
"IsLoaded
")
688 Case Else : If Not IsLoaded Then Goto Trace_Error_Form
690 Select Case UCase(psProperty)
691 Case UCase(
"AllowAdditions
")
692 _PropertyGet = DatabaseForm.AllowInserts
693 Case UCase(
"AllowDeletions
")
694 _PropertyGet = DatabaseForm.AllowDeletes
695 Case UCase(
"AllowEdits
")
696 _PropertyGet = DatabaseForm.AllowUpdates
697 Case UCase(
"Bookmark
")
698 On Local Error Resume Next
' 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(
"Caption
")
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
709 Case UCase(
"CurrentRecord
")
710 _PropertyGet = DatabaseForm.Row
711 Case UCase(
"Filter
")
712 _PropertyGet = DatabaseForm.Filter
713 Case UCase(
"FilterOn
")
714 _PropertyGet = DatabaseForm.ApplyFilter
715 Case UCase(
"Height
")
716 _PropertyGet = ContainerWindow.getPosSize().Height
717 Case UCase(
"IsLoaded
")
' Only for indirect access from property object
718 _PropertyGet = IsLoaded
719 Case UCase(
"Name
")
721 Case UCase(
"ObjectType
")
723 Case UCase(
"OpenArgs
")
724 _PropertyGet = _OpenArgs
725 Case UCase(
"OrderBy
")
726 _PropertyGet = _OrderBy
727 Case UCase(
"OrderByOn
")
728 If DatabaseForm.Order =
"" Then _PropertyGet = False Else _PropertyGet = True
729 Case UCase(
"Recordset
")
730 If DatabaseForm.Command =
"" Then Goto Trace_Error
' No underlying data ??
731 Set oObject = New Recordset
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()
746 .RecordsetMax = .RecordsetMax +
1
747 oObject._Name = Format(.RecordsetMax,
"0000000")
748 .RecordsetsColl.Add(oObject, UCase(oObject._Name))
750 If Not ( oObject._BOF And oObject._EOF ) Then oObject.MoveFirst()
' Do nothing if resultset empty
751 Set _PropertyGet = oObject
752 Case UCase(
"RecordSource
")
753 _PropertyGet = DatabaseForm.ActiveCommand
754 Case UCase(
"Visible
")
755 _PropertyGet = ContainerWindow.IsVisible()
756 Case UCase(
"Width
")
757 _PropertyGet = ContainerWindow.getPosSize().Width
763 Utils._ResetCalledSub(
"Form.get
" & psProperty)
766 TraceError(TRACEWARNING, ERRPROPERTY, Utils._CalledSub(),
0,
1, psProperty)
767 _PropertyGet = vEMPTY
770 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(),
0,
1, _Name)
771 _PropertyGet = vEMPTY
774 TraceError(TRACEABORT, Err,
"Form._PropertyGet
", Erl)
775 _PropertyGet = vEMPTY
777 End Function
' _PropertyGet
779 REM -----------------------------------------------------------------------------------------------------------------------
780 Private Function _PropertySet(ByVal psProperty As String, ByVal pvValue As Variant) As Boolean
782 Utils._SetCalledSub(
"Form.set
" & psProperty)
783 If _ErrorHandler() Then On Local Error Goto Error_Function
787 Dim iArgNr As Integer
788 Dim oDatabase As Object
790 If _Isleft(_A2B_.CalledSub,
"Form.
") Then iArgNr =
1 Else iArgNr =
2
791 If Not IsLoaded Then Goto Trace_Error_Form
792 Select Case UCase(psProperty)
793 Case UCase(
"AllowAdditions
")
794 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
795 DatabaseForm.AllowInserts = pvValue
796 DatabaseForm.reload()
797 Case UCase(
"AllowDeletions
")
798 If Not Utils._CheckArgument(pvValue,iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
799 DatabaseForm.AllowDeletes = pvValue
800 DatabaseForm.reload()
801 Case UCase(
"AllowEdits
")
802 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
803 DatabaseForm.AllowUpdates = pvValue
804 DatabaseForm.reload()
805 Case UCase(
"Bookmark
")
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(
"Caption
")
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
816 Case UCase(
"CurrentRecord
")
817 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
818 If pvValue
< 1 Then Goto Trace_Error_Value
819 DatabaseForm.absolute(pvValue)
820 Case UCase(
"Filter
")
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(
"FilterOn
")
824 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
825 DatabaseForm.ApplyFilter = pvValue
826 DatabaseForm.reload()
827 Case UCase(
"Height
")
828 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric(), , False) Then Goto Trace_Error_Value
829 If Utils._hasUNOProperty(ContainerWindow,
"IsMaximized
") Then
' Ignored when
<= OO3.2
830 ContainerWindow.IsMaximized = False
831 ContainerWindow.IsMinimized = False
833 ContainerWindow.setPosSize(
0,
0,
0, pvValue, com.sun.star.awt.PosSize.HEIGHT)
834 Case UCase(
"OrderBy
")
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(
"OrderByOn
")
838 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
839 If pvValue Then DatabaseForm.Order = _OrderBy Else DatabaseForm.Order =
""
840 DatabaseForm.reload()
841 Case UCase(
"RecordSource
")
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 =
""
846 DatabaseForm.reload()
847 Case UCase(
"Visible
")
848 If Not Utils._CheckArgument(pvValue, iArgNr, vbBoolean, , False) Then Goto Trace_Error_Value
849 ContainerWindow.setVisible(pvValue)
850 Case UCase(
"Width
")
851 If Not Utils._CheckArgument(pvValue, iArgNr, Utils._AddNumeric()) Then Goto Trace_Error_Value
852 If Utils._hasUNOProperty(ContainerWindow,
"IsMaximized
") Then
' Ignored when
<= OO3.2
853 ContainerWindow.IsMaximized = False
854 ContainerWindow.IsMinimized = False
856 ContainerWindow.setPosSize(
0,
0, pvValue,
0, com.sun.star.awt.PosSize.WIDTH)
862 Utils._ResetCalledSub(
"Form.set
" & psProperty)
865 TraceError(TRACEFATAL, ERRFORMNOTOPEN, Utils._CalledSub(),
0,
1, _Name)
869 TraceError(TRACEFATAL, ERRPROPERTY, Utils._CalledSub(),
0,
1, psProperty)
873 TraceError(TRACEFATAL, ERRPROPERTYVALUE, Utils._CalledSub(),
0,
1, Array(pvValue, psProperty))
877 TraceError(TRACEABORT, Err,
"Form._PropertySet
", Erl)
880 End Function
' _PropertySet