wizards/source/scriptforge/SF_Platform.xba       |   32 +++++++++++++++++++++++
 wizards/source/scriptforge/SF_PythonHelper.xba   |    2 +
 wizards/source/scriptforge/python/scriptforge.py |   12 +++++++-
 3 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit 0f43960ec87229f15f9138d83072bb1f510fa9b2
Author:     Jean-Pierre Ledure <j...@ledure.be>
AuthorDate: Fri Jul 28 16:47:10 2023 +0200
Commit:     Jean-Pierre Ledure <j...@ledure.be>
CommitDate: Sat Jul 29 12:39:34 2023 +0200

    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 <j...@ledure.be>
    Tested-by: Jenkins

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(&quot;SystemLocale&quot;)
 End Property   &apos;  ScriptForge.SF_Platform.SystemLocale (get)
 
+REM 
-----------------------------------------------------------------------------
+Property Get UserData() As Variant
+&apos;&apos;&apos;     Returns a dictionary of all Options + User Data values
+&apos;&apos;&apos;     Example:
+&apos;&apos;&apos;             MsgBox platform.UserData
+       UserData = _PropertyGet(&quot;UserData&quot;)
+End Property   &apos;  ScriptForge.SF_Platform.UserData (get)
+
 REM ===================================================================== 
METHODS
 
 REM 
-----------------------------------------------------------------------------
@@ -285,6 +293,7 @@ Public Function Properties() As Variant
                                        , &quot;Processor&quot; _
                                        , &quot;PythonVersion&quot; _
                                        , &quot;SystemLocale&quot; _
+                                       , &quot;UserData&quot; _
                                        )
 
 End Function   &apos;  ScriptForge.SF_Platform.Properties
@@ -374,6 +383,10 @@ Dim sFont As String                                &apos;  
A single font name
 Dim vExtensionsList As Variant &apos;  Array of extension descriptors
 Dim sExtensions As String              &apos;  Comma separated list of 
extensions
 Dim sExtension As String               &apos;  A single extension name
+Dim vUserDataInternal As Variant&apos; The internal names of the supported 
user data items
+Dim vUserDataExternal As Variant&apos; The external names of the supported 
user data items
+Dim vUserData As Variant               &apos;  A SF_Dictionary instance 
linking user data external names and values
+Dim vUserDataOptions As Variant        &apos;  configmgr.RootAccess
 Dim i As Long
 
 Const cstPyHelper = &quot;$&quot; &amp; &quot;_SF_Platform&quot;
@@ -438,6 +451,25 @@ Const cstSubArgs = &quot;&quot;
                Case &quot;SystemLocale&quot;, &quot;Locale&quot;
                        Set oLocale = 
SF_Utils._GetUNOService(&quot;SystemLocale&quot;)
                        _PropertyGet = oLocale.Language &amp; &quot;-&quot; 
&amp; oLocale.Country
+               Case &quot;UserData&quot;
+                       vUserDataExternal = Array( _
+                               &quot;city&quot;, &quot;company&quot;, 
&quot;country&quot;, &quot;email&quot;, &quot;encryptionkey&quot;, 
&quot;encrypttoself&quot;, &quot;fax&quot; _
+                               , &quot;firstname&quot;, &quot;homephone&quot;, 
&quot;initials&quot;, &quot;lastname&quot;, &quot;officephone&quot;, 
&quot;position&quot; _
+                               , &quot;postalcode&quot;, 
&quot;signingkey&quot;, &quot;state&quot;, &quot;street&quot;, 
&quot;title&quot; _
+                               )
+                       vUserDataInternal = Array( _
+                               &quot;l&quot;, &quot;o&quot;, &quot;c&quot;, 
&quot;mail&quot;, &quot;encryptionkey&quot;, &quot;encrypttoself&quot;, 
&quot;facsimiletelephonenumber&quot; _
+                               , &quot;givenname&quot;, &quot;homephone&quot;, 
&quot;initials&quot;, &quot;sn&quot;, &quot;telephonenumber&quot;, 
&quot;position&quot; _
+                               , &quot;postalcode&quot;, 
&quot;signingkey&quot;, &quot;st&quot;, &quot;street&quot;, &quot;title&quot; _
+                               )
+                       &apos;  Get the UserData page from the Options database
+                       vUserDataOptions = 
SF_Utils._GetRegistryKeyContent(&quot;org.openoffice.UserProfile/Data&quot;)
+                       &apos;  Create and feed the ouput dictionary
+                       vUserData = 
CreateScriptService(&quot;ScriptForge.Dictionary&quot;)
+                       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 = &quot;Dispose&quot; Then
                                &apos;  Special case: Dispose() must update the 
cache for class objects created in Python scripts
                                Set _SF_.PythonStorage(BasicObject) = Nothing
+                       ElseIf sServiceName = &quot;ScriptForge.Platform&quot; 
And Script = &quot;UserData&quot; 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
     # #########################################################################

Reply via email to