summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-02-24 08:07:12 +0100
committerAndras Timar <andras.timar@collabora.com>2020-02-24 13:32:45 +0100
commitf07e77b93ddfbac967dbc526dc01ec39b5a046c7 (patch)
tree226cb1bad579ae9eb0f2851ccb8c09ea36349172 /desktop
parentef6f94e93bbe55a26b67b55b2aecda67d406ab85 (diff)
Fix currency symbol selection in Calc on mobile
In LOK we use one language identifier for both - UI language and the locale used. This is a problem when we determine that we a language for UI is not available and fall-back to the default "en-US" langauge, which also changes the locale. This introduces a separate variable that stores the language tag for the locale independently to the language. Another problem is that in some cases we don't reset the staticly initialized data, when the new document is loaded, which is on the other hand used to define which currency symbol is used as SYSTEM locale. That can in some cases select the wrong currency symbol even when we changed the locale to something else. This fix introduces a reset function, which is triggered on every document load. Change-Id: I55c7f467600a832895f94346f8bf11a6ef6a1e49 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89320 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/CppunitTest_desktop_lib.mk1
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx2
-rw-r--r--desktop/source/lib/init.cxx39
3 files changed, 25 insertions, 17 deletions
diff --git a/desktop/CppunitTest_desktop_lib.mk b/desktop/CppunitTest_desktop_lib.mk
index b25ab04bda8d..19c00b5d5e66 100644
--- a/desktop/CppunitTest_desktop_lib.mk
+++ b/desktop/CppunitTest_desktop_lib.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_use_libraries,desktop_lib, \
comphelper \
cppu \
cppuhelper \
+ i18nlangtag \
sal \
sc \
scfilt \
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 1f3365faf2f9..101fdda65742 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2729,7 +2729,7 @@ void DesktopLOKTest::testSpellcheckerMultiView()
SvtSysLocaleOptions aSysLocaleOptions;
aSysLocaleOptions.SetLocaleConfigString(aLangISO);
aSysLocaleOptions.SetUILocaleConfigString(aLangISO);
- comphelper::LibreOfficeKit::setLanguageTag(aLangISO, true);
+ comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLangISO, true));
auto aSavedSettings = Application::GetSettings();
std::unique_ptr<Resetter> pResetter(
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index aa6452e3d2cd..40abb74cd060 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -47,6 +47,7 @@
#include <rtl/bootstrap.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/uri.hxx>
+#include <svl/zforlist.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <comphelper/base64.hxx>
#include <comphelper/dispatchcommand.hxx>
@@ -2085,6 +2086,14 @@ void paintTileIOS(LibreOfficeKitDocument* pThis,
}
#endif
+void setLanguageAndLocale(OUString const & aLangISO)
+{
+ SvtSysLocaleOptions aLocalOptions;
+ aLocalOptions.SetLocaleConfigString(aLangISO);
+ aLocalOptions.SetUILocaleConfigString(aLangISO);
+ aLocalOptions.Commit();
+}
+
} // anonymous namespace
// Wonder global state ...
@@ -2141,13 +2150,17 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
if (!aLanguage.isEmpty())
{
+ SfxLokHelper::setDefaultLanguage(aLanguage);
+ // Set the LOK language tag, used for dialog tunneling.
+ comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLanguage));
+ comphelper::LibreOfficeKit::setLocale(LanguageTag(aLanguage));
+
+ SAL_INFO("lok", "Set document language to " << aLanguage);
// use with care - it sets it for the entire core, not just the
// document
- SvtSysLocaleOptions aSysLocaleOptions;
- aSysLocaleOptions.SetLocaleConfigString(aLanguage);
- aSysLocaleOptions.SetUILocaleConfigString(aLanguage);
- // Set the LOK language tag, used for dialog tunneling.
- comphelper::LibreOfficeKit::setLanguageTag(aSysLocaleOptions.GetLanguageTag());
+ setLanguageAndLocale(aLanguage);
+ // Need to reset the static initialized values
+ SvNumberFormatter::resetTheCurrencyTable();
}
uno::Sequence<css::beans::PropertyValue> aFilterOptions(2);
@@ -4865,6 +4878,7 @@ static int doc_createViewWithOptions(LibreOfficeKitDocument* pThis,
{
// Set the LOK language tag, used for dialog tunneling.
comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(aLanguage));
+ comphelper::LibreOfficeKit::setLocale(LanguageTag(aLanguage));
}
int nId = SfxLokHelper::createView();
@@ -4942,7 +4956,9 @@ static void doc_setViewLanguage(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*p
SolarMutexGuard aGuard;
SetLastExceptionMsg();
- SfxLokHelper::setViewLanguage(nId, OStringToOUString(language, RTL_TEXTENCODING_UTF8));
+ OUString sLanguage = OStringToOUString(language, RTL_TEXTENCODING_UTF8);
+ SfxLokHelper::setViewLanguage(nId, sLanguage);
+ SfxLokHelper::setViewLocale(nId, sLanguage);
}
@@ -5491,15 +5507,6 @@ static char* lo_getVersionInfo(SAL_UNUSED_PARAMETER LibreOfficeKit* /*pThis*/)
return convertOUString(ReplaceStringHookProc(sVersionStrTemplate));
}
-static void force_c_locale()
-{
- // force locale (and resource files loaded) to en-US
- OUString aLangISO("en-US");
- SvtSysLocaleOptions aLocalOptions;
- aLocalOptions.SetLocaleConfigString(aLangISO);
- aLocalOptions.SetUILocaleConfigString(aLangISO);
-}
-
static void aBasicErrorFunc(const OUString& rError, const OUString& rAction)
{
OStringBuffer aBuffer("Unexpected dialog: ");
@@ -5966,7 +5973,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
Application::ReleaseSolarMutex();
}
- force_c_locale();
+ setLanguageAndLocale("en-US");
}
if (eStage != PRE_INIT)