[Libreoffice-commits] core.git: wizards/source
Jean-Pierre Ledure (via logerrit)
logerrit at kemper.freedesktop.org
Sat Mar 13 12:12:37 UTC 2021
wizards/source/scriptforge/python/scriptforge.py | 76 ++++++++++++++++++++++-
1 file changed, 74 insertions(+), 2 deletions(-)
New commits:
commit 42f05d000a618a004eb73b3d259841b258ecb902
Author: Jean-Pierre Ledure <jp at ledure.be>
AuthorDate: Fri Mar 12 14:40:27 2021 +0100
Commit: Jean-Pierre Ledure <jp at ledure.be>
CommitDate: Sat Mar 13 13:12:00 2021 +0100
ScriptForge - (scriptforge.py) Platform class
Addition of SF_Platform class
Most properties are provided by a direct call to
ScriptForgeHelper.py
Others result from an interaction with the Basic-Python machinery
Addition of STarDesktop() method in the SF_Basic class
Change-Id: If1c03fe8e0ad36b6a665c8c44b477eca7cbc24bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112393
Tested-by: Jean-Pierre Ledure <jp at ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp at ledure.be>
diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py
index 7547367d3ed6..2941c0db1e8b 100644
--- a/wizards/source/scriptforge/python/scriptforge.py
+++ b/wizards/source/scriptforge/python/scriptforge.py
@@ -550,6 +550,16 @@ class SFScriptForge:
def RGB(red, green, blue):
return int('%02x%02x%02x' % (red, green, blue), 16)
+ @staticmethod
+ def StarDesktop():
+ ctx = ScriptForge.componentcontext
+ if ctx is None:
+ return None
+ smgr = ctx.getServiceManager() # com.sun.star.lang.XMultiComponentFactory
+ DESK = 'com.sun.star.frame.Desktop'
+ desktop = smgr.createInstanceWithContext(DESK, ctx)
+ return desktop
+
def Xray(self, unoobject = None):
return self.SIMPLEEXEC('XrayTool._main.xray', unoobject)
@@ -698,7 +708,7 @@ class SFScriptForge:
serviceProperties = dict(Folder = False, Languages = False, Locale = False)
def AddText(self, context = '', msgid = '', comment = ''):
- return self.Execute(self.vbMethod, 'AddText', context, msgid, context)
+ return self.Execute(self.vbMethod, 'AddText', context, msgid, comment)
def ExportToPOTFile(self, filename, header = '', encoding= 'UTF-8'):
return self.Execute(self.vbMethod, 'ExportToPOTFile', filename, header, encoding)
@@ -708,6 +718,69 @@ class SFScriptForge:
_ = GetText
+ # #########################################################################
+ # SF_Platform CLASS
+ # #########################################################################
+ class SF_Platform(SFServices, metaclass = _Singleton):
+ """
+ The 'Platform' service implements a collection of properties about the actual execution environment
+ and context :
+ the hardware platform
+ the operating system
+ the LibreOffice version
+ the current user
+ All those properties are read-only.
+ The implementation is mainly based on the 'platform' module of the Python standard library
+ """
+ # Mandatory class properties for service registration
+ serviceimplementation = 'basic'
+ servicename = 'ScriptForge.Platform'
+ serviceProperties = dict(Architecture = False, ComputerName = False, CPUCount = False, CurrentUser = False,
+ Locale = False, Machine = False, OfficeVersion = False, OSName = False,
+ OSPlatform = False, OSRelease = False, OSVersion = False, Processor = False)
+ # Python helper functions
+ py = ScriptForge.pythonhelpermodule + '$' + '_SF_Platform'
+
+ @property
+ def Architecture(self):
+ return self.SIMPLEEXEC(self.py, 'Architecture')
+
+ @property
+ def ComputerName(self):
+ return self.SIMPLEEXEC(self.py, 'ComputerName')
+
+ @property
+ def CPUCount(self):
+ return self.SIMPLEEXEC(self.py, 'CPUCount')
+
+ @property
+ def CurrentUser(self):
+ return self.SIMPLEEXEC(self.py, 'CurrentUser')
+
+ @property
+ def Machine(self):
+ return self.SIMPLEEXEC(self.py, 'Machine')
+
+ @property
+ def OSName(self):
+ return self.SIMPLEEXEC(self.py, 'OSName')
+
+ @property
+ def OSPlatform(self):
+ return self.SIMPLEEXEC(self.py, 'OSPlatform')
+
+ @property
+ def OSRelease(self):
+ return self.SIMPLEEXEC(self.py, 'OSRelease')
+
+ @property
+ def OSVersion(self):
+ return self.SIMPLEEXEC(self.py, 'OSVersion')
+
+ @property
+ def Processor(self):
+ return self.SIMPLEEXEC(self.py, 'Processor')
+
# #########################################################################
# SF_TextStream CLASS
# #########################################################################
@@ -748,7 +821,6 @@ class SFScriptForge:
def WriteLine(self, line):
return self.Execute(self.vbMethod, 'WriteLine', line)
-
# #########################################################################
# SF_Timer CLASS
# #########################################################################
More information about the Libreoffice-commits
mailing list