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
   Controls
   EndExecute
   Execute

(Controls is already hardcoded because returning an array)

Patch on master: https://gerrit.libreoffice.org/c/core/+/137084
Patch on libreoffice-7-4: https://gerrit.libreoffice.org/c/core/+/137113

Change-Id: I1d2ef4d6e5d5e2863ac39ce646084cbd9265fe84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138093
Tested-by: Jenkins
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Rafael Lima <rafael.palma.lima@gmail.com>
diff --git a/wizards/source/scriptforge/SF_PythonHelper.xba b/wizards/source/scriptforge/SF_PythonHelper.xba
index 5b919ba..d257df3 100644
--- a/wizards/source/scriptforge/SF_PythonHelper.xba
+++ b/wizards/source/scriptforge/SF_PythonHelper.xba
@@ -614,6 +614,7 @@ 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

@@ -792,6 +793,17 @@ Try:
						If Script = &quot;Controls&quot; Then		vReturn = vBasicObject.Controls(vArgs(0))
				End Select
			
			&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;EndExecute&quot;		:	vReturn = vBasicObject.EndExecute(vArgs(0))
							Case &quot;Execute&quot;			:	vReturn = vBasicObject.Execute(vArgs(0))
						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 9dc95d2..894ead0 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -445,6 +445,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
    #
@@ -1652,16 +1653,16 @@ class SFDialogs:
            return container, library, dialogname, ScriptForge.componentcontext

        def Activate(self):
            return self.ExecMethod(self.vbMethod, 'Activate')
            return self.ExecMethod(self.vbMethod + self.flgHardCode, 'Activate')

        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)
            return self.ExecMethod(self.vbMethod + self.flgHardCode, 'Execute', modal)

        def GetTextsFromL10N(self, l10n):
            l10nobj = l10n.objectreference if isinstance(l10n, SFScriptForge.SF_L10N) else l10n