summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2022-07-14 16:31:01 +0200
committerJean-Pierre Ledure <jp@ledure.be>2022-07-16 09:49:06 +0200
commit91a1662c66e5e988d36012533fceab9221607282 (patch)
tree47eefe935cc5607ab904efaffaee8580b9975df7 /wizards
parentce29e6299932fc079b05b60662ba95c8342990bc (diff)
ScriptForge - tdf#149983 dialog.EndExecute() failure
In SF_PythonHelper._PythonDispatcher(): Force a hardcoded call of the methods in the Dialog service which may potentially be invoked while the dialog is displayed, bypassing the generic CallByName() Basic builtin function: Activate Center EndExecute Resize (Controls is already hardcoded because returning an array) Change-Id: I4931f43b37ae5f7337740d1c65b255f4a14ca069 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137084 Tested-by: Jean-Pierre Ledure <jp@ledure.be> Reviewed-by: Jean-Pierre Ledure <jp@ledure.be> Tested-by: Jenkins
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/scriptforge/SF_PythonHelper.xba24
-rw-r--r--wizards/source/scriptforge/python/scriptforge.py12
2 files changed, 26 insertions, 10 deletions
diff --git a/wizards/source/scriptforge/SF_PythonHelper.xba b/wizards/source/scriptforge/SF_PythonHelper.xba
index c3d67d8764fc..178dfcc09749 100644
--- a/wizards/source/scriptforge/SF_PythonHelper.xba
+++ b/wizards/source/scriptforge/SF_PythonHelper.xba
@@ -611,10 +611,11 @@ Const vbGet = 2, vbLet = 4, vbMethod = 1, vbSet = 8
&apos; Protocol flags
Const cstDateArg = 64 &apos; May contain a date argument
Const cstDateRet = 128 &apos; Return value can be a date
+Const cstUno = 256 &apos; Return value can be a UNO object
Const cstArgArray = 512 &apos; Any argument can be a 2D array
Const cstRetArray = 1024 &apos; Return value can be an array
-Const cstUno = 256 &apos; Return value can be a UNO object
Const cstObject = 2048 &apos; 1st argument is a Basic object when numeric
+Const cstHardCode = 4096 &apos; Method must not be executed with CallByName()
&apos; Object nature in returned array
Const objMODULE = 1, objCLASS = 2, objUNO = 3
@@ -625,7 +626,7 @@ Check:
&apos; Ignore Null basic objects (Null = Null or Nothing)
If IsNull(BasicObject) Or IsEmpty(BasicObject) Then GoTo Catch
- &apos; Reinterpret arguments one by one into vArgs, examine iso-dates and conventional NoArgs/Empty/Null values
+ &apos; Reinterpret arguments one by one into vArgs, convert UNO date/times and conventional NoArgs/Empty/Null/Missing values
iNbArgs = -1
vArgs = Array()
@@ -667,14 +668,14 @@ Try:
&apos; The CallByName function fails when returning an array
&apos; (2) Python has tuples and tuple of tuples, not 2D arrays
&apos; (3) Passing 2D arrays through a script provider always transform it into a sequence of sequences
+ &apos; (4) The CallByName function takes exclusive control on the targeted object up to its exit
&apos; 1. Methods in usual modules are called by ExecuteBasicScript() except if they use a ParamArray
&apos; 2. Properties in any service are got and set with obj.GetProperty/SetProperty(...)
&apos; 3. Methods in class modules are invoked with CallByName
&apos; 4. Methods in class modules using a 2D array or returning arrays, or methods using ParamArray,
&apos;&apos;&apos; are hardcoded as exceptions or are not implemented
- &apos; 5. Methods returning a 1D array when no arguments and a scalar otherwise (e.g. SF_Dialog.Controls())
- &apos; may be considered as properties when no argument
-&apos; Requires Python and Basic update in the concerned library but is transparent for this dispatcher
+ &apos; 5. Due to constraint (4), a predefined list of method calls must be hardcoded to avoid blocking use of CallByName
+ &apos; The concerned methods are flagged with cstHardCode
With _SF_
&apos; Initialize Python persistent storage at 1st call
@@ -816,6 +817,19 @@ Try:
End Select
End If
+ &apos; Methods in class modules may better not be executed with CallByName()
+ ElseIf bBasicClass And ((CallType And vbMethod) + (CallType And cstHardCode)) = vbMethod + cstHardCode Then
+ Select Case sServiceName
+ Case &quot;SFDialogs.Dialog&quot;
+ Select Case Script
+ Case &quot;Activate&quot; : vReturn = vBasicObject.Activate()
+ Case &quot;Center&quot;
+ If UBound(vArgs) &lt; 0 Then vReturn = vBasicObject.Center() Else vReturn = vBasicObject.Center(vArgs(0))
+ Case &quot;EndExecute&quot; : vReturn = vBasicObject.EndExecute(vArgs(0))
+ Case &quot;Resize&quot; : vReturn = vBasicObject.Resize(vArgs(0), vArgs(1), vArgs(2), vArgs(3))
+ End Select
+ End Select
+
&apos; Methods in class modules are invoked with CallByName
ElseIf bBasicClass And ((CallType And vbMethod) = vbMethod) Then
Select Case UBound(vArgs)
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py
index 452530a34c26..6ad4720e6686 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -455,6 +455,7 @@ class SFServices(object):
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
+ flgHardCode = 4096 # Force hardcoded call to method, avoid CallByName()
# Basic class type
moduleClass, moduleStandard = 2, 1
#
@@ -1784,20 +1785,21 @@ class SFDialogs:
"""
return container, library, dialogname, ScriptForge.componentcontext
+ # Methods potentially executed while the dialog is in execution require the flgHardCode flag
def Activate(self):
- return self.ExecMethod(self.vbMethod, 'Activate')
+ return self.ExecMethod(self.vbMethod + self.flgHardCode, 'Activate')
def Center(self, parent = ScriptForge.cstSymMissing):
parentclasses = (SFDocuments.SF_Document, SFDocuments.SF_Base, SFDocuments.SF_Calc, SFDocuments.SF_Writer,
SFDialogs.SF_Dialog)
parentobj = parent.objectreference if isinstance(parent, parentclasses) else parent
- return self.ExecMethod(self.vbMethod + self.flgObject, 'Center', parentobj)
+ return self.ExecMethod(self.vbMethod + self.flgObject + self.flgHardCode, 'Center', parentobj)
def Controls(self, controlname = ''):
- return self.ExecMethod(self.vbMethod + self.flgArrayRet, 'Controls', controlname)
+ return self.ExecMethod(self.vbMethod + self.flgArrayRet + self.flgHardCode, 'Controls', controlname)
def EndExecute(self, returnvalue):
- return self.ExecMethod(self.vbMethod, 'EndExecute', returnvalue)
+ return self.ExecMethod(self.vbMethod + self.flgHardCode, 'EndExecute', returnvalue)
def Execute(self, modal = True):
return self.ExecMethod(self.vbMethod, 'Execute', modal)
@@ -1807,7 +1809,7 @@ class SFDialogs:
return self.ExecMethod(self.vbMethod + self.flgObject, 'GetTextsFromL10N', l10nobj)
def Resize(self, left = -1, top = -1, width = -1, height = -1):
- return self.ExecMethod(self.vbMethod, 'Resize', left, top, width, height)
+ return self.ExecMethod(self.vbMethod + self.flgHardCode, 'Resize', left, top, width, height)
def Terminate(self):
return self.ExecMethod(self.vbMethod, 'Terminate')