wizards/source/scriptforge/SF_Services.xba       |   19 +++++++++++--------
 wizards/source/scriptforge/python/scriptforge.py |   22 ++++++++++++++++++----
 2 files changed, 29 insertions(+), 12 deletions(-)

New commits:
commit 2d7c0af3c36c6613e4028ed44484f5f021f85deb
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Thu Jul 22 10:34:16 2021 +0200
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Thu Jul 22 12:03:20 2021 +0200

    ScriptForge - (scriptforge.py/CreateScriptService) allow keyword arguments
    
    For Python scripts only:
    
    the CreateScriptService() method accepts now both positional
    (as before) and keyword arguments.
    
    The impacted services are:
    - l10n
    - timer
    
    Done with the ReviewServiceArgs() class method that returns the
    input arguments as a tuple in the correct sequence. This method
    is inserted in each of the impacted service definitions.
    
    Implied a review of the creation of the L10N service to
    replace absent arguments by zero-length default arguments
    
    Change-Id: I3cc3b98847a395a2fd9f5e5bb15f45b398858b12
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119359
    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_Services.xba 
b/wizards/source/scriptforge/SF_Services.xba
index 4bd57c9e1b64..9533a4741b23 100644
--- a/wizards/source/scriptforge/SF_Services.xba
+++ b/wizards/source/scriptforge/SF_Services.xba
@@ -535,16 +535,17 @@ Dim sEncoding As String           &apos;  Alias for 
Encoding
 
 Check:
        If IsMissing(pvArgs) Then pvArgs = Array()
-       If UBound(pvArgs) &lt; 0 Then
-               sPOFile = &quot;&quot;
-               sEncoding = &quot;&quot;
-       Else
-               If Not SF_Utils._ValidateFile(pvArgs(0), &quot;Folder 
(Arg0)&quot;) Then GoTo Catch
+       sPOFile = &quot;&quot;
+       sEncoding = &quot;&quot;
+       If UBound(pvArgs) &gt;= 0 Then
+               If Not SF_Utils._ValidateFile(pvArgs(0), &quot;Folder 
(Arg0)&quot;, , True) Then GoTo Catch
                sFolderName = pvArgs(0)
+               sLocale = &quot;&quot;
                If UBound(pvArgs) &gt;= 1 Then
                        If Not SF_Utils._Validate(pvArgs(1), &quot;Locale 
(Arg1)&quot;, V_STRING) Then GoTo Catch
                        sLocale = pvArgs(1)
-               Else
+               End If
+               If Len(sLocale) = 0 Then        &apos;  Called from Python, the 
Locale argument may be the zero-length string
                        Set oLocale = 
SF_Utils._GetUNOService(&quot;Locale&quot;)
                        sLocale = oLocale.Language &amp; &quot;-&quot; &amp; 
oLocale.Country
                End If
@@ -554,8 +555,10 @@ Check:
                Else
                        sEncoding = &quot;UTF-8&quot;
                End If
-               sPOFile = SF_FileSystem.BuildPath(sFolderName, sLocale &amp; 
&quot;.po&quot;)
-               If Not SF_FileSystem.FileExists(sPOFile) Then GoTo 
CatchNotExists
+               If Len(sFolderName) &gt; 0 Then
+                       sPOFile = SF_FileSystem.BuildPath(sFolderName, sLocale 
&amp; &quot;.po&quot;)
+                       If Not SF_FileSystem.FileExists(sPOFile) Then GoTo 
CatchNotExists
+               End If
        End If
 
 Try:
diff --git a/wizards/source/scriptforge/python/scriptforge.py 
b/wizards/source/scriptforge/python/scriptforge.py
index 16dbca2b4fd2..d22d5d832d9a 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -1166,9 +1166,16 @@ class SFScriptForge:
         # Mandatory class properties for service registration
         serviceimplementation = 'basic'
         servicename = 'ScriptForge.L10N'
-        servicesynonyms = ()
+        servicesynonyms = ('l10n', 'scriptforge.l10n')
         serviceproperties = dict(Folder = False, Languages = False, Locale = 
False)
 
+        @classmethod
+        def ReviewServiceArgs(cls, foldername = '', locale = '', encoding = 
'UTF-8'):
+            """
+                Transform positional and keyword arguments into positional only
+                """
+            return foldername, locale, encoding
+
         def AddText(self, context = '', msgid = '', comment = ''):
             return self.ExecMethod(self.vbMethod, 'AddText', context, msgid, 
comment)
 
@@ -1429,12 +1436,19 @@ class SFScriptForge:
         # Mandatory class properties for service registration
         serviceimplementation = 'basic'
         servicename = 'ScriptForge.Timer'
-        servicesynonyms = ()
+        servicesynonyms = ('timer', 'scriptforge.timer')
         serviceproperties = dict(Duration = False, IsStarted = False, 
IsSuspended = False,
                                  SuspendDuration = False, TotalDuration = 
False)
         # Force for each property to get its value from Basic
         forceGetProperty = True
 
+        @classmethod
+        def ReviewServiceArgs(cls, start = False):
+            """
+                Transform positional and keyword arguments into positional only
+                """
+            return (start,)
+
         def Continue(self):
             return self.ExecMethod(self.vbMethod, 'Continue')
 
@@ -1661,7 +1675,7 @@ class SFDialogs:
         # Mandatory class properties for service registration
         serviceimplementation = 'basic'
         servicename = 'SFDialogs.DialogControl'
-        servicesynonyms = ('dialogcontrol', 'sfdialogs.dialog')
+        servicesynonyms = ()
         serviceproperties = dict(Cancel = True, Caption = True, ControlType = 
False, CurrentNode = True,
                                  Default = True, Enabled = True, Format = 
True, ListCount = False,
                                  ListIndex = True, Locked = True, MultiSelect 
= True, Name = False,
@@ -1779,7 +1793,7 @@ class SFDocuments:
         # Mandatory class properties for service registration
         serviceimplementation = 'basic'
         servicename = 'SFDocuments.Base'
-        servicesynonyms = ()
+        servicesynonyms = ('base', 'scriptforge.base')
         serviceproperties = dict(DocumentType = False, IsBase = False, IsCalc 
= False,
                                  IsDraw = False, IsImpress = False, IsMath = 
False, IsWriter = False,
                                  XComponent = False)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to