diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2021-07-07 13:09:43 +0200 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2021-07-07 14:31:04 +0200 |
commit | f3657a886d99a56366104335b0c4939ac0d0cb57 (patch) | |
tree | 4622e3f79ccc1dbda33387bd27222d0d1f08e19c /wizards/source | |
parent | d9d86730a6acbb7fe1c94d7bf8b58b81ab51b4a6 (diff) |
ScriptForge - (SF_Writer) move Forms() method from SF_Document
The Forms() method was placed in the SF_Document service
but was applicable only on Writer documents
Now it is placed correctly in the recently created Writer service.
Effective in Basic and Python.
Additionally redundant parentheses have been removed in scriptforge.py
Change-Id: I0d328b40577ddf81a188fdf72611f84751bcb506
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118559
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards/source')
-rw-r--r-- | wizards/source/scriptforge/python/scriptforge.py | 16 | ||||
-rw-r--r-- | wizards/source/sfdocuments/SF_Document.xba | 74 | ||||
-rw-r--r-- | wizards/source/sfdocuments/SF_Writer.xba | 76 |
3 files changed, 83 insertions, 83 deletions
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py index 689d4a9276ec..55584406bef3 100644 --- a/wizards/source/scriptforge/python/scriptforge.py +++ b/wizards/source/scriptforge/python/scriptforge.py @@ -1557,7 +1557,7 @@ class SFDatabases: """ Transform positional and keyword arguments into positional only """ - return (filename, registrationname, readonly, user, password) + return filename, registrationname, readonly, user, password def CloseDatabase(self): return self.ExecMethod(self.vbMethod, 'CloseDatabase') @@ -1631,7 +1631,7 @@ class SFDialogs: Transform positional and keyword arguments into positional only Add the XComponentContext as last argument """ - return (container, library, dialogname, ScriptForge.componentcontext) + return container, library, dialogname, ScriptForge.componentcontext def Activate(self): return self.ExecMethod(self.vbMethod, 'Activate') @@ -1740,7 +1740,7 @@ class SFDocuments: """ Transform positional and keyword arguments into positional only """ - return (windowname,) + return windowname, def Activate(self): return self.ExecMethod(self.vbMethod, 'Activate') @@ -1748,9 +1748,6 @@ class SFDocuments: def CloseDocument(self, saveask = True): return self.ExecMethod(self.vbMethod, 'CloseDocument', saveask) - def Forms(self, form = ''): - return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Forms', form) - def RunCommand(self, command): return self.ExecMethod(self.vbMethod, 'RunCommand', command) @@ -1786,7 +1783,7 @@ class SFDocuments: """ Transform positional and keyword arguments into positional only """ - return (windowname,) + return windowname, def CloseDocument(self, saveask = True): return self.ExecMethod(self.vbMethod, 'CloseDocument', saveask) @@ -1832,7 +1829,7 @@ class SFDocuments: """ Transform positional and keyword arguments into positional only """ - return (windowname,) + return windowname, # Next functions are implemented in Basic as read-only properties with 1 argument def Height(self, rangename): @@ -2097,6 +2094,9 @@ class SFDocuments: """ return (windowname,) + def Forms(self, form = ''): + return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Forms', form) + # ##############################################False################################################################## # CreateScriptService() ### diff --git a/wizards/source/sfdocuments/SF_Document.xba b/wizards/source/sfdocuments/SF_Document.xba index 3894d0fccb5b..849b357e643e 100644 --- a/wizards/source/sfdocuments/SF_Document.xba +++ b/wizards/source/sfdocuments/SF_Document.xba @@ -460,80 +460,6 @@ Catch: End Function ' SFDocuments.SF_Document.CloseDocument REM ----------------------------------------------------------------------------- -Public Function Forms(Optional ByVal Form As Variant) As Variant -''' APPLICABLE ONLY ON WRITER DOCUMENTS -''' Return either -''' - the list of the Forms contained in the form document -''' - a SFDocuments.Form object based on its name or its index -''' Args: -''' Form: a form stored in the document given by its name or its index -''' When absent, the list of available forms is returned -''' To get the first (unique ?) form stored in the form document, set Form = 0 -''' Exceptions: -''' WRITERFORMNOTFOUNDERROR Form not found -''' Returns: -''' A zero-based array of strings if Form is absent -''' An instance of the SF_Form class if Form exists -''' Example: -''' Dim myForm As Object, myList As Variant -''' myList = oDoc.Forms() -''' Set myForm = oDoc.Forms("myForm") - -Dim oForm As Object ' The new Form class instance -Dim oMainForm As Object ' com.sun.star.comp.sdb.Content -Dim oXForm As Object ' com.sun.star.form.XForm -Dim vFormNames As Variant ' Array of form names -Dim oForms As Object ' Forms collection -Const cstDrawPage = 0 ' Only 1 drawpage in a Writer document - -Const cstThisSub = "SFDocuments.Document.Forms" -Const cstSubArgs = "[Form=""""]" - - If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch - -Check: - If IsMissing(Form) Or IsEmpty(Form) Then Form = "" - If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then - If Not _IsStillAlive() Then GoTo Finally - If Not ScriptForge.SF_Utils._Validate(Form, "Form", Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally - End If - -Try: - ' Start from the document component and go down to forms - Set oForms = _Component.DrawPages(cstDrawPage).Forms - vFormNames = oForms.getElementNames() - - If Len(Form) = 0 Then ' Return the list of valid form names - Forms = vFormNames - Else - If VarType(Form) = V_STRING Then ' Find the form by name - If Not ScriptForge.SF_Array.Contains(vFormNames, Form, CaseSensitive := True) Then GoTo CatchNotFound - Set oXForm = oForms.getByName(Form) - Else ' Find the form by index - If Form < 0 Or Form >= oForms.Count Then GoTo CatchNotFound - Set oXForm = oForms.getByIndex(Form) - End If - ' Create the new Form class instance - Set oForm = SF_Register._NewForm(oXForm) - With oForm - Set .[_Parent] = [Me] - ._FormType = ISDOCFORM - Set ._Component = _Component - ._Initialize() - End With - Set Forms = oForm - End If - -Finally: - ScriptForge.SF_Utils._ExitFunction(cstThisSub) - Exit Function -Catch: - GoTo Finally -CatchNotFound: - ScriptForge.SF_Exception.RaiseFatal(WRITERFORMNOTFOUNDERROR, Form, _FileIdent()) -End Function ' SFDocuments.SF_Document.Forms - -REM ----------------------------------------------------------------------------- Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant ''' Return the actual value of the given property ''' Args: diff --git a/wizards/source/sfdocuments/SF_Writer.xba b/wizards/source/sfdocuments/SF_Writer.xba index d175d64f5e9a..2873f9057101 100644 --- a/wizards/source/sfdocuments/SF_Writer.xba +++ b/wizards/source/sfdocuments/SF_Writer.xba @@ -53,7 +53,7 @@ Option Explicit REM ================================================================== EXCEPTIONS -Private Const UNKNOWNFILEERROR = "UNKNOWNFILEERROR" +Private Const WRITERFORMNOTFOUNDERROR = "WRITERFORMNOTFOUNDERROR" REM ============================================================= PRIVATE MEMBERS @@ -97,6 +97,79 @@ REM ================================================================== PROPERTIE REM ===================================================================== METHODS REM ----------------------------------------------------------------------------- +Public Function Forms(Optional ByVal Form As Variant) As Variant +''' Return either +''' - the list of the Forms contained in the form document +''' - a SFDocuments.Form object based on its name or its index +''' Args: +''' Form: a form stored in the document given by its name or its index +''' When absent, the list of available forms is returned +''' To get the first (unique ?) form stored in the form document, set Form = 0 +''' Exceptions: +''' WRITERFORMNOTFOUNDERROR Form not found +''' Returns: +''' A zero-based array of strings if Form is absent +''' An instance of the SF_Form class if Form exists +''' Example: +''' Dim myForm As Object, myList As Variant +''' myList = oDoc.Forms() +''' Set myForm = oDoc.Forms("myForm") + +Dim oForm As Object ' The new Form class instance +Dim oMainForm As Object ' com.sun.star.comp.sdb.Content +Dim oXForm As Object ' com.sun.star.form.XForm +Dim vFormNames As Variant ' Array of form names +Dim oForms As Object ' Forms collection +Const cstDrawPage = 0 ' Only 1 drawpage in a Writer document + +Const cstThisSub = "SFDocuments.Writer.Forms" +Const cstSubArgs = "[Form=""""]" + + If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch + +Check: + If IsMissing(Form) Or IsEmpty(Form) Then Form = "" + If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then + If Not _IsStillAlive() Then GoTo Finally + If Not ScriptForge.SF_Utils._Validate(Form, "Form", Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally + End If + +Try: + ' Start from the document component and go down to forms + Set oForms = _Component.DrawPages(cstDrawPage).Forms + vFormNames = oForms.getElementNames() + + If Len(Form) = 0 Then ' Return the list of valid form names + Forms = vFormNames + Else + If VarType(Form) = V_STRING Then ' Find the form by name + If Not ScriptForge.SF_Array.Contains(vFormNames, Form, CaseSensitive := True) Then GoTo CatchNotFound + Set oXForm = oForms.getByName(Form) + Else ' Find the form by index + If Form < 0 Or Form >= oForms.Count Then GoTo CatchNotFound + Set oXForm = oForms.getByIndex(Form) + End If + ' Create the new Form class instance + Set oForm = SF_Register._NewForm(oXForm) + With oForm + Set .[_Parent] = [Me] + ._FormType = ISDOCFORM + Set ._Component = _Component + ._Initialize() + End With + Set Forms = oForm + End If + +Finally: + ScriptForge.SF_Utils._ExitFunction(cstThisSub) + Exit Function +Catch: + GoTo Finally +CatchNotFound: + ScriptForge.SF_Exception.RaiseFatal(WRITERFORMNOTFOUNDERROR, Form, _FileIdent()) +End Function ' SFDocuments.SF_Writer.Forms + +REM ----------------------------------------------------------------------------- Public Function GetProperty(Optional ByVal PropertyName As Variant _ , Optional ObjectName As Variant _ ) As Variant @@ -146,6 +219,7 @@ Public Function Methods() As Variant Methods = Array( _ "Activate" _ , "CloseDocument" _ + , "Forms" _ , "RunCommand" _ , "Save" _ , "SaveAs" _ |