[Libreoffice-commits] core.git: wizards/source

Jean-Pierre Ledure (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 22 10:03:55 UTC 2021


 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 <jp at ledure.be>
AuthorDate: Thu Jul 22 10:34:16 2021 +0200
Commit:     Jean-Pierre Ledure <jp at 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 <jp at ledure.be>
    Tested-by: Jenkins
    Reviewed-by: Jean-Pierre Ledure <jp at 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		'	Alias for Encoding
 
 Check:
 	If IsMissing(pvArgs) Then pvArgs = Array()
-	If UBound(pvArgs) < 0 Then
-		sPOFile = ""
-		sEncoding = ""
-	Else
-		If Not SF_Utils._ValidateFile(pvArgs(0), "Folder (Arg0)") Then GoTo Catch
+	sPOFile = ""
+	sEncoding = ""
+	If UBound(pvArgs) >= 0 Then
+		If Not SF_Utils._ValidateFile(pvArgs(0), "Folder (Arg0)", , True) Then GoTo Catch
 		sFolderName = pvArgs(0)
+		sLocale = ""
 		If UBound(pvArgs) >= 1 Then
 			If Not SF_Utils._Validate(pvArgs(1), "Locale (Arg1)", V_STRING) Then GoTo Catch
 			sLocale = pvArgs(1)
-		Else
+		End If
+		If Len(sLocale) = 0 Then	'	Called from Python, the Locale argument may be the zero-length string
 			Set oLocale = SF_Utils._GetUNOService("Locale")
 			sLocale = oLocale.Language & "-" & oLocale.Country
 		End If
@@ -554,8 +555,10 @@ Check:
 		Else
 			sEncoding = "UTF-8"
 		End If
-		sPOFile = SF_FileSystem.BuildPath(sFolderName, sLocale & ".po")
-		If Not SF_FileSystem.FileExists(sPOFile) Then GoTo CatchNotExists
+		If Len(sFolderName) > 0 Then
+			sPOFile = SF_FileSystem.BuildPath(sFolderName, sLocale & ".po")
+			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)


More information about the Libreoffice-commits mailing list