summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorJean-Pierre Ledure <jp@ledure.be>2021-03-12 14:40:27 +0100
committerJean-Pierre Ledure <jp@ledure.be>2021-03-13 13:12:00 +0100
commit42f05d000a618a004eb73b3d259841b258ecb902 (patch)
treef42c6b411217dbe3c8966cf5ddc9006163ca0b9c /wizards
parent1beb97dfc2d8c8e9ee06001ac59a22a3208214d1 (diff)
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@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Diffstat (limited to 'wizards')
-rw-r--r--wizards/source/scriptforge/python/scriptforge.py76
1 files changed, 74 insertions, 2 deletions
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)
@@ -709,6 +719,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
# #########################################################################
class SF_TextStream(SFServices):
@@ -748,7 +821,6 @@ class SFScriptForge:
def WriteLine(self, line):
return self.Execute(self.vbMethod, 'WriteLine', line)
-
# #########################################################################
# SF_Timer CLASS
# #########################################################################