wizards/source/scriptforge/python/scriptforge.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
New commits: commit af67aa7cc90775107ce42265d81e30b04fc0f54f Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Sun Oct 13 17:29:45 2024 +0200 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Mon Oct 14 10:25:03 2024 +0200 scriptforge.py - clarify pipe mode Introduction of a ScriptForge.outsideprocess property: when True the actual mode is via socket or via pipe. The property is for internal use only. Once set it cannot be changed anymore. Previous statements similar to if ScriptForge.port > 0: which returned True when socket mode are replaced by a broader if ScriptForge.outsideprocess: No effect on user scripts. Change-Id: Ice0efd8c2ab9925511fc8c6889cab714fd208ba1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174874 Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py index d751f62c6c50..0c96645df721 100644 --- a/wizards/source/scriptforge/python/scriptforge.py +++ b/wizards/source/scriptforge/python/scriptforge.py @@ -108,6 +108,7 @@ class ScriptForge(object, metaclass = _Singleton): hostname = '' port = 0 pipe = '' + outsideprocess = False componentcontext = None # com.sun.star.uno.XComponentContext scriptprovider = None # com.sun.star.script.provider.XScriptProvider @@ -162,6 +163,7 @@ class ScriptForge(object, metaclass = _Singleton): # Determine main pyuno entry points ScriptForge.componentcontext = self.ConnectToLOProcess(hostname, port, pipe) # com.sun.star.uno.XComponentContext + ScriptForge.outsideprocess = (port > 0 and len(hostname) > 0) or len(pipe) > 0 ScriptForge.scriptprovider = self.ScriptProvider(ScriptForge.componentcontext) # ...script.provider.XScriptProvider # # Establish a list of the available services as a dictionary (servicename, serviceclass) @@ -1114,8 +1116,8 @@ class SFScriptForge: apso = 'apso.python.script.organizer' if len(ext.getPackageLocation(apso)) > 0: # APSO is available. However, PythonShell() is ignored in bridge mode - # because APSO library not in pythonpath - if ScriptForge.port > 0: + # because APSO library is not in pythonpath + if ScriptForge.outsideprocess: return None # Directly derived from apso.oxt|python|scripts|tools.py$console # we need to load apso before import statement @@ -2195,8 +2197,7 @@ class SFDialogs: Transform positional and keyword arguments into positional only Add the XComponentContext as last argument """ - outsideprocess = len(ScriptForge.hostname) > 0 and ScriptForge.port > 0 - if outsideprocess: + if ScriptForge.outsideprocess: return dialogname, place, ScriptForge.componentcontext else: return dialogname, place @@ -2367,8 +2368,8 @@ class SFDocuments: # Exclude Base and Math doctype = self.DocumentType if doctype in ('Calc', 'Writer', 'FormDocument', 'Draw', 'Impress'): - # XStyles() DOES NOT WORK through the socket bridge ?!? Works normally in direct mode. - if ScriptForge.port > 0: + # XStyles() DOES NOT WORK in bridged mode ?!? Works normally in direct mode. + if ScriptForge.outsideprocess: return None return self.ExecMethod(self.vbMethod + self.flgUno, 'XStyle', family, stylename) raise RuntimeError('The \'XStyle\' method is not applicable to {0} documents'.format(doctype))