wizards/source/scriptforge/SF_Root.xba | 10 +++++++--- wizards/source/scriptforge/SF_Utils.xba | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-)
New commits: commit 7e834362a868979e8d703ff61bc22772b671e678 Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Tue Mar 8 15:53:37 2022 +0100 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Tue Mar 8 19:53:14 2022 +0100 ScriptForge - 'SF_Root) load user interface from code when locale=en The user interface is loaded in the user's language at the first use of Scriptforge during the LO session. So far the labels were always loaded from the relevant .po file. Now they are loaded in memory by code when the user's language = "en". Objective = gain in performance. Additionally the default language is set to SF_Platform.OfficeLocale i.o. SF_Platform.SystemLocale Internal change, no impact on documentation Change-Id: Ia0d1235f8ca6a42141a5481fe80b5bec1d53a7e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131214 Tested-by: Jean-Pierre Ledure <j...@ledure.be> Tested-by: Jenkins Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> diff --git a/wizards/source/scriptforge/SF_Root.xba b/wizards/source/scriptforge/SF_Root.xba index 46cdec9f7ea5..d7c4cc639737 100644 --- a/wizards/source/scriptforge/SF_Root.xba +++ b/wizards/source/scriptforge/SF_Root.xba @@ -61,6 +61,7 @@ Private SearchOptions As Object ' com.sun.star.util.SearchOptions Private SystemLocale As Object ' com.sun.star.lang.Locale Private OfficeLocale As Object ' com.sun.star.lang.Locale Private FormatLocale As Object ' com.sun.star.lang.Locale +Private LocaleData As Object ' com.sun.star.i18n.LocaleData Private PrinterServer As Object ' com.sun.star.awt.PrinterServer Private CharacterClass As Object ' com.sun.star.i18n.CharacterClassification Private FileAccess As Object ' com.sun.star.ucb.SimpleFileAccess @@ -121,9 +122,10 @@ Private Sub Class_Initialize() Set DispatchHelper = Nothing Set TextSearch = Nothing Set SearchOptions = Nothing + Set SystemLocale = Nothing Set OfficeLocale = Nothing Set FormatLocale = Nothing - Set SystemLocale = Nothing + Set LocaleData = Nothing Set PrinterServer = Nothing Set CharacterClass = Nothing Set FileAccess = Nothing @@ -289,10 +291,12 @@ Try: ' Build the po file name With SF_FileSystem sInstallFolder = ._SFInstallFolder() ' ScriptForge installation folder - sLocale = SF_Utils._GetUNOService("SystemLocale").Language + sLocale = SF_Utils._GetUNOService("OfficeLocale").Language sPOFolder = .BuildPath(sInstallFolder, "po") sPOFile = .BuildPath(sPOFolder, sLocale & ".po") - If Not .FileExists(sPOFile) Then ' File not found => load texts from code below + If sLocale = "en" Then ' Interface loaded by code i.o. read from po file + psMode = "ADDTEXT" + ElseIf Not .FileExists(sPOFile) Then ' File not found => load texts from code below psMode = "ADDTEXT" Else Set Interface = CreateScriptService("L10N", sPOFolder, sLocale) diff --git a/wizards/source/scriptforge/SF_Utils.xba b/wizards/source/scriptforge/SF_Utils.xba index a6a4f49abe4d..28aed74fa19f 100644 --- a/wizards/source/scriptforge/SF_Utils.xba +++ b/wizards/source/scriptforge/SF_Utils.xba @@ -393,6 +393,11 @@ Dim oDefaultContext As Object Set .Introspection = CreateUnoService("com.sun.star.beans.Introspection") End If Set _GetUNOService = .Introspection + Case "LocaleData" + If IsEmpty(.LocaleData) Or IsNull(.LocaleData) Then + Set .LocaleData = CreateUnoService("com.sun.star.i18n.LocaleData") + End If + Set _GetUNOService = .LocaleData Case "MacroExpander" Set oDefaultContext = GetDefaultContext() If Not IsNull(oDefaultContext) Then Set _GetUNOService = oDefaultContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander")