summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2021-01-12 15:38:15 +0100
committerJean-Pierre Ledure <jp@ledure.be>2021-01-13 10:43:28 +0100
commitedb2724623e58cd8c9a5d3a85e8ee5d3858872d5 (patch)
tree7d379160384541bae8e1494da78c5e12ae1e7a0b /wizards
parent3ae18b4e8ac615a4150f72630fea64b655b960b9 (diff)
ScriptForge - (SF_Form)get/set properties of forms/subforms
Includes a bunch of OnXxx event properties Change-Id: Ie2cbb91bb29288a17eb835e8abeeeaa6e8ef6d2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109177 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/sfdocuments/SF_Calc.xba4
-rw-r--r--wizards/source/sfdocuments/SF_Document.xba4
-rw-r--r--wizards/source/sfdocuments/SF_Form.xba485
-rw-r--r--wizards/source/sfdocuments/SF_Register.xba123
4 files changed, 553 insertions, 63 deletions
diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba
index 852cd0ad138d..c1e4c1c75549 100644
--- a/wizards/source/sfdocuments/SF_Calc.xba
+++ b/wizards/source/sfdocuments/SF_Calc.xba
@@ -16,10 +16,10 @@ Option Explicit
&apos;&apos;&apos; =======
&apos;&apos;&apos;
&apos;&apos;&apos; The SFDocuments library gathers a number of methods and properties making easy
-&apos;&apos;&apos; the management and several manipulations of LibreOffice documents
+&apos;&apos;&apos; managing and manipulating LibreOffice documents
&apos;&apos;&apos;
&apos;&apos;&apos; Some methods are generic for all types of documents: they are combined in the SF_Document module.
-&apos;&apos;&apos; Specific properties and methods are implemented in the concerned subclass(es) SF_Calc, SF_Writer, ...
+&apos;&apos;&apos; Specific properties and methods are implemented in the concerned subclass(es) SF_Calc, SF_Base, ...
&apos;&apos;&apos;
&apos;&apos;&apos; To workaround the absence of class inheritance in LibreOffice Basic, some redundancy is necessary
&apos;&apos;&apos; Each subclass MUST implement also the generic methods and properties, even if they only call
diff --git a/wizards/source/sfdocuments/SF_Document.xba b/wizards/source/sfdocuments/SF_Document.xba
index 7b66600794a9..b4d3edbe915a 100644
--- a/wizards/source/sfdocuments/SF_Document.xba
+++ b/wizards/source/sfdocuments/SF_Document.xba
@@ -16,13 +16,13 @@ Option Explicit
&apos;&apos;&apos; ===========
&apos;&apos;&apos;
&apos;&apos;&apos; The SFDocuments library gathers a number of methods and properties making easy
-&apos;&apos;&apos; the management and several manipulations of LibreOffice documents
+&apos;&apos;&apos; managing and manipulating LibreOffice documents
&apos;&apos;&apos;
&apos;&apos;&apos; Some methods are generic for all types of documents: they are combined in the
&apos;&apos;&apos; current SF_Document module
&apos;&apos;&apos; - saving, closing documents
&apos;&apos;&apos; - accessing their standard or custom properties
-&apos;&apos;&apos; Specific properties and methods are implemented in the concerned subclass(es) SF_Calc, SF_Writer, ...
+&apos;&apos;&apos; Specific properties and methods are implemented in the concerned subclass(es) SF_Calc, SF_Base, ...
&apos;&apos;&apos;
&apos;&apos;&apos; Documents might contain forms. The current service gives access to the &quot;SFDocuments.Form&quot; service
&apos;&apos;&apos;
diff --git a/wizards/source/sfdocuments/SF_Form.xba b/wizards/source/sfdocuments/SF_Form.xba
index 1c6b14770055..56e60785e40c 100644
--- a/wizards/source/sfdocuments/SF_Form.xba
+++ b/wizards/source/sfdocuments/SF_Form.xba
@@ -26,7 +26,7 @@ Option Explicit
&apos;&apos;&apos; FormDocument:
&apos;&apos;&apos; For usual documents, there is only 1 form document. It is in fact the document itself.
&apos;&apos;&apos; A Base document may contain an unlimited number of form documents.
-&apos;&apos;&apos; In the Base terminology they are called &quot;forms&quot;. This could create some confusion.
+&apos;&apos;&apos; In the Base terminology they are called &quot;forms&quot; or &quot;Base forms&quot;. This could create some confusion.
&apos;&apos;&apos; They can be organized in folders. Their name is then always the full path of folders + form
&apos;&apos;&apos; with the slash (&quot;/&quot;) as path separator
&apos;&apos;&apos; A FormDocument is a set of Forms. Form names are visible in the user interface thanks to the form navigator
@@ -142,28 +142,100 @@ End Function &apos; SFDocuments.SF_Form Explicit Destructor
REM ================================================================== PROPERTIES
REM -----------------------------------------------------------------------------
-Property Get Caption() As Variant
-&apos;&apos;&apos; The Caption property refers to the title of the Form
- Caption = _PropertyGet(&quot;Caption&quot;)
-End Property &apos; SFDocuments.SF_Form.Caption (get)
+Property Get AllowDeletes() As Variant
+&apos;&apos;&apos; The AllowDeletes property specifies if the form allows to delete records
+ AllowDeletes = _PropertyGet(&quot;AllowDeletes&quot;)
+End Property &apos; SFDocuments.SF_Form.AllowDeletes (get)
REM -----------------------------------------------------------------------------
-Property Let Caption(Optional ByVal pvCaption As Variant)
-&apos;&apos;&apos; Set the updatable property Caption
- _PropertySet(&quot;Caption&quot;, pvCaption)
-End Property &apos; SFDocumentsDialog.SF_Form.Caption (let)
+Property Let AllowDeletes(Optional ByVal pvAllowDeletes As Variant)
+&apos;&apos;&apos; Set the updatable property AllowDeletes
+ _PropertySet(&quot;AllowDeletes&quot;, pvAllowDeletes)
+End Property &apos; SFDocuments.SF_Form.AllowDeletes (let)
REM -----------------------------------------------------------------------------
-Property Get Height() As Variant
-&apos;&apos;&apos; The Height property refers to the height of the Form box
- Height = _PropertyGet(&quot;Height&quot;)
-End Property &apos; SFDocuments.SF_Form.Height (get)
+Property Get AllowInserts() As Variant
+&apos;&apos;&apos; The AllowInserts property specifies if the form allows to add records
+ AllowInserts = _PropertyGet(&quot;AllowInserts&quot;)
+End Property &apos; SFDocuments.SF_Form.AllowInserts (get)
REM -----------------------------------------------------------------------------
-Property Let Height(Optional ByVal pvHeight As Variant)
-&apos;&apos;&apos; Set the updatable property Height
- _PropertySet(&quot;Height&quot;, pvHeight)
-End Property &apos; SFDocuments.SF_Form.Height (let)
+Property Let AllowInserts(Optional ByVal pvAllowInserts As Variant)
+&apos;&apos;&apos; Set the updatable property AllowInserts
+ _PropertySet(&quot;AllowInserts&quot;, pvAllowInserts)
+End Property &apos; SFDocuments.SF_Form.AllowInserts (let)
+
+REM -----------------------------------------------------------------------------
+Property Get AllowUpdates() As Variant
+&apos;&apos;&apos; The AllowUpdates property specifies if the form allows to update records
+ AllowUpdates = _PropertyGet(&quot;AllowUpdates&quot;)
+End Property &apos; SFDocuments.SF_Form.AllowUpdates (get)
+
+REM -----------------------------------------------------------------------------
+Property Let AllowUpdates(Optional ByVal pvAllowUpdates As Variant)
+&apos;&apos;&apos; Set the updatable property AllowUpdates
+ _PropertySet(&quot;AllowUpdates&quot;, pvAllowUpdates)
+End Property &apos; SFDocuments.SF_Form.AllowUpdates (let)
+
+REM -----------------------------------------------------------------------------
+Property Get BaseForm() As String
+&apos;&apos;&apos; The BaseForm property specifies the hierarchical name of the Base form containing the actual form
+ BaseForm = _PropertyGet(&quot;BaseForm&quot;)
+End Property &apos; SFDocuments.SF_Form.BaseForm (get)
+
+REM -----------------------------------------------------------------------------
+Property Get Bookmark() As Variant
+&apos;&apos;&apos; The Bookmark property specifies uniquely the current record of the form&apos;s underlying table, query or SQL statement.
+ Bookmark = _PropertyGet(&quot;Bookmark&quot;)
+End Property &apos; SFDocuments.SF_Form.Bookmark (get)
+
+REM -----------------------------------------------------------------------------
+Property Let Bookmark(Optional ByVal pvBookmark As Variant)
+&apos;&apos;&apos; Set the updatable property Bookmark
+ _PropertySet(&quot;Bookmark&quot;, pvBookmark)
+End Property &apos; SFDocuments.SF_Form.Bookmark (let)
+
+REM -----------------------------------------------------------------------------
+Property Get CurrentRecord() As Variant
+&apos;&apos;&apos; The CurrentRecord property identifies the current record in the recordset being viewed on a form
+ CurrentRecord = _PropertyGet(&quot;CurrentRecord&quot;)
+End Property &apos; SFDocuments.SF_Form.CurrentRecord (get)
+
+REM -----------------------------------------------------------------------------
+Property Let CurrentRecord(Optional ByVal pvCurrentRecord As Variant)
+&apos;&apos;&apos; Set the updatable property CurrentRecord
+&apos;&apos;&apos; If the row number is positive, the cursor moves to the given row number with respect to the beginning of the result set.
+&apos;&apos;&apos; The first row is row 1, the second is row 2, and so on.
+&apos;&apos;&apos; If the given row number is negative, the cursor moves to an absolute row position with respect to the end of the result set.
+&apos;&apos;&apos; For example, setting CurrentRecord = -1 positions the cursor on the last row, -2 indicates the next-to-last row, and so on
+ _PropertySet(&quot;CurrentRecord&quot;, pvCurrentRecord)
+End Property &apos; SFDocuments.SF_Form.CurrentRecord (let)
+
+REM -----------------------------------------------------------------------------
+Property Get Filter() As Variant
+&apos;&apos;&apos; The Filter property specifies a subset of records to be displayed.
+ Filter = _PropertyGet(&quot;Filter&quot;)
+End Property &apos; SFDocuments.SF_Form.Filter (get)
+
+REM -----------------------------------------------------------------------------
+Property Let Filter(Optional ByVal pvFilter As Variant)
+&apos;&apos;&apos; Set the updatable property Filter
+ _PropertySet(&quot;Filter&quot;, pvFilter)
+End Property &apos; SFDocuments.SF_Form.Filter (let)
+
+REM -----------------------------------------------------------------------------
+Property Get LinkChildFields() As Variant
+&apos;&apos;&apos; The LinkChildFields property specifies how records in a subform (child) are linked to records in its parent form
+&apos;&apos;&apos; It returns an array of strings
+ LinkChildFields = _PropertyGet(&quot;LinkChildFields&quot;)
+End Property &apos; SFDocuments.SF_Form.LinkChildFields (get)
+
+REM -----------------------------------------------------------------------------
+Property Get LinkParentFields() As Variant
+&apos;&apos;&apos; The LinkParentFields property specifies how records in a subform (Child) are linked to records in its parent form
+&apos;&apos;&apos; It returns an array of strings
+ LinkParentFields = _PropertyGet(&quot;LinkParentFields&quot;)
+End Property &apos; SFDocuments.SF_Form.LinkParentFields (get)
REM -----------------------------------------------------------------------------
Property Get Name() As String
@@ -172,34 +244,203 @@ Property Get Name() As String
End Property &apos; SFDocuments.SF_Form.Name
REM -----------------------------------------------------------------------------
-Property Get Parent() As Object
-&apos;&apos;&apos; Return the Parent of the actual Form
- Parent = _PropertyGet(&quot;Parent&quot;)
-End Property &apos; SFDocuments.SF_Form.Parent
+Property Get OnApproveCursorMove() As Variant
+&apos;&apos;&apos; The OnApproveCursorMove property specifies the script to trigger when this event occurs
+ OnApproveCursorMove = _PropertyGet(&quot;OnApproveCursorMove&quot;)
+End Property &apos; SFDocuments.SF_Form.OnApproveCursorMove (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnApproveCursorMove(Optional ByVal pvOnApproveCursorMove As Variant)
+&apos;&apos;&apos; Set the updatable property OnApproveCursorMove
+ _PropertySet(&quot;OnApproveCursorMove&quot;, pvOnApproveCursorMove)
+End Property &apos; SFDocuments.SF_Form.OnApproveCursorMove (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnApproveReset() As Variant
+&apos;&apos;&apos; The OnApproveReset property specifies the script to trigger when this event occurs
+ OnApproveReset = _PropertyGet(&quot;OnApproveReset&quot;)
+End Property &apos; SFDocuments.SF_Form.OnApproveReset (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnApproveReset(Optional ByVal pvOnApproveReset As Variant)
+&apos;&apos;&apos; Set the updatable property OnApproveReset
+ _PropertySet(&quot;OnApproveReset&quot;, pvOnApproveReset)
+End Property &apos; SFDocuments.SF_Form.OnApproveReset (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnApproveRowChange() As Variant
+&apos;&apos;&apos; The OnApproveRowChange property specifies the script to trigger when this event occurs
+ OnApproveRowChange = _PropertyGet(&quot;OnApproveRowChange&quot;)
+End Property &apos; SFDocuments.SF_Form.OnApproveRowChange (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnApproveRowChange(Optional ByVal pvOnApproveRowChange As Variant)
+&apos;&apos;&apos; Set the updatable property OnApproveRowChange
+ _PropertySet(&quot;OnApproveRowChange&quot;, pvOnApproveRowChange)
+End Property &apos; SFDocuments.SF_Form.OnApproveRowChange (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnApproveSubmit() As Variant
+&apos;&apos;&apos; The OnApproveSubmit property specifies the script to trigger when this event occurs
+ OnApproveSubmit = _PropertyGet(&quot;OnApproveSubmit&quot;)
+End Property &apos; SFDocuments.SF_Form.OnApproveSubmit (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnApproveSubmit(Optional ByVal pvOnApproveSubmit As Variant)
+&apos;&apos;&apos; Set the updatable property OnApproveSubmit
+ _PropertySet(&quot;OnApproveSubmit&quot;, pvOnApproveSubmit)
+End Property &apos; SFDocuments.SF_Form.OnApproveSubmit (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnConfirmDelete() As Variant
+&apos;&apos;&apos; The OnConfirmDelete property specifies the script to trigger when this event occurs
+ OnConfirmDelete = _PropertyGet(&quot;OnConfirmDelete&quot;)
+End Property &apos; SFDocuments.SF_Form.OnConfirmDelete (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnConfirmDelete(Optional ByVal pvOnConfirmDelete As Variant)
+&apos;&apos;&apos; Set the updatable property OnConfirmDelete
+ _PropertySet(&quot;OnConfirmDelete&quot;, pvOnConfirmDelete)
+End Property &apos; SFDocuments.SF_Form.OnConfirmDelete (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnCursorMoved() As Variant
+&apos;&apos;&apos; The OnCursorMoved property specifies the script to trigger when this event occurs
+ OnCursorMoved = _PropertyGet(&quot;OnCursorMoved&quot;)
+End Property &apos; SFDocuments.SF_Form.OnCursorMoved (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnCursorMoved(Optional ByVal pvOnCursorMoved As Variant)
+&apos;&apos;&apos; Set the updatable property OnCursorMoved
+ _PropertySet(&quot;OnCursorMoved&quot;, pvOnCursorMoved)
+End Property &apos; SFDocuments.SF_Form.OnCursorMoved (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnErrorOccurred() As Variant
+&apos;&apos;&apos; The OnErrorOccurred property specifies the script to trigger when this event occurs
+ OnErrorOccurred = _PropertyGet(&quot;OnErrorOccurred&quot;)
+End Property &apos; SFDocuments.SF_Form.OnErrorOccurred (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnErrorOccurred(Optional ByVal pvOnErrorOccurred As Variant)
+&apos;&apos;&apos; Set the updatable property OnErrorOccurred
+ _PropertySet(&quot;OnErrorOccurred&quot;, pvOnErrorOccurred)
+End Property &apos; SFDocuments.SF_Form.OnErrorOccurred (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnLoaded() As Variant
+&apos;&apos;&apos; The OnLoaded property specifies the script to trigger when this event occurs
+ OnLoaded = _PropertyGet(&quot;OnLoaded&quot;)
+End Property &apos; SFDocuments.SF_Form.OnLoaded (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnLoaded(Optional ByVal pvOnLoaded As Variant)
+&apos;&apos;&apos; Set the updatable property OnLoaded
+ _PropertySet(&quot;OnLoaded&quot;, pvOnLoaded)
+End Property &apos; SFDocuments.SF_Form.OnLoaded (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnReloaded() As Variant
+&apos;&apos;&apos; The OnReloaded property specifies the script to trigger when this event occurs
+ OnReloaded = _PropertyGet(&quot;OnReloaded&quot;)
+End Property &apos; SFDocuments.SF_Form.OnReloaded (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnReloaded(Optional ByVal pvOnReloaded As Variant)
+&apos;&apos;&apos; Set the updatable property OnReloaded
+ _PropertySet(&quot;OnReloaded&quot;, pvOnReloaded)
+End Property &apos; SFDocuments.SF_Form.OnReloaded (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnReloading() As Variant
+&apos;&apos;&apos; The OnReloading property specifies the script to trigger when this event occurs
+ OnReloading = _PropertyGet(&quot;OnReloading&quot;)
+End Property &apos; SFDocuments.SF_Form.OnReloading (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnReloading(Optional ByVal pvOnReloading As Variant)
+&apos;&apos;&apos; Set the updatable property OnReloading
+ _PropertySet(&quot;OnReloading&quot;, pvOnReloading)
+End Property &apos; SFDocuments.SF_Form.OnReloading (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnResetted() As Variant
+&apos;&apos;&apos; The OnResetted property specifies the script to trigger when this event occurs
+ OnResetted = _PropertyGet(&quot;OnResetted&quot;)
+End Property &apos; SFDocuments.SF_Form.OnResetted (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnResetted(Optional ByVal pvOnResetted As Variant)
+&apos;&apos;&apos; Set the updatable property OnResetted
+ _PropertySet(&quot;OnResetted&quot;, pvOnResetted)
+End Property &apos; SFDocuments.SF_Form.OnResetted (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnRowChanged() As Variant
+&apos;&apos;&apos; The OnRowChanged property specifies the script to trigger when this event occurs
+ OnRowChanged = _PropertyGet(&quot;OnRowChanged&quot;)
+End Property &apos; SFDocuments.SF_Form.OnRowChanged (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OnRowChanged(Optional ByVal pvOnRowChanged As Variant)
+&apos;&apos;&apos; Set the updatable property OnRowChanged
+ _PropertySet(&quot;OnRowChanged&quot;, pvOnRowChanged)
+End Property &apos; SFDocuments.SF_Form.OnRowChanged (let)
+
+REM -----------------------------------------------------------------------------
+Property Get OnUnloaded() As Variant
+&apos;&apos;&apos; The OnUnloaded property specifies the script to trigger when this event occurs
+ OnUnloaded = _PropertyGet(&quot;OnUnloaded&quot;)
+End Property &apos; SFDocuments.SF_Form.OnUnloaded (get)
REM -----------------------------------------------------------------------------
-Property Get Visible() As Variant
-&apos;&apos;&apos; The Visible property is False before the Execute() statement
- Visible = _PropertyGet(&quot;Visible&quot;)
-End Property &apos; SFDocuments.SF_Form.Visible (get)
+Property Let OnUnloaded(Optional ByVal pvOnUnloaded As Variant)
+&apos;&apos;&apos; Set the updatable property OnUnloaded
+ _PropertySet(&quot;OnUnloaded&quot;, pvOnUnloaded)
+End Property &apos; SFDocuments.SF_Form.OnUnloaded (let)
REM -----------------------------------------------------------------------------
-Property Let Visible(Optional ByVal pvVisible As Variant)
-&apos;&apos;&apos; Set the updatable property Visible
- _PropertySet(&quot;Visible&quot;, pvVisible)
-End Property &apos; SFDocuments.SF_Form.Visible (let)
+Property Get OnUnloading() As Variant
+&apos;&apos;&apos; The OnUnloading property specifies the script to trigger when this event occurs
+ OnUnloading = _PropertyGet(&quot;OnUnloading&quot;)
+End Property &apos; SFDocuments.SF_Form.OnUnloading (get)
REM -----------------------------------------------------------------------------
-Property Get Width() As Variant
-&apos;&apos;&apos; The Width property refers to the Width of the Form box
- Width = _PropertyGet(&quot;Width&quot;)
-End Property &apos; SFDocuments.SF_Form.Width (get)
+Property Let OnUnloading(Optional ByVal pvOnUnloading As Variant)
+&apos;&apos;&apos; Set the updatable property OnUnloading
+ _PropertySet(&quot;OnUnloading&quot;, pvOnUnloading)
+End Property &apos; SFDocuments.SF_Form.OnUnloading (let)
REM -----------------------------------------------------------------------------
-Property Let Width(Optional ByVal pvWidth As Variant)
-&apos;&apos;&apos; Set the updatable property Width
- _PropertySet(&quot;Width&quot;, pvWidth)
-End Property &apos; SFDocuments.SF_Form.Width (let)
+Property Get OrderBy() As Variant
+&apos;&apos;&apos; The OrderBy property specifies in which order the records should be displayed.
+ OrderBy = _PropertyGet(&quot;OrderBy&quot;)
+End Property &apos; SFDocuments.SF_Form.OrderBy (get)
+
+REM -----------------------------------------------------------------------------
+Property Let OrderBy(Optional ByVal pvOrderBy As Variant)
+&apos;&apos;&apos; Set the updatable property OrderBy
+ _PropertySet(&quot;OrderBy&quot;, pvOrderBy)
+End Property &apos; SFDocuments.SF_Form.OrderBy (let)
+
+REM -----------------------------------------------------------------------------
+Property Get Parent() As Object
+&apos;&apos;&apos; Return the Parent of the actual Form
+ Parent = _PropertyGet(&quot;Parent&quot;)
+End Property &apos; SFDocuments.SF_Form.Parent
+
+REM -----------------------------------------------------------------------------
+Property Get RecordSource() As Variant
+&apos;&apos;&apos; The RecordSource property specifies the source of the data,
+&apos;&apos;&apos; a table name, a query name or a SQL statement
+ RecordSource = _PropertyGet(&quot;RecordSource&quot;)
+End Property &apos; SFDocuments.SF_Form.RecordSource (get)
+
+REM -----------------------------------------------------------------------------
+Property Let RecordSource(Optional ByVal pvRecordSource As Variant)
+&apos;&apos;&apos; Set the updatable property RecordSource
+ _PropertySet(&quot;RecordSource&quot;, pvRecordSource)
+End Property &apos; SFDocuments.SF_Form.RecordSource (let)
REM -----------------------------------------------------------------------------
Property Get XForm() As Object
@@ -399,7 +640,7 @@ Try:
&apos; Fetch the shared connection
Set _Database = [_Parent].GetDatabase(User, Password)
ElseIf _FormType = ISSUBFORM Then
- &apos; Return Nothing : method is not applicable to subforms
+ Set _Database = [_Parent].GetDatabase() &apos; Recursive call, climb the tree
ElseIf Len(_Form.DataSourceName) = 0 Then &apos; There is no database linked with the form
&apos; Return Nothing
Else
@@ -488,16 +729,12 @@ Public Function Properties() As Variant
&apos;&apos;&apos; Return the list or properties of the Form class as an array
Properties = Array( _
- &quot;AllowAdditions&quot; _
- , &quot;AllowDeletions&quot; _
- , &quot;AllowEdits&quot; _
+ &quot;AllowDeletes&quot; _
+ , &quot;AllowInserts&quot; _
+ , &quot;AllowUpdates&quot; _
, &quot;Bookmark&quot; _
- , &quot;Caption&quot; _
, &quot;CurrentRecord&quot; _
, &quot;Filter&quot; _
- , &quot;FilterOn&quot; _
- , &quot;Height&quot; _
- , &quot;IsLoaded&quot; _
, &quot;LinkChildFields&quot; _
, &quot;LinkParentFields&quot; _
, &quot;Name&quot; _
@@ -517,11 +754,8 @@ Public Function Properties() As Variant
, &quot;OnUnloaded&quot; _
, &quot;OnUnloading&quot; _
, &quot;OrderBy&quot; _
- , &quot;OrderByOn&quot; _
, &quot;Parent&quot; _
, &quot;RecordSource&quot; _
- , &quot;Visible&quot; _
- , &quot;Width&quot; _
, &quot;XForm&quot; _
)
@@ -551,7 +785,6 @@ Check:
Try:
SetProperty = _PropertySet(PropertyName, Value)
- Set UI = ScriptForge.SF_Services.CreateScriptService(&quot;ScriptForge.UI&quot;)
Finally:
SF_Utils._ExitFunction(cstThisSub)
@@ -626,6 +859,7 @@ Try:
Set ._FormDocument = _FormDocument
._SheetName = _SheetName
._FormDocumentName = _FormDocumentName
+ Set ._Database = _Database
._Initialize()
End With
Set Subforms = oSubform
@@ -665,8 +899,24 @@ Private Function _GetListener(ByVal psEventName As String) As String
&apos;&apos;&apos; Return the X...Listener corresponding with the event name in argument
Select Case UCase(psEventName)
- Case Else
- _GetListener = &quot;&quot;
+ Case UCase(&quot;OnApproveCursorMove&quot;)
+ _GetListener = &quot;XRowSetApproveListener&quot;
+ Case UCase(&quot;OnApproveParameter&quot;)
+ _GetListener = &quot;XDatabaseParameterListener&quot;
+ Case UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnResetted&quot;)
+ _GetListener = &quot;XResetListener&quot;
+ Case UCase(&quot;OnApproveRowChange&quot;)
+ _GetListener = &quot;XRowSetApproveListener&quot;
+ Case UCase(&quot;OnApproveSubmit&quot;)
+ _GetListener = &quot;XSubmitListener&quot;
+ Case UCase(&quot;OnConfirmDelete&quot;)
+ _GetListener = &quot;XConfirmDeleteListener&quot;
+ Case UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnRowChanged&quot;)
+ _GetListener = &quot;XRowSetListener&quot;
+ Case UCase(&quot;OnErrorOccurred&quot;)
+ _GetListener = &quot;XSQLErrorListener&quot;
+ Case UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
+ _GetListener = &quot;XLoadListener&quot;
End Select
End Function &apos; SFDocuments.SF_Form._GetListener
@@ -811,6 +1061,7 @@ Private Function _PropertyGet(Optional ByVal psProperty As String) As Variant
&apos;&apos;&apos; psProperty: the name of the property
Static oSession As Object &apos; Alias of SF_Session
+Dim vBookmark As variant &apos; Form bookmark
Dim cstThisSub As String
Const cstSubArgs = &quot;&quot;
@@ -818,18 +1069,50 @@ Const cstSubArgs = &quot;&quot;
If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs)
+ _PropertyGet = Empty
If Not _IsStillAlive() Then GoTo Finally
If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
Select Case UCase(psProperty)
-&apos; Case UCase(&quot;Caption&quot;)
-&apos; Case UCase(&quot;Height&quot;)
+ Case UCase(&quot;AllowDeletes&quot;)
+ If Not IsNull(_Form) Then _PropertyGet = _Form.AllowDeletes
+ Case UCase(&quot;AllowInserts&quot;)
+ If Not IsNull(_Form) Then _PropertyGet = _Form.AllowInserts
+ Case UCase(&quot;AllowUpdates&quot;)
+ If Not IsNull(_Form) Then _PropertyGet = _Form.AllowUpdates
+ Case UCase(&quot;BaseForm&quot;)
+ _PropertyGet = _FormDocumentName
+ Case UCase(&quot;Bookmark&quot;)
+ If IsNull(_Form) Then
+ _PropertyGet = 0
+ Else
+ On Local Error Resume Next &apos; Disable error handler because bookmarking does not always react well in events ...
+ If _Form.IsBookmarkable Then vBookmark = _Form.getBookmark() Else vBookmark = Nothing
+ If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error Goto Catch Else On Local Error Goto 0
+ If IsNull(vBookmark) Then Goto Catch
+ _PropertyGet = vBookmark
+ End If
+ Case UCase(&quot;CurrentRecord&quot;)
+ If IsNull(_Form) Then _PropertyGet = 0 Else _PropertyGet = _Form.Row
+ Case UCase(&quot;Filter&quot;)
+ If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Filter
+ Case UCase(&quot;LinkChildFields&quot;)
+ If IsNull(_Form) Or _FormType &lt;&gt; ISSUBFORM Then _PropertyGet = Array() Else _PropertyGet = _Form.DetailFields
+ Case UCase(&quot;LinkParentFields&quot;)
+ If IsNull(_Form) Or _FormType &lt;&gt; ISSUBFORM Then _PropertyGet = Array() Else _PropertyGet = _Form.MasterFields
Case UCase(&quot;Name&quot;)
_PropertyGet = _Name
+ Case UCase(&quot;OnApproveCursorMove&quot;), UCase(&quot;OnApproveParameter&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveRowChange&quot;) _
+ , UCase(&quot;OnApproveSubmit&quot;), UCase(&quot;OnConfirmDelete&quot;), UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnErrorOccurred&quot;) _
+ , UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnResetted&quot;), UCase(&quot;OnRowChanged&quot;) _
+ , UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
+ If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = SF_Register._GetEventScriptCode(_Form, psProperty, _Name)
+ Case UCase(&quot;OrderBy&quot;)
+ If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Order
Case UCase(&quot;Parent&quot;)
_PropertyGet = [_Parent]
-&apos; Case UCase(&quot;Visible&quot;)
-&apos; Case UCase(&quot;Width&quot;)
+ Case UCase(&quot;RecordSource&quot;)
+ If IsNull(_Form) Then _PropertyGet = &quot;&quot; Else _PropertyGet = _Form.Command
Case UCase(&quot;XForm&quot;)
Set _PropertyGet = _Form
Case Else
@@ -855,6 +1138,9 @@ Private Function _PropertySet(Optional ByVal psProperty As String _
&apos;&apos;&apos; True if successful
Dim bSet As Boolean &apos; Return value
+Dim oDatabase As Object &apos; Database class instance
+Dim iCommandType As Integer &apos; Record source type: 0 = Table, 1 = Query, 2 = SELECT
+Dim sCommand As String &apos; Record source
Static oSession As Object &apos; Alias of SF_Session
Dim cstThisSub As String
Const cstSubArgs = &quot;Value&quot;
@@ -869,10 +1155,91 @@ Const cstSubArgs = &quot;Value&quot;
If IsNull(oSession) Then Set oSession = ScriptForge.SF_Services.CreateScriptService(&quot;Session&quot;)
bSet = True
Select Case UCase(psProperty)
- Case UCase(&quot;Caption&quot;)
- Case UCase(&quot;Height&quot;)
- Case UCase(&quot;Visible&quot;)
- Case UCase(&quot;Width&quot;)
+ Case UCase(&quot;AllowDeletes&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowDeletes&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
+ If Not IsNull(_Form) Then
+ _Form.AllowDeletes = pvValue
+ _Form.reload()
+ End If
+ Case UCase(&quot;AllowInserts&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowInserts&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
+ If Not IsNull(_Form) Then
+ _Form.AllowInserts = pvValue
+ _Form.reload()
+ End If
+ Case UCase(&quot;AllowUpdates&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;AllowUpdates&quot;, ScriptForge.V_BOOLEAN) Then GoTo Finally
+ If Not IsNull(_Form) Then
+ _Form.AllowUpdates = pvValue
+ _Form.reload()
+ End If
+ Case UCase(&quot;Bookmark&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Bookmark&quot;, Array(ScriptForge.V_NUMERIC, ScriptForge.V_OBJECT)) Then GoTo Finally
+ If Not IsNull(pvValue) And Not IsNull(_Form) Then bSet = _Form.moveToBookmark(pvValue)
+ Case UCase(&quot;CurrentRecord&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;CurrentRecord&quot;, ScriptForge.V_NUMERIC) Then GoTo Finally
+ If Not IsNull(_Form) Then bSet = _Form.absolute(pvValue)
+ Case UCase(&quot;Filter&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;Filter&quot;, V_STRING) Then GoTo Finally
+ If Not IsNull(_Form) Then
+ With _Form
+ If Len(pvValue) &gt; 0 Then
+ Set oDatabase = GetDatabase()
+ If Not IsNull(oDatabase) Then .Filter = oDatabase._ReplaceSquareBrackets(pvValue) Else .Filter = pvValue
+ Else
+ .Filter = &quot;&quot;
+ End If
+ .ApplyFilter = True
+ .reload()
+ End With
+ End If
+ Case UCase(&quot;OnApproveCursorMove&quot;), UCase(&quot;OnApproveParameter&quot;), UCase(&quot;OnApproveReset&quot;), UCase(&quot;OnApproveRowChange&quot;) _
+ , UCase(&quot;OnApproveSubmit&quot;), UCase(&quot;OnConfirmDelete&quot;), UCase(&quot;OnCursorMoved&quot;), UCase(&quot;OnErrorOccurred&quot;) _
+ , UCase(&quot;OnLoaded&quot;), UCase(&quot;OnReloaded&quot;), UCase(&quot;OnReloading&quot;), UCase(&quot;OnResetted&quot;), UCase(&quot;OnRowChanged&quot;) _
+ , UCase(&quot;OnUnloaded&quot;), UCase(&quot;OnUnloading&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, psProperty, V_STRING) Then Goto Finally
+ If Not IsNull(_Form) Then
+ bSet = SF_Register._RegisterEventScript(_Form _
+ , psProperty _
+ , _GetListener(psProperty) _
+ , pvValue _
+ , _Name _
+ )
+ End If
+ Case UCase(&quot;OrderBy&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;OrderBy&quot;, V_STRING) Then GoTo Finally
+ If Not IsNull(_Form) Then
+ With _Form
+ If Len(pvValue) &gt; 0 Then
+ Set oDatabase = GetDatabase()
+ If Not IsNull(oDatabase) Then .Order = oDatabase._ReplaceSquareBrackets(pvValue) Else .Order = pvValue
+ Else
+ .Order = &quot;&quot;
+ End If
+ .reload()
+ End With
+ End If
+ Case UCase(&quot;RecordSource&quot;)
+ If Not ScriptForge.SF_Utils._Validate(pvValue, &quot;RecordSource&quot;, V_STRING) Then GoTo Finally
+ If Not IsNull(_Form) And Len(pvValue) &gt; 0 Then
+ Set oDatabase = GetDatabase()
+ If Not IsNull(oDatabase) Then
+ With oDatabase
+ If ScriptForge.SF_Array.Contains(.Tables, pvValue, CaseSensitive := True) Then
+ sCommand = pvValue
+ iCommandType = com.sun.star.sdb.CommandType.TABLE
+ ElseIf ScriptForge.SF_Array.Contains(.Queries, pvValue, CaseSensitive := True) Then
+ sCommand = pvValue
+ iCommandType = com.sun.star.sdb.CommandType.QUERY
+ ElseIf ScriptForge.SF_String.StartsWith(pvValue, &quot;SELECT&quot;, CaseSensitive := False) Then
+ sCommand = .ReplaceSquareBrackets(pvValue)
+ iCommandType = com.sun.star.sdb.CommandType.COMMAND
+ End If
+ _Form.Command = sCommand
+ _Form.CommandType = iCommandType
+ End With
+ End If
+ End If
Case Else
bSet = False
End Select
diff --git a/wizards/source/sfdocuments/SF_Register.xba b/wizards/source/sfdocuments/SF_Register.xba
index d530d5b84181..b83518d9491c 100644
--- a/wizards/source/sfdocuments/SF_Register.xba
+++ b/wizards/source/sfdocuments/SF_Register.xba
@@ -257,6 +257,64 @@ Finally:
End Function &apos; SFDocuments.SF_Register._FormEventManager
REM -----------------------------------------------------------------------------
+Public Function _GetEventScriptCode(poObject As Object _
+ , ByVal psEvent As String _
+ , ByVal psName As String _
+ ) As String
+&apos;&apos;&apos; Extract from the parent of poObject the Basic script linked to psEvent.
+&apos;&apos;&apos; Helper function common to forms and form controls
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; poObject: a com.sun.star.form.XForm or XControl object
+&apos;&apos;&apos; psEvent: the &quot;On...&quot; name of the event
+&apos;&apos;&apos; psName: the name of the object to be identified from the parent object
+&apos;&apos;&apos; Returne:
+&apos;&apos;&apos; The script to trigger when psEvent occurs
+&apos;&apos;&apos; See Scripting Framework URI Specification : https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification
+
+Dim vEvents As Variant &apos; List of available events in the parent object
+ &apos; Array of com.sun.star.script.ScriptEventDescriptor
+Dim sEvent As String &apos; The targeted event name
+Dim oParent As Object &apos; The parent object
+Dim lIndex As Long &apos; The index of the targeted event in the events list of the parent object
+Dim sName As String &apos; The corrected UNO event name
+Dim i As Long
+
+ _GetEventScriptCode = &quot;&quot;
+ On Local Error GoTo Catch
+ If Not ScriptForge.SF_Session.HasUnoMethod(poObject, &quot;getParent&quot;) Then GoTo Finally
+
+Try:
+ &apos; Find form index i.e. find control via getByIndex()
+ &apos; The name is known (= psName) but getByIndex() is not in the same sequence as getElementNames()
+ Set oParent = poObject.getParent()
+ lIndex = -1
+ For i = 0 To oParent.getCount() - 1
+ sName = oParent.getByIndex(i).Name
+ If (sName = psName) Then
+ lIndex = i
+ Exit For
+ End If
+ Next i
+ If lIndex &lt; 0 Then GoTo Finally &apos; Not found, should not happen
+
+ &apos; Find script triggered by event
+ vEvents = oParent.getScriptEvents(lIndex) &apos; Returns an array
+ &apos; Fix historical typo error
+ sEvent = Replace(LCase(Mid(psEvent, 3, 1)) &amp; Mid(psEvent, 4), &quot;errorOccurred&quot;, &quot;errorOccured&quot;)
+ For i = 0 To UBound(vEvents)
+ If vEvents(i).EventMethod = sEvent Then
+ _GetEventScriptCode = vEvents(i).ScriptCode
+ Exit For
+ End If
+ Next i
+
+Finally:
+ Exit Function
+Catch:
+ GoTo Finally
+End Function &apos; SFDocuments.SF_Register._GetEventScriptCode
+
+REM -----------------------------------------------------------------------------
Public Function _NewDocument(Optional ByVal pvArgs As Variant) As Object
&apos;&apos;&apos; Create a new instance of the (super) SF_Document class or of one of its subclasses (SF_Calc, ...)
&apos; Args:
@@ -385,5 +443,70 @@ Finally:
Exit Function
End Function &apos; SFDocuments.SF_Register._NewForm
+REM -----------------------------------------------------------------------------
+Public Function _RegisterEventScript(poObject As Object _
+ , ByVal psEvent As String _
+ , ByVal psListener As String _
+ , ByVal psScriptCode As String _
+ , ByVal psName As String _
+ ) As Boolean
+&apos;&apos;&apos; Register a script event (psEvent) to poObject (Form, SubForm or Control)
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; poObject: a com.sun.star.form.XForm or XControl object
+&apos;&apos;&apos; psEvent: the &quot;On...&quot; name of the event
+&apos;&apos;&apos; psListener: the listener name corresponding with the event
+&apos;&apos;&apos; psScriptCode: The script to trigger when psEvent occurs
+&apos;&apos;&apos; See Scripting Framework URI Specification : https://wiki.openoffice.org/wiki/Documentation/DevGuide/Scripting/Scripting_Framework_URI_Specification
+&apos;&apos;&apos; psName: the name of the object to associate with the event
+&apos;&apos;&apos; Returne:
+&apos;&apos;&apos; True when successful
+
+Dim oEvent As Object &apos; com.sun.star.script.ScriptEventDescriptor
+Dim sEvent As String &apos; The targeted event name
+Dim oParent As Object &apos; The parent object
+Dim lIndex As Long &apos; The index of the targeted event in the events list of the parent object
+Dim sName As String &apos; The corrected UNO event name
+Dim i As Long
+
+ _RegisterEventScript = False
+ On Local Error GoTo Catch
+ If Not ScriptForge.SF_Session.HasUnoMethod(poObject, &quot;getParent&quot;) Then GoTo Finally
+
+Try:
+ &apos; Find object&apos;s internal index i.e. how to reach it via getByIndex()
+ Set oParent = poObject.getParent()
+ lIndex = -1
+ For i = 0 To oParent.getCount() - 1
+ sName = oParent.getByIndex(i).Name
+ If (sName = psName) Then
+ lIndex = i
+ Exit For
+ End If
+ Next i
+ If lIndex &lt; 0 Then GoTo Finally &apos; Not found, should not happen
+
+ &apos; Fix historical typo error
+ sEvent = Replace(LCase(Mid(psEvent, 3, 1)) &amp; Mid(psEvent, 4), &quot;errorOccurred&quot;, &quot;errorOccured&quot;)
+ &apos; Apply new script code. Erasing it is done with a specific UNO method
+ If psScriptCode = &quot;&quot; Then
+ oParent.revokeScriptEvent(lIndex, psListener, sEvent, &quot;&quot;)
+ Else
+ Set oEvent = CreateUnoStruct(&quot;com.sun.star.script.ScriptEventDescriptor&quot;)
+ With oEvent
+ .ListenerType = psListener
+ .EventMethod = sEvent
+ .ScriptType = &quot;Script&quot; &apos; Better than &quot;Basic&quot;
+ .ScriptCode = psScriptCode
+ End With
+ oParent.registerScriptEvent(lIndex, oEvent)
+ End If
+ _RegisterEventScript = True
+
+Finally:
+ Exit Function
+Catch:
+ GoTo Finally
+End Function &apos; SFDocuments.SF_Register._RegisterEventScript
+
REM ============================================== END OF SFDOCUMENTS.SF_REGISTER
</script:module> \ No newline at end of file