diff options
Diffstat (limited to 'wizards/source/scriptforge/SF_Utils.xba')
-rw-r--r-- | wizards/source/scriptforge/SF_Utils.xba | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/wizards/source/scriptforge/SF_Utils.xba b/wizards/source/scriptforge/SF_Utils.xba index c0d63bcc6b36..cbe07ce2b0ae 100644 --- a/wizards/source/scriptforge/SF_Utils.xba +++ b/wizards/source/scriptforge/SF_Utils.xba @@ -288,6 +288,23 @@ Const cstConfigUpdate = "com.sun.star.configuration.ConfigurationUpdateAcce End Function ' ScriptForge.SF_Utils._GetRegistryKeyContent REM ----------------------------------------------------------------------------- +Private Function _GetSetting(ByVal psPreference As String, psProperty As String) As Variant +''' Find in the configuration a specific setting based on its location in the +''' settings registry + +Dim oConfigProvider As Object ' com.sun.star.configuration.ConfigurationProvider +Dim vNodePath As Variant ' Array of com.sun.star.beans.PropertyValue + + ' Derived from the Tools library + Set oConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider") + vNodePath = Array(SF_Utils._MakePropertyValue("nodepath", psPreference)) + + _GetSetting = oConfigProvider.createInstanceWithArguments( _ + "com.sun.star.configuration.ConfigurationAccess", vNodePath()).getByName(psProperty) + +End Function ' ScriptForge.SF_Utils._GetSetting + +REM ----------------------------------------------------------------------------- Public Function _GetUNOService(ByVal psService As String _ , Optional ByVal pvArg As Variant _ ) As Object @@ -298,9 +315,7 @@ Public Function _GetUNOService(ByVal psService As String _ ''' pvArg: some services might require an argument Dim sLocale As String ' fr-BE f.i. -Dim oConfigProvider As Object Dim oDefaultContext As Object -Dim vNodePath As Variant Set _GetUNOService = Nothing With _SF_ @@ -353,6 +368,16 @@ Dim vNodePath As Variant Set .FolderPicker = CreateUnoService("com.sun.star.ui.dialogs.FolderPicker") End If Set _GetUNOService = .FolderPicker + Case "FormatLocale" + If IsEmpty(.FormatLocale) Or IsNull(.FormatLocale) Then + .FormatLocale = CreateUnoStruct("com.sun.star.lang.Locale") + ' 1st and 2nd chance + sLocale = SF_Utils._GetSetting("org.openoffice.Setup/L10N", "ooSetupSystemLocale") + If Len(sLocale) = 0 Then sLocale = SF_Utils._GetSetting("org.openoffice.System/L10N", "UILocale") + .FormatLocale.Language = Split(sLocale, "-")(0) ' Language is most often 2 chars long, but not always + .FormatLocale.Country = Right(sLocale, 2) + End If + Set _GetUNOService = .FormatLocale Case "FunctionAccess" If IsEmpty(.FunctionAccess) Or IsNull(.FunctionAccess) Then Set .FunctionAccess = CreateUnoService("com.sun.star.sheet.FunctionAccess") @@ -380,6 +405,16 @@ Dim vNodePath As Variant End If End If Set _GetUNOService = .MailService + Case "OfficeLocale" + If IsEmpty(.OfficeLocale) Or IsNull(.OfficeLocale) Then + .OfficeLocale = CreateUnoStruct("com.sun.star.lang.Locale") + ' 1st and 2nd chance + sLocale = SF_Utils._GetSetting("org.openoffice.Setup/L10N", "ooLocale") + If Len(sLocale) = 0 Then sLocale = SF_Utils._GetSetting("org.openoffice.System/L10N", "UILocale") + .OfficeLocale.Language = Split(sLocale, "-")(0) ' Language is most often 2 chars long, but not always + .OfficeLocale.Country = Right(sLocale, 2) + End If + Set _GetUNOService = .OfficeLocale Case "PathSettings" If IsEmpty(.PathSettings) Or IsNull(.PathSettings) Then Set .PathSettings = CreateUnoService("com.sun.star.util.PathSettings") @@ -417,18 +452,13 @@ Dim vNodePath As Variant End If Set _GetUNOService = .SearchOptions Case "SystemLocale", "Locale" - If IsEmpty(.Locale) Or IsNull(.Locale) Then - .Locale = CreateUnoStruct("com.sun.star.lang.Locale") - ' Derived from the Tools library - Set oConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider") - vNodePath = Array() : ReDim vNodePath(0) - vNodePath(0) = New com.sun.star.beans.PropertyValue - vNodePath(0).Name = "nodepath" : vNodePath(0).Value = "org.openoffice.System/L10N" - sLocale = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", vNodePath()).getByName("SystemLocale") - .Locale.Language = Split(sLocale, "-")(0) ' Language is most often 2 chars long, but not always - .Locale.Country = Right(sLocale, 2) + If IsEmpty(.SystemLocale) Or IsNull(.SystemLocale) Then + .SystemLocale = CreateUnoStruct("com.sun.star.lang.Locale") + sLocale = SF_Utils._GetSetting("org.openoffice.System/L10N", "SystemLocale") + .SystemLocale.Language = Split(sLocale, "-")(0) ' Language is most often 2 chars long, but not always + .SystemLocale.Country = Right(sLocale, 2) End If - Set _GetUNOService = .Locale + Set _GetUNOService = .SystemLocale Case "SystemShellExecute" If IsEmpty(.SystemShellExecute) Or IsNull(.SystemShellExecute) Then Set .SystemShellExecute = CreateUnoService("com.sun.star.system.SystemShellExecute") |