diff options
author | Jean-Pierre Ledure <jp@ledure.be> | 2021-11-25 17:26:06 +0100 |
---|---|---|
committer | Jean-Pierre Ledure <jp@ledure.be> | 2021-11-25 17:35:45 +0100 |
commit | 6983e9e0a299d3645a1eaaad9ff1b0a79ea2d207 (patch) | |
tree | dff33e248e4494aa467d7207f10324fd2e623c4c | |
parent | a0e27322bebf5443ef895cb4c43d9288bcf13f9f (diff) |
ScriptForge - (SF_Platform) fix Locale should return the OS locale
So far it returned the LO locale.
Discussed on Telegram
Change-Id: I2cf66ca3acebe695354de9185e0698ffa4d8cf05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125820
Tested-by: Jean-Pierre Ledure <jp@ledure.be>
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
-rw-r--r-- | wizards/source/scriptforge/SF_Platform.xba | 2 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_Root.xba | 2 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_Services.xba | 2 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_String.xba | 14 | ||||
-rw-r--r-- | wizards/source/scriptforge/SF_Utils.xba | 26 |
5 files changed, 23 insertions, 23 deletions
diff --git a/wizards/source/scriptforge/SF_Platform.xba b/wizards/source/scriptforge/SF_Platform.xba index c504de6b9809..a19ee2bc7a6c 100644 --- a/wizards/source/scriptforge/SF_Platform.xba +++ b/wizards/source/scriptforge/SF_Platform.xba @@ -351,7 +351,7 @@ Const cstSubArgs = "" ' Remove leading and trailing commas If Len(sFonts) > 1 Then _PropertyGet = Split(Mid(sFonts, 2, Len(sFonts) - 2), ",") Else _PropertyGet = Array() Case "Locale" - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") _PropertyGet = oLocale.Language & "-" & oLocale.Country Case "OfficeVersion" _PropertyGet = _GetProductName() diff --git a/wizards/source/scriptforge/SF_Root.xba b/wizards/source/scriptforge/SF_Root.xba index 258eea4bde2f..3ec4c2936908 100644 --- a/wizards/source/scriptforge/SF_Root.xba +++ b/wizards/source/scriptforge/SF_Root.xba @@ -283,7 +283,7 @@ Try: ' Build the po file name With SF_FileSystem sInstallFolder = ._SFInstallFolder() ' ScriptForge installation folder - sLocale = SF_Utils._GetUNOService("Locale").Language + sLocale = SF_Utils._GetUNOService("SystemLocale").Language sPOFolder = .BuildPath(sInstallFolder, "po") sPOFile = .BuildPath(sPOFolder, sLocale & ".po") If Not .FileExists(sPOFile) Then ' File not found => load texts from code below diff --git a/wizards/source/scriptforge/SF_Services.xba b/wizards/source/scriptforge/SF_Services.xba index a5f360fa386e..74bc110c9371 100644 --- a/wizards/source/scriptforge/SF_Services.xba +++ b/wizards/source/scriptforge/SF_Services.xba @@ -547,7 +547,7 @@ Check: sLocale = pvArgs(1) End If If Len(sLocale) = 0 Then ' Called from Python, the Locale argument may be the zero-length string - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") sLocale = oLocale.Language & "-" & oLocale.Country End If If UBound(pvArgs) >= 2 Then diff --git a/wizards/source/scriptforge/SF_String.xba b/wizards/source/scriptforge/SF_String.xba index 28145ab42750..10ce48045ab8 100644 --- a/wizards/source/scriptforge/SF_String.xba +++ b/wizards/source/scriptforge/SF_String.xba @@ -173,7 +173,7 @@ Check: Try: lLength = Len(InputStr) If lLength > 0 Then - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") Set oChar = SF_Utils._GetUNOService("CharacterClass") sCapital = oChar.toTitle(InputStr, 0, lLength * 4, oLocale) ' length * 4 because length is expressed in bytes End If @@ -444,7 +444,7 @@ Try: lLength = Len(InputStr) lReplace = Len(ReplacedBy) If lLength > 0 Then - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") Set oChar = SF_Utils._GetUNOService("CharacterClass") For i = 0 To lLength - 1 sChar = Mid(InputStr, i + 1, 1) @@ -804,7 +804,7 @@ Check: Try: lLength = Len(InputStr) If lLength > 0 Then - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") Set oChar = SF_Utils._GetUNOService("CharacterClass") For i = 0 To lLength - 1 lType = oChar.getCharacterType(InputStr, i, oLocale) @@ -860,7 +860,7 @@ Try: bAlphanum = ( sFirst < "0" Or sFirst > "9" ) If bAlphaNum Then sInputStr = Replace(InputStr, "_", "A") ' Replace by an arbitrary alphabetic character - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") Set oChar = SF_Utils._GetUNOService("CharacterClass") For i = 0 To lLength - 1 lType = oChar.getCharacterType(sInputStr, i, oLocale) @@ -1303,7 +1303,7 @@ Check: Try: lLength = Len(InputStr) If lLength > 0 Then - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") Set oChar = SF_Utils._GetUNOService("CharacterClass") For i = 0 To lLength - 1 sChar = Mid(InputStr, i + 1, 1) @@ -2337,7 +2337,7 @@ Try: Else If Occurrences < 0 Then Occurrences = 0 Set oCharacterClass = SF_Utils._GetUNOService("CharacterClass") - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") ' Build an array of start/end positions of quoted strings containing at least 1x the Delimiter vStart = Array() : vEnd = Array() @@ -2571,7 +2571,7 @@ Try: sUnquote = InputStr Else Set oCharacterClass = SF_Utils._GetUNOService("CharacterClass") - Set oLocale = SF_Utils._GetUNOService("Locale") + Set oLocale = SF_Utils._GetUNOService("SystemLocale") ' https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1i18n_1_1XCharacterClassification.html#ad5f1be91fbe86853200391f828d4166b Set oParse = oCharacterClass.parsePredefinedToken( _ diff --git a/wizards/source/scriptforge/SF_Utils.xba b/wizards/source/scriptforge/SF_Utils.xba index b18a42781bab..b3031e33f09a 100644 --- a/wizards/source/scriptforge/SF_Utils.xba +++ b/wizards/source/scriptforge/SF_Utils.xba @@ -368,19 +368,6 @@ Dim vNodePath As Variant Set .Introspection = CreateUnoService("com.sun.star.beans.Introspection") End If Set _GetUNOService = .Introspection - Case "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.Setup/L10N" - sLocale = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", vNodePath()).getByName("ooLocale") - .Locale.Language = Left(sLocale, 2) - .Locale.Country = Right(sLocale, 2) - End If - Set _GetUNOService = .Locale Case "MacroExpander" Set oDefaultContext = GetDefaultContext() If Not IsNull(oDefaultContext) Then Set _GetUNOService = oDefaultContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander") @@ -429,6 +416,19 @@ Dim vNodePath As Variant End With 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 = Left(sLocale, 2) + .Locale.Country = Right(sLocale, 2) + End If + Set _GetUNOService = .Locale Case "SystemShellExecute" If IsEmpty(.SystemShellExecute) Or IsNull(.SystemShellExecute) Then Set .SystemShellExecute = CreateUnoService("com.sun.star.system.SystemShellExecute") |