diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2023-07-28 16:47:10 +0200 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2023-07-29 12:39:34 +0200 |
commit | 0f43960ec87229f15f9138d83072bb1f510fa9b2 (patch) | |
tree | b9fdf83b48bf7a346bed881fd8bede228b3b68ef /wizards | |
parent | 163fe25cb86435109aef7ce6dd1c37e5cf5cfbfa (diff) |
ScriptForge (SF_Platform) new UserData property
The UserData property lists the content of the
"User Data" oage of the Options dialog.
The content is returned:
- in Basic: in a SF_Dictionary instance
- in Python: in a dict[] instance.
The list of the available keys is:
city, company, country, email, encryptionkey,
encrypttoself, fax, firstname, homephone,
initials, lastname, officephone, position,
postalcode, signingkey, state, street, title
Many are different from the UNO/priginal values
to make them more user understandable.
This commit will require an update of the SF_Platform
help page.
Both Basic and Python user scripts are supported.
Change-Id: If645579ee9109a1b8180da5a5f3a71979bb5ca59
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155024
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
Diffstat (limited to 'wizards')
-rw-r--r-- | wizards/source/scriptforge/SF_Platform.xba | 32 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_PythonHelper.xba | 2 | ||||
-rw-r--r-- | wizards/source/scriptforge/python/scriptforge.py | 12 |
3 files changed, 45 insertions, 1 deletions
diff --git a/wizards/source/scriptforge/SF_Platform.xba b/wizards/source/scriptforge/SF_Platform.xba index 8403866fffe8..8e8aa5330a9d 100644 --- a/wizards/source/scriptforge/SF_Platform.xba +++ b/wizards/source/scriptforge/SF_Platform.xba @@ -217,6 +217,14 @@ Property Get SystemLocale() As String SystemLocale = _PropertyGet("SystemLocale") End Property ' ScriptForge.SF_Platform.SystemLocale (get) +REM ----------------------------------------------------------------------------- +Property Get UserData() As Variant +''' Returns a dictionary of all Options + User Data values +''' Example: +''' MsgBox platform.UserData + UserData = _PropertyGet("UserData") +End Property ' ScriptForge.SF_Platform.UserData (get) + REM ===================================================================== METHODS REM ----------------------------------------------------------------------------- @@ -285,6 +293,7 @@ Public Function Properties() As Variant , "Processor" _ , "PythonVersion" _ , "SystemLocale" _ + , "UserData" _ ) End Function ' ScriptForge.SF_Platform.Properties @@ -374,6 +383,10 @@ Dim sFont As String ' A single font name Dim vExtensionsList As Variant ' Array of extension descriptors Dim sExtensions As String ' Comma separated list of extensions Dim sExtension As String ' A single extension name +Dim vUserDataInternal As Variant' The internal names of the supported user data items +Dim vUserDataExternal As Variant' The external names of the supported user data items +Dim vUserData As Variant ' A SF_Dictionary instance linking user data external names and values +Dim vUserDataOptions As Variant ' configmgr.RootAccess Dim i As Long Const cstPyHelper = "$" & "_SF_Platform" @@ -438,6 +451,25 @@ Const cstSubArgs = "" Case "SystemLocale", "Locale" Set oLocale = SF_Utils._GetUNOService("SystemLocale") _PropertyGet = oLocale.Language & "-" & oLocale.Country + Case "UserData" + vUserDataExternal = Array( _ + "city", "company", "country", "email", "encryptionkey", "encrypttoself", "fax" _ + , "firstname", "homephone", "initials", "lastname", "officephone", "position" _ + , "postalcode", "signingkey", "state", "street", "title" _ + ) + vUserDataInternal = Array( _ + "l", "o", "c", "mail", "encryptionkey", "encrypttoself", "facsimiletelephonenumber" _ + , "givenname", "homephone", "initials", "sn", "telephonenumber", "position" _ + , "postalcode", "signingkey", "st", "street", "title" _ + ) + ' Get the UserData page from the Options database + vUserDataOptions = SF_Utils._GetRegistryKeyContent("org.openoffice.UserProfile/Data") + ' Create and feed the ouput dictionary + vUserData = CreateScriptService("ScriptForge.Dictionary") + For i = 0 To UBound(vUserDataExternal) + vUserData.Add(vUserDataExternal(i), vUserDataOptions.getByName(vUserDataInternal(i))) + Next i + _PropertyGet = vUserData Case Else _PropertyGet = Null End Select diff --git a/wizards/source/scriptforge/SF_PythonHelper.xba b/wizards/source/scriptforge/SF_PythonHelper.xba index f7345d4c6c40..58a841d4dc26 100644 --- a/wizards/source/scriptforge/SF_PythonHelper.xba +++ b/wizards/source/scriptforge/SF_PythonHelper.xba @@ -899,6 +899,8 @@ Try: If Script = "Dispose" Then ' Special case: Dispose() must update the cache for class objects created in Python scripts Set _SF_.PythonStorage(BasicObject) = Nothing + ElseIf sServiceName = "ScriptForge.Platform" And Script = "UserData" Then + vReturn = vReturn.ConvertToPropertyValues() End If Case Else End Select diff --git a/wizards/source/scriptforge/python/scriptforge.py b/wizards/source/scriptforge/python/scriptforge.py index d073197a11a5..e978c30b4304 100644 --- a/wizards/source/scriptforge/python/scriptforge.py +++ b/wizards/source/scriptforge/python/scriptforge.py @@ -1255,7 +1255,8 @@ class SFScriptForge: Extensions = False, FilterNames = False, Fonts = False, FormatLocale = False, Locale = False, Machine = False, OfficeLocale = False, OfficeVersion = False, OSName = False, OSPlatform = False, OSRelease = False, OSVersion = False, - Printers = False, Processor = False, PythonVersion = False, SystemLocale = False) + Printers = False, Processor = False, PythonVersion = False, SystemLocale = False, + UserData = False) # Python helper functions py = ScriptForge.pythonhelpermodule + '$' + '_SF_Platform' @@ -1303,6 +1304,15 @@ class SFScriptForge: def PythonVersion(self): return self.SIMPLEEXEC(self.py, 'PythonVersion') + @property + def UserData(self): + props = self.GetProperty('UserData') # is an array of property values + if len(props) == 0: + return dict() + dico = CreateScriptService('Dictionary') + dico.ImportFromPropertyValues(props, overwrite = True) + return dico + # ######################################################################### # SF_Region CLASS # ######################################################################### |