wizards/source/scriptforge/SF_Dictionary.xba      |    2 
 wizards/source/scriptforge/SF_FileSystem.xba      |    2 
 wizards/source/scriptforge/SF_PythonHelper.xba    |   37 +++++++++++++
 wizards/source/scriptforge/SF_Services.xba        |    2 
 wizards/source/scriptforge/SF_Session.xba         |   60 ++++++++++++++++++++++
 wizards/source/scriptforge/SF_Utils.xba           |    2 
 wizards/source/scriptforge/_CodingConventions.xba |    2 
 wizards/source/scriptforge/python/scriptforge.py  |   22 +++++++-
 wizards/source/sfdocuments/SF_Base.xba            |    6 +-
 wizards/source/sfdocuments/SF_Calc.xba            |    6 +-
 wizards/source/sfdocuments/SF_Document.xba        |   43 ++++++++++++---
 wizards/source/sfdocuments/SF_Form.xba            |    2 
 wizards/source/sfdocuments/SF_FormControl.xba     |    2 
 wizards/source/sfdocuments/SF_Writer.xba          |    6 +-
 14 files changed, 170 insertions(+), 24 deletions(-)

New commits:
commit 9688e4970eed2b4bb4265df2a5781452a8ef5c52
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Sun Jan 30 17:19:31 2022 +0100
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Sun Jan 30 18:26:36 2022 +0100

    ScriptForge - (SF_Session, SF_Document) add arguments to RunCommand()
    
    Next wiki page
     https://wiki.documentfoundation.org/Development/DispatchCommands
    facilitates the use of commands with the
    DispatchHelper service, including with arguments
    
    This commit
    - adds the RunCommand() method in the Session service
    - extends the scope of existing RunCommand() methods
      for the Document, Base, Calc and Writer services
      with the addition of command arguments
    Syntax by examples:
     (Basic)
      session.RunCommand("BasicIDEAppear", _
        "Document", "LibreOffice Macros & Dialogs", _
        "LibName", "ScriptForge", _
        "Name", "SF_Session", _
        "Line", 100)
     (Python) (1)
      session.RunCommand("BasicIDEAppear",
        "Document", "LibreOffice Macros & Dialogs",
        "LibName", "ScriptForge",
        "Name", "SF_Session",
        "Line", 100)
     (Python) (2)
      session.RunCommand("BasicIDEAppear",
        Document = "LibreOffice Macros & Dialogs",
        LibName = "ScriptForge",
        Name = "SF_Session",
        Line = 100)
    
    Change-Id: I60cd5eb1ed0a057420215ce7aebe92b2aafabd53
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129175
    Tested-by: Jean-Pierre Ledure <j...@ledure.be>
    Tested-by: Jenkins
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>

diff --git a/wizards/source/scriptforge/SF_Dictionary.xba 
b/wizards/source/scriptforge/SF_Dictionary.xba
index fc92e24dd2ad..367fc47553d8 100644
--- a/wizards/source/scriptforge/SF_Dictionary.xba
+++ b/wizards/source/scriptforge/SF_Dictionary.xba
@@ -952,4 +952,4 @@ Const cstSeparator = &quot;, &quot;
 End Function   &apos;  ScriptForge.SF_Dictionary._Repr
 
 REM ============================================ END OF 
SCRIPTFORGE.SF_DICTIONARY
-</script:module>
+</script:module>
\ No newline at end of file
diff --git a/wizards/source/scriptforge/SF_FileSystem.xba 
b/wizards/source/scriptforge/SF_FileSystem.xba
index 3f38d141e5fd..d71937d6e64a 100644
--- a/wizards/source/scriptforge/SF_FileSystem.xba
+++ b/wizards/source/scriptforge/SF_FileSystem.xba
@@ -2085,4 +2085,4 @@ Dim sFolder As String             &apos;  Folder
 End Function   &apos;  ScriptForge.SF_FileSystem._SFInstallFolder
 
 REM ============================================ END OF 
SCRIPTFORGE.SF_FileSystem
-</script:module>
+</script:module>
\ No newline at end of file
diff --git a/wizards/source/scriptforge/SF_PythonHelper.xba 
b/wizards/source/scriptforge/SF_PythonHelper.xba
index 5b919ba5abe1..442a4bd1b856 100644
--- a/wizards/source/scriptforge/SF_PythonHelper.xba
+++ b/wizards/source/scriptforge/SF_PythonHelper.xba
@@ -795,6 +795,10 @@ Try:
                        &apos;  Methods in class modules are invoked with 
CallByName
                        ElseIf bBasicClass And ((CallType And vbMethod) = 
vbMethod) Then
                                Select Case UBound(vArgs)
+                                       &apos;  Dirty alternatives to process 
usual and ParamArray cases
+                                       &apos;  But, up to ... how many ?
+                                       &apos;          - The 
OFFSETADDRESSERROR has 12 arguments
+                                       &apos;          - The 
&quot;.uno:DataSort&quot; command may have 14 property name-value pairs
                                        Case -1 :       vReturn = 
CallByName(vBasicObject, Script, vbMethod)
                                        Case 0  :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0))
                                        Case 1  :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1))
@@ -804,6 +808,37 @@ Try:
                                        Case 5  :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5))
                                        Case 6  :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6))
                                        Case 7  :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7))
+                                       Case 8  :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8))
+                                       Case 9  :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9))
+                                       Case 10 :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10))
+                                       Case 11 :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11))
+                                       Case 12, 13     :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12))
+                                       Case 14, 15     :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12), vArgs(13), 
vArgs(14))
+                                       Case 16, 17     :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12), vArgs(13), 
vArgs(14), vArgs(15), vArgs(16))
+                                       Case 18, 19     :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12), vArgs(13), 
vArgs(14), vArgs(15), vArgs(16), vArgs(17), vArgs(18))
+                                       Case 20, 21     :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12), vArgs(13), 
vArgs(14), vArgs(15), vArgs(16), vArgs(17), vArgs(18) _
+                                                                               
        , vArgs(19), vArgs(20))
+                                       Case 22, 23     :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12), vArgs(13), 
vArgs(14), vArgs(15), vArgs(16), vArgs(17), vArgs(18) _
+                                                                               
        , vArgs(19), vArgs(20), vArgs(21), vArgs(22))
+                                       Case 24, 25     :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12), vArgs(13), 
vArgs(14), vArgs(15), vArgs(16), vArgs(17), vArgs(18) _
+                                                                               
        , vArgs(19), vArgs(20), vArgs(21), vArgs(22), vArgs(23), vArgs(24))
+                                       Case 26, 27     :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12), vArgs(13), 
vArgs(14), vArgs(15), vArgs(16), vArgs(17), vArgs(18) _
+                                                                               
        , vArgs(19), vArgs(20), vArgs(21), vArgs(22), vArgs(23), vArgs(24), 
vArgs(25), vArgs(26))
+                                       Case &gt;= 28   :       vReturn = 
CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), 
vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7) _
+                                                                               
        , vArgs(8), vArgs(9), vArgs(10), vArgs(11), vArgs(12), vArgs(13), 
vArgs(14), vArgs(15), vArgs(16), vArgs(17), vArgs(18) _
+                                                                               
        , vArgs(19), vArgs(20), vArgs(21), vArgs(22), vArgs(23), vArgs(24), 
vArgs(25), vArgs(26), vArgs(27), vArgs(28))
                                End Select
                        End If
 
@@ -824,7 +859,7 @@ Try:
        If IsArray(vReturn) Then
                ReDim vReturnArray(0 To 2)
                iDims = SF_Array.CountDims(vReturn)
-               &apos;  Replace dates by ISO notation
+               &apos;  Replace dates by UNO format
                If iDims = 1 Then
                        For i = LBound(vReturn) To UBound(vReturn)
                                If VarType(vReturn(i)) = V_DATE Then vReturn(i) 
= CDateToUnoDateTime(vReturn(i))
diff --git a/wizards/source/scriptforge/SF_Services.xba 
b/wizards/source/scriptforge/SF_Services.xba
index d77058cb3ba0..c6910aea5e50 100644
--- a/wizards/source/scriptforge/SF_Services.xba
+++ b/wizards/source/scriptforge/SF_Services.xba
@@ -612,4 +612,4 @@ Catch:
 End Function   &apos;  ScriptForge.SF_Services._NewTimer
 
 REM ============================================== END OF 
SCRIPTFORGE.SF_SERVICES
-</script:module>
+</script:module>
\ No newline at end of file
diff --git a/wizards/source/scriptforge/SF_Session.xba 
b/wizards/source/scriptforge/SF_Session.xba
index f02a958768ce..748daf597f46 100644
--- a/wizards/source/scriptforge/SF_Session.xba
+++ b/wizards/source/scriptforge/SF_Session.xba
@@ -598,6 +598,66 @@ Catch:
        GoTo Finally
 End Function   &apos;  ScriptForge.SF_Session.RunApplication
 
+REM 
-----------------------------------------------------------------------------
+Public Sub RunCommand(Optional ByVal Command As Variant _
+                                                                       , 
ParamArray Args As Variant _
+                                                                       )
+&apos;&apos;&apos; Run on the current window the given menu command. The 
command is executed with or without arguments
+&apos;&apos;&apos;     A few typical commands:
+&apos;&apos;&apos;             About, Delete, Edit, Undo, Copy, Paste, ...
+&apos;&apos;&apos;     Dozens can be found on next page: 
https://wiki.documentfoundation.org/Development/DispatchCommands
+&apos;&apos;&apos;     Args:
+&apos;&apos;&apos;             Command: Case-sensitive. The command itself is 
not checked.
+&apos;&apos;&apos;                     If the command does not contain the 
&quot;.uno:&quot; prefix, it is added.
+&apos;&apos;&apos;                     If nothing happens, then the command is 
probably wrong
+&apos;&apos;&apos;             Args: Pairs of arguments name (string), value 
(any)     
+&apos;&apos;&apos;     Returns:
+&apos;&apos;&apos;     Examples:
+&apos;&apos;&apos;             session.RunCommand(&quot;BasicIDEAppear&quot;, _
+&apos;&apos;&apos;                                     &quot;Document&quot;, 
&quot;LibreOffice Macros &amp; Dialogs&quot;, _
+&apos;&apos;&apos;                                     &quot;LibName&quot;, 
&quot;ScriptForge&quot;, _
+&apos;&apos;&apos;                                     &quot;Name&quot;, 
&quot;SF_Session&quot;, _
+&apos;&apos;&apos;                                     &quot;Line&quot;, 600)
+
+Dim oDispatch                          &apos;  
com.sun.star.frame.DispatchHelper
+Dim vProps As Variant          &apos;  Array of PropertyValues
+Dim vValue As Variant          &apos;  A single value argument
+Dim sCommand As String         &apos;  Alias of Command
+Dim i As Long
+Const cstPrefix = &quot;.uno:&quot;
+
+Const cstThisSub = &quot;Session.RunCommand&quot;
+Const cstSubArgs = &quot;Command, [arg0Name, arg0Value], [arg1Name, 
arg1Value], ...&quot;
+
+       If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
+
+Check:
+       If SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
+               If Not SF_Utils._Validate(Command, &quot;Command&quot;, 
V_STRING) Then GoTo Finally
+               If Not SF_Utils._ValidateArray(Args, &quot;Args&quot;, 1) Then 
GoTo Finally
+               For i = 0 To UBound(Args) - 1 Step 2
+                       If Not SF_Utils._Validate(Args(i), &quot;Arg&quot; 
&amp; CStr(i/2) &amp; &quot;Name&quot;, V_STRING) Then GoTo Finally
+               Next i
+       End If
+
+Try:
+       &apos;  Build array of property values
+       vProps = Array()
+       For i = 0 To UBound(Args) - 1 Step 2
+               If IsEmpty(Args(i + 1)) Then vValue = Null Else vValue = Args(i 
+ 1)
+               vProps = SF_Array.Append(vProps, 
SF_Utils._MakePropertyValue(Args(i), vValue))
+       Next i
+       Set oDispatch = SF_Utils._GetUNOService(&quot;DispatchHelper&quot;)
+       If SF_String.StartsWith(Command, cstPrefix) Then sCommand = Command 
Else sCommand = cstPrefix &amp; Command
+       oDispatch.executeDispatch(StarDesktop.ActiveFrame, sCommand, 
&quot;&quot;, 0, vProps)
+
+Finally:
+       SF_Utils._ExitFunction(cstThisSub)
+       Exit Sub
+Catch:
+       GoTo Finally
+End Sub                        &apos;  ScriptForge.SF_Session.RunCommand
+
 REM 
-----------------------------------------------------------------------------
 Public Sub SendMail(Optional ByVal Recipient As Variant _
                                                , Optional ByRef Cc As Variant _
diff --git a/wizards/source/scriptforge/SF_Utils.xba 
b/wizards/source/scriptforge/SF_Utils.xba
index 8b8b8d7eea93..c0d63bcc6b36 100644
--- a/wizards/source/scriptforge/SF_Utils.xba
+++ b/wizards/source/scriptforge/SF_Utils.xba
@@ -986,4 +986,4 @@ Dim iType As Integer        &apos;  VarType of argument
 End Function   &apos;  ScriptForge.SF_Utils._VarTypeExt
 
 REM ================================================= END OF 
SCRIPTFORGE.SF_UTILS
-</script:module>
+</script:module>
\ No newline at end of file
diff --git a/wizards/source/scriptforge/_CodingConventions.xba 
b/wizards/source/scriptforge/_CodingConventions.xba
index 913c8b254810..71fb42c77201 100644
--- a/wizards/source/scriptforge/_CodingConventions.xba
+++ b/wizards/source/scriptforge/_CodingConventions.xba
@@ -97,4 +97,4 @@ REM 
============================================================================
 &apos;         *       Comments about a code block should be left indented.
 &apos;                 If it concerns only the next line, no indent required 
(may also be put at the end of the line).
 &apos;&apos;&apos;
-</script:module>
+</script:module>
\ No newline at end of file
diff --git a/wizards/source/scriptforge/python/scriptforge.py 
b/wizards/source/scriptforge/python/scriptforge.py
index 18334f3684c8..c4b14ba52ff7 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -370,6 +370,15 @@ class ScriptForge(object, metaclass = _Singleton):
                         setattr(cls, cc, func)
         return
 
+    @staticmethod
+    def unpack_args(kwargs):
+        """
+            Convert a dictioany passed as argument to a list alternating keys 
and values
+            Example:
+                dict(A = 'a', B = 2) => 'A', 'a', 'B', 2
+            """
+        return [v for p in zip(list(kwargs.keys()), list(kwargs.values())) for 
v in p]
+
 
 # 
#####################################################################################################################
 #                           SFServices CLASS    (ScriptForge services 
superclass)                                   ###
@@ -1322,6 +1331,14 @@ class SFScriptForge:
         def RunApplication(self, command, parameters):
             return self.ExecMethod(self.vbMethod, 'RunApplication', command, 
parameters)
 
+        def RunCommand(self, command, *args, **kwargs):
+            params = tuple(list(args) + ScriptForge.unpack_args(kwargs))
+            if len(params) == 0:
+                params = (command,) + (None,)
+            else:
+                params = (command,) + params
+            return self.SIMPLEEXEC('@SF_Session.RunCommand', params)
+
         def SendMail(self, recipient, cc = '', bcc = '', subject = '', body = 
'', filenames = '', editmessage = True):
             return self.ExecMethod(self.vbMethod, 'SendMail', recipient, cc, 
bcc, subject, body, filenames, editmessage)
 
@@ -1786,8 +1803,9 @@ class SFDocuments:
         def RemoveMenu(self, menuheader):
             return self.ExecMethod(self.vbMethod, 'RemoveMenu', menuheader)
 
-        def RunCommand(self, command):
-            return self.ExecMethod(self.vbMethod, 'RunCommand', command)
+        def RunCommand(self, command, *args, **kwargs):
+            params = tuple([command] + list(args) + 
ScriptForge.unpack_args(kwargs))
+            return self.ExecMethod(self.vbMethod, 'RunCommand', *params)
 
         def Save(self):
             return self.ExecMethod(self.vbMethod, 'Save')
diff --git a/wizards/source/sfdocuments/SF_Base.xba 
b/wizards/source/sfdocuments/SF_Base.xba
index 0199341bb5da..8e8dbfb4e27e 100644
--- a/wizards/source/sfdocuments/SF_Base.xba
+++ b/wizards/source/sfdocuments/SF_Base.xba
@@ -808,8 +808,10 @@ Public Function RemoveMenu(Optional ByVal MenuHeader As 
Variant) As Boolean
 End Function   &apos;  SFDocuments.SF_Base.RemoveMenu
 
 REM 
-----------------------------------------------------------------------------
-Public Sub RunCommand(Optional ByVal Command As Variant)
-       [_Super].RunCommand(Command)
+Public Sub RunCommand(Optional ByVal Command As Variant _
+                                                                       , 
ParamArray Args As Variant _
+                                                                       )
+       [_Super].RunCommand(Command, Args)
 End Sub                  &apos;   SFDocuments.SF_Base.RunCommand
 
 REM 
-----------------------------------------------------------------------------
diff --git a/wizards/source/sfdocuments/SF_Calc.xba 
b/wizards/source/sfdocuments/SF_Calc.xba
index f22a64642e36..29b22f4b0ed0 100644
--- a/wizards/source/sfdocuments/SF_Calc.xba
+++ b/wizards/source/sfdocuments/SF_Calc.xba
@@ -3093,8 +3093,10 @@ Public Function RemoveMenu(Optional ByVal MenuHeader As 
Variant) As Boolean
 End Function   &apos;  SFDocuments.SF_Calc.RemoveMenu
 
 REM 
-----------------------------------------------------------------------------
-Public Sub RunCommand(Optional ByVal Command As Variant)
-       [_Super].RunCommand(Command)
+Public Sub RunCommand(Optional ByVal Command As Variant _
+                                                                       , 
ParamArray Args As Variant _
+                                                                       )
+       [_Super].RunCommand(Command, Args)
 End Sub                  &apos;   SFDocuments.SF_Calc.RunCommand
 
 REM 
-----------------------------------------------------------------------------
diff --git a/wizards/source/sfdocuments/SF_Document.xba 
b/wizards/source/sfdocuments/SF_Document.xba
index 37c4e4e6bbe7..9f95470d2903 100644
--- a/wizards/source/sfdocuments/SF_Document.xba
+++ b/wizards/source/sfdocuments/SF_Document.xba
@@ -813,40 +813,67 @@ Catch:
 End Function   &apos;   SFDocuments.SF_Document.RemoveMenu
 
 REM 
-----------------------------------------------------------------------------
-Public Sub RunCommand(Optional ByVal Command As Variant)
-&apos;&apos;&apos; Run on the document the given menu command. The command is 
executed without arguments
+Public Sub RunCommand(Optional ByVal Command As Variant _
+                                                                       , 
ParamArray Args As Variant _
+                                                                       )
+&apos;&apos;&apos; Run on the current document window the given menu command. 
The command is executed with or without arguments
 &apos;&apos;&apos;     A few typical commands:
 &apos;&apos;&apos;             Save, SaveAs, ExportToPDF, 
SetDocumentProperties, Undo, Copy, Paste, ...
-&apos;&apos;&apos;     Dozens can be found in the directory 
$install/share/config/soffice.cfg/modules
+&apos;&apos;&apos;     Dozens can be found on next page: 
https://wiki.documentfoundation.org/Development/DispatchCommands
 &apos;&apos;&apos;     Args:
 &apos;&apos;&apos;             Command: Case-sensitive. The command itself is 
not checked.
+&apos;&apos;&apos;                     If the command does not contain the 
&quot;.uno:&quot; prefix, it is added.
 &apos;&apos;&apos;                     If nothing happens, then the command is 
probably wrong
+&apos;&apos;&apos;             Args: Pairs of arguments name (string), value 
(any)     
 &apos;&apos;&apos;     Returns:
 &apos;&apos;&apos;     Examples:
-&apos;&apos;&apos;             oDoc.RunCommand(&quot;About&quot;)
+&apos;&apos;&apos;             oDoc.RunCommand(&quot;EditDoc&quot;, 
&quot;Editable&quot;, False)       &apos;  Toggle edit mode
 
+Dim vArgs As Variant           &apos;  Alias of Args
 Dim oDispatch                          &apos;  
com.sun.star.frame.DispatchHelper
+Dim vProps As Variant          &apos;  Array of PropertyValues
+Dim vValue As Variant          &apos;  A single value argument
+Dim sCommand As String         &apos;  Alias of Command
+Dim i As Long
+Const cstPrefix = &quot;.uno:&quot;
+
 Const cstThisSub = &quot;SFDocuments.Document.RunCommand&quot;
-Const cstSubArgs = &quot;Command&quot;
+Const cstSubArgs = &quot;Command, [arg0Name, arg0Value], [arg1Name, 
arg1Value], ...&quot;
 
-       If ScriptForge.SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
+       If SF_Utils._ErrorHandling() Then On Local Error GoTo Catch
 
 Check:
+       &apos;  When called from a subclass (Calc, Writer, ..) the arguments 
are gathered into one single array item
+       vArgs = Args
+       If IsArray(Args) Then
+               If UBound(Args) &gt;= 0 And IsArray(Args(0)) Then vArgs = 
Args(0)
+       End If
        If ScriptForge.SF_Utils._EnterFunction(cstThisSub, cstSubArgs) Then
                If Not _IsStillAlive() Then GoTo Finally
                If Not ScriptForge.SF_Utils._Validate(Command, 
&quot;Command&quot;, V_STRING) Then GoTo Finally
+               If Not ScriptForge.SF_Utils._ValidateArray(vArgs, 
&quot;Args&quot;, 1) Then GoTo Finally
+               For i = 0 To UBound(vArgs) - 1 Step 2
+                       If Not ScriptForge.SF_Utils._Validate(vArgs(i), 
&quot;Arg&quot; &amp; CStr(i/2) &amp; &quot;Name&quot;, V_STRING) Then GoTo 
Finally
+               Next i
        End If
 
 Try:
+       &apos;  Build array of property values
+       vProps = Array()
+       For i = 0 To UBound(vArgs) - 1 Step 2
+               If IsEmpty(vArgs(i + 1)) Then vValue = Null Else vValue = 
vArgs(i + 1)
+               vProps = ScriptForge.SF_Array.Append(vProps, 
ScriptForge.SF_Utils._MakePropertyValue(vArgs(i), vValue))
+       Next i
        Set oDispatch = 
ScriptForge.SF_Utils._GetUNOService(&quot;DispatchHelper&quot;)
-       oDispatch.executeDispatch(_Frame, &quot;.uno:&quot; &amp; Command, 
&quot;&quot;, 0, Array())
+       If ScriptForge.SF_String.StartsWith(Command, cstPrefix) Then sCommand = 
Command Else sCommand = cstPrefix &amp; Command
+       oDispatch.executeDispatch(_Frame, sCommand, &quot;&quot;, 0, vProps)
 
 Finally:
        ScriptForge.SF_Utils._ExitFunction(cstThisSub)
        Exit Sub
 Catch:
        GoTo Finally
-End Sub                  &apos;   SFDocuments.SF_Document.RunCommand
+End Sub                        &apos;  SFDocuments.SF_Document.RunCommand
 
 REM 
-----------------------------------------------------------------------------
 Public Function Save() As Boolean
diff --git a/wizards/source/sfdocuments/SF_Form.xba 
b/wizards/source/sfdocuments/SF_Form.xba
index 43e6bb513351..15c3d498e78e 100644
--- a/wizards/source/sfdocuments/SF_Form.xba
+++ b/wizards/source/sfdocuments/SF_Form.xba
@@ -1531,4 +1531,4 @@ Dim sParent As String             &apos;  To recognize 
the parent
 End Function   &apos;  SFDocuments.SF_Form._Repr
 
 REM ============================================ END OF SFDOCUMENTS.SF_FORM
-</script:module>
+</script:module>
\ No newline at end of file
diff --git a/wizards/source/sfdocuments/SF_FormControl.xba 
b/wizards/source/sfdocuments/SF_FormControl.xba
index c0db1d6cf92b..a48c22b6c1c5 100644
--- a/wizards/source/sfdocuments/SF_FormControl.xba
+++ b/wizards/source/sfdocuments/SF_FormControl.xba
@@ -1885,4 +1885,4 @@ Private Function _Repr() As String
 End Function   &apos;  SFDocuments.SF_FormControl._Repr
 
 REM ============================================ END OF 
SFDOCUMENTS.SF_FORMCONTROL
-</script:module>
+</script:module>
\ No newline at end of file
diff --git a/wizards/source/sfdocuments/SF_Writer.xba 
b/wizards/source/sfdocuments/SF_Writer.xba
index 96ed289f92ff..9d2234637dd4 100644
--- a/wizards/source/sfdocuments/SF_Writer.xba
+++ b/wizards/source/sfdocuments/SF_Writer.xba
@@ -518,8 +518,10 @@ Public Function RemoveMenu(Optional ByVal MenuHeader As 
Variant) As Boolean
 End Function   &apos;  SFDocuments.SF_Writer.RemoveMenu
 
 REM 
-----------------------------------------------------------------------------
-Public Sub RunCommand(Optional ByVal Command As Variant)
-       [_Super].RunCommand(Command)
+Public Sub RunCommand(Optional ByVal Command As Variant _
+                                                                       , 
ParamArray Args As Variant _
+                                                                       )
+       [_Super].RunCommand(Command, Args)
 End Sub                  &apos;   SFDocuments.SF_Writer.RunCommand
 
 REM 
-----------------------------------------------------------------------------

Reply via email to