ScriptForge - (scriptforge.py) None as default value

CreateScriptService() does not accept keyword arguments.

In Basic positional arguments may be skipped, not in Python.
This makes
    CreateScriptSevice('Dialog', '', '', 'myDialog')
rather inelegant.

Only for the Dialog service, None is accepted as default value
i.o. '' for the Container and Library arguments.

Change-Id: Ib96e23373140264c7100f174c7704ed32351f124
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115629
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
This commit is contained in:
Jean-Pierre Ledure
2021-05-14 18:21:35 +02:00
parent d7bc3b5d3a
commit 1054cad056

View File

@@ -1548,9 +1548,17 @@ class SFDialogs:
def PreProcessArgs(cls, args):
"""
Review the arguments of the creation of the Basic service (must be a class method)
Add the XComponentContext as last argument
- accept None as default values for Container and Library arguments
- add the XComponentContext as last argument
"""
newargs = (*args, ScriptForge.componentcontext)
listargs = list(args) # Make a mutable list because args is an immutable tuple
if len(listargs) >= 1:
if listargs[0] is None: # Container
listargs[0] = ''
if len(listargs) >= 2:
if listargs[1] is None:
listargs[1] = 'Standard' # Library
newargs = (*listargs, ScriptForge.componentcontext)
return newargs
def Activate(self):