summaryrefslogtreecommitdiff
path: root/wizards/source
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2021-07-07 13:09:43 +0200
committerJean-Pierre Ledure <jp@ledure.be>2021-07-07 14:31:04 +0200
commitf3657a886d99a56366104335b0c4939ac0d0cb57 (patch)
tree4622e3f79ccc1dbda33387bd27222d0d1f08e19c /wizards/source
parentd9d86730a6acbb7fe1c94d7bf8b58b81ab51b4a6 (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.py16
-rw-r--r--wizards/source/sfdocuments/SF_Document.xba74
-rw-r--r--wizards/source/sfdocuments/SF_Writer.xba76
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 &apos; SFDocuments.SF_Document.CloseDocument
REM -----------------------------------------------------------------------------
-Public Function Forms(Optional ByVal Form As Variant) As Variant
-&apos;&apos;&apos; APPLICABLE ONLY ON WRITER DOCUMENTS
-&apos;&apos;&apos; Return either
-&apos;&apos;&apos; - the list of the Forms contained in the form document
-&apos;&apos;&apos; - a SFDocuments.Form object based on its name or its index
-&apos;&apos;&apos; Args:
-&apos;&apos;&apos; Form: a form stored in the document given by its name or its index
-&apos;&apos;&apos; When absent, the list of available forms is returned
-&apos;&apos;&apos; To get the first (unique ?) form stored in the form document, set Form = 0
-&apos;&apos;&apos; Exceptions:
-&apos;&apos;&apos; WRITERFORMNOTFOUNDERROR Form not found
-&apos;&apos;&apos; Returns:
-&apos;&apos;&apos; A zero-based array of strings if Form is absent
-&apos;&apos;&apos; An instance of the SF_Form class if Form exists
-&apos;&apos;&apos; Example:
-&apos;&apos;&apos; Dim myForm As Object, myList As Variant
-&apos;&apos;&apos; myList = oDoc.Forms()
-&apos;&apos;&apos; Set myForm = oDoc.Forms(&quot;myForm&quot;)
-
-Dim oForm As Object &apos; The new Form class instance
-Dim oMainForm As Object &apos; com.sun.star.comp.sdb.Content
-Dim oXForm As Object &apos; com.sun.star.form.XForm
-Dim vFormNames As Variant &apos; Array of form names
-Dim oForms As Object &apos; Forms collection
-Const cstDrawPage = 0 &apos; Only 1 drawpage in a Writer document
-
-Const cstThisSub = &quot;SFDocuments.Document.Forms&quot;
-Const cstSubArgs = &quot;[Form=&quot;&quot;&quot;&quot;]&quot;
-
- If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
-
-Check:
- If IsMissing(Form) Or IsEmpty(Form) Then Form = &quot;&quot;
- If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
- If Not _IsStillAlive() Then GoTo Finally
- If Not ScriptForge.SF_Utils._Validate(Form, &quot;Form&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
- End If
-
-Try:
- &apos; Start from the document component and go down to forms
- Set oForms = _Component.DrawPages(cstDrawPage).Forms
- vFormNames = oForms.getElementNames()
-
- If Len(Form) = 0 Then &apos; Return the list of valid form names
- Forms = vFormNames
- Else
- If VarType(Form) = V_STRING Then &apos; Find the form by name
- If Not ScriptForge.SF_Array.Contains(vFormNames, Form, CaseSensitive := True) Then GoTo CatchNotFound
- Set oXForm = oForms.getByName(Form)
- Else &apos; Find the form by index
- If Form &lt; 0 Or Form &gt;= oForms.Count Then GoTo CatchNotFound
- Set oXForm = oForms.getByIndex(Form)
- End If
- &apos; 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 &apos; SFDocuments.SF_Document.Forms
-
-REM -----------------------------------------------------------------------------
Public Function GetProperty(Optional ByVal PropertyName As Variant) As Variant
&apos;&apos;&apos; Return the actual value of the given property
&apos;&apos;&apos; 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 = &quot;UNKNOWNFILEERROR&quot;
+Private Const WRITERFORMNOTFOUNDERROR = &quot;WRITERFORMNOTFOUNDERROR&quot;
REM ============================================================= PRIVATE MEMBERS
@@ -97,6 +97,79 @@ REM ================================================================== PROPERTIE
REM ===================================================================== METHODS
REM -----------------------------------------------------------------------------
+Public Function Forms(Optional ByVal Form As Variant) As Variant
+&apos;&apos;&apos; Return either
+&apos;&apos;&apos; - the list of the Forms contained in the form document
+&apos;&apos;&apos; - a SFDocuments.Form object based on its name or its index
+&apos;&apos;&apos; Args:
+&apos;&apos;&apos; Form: a form stored in the document given by its name or its index
+&apos;&apos;&apos; When absent, the list of available forms is returned
+&apos;&apos;&apos; To get the first (unique ?) form stored in the form document, set Form = 0
+&apos;&apos;&apos; Exceptions:
+&apos;&apos;&apos; WRITERFORMNOTFOUNDERROR Form not found
+&apos;&apos;&apos; Returns:
+&apos;&apos;&apos; A zero-based array of strings if Form is absent
+&apos;&apos;&apos; An instance of the SF_Form class if Form exists
+&apos;&apos;&apos; Example:
+&apos;&apos;&apos; Dim myForm As Object, myList As Variant
+&apos;&apos;&apos; myList = oDoc.Forms()
+&apos;&apos;&apos; Set myForm = oDoc.Forms(&quot;myForm&quot;)
+
+Dim oForm As Object &apos; The new Form class instance
+Dim oMainForm As Object &apos; com.sun.star.comp.sdb.Content
+Dim oXForm As Object &apos; com.sun.star.form.XForm
+Dim vFormNames As Variant &apos; Array of form names
+Dim oForms As Object &apos; Forms collection
+Const cstDrawPage = 0 &apos; Only 1 drawpage in a Writer document
+
+Const cstThisSub = &quot;SFDocuments.Writer.Forms&quot;
+Const cstSubArgs = &quot;[Form=&quot;&quot;&quot;&quot;]&quot;
+
+ If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
+
+Check:
+ If IsMissing(Form) Or IsEmpty(Form) Then Form = &quot;&quot;
+ If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+ If Not _IsStillAlive() Then GoTo Finally
+ If Not ScriptForge.SF_Utils._Validate(Form, &quot;Form&quot;, Array(V_STRING, ScriptForge.V_NUMERIC)) Then GoTo Finally
+ End If
+
+Try:
+ &apos; Start from the document component and go down to forms
+ Set oForms = _Component.DrawPages(cstDrawPage).Forms
+ vFormNames = oForms.getElementNames()
+
+ If Len(Form) = 0 Then &apos; Return the list of valid form names
+ Forms = vFormNames
+ Else
+ If VarType(Form) = V_STRING Then &apos; Find the form by name
+ If Not ScriptForge.SF_Array.Contains(vFormNames, Form, CaseSensitive := True) Then GoTo CatchNotFound
+ Set oXForm = oForms.getByName(Form)
+ Else &apos; Find the form by index
+ If Form &lt; 0 Or Form &gt;= oForms.Count Then GoTo CatchNotFound
+ Set oXForm = oForms.getByIndex(Form)
+ End If
+ &apos; 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 &apos; 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( _
&quot;Activate&quot; _
, &quot;CloseDocument&quot; _
+ , &quot;Forms&quot; _
, &quot;RunCommand&quot; _
, &quot;Save&quot; _
, &quot;SaveAs&quot; _