ScriptForge Extend Python-Basic gateway for objects

A Python ScriptForge object may be passed to
Basic functions, so far only when it is
positioned as the first argument in the
method signature.

Like in:
   dialogB.Center(dialogA)

The actual commit extends the protocol
between Python and Basic to allow passing
Python objects from another position
in the method signature.

However this possibility is limited to
maximum 1 such argument.
(Note that removing this limitation,
if ever needed, would not require
a big change.)

No impact on user existing scripts.
No documentation update.

Change-Id: I191b7bb7c32b158b7274815577349ddfa1406b93
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190931
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
This commit is contained in:
Jean-Pierre Ledure
2025-09-15 07:35:37 +02:00
parent eb4b5ec72b
commit 8bc9ddf832
3 changed files with 47 additions and 30 deletions
@@ -348,9 +348,10 @@ class ScriptForge(object, metaclass = _Singleton):
argslist[i] = argdict.ConvertToPropertyValues()
return tuple(argslist)
#
# Intercept flags is a tuple
flag = (flags[0] if isinstance(flags, tuple) else flags)
# Intercept dictionary arguments
if flags & SFServices.flgDictArg == SFServices.flgDictArg: # Bits comparison
if flag & SFServices.flgDictArg == SFServices.flgDictArg: # Bits comparison
args = ConvertDictArgs()
#
# Run the basic script
@@ -395,7 +396,7 @@ class ScriptForge(object, metaclass = _Singleton):
# Intercept empty array
if isinstance(returnvalue, uno.ByteSequence):
return ()
if flags & SFServices.flgDateRet == SFServices.flgDateRet: # Bits comparison
if flag & SFServices.flgDateRet == SFServices.flgDateRet: # Bits comparison
# Intercept all UNO dates in the 1D or 2D array
if isinstance(returnvalue[0], tuple): # tuple of tuples
arr = []
@@ -555,7 +556,8 @@ class SFServices(object):
flgArrayArg = 512 # 1st argument can be a 2D array
flgArrayRet = 1024 # Invoked service method can return a 2D array (standard modules) or any array (class modules)
flgUno = 256 # Invoked service method/property can return a UNO object
flgObject = 2048 # 1st argument may be a Basic object
flgObject = 2048 # N-th argument may be a Basic object
# N (default = 0) can be passed as companion in a tuple
flgHardCode = 4096 # Force hardcoded call to method, avoid CallByName()
# Basic class type
moduleClass, moduleStandard = 2, 1