wizards/source/scriptforge/SF_Session.xba        |   60 ----------------------
 wizards/source/scriptforge/SF_UI.xba             |   61 +++++++++++++++++++++++
 wizards/source/scriptforge/python/scriptforge.py |   16 +++---
 3 files changed, 69 insertions(+), 68 deletions(-)

New commits:
commit a1513003543e4a7a47da47659a715eec2b6af452
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Thu Feb 3 16:54:00 2022 +0100
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Fri Feb 4 14:20:10 2022 +0100

    ScriptForge - (SF_UI) Import RunCommand() from SF_Session
    
    Functionally SF_UI groups methods impacting the
    user interface, while the Session service groups general-purpose
    actions.
    
    The RunCommand() method (newly introduced in 7.4) simulates
    menu commands applied on the active window.
    
    RunCommand() fits better in the UI service.
    
    It is removed from SF_Session.
    
    Change-Id: Ia72150efea2f50de13d15a4c1f5fea79777d1760
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129453
    Tested-by: Jenkins
    Tested-by: Jean-Pierre Ledure <j...@ledure.be>
    Reviewed-by: Jean-Pierre Ledure <j...@ledure.be>

diff --git a/wizards/source/scriptforge/SF_Session.xba 
b/wizards/source/scriptforge/SF_Session.xba
index 748daf597f46..f02a958768ce 100644
--- a/wizards/source/scriptforge/SF_Session.xba
+++ b/wizards/source/scriptforge/SF_Session.xba
@@ -598,66 +598,6 @@ 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_UI.xba 
b/wizards/source/scriptforge/SF_UI.xba
index 4c9907ec39e3..c1726d1cdcb9 100644
--- a/wizards/source/scriptforge/SF_UI.xba
+++ b/wizards/source/scriptforge/SF_UI.xba
@@ -625,6 +625,7 @@ Public Function Methods() As Variant
                                        , &quot;OpenBaseDocument&quot; _
                                        , &quot;OpenDocument&quot; _
                                        , &quot;Resize&quot; _
+                                       , &quot;RunCommand&quot; _
                                        , &quot;SetStatusbar&quot; _
                                        , &quot;ShowProgressBar&quot; _
                                        , &quot;WindowExists&quot; _
@@ -882,6 +883,66 @@ Catch:
        GoTo Finally
 End Sub                    &apos;   ScriptForge.SF_UI.Resize
 
+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;             ui.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;UI.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_UI.RunCommand
+
 REM 
-----------------------------------------------------------------------------
 Public Function SetProperty(Optional ByVal PropertyName As Variant _
                                                                , Optional 
ByRef Value As Variant _
diff --git a/wizards/source/scriptforge/python/scriptforge.py 
b/wizards/source/scriptforge/python/scriptforge.py
index 94d5a3de7d58..7edc737acec4 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1332,14 +1332,6 @@ 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)
 
@@ -1548,6 +1540,14 @@ class SFScriptForge:
         def Resize(self, left = -1, top = -1, width = -1, height = -1):
             return self.ExecMethod(self.vbMethod, 'Resize', left, top, width, 
height)
 
+        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_UI.RunCommand', params)
+
         def SetStatusbar(self, text = '', percentage = -1):
             return self.ExecMethod(self.vbMethod, 'SetStatusbar', text, 
percentage)
 

Reply via email to