diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-02-24 08:07:12 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-02-25 09:25:33 +0100 |
commit | 3810f28d784ff71d4c6d68557e70bd80c1d1d99c (patch) | |
tree | 6693669512264f402e9169107141150c2347bd7c /sfx2/source | |
parent | 58fab0b920303e58d3ac3be28b22763970085f02 (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>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89343
Tested-by: Jenkins
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 32 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 11 |
2 files changed, 41 insertions, 2 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 5556caa26be3..f924ca8edaf4 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -63,6 +63,11 @@ private: int DisableCallbacks::m_nDisabled = 0; } +namespace +{ +static LanguageTag g_defaultLanguageTag("en-US", true); +} + int SfxLokHelper::createView() { SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); @@ -112,8 +117,9 @@ void SfxLokHelper::setView(int nId) { DisableCallbacks dc; - // update the current LOK language for the dialog tunneling + // update the current LOK language and locale for the dialog tunneling comphelper::LibreOfficeKit::setLanguageTag(pViewShell->GetLOKLanguageTag()); + comphelper::LibreOfficeKit::setLocale(pViewShell->GetLOKLocale()); if (pViewShell == SfxViewShell::Current()) return; @@ -166,6 +172,16 @@ bool SfxLokHelper::getViewIds(int* pArray, size_t nSize) return true; } +LanguageTag SfxLokHelper::getDefaultLanguage() +{ + return g_defaultLanguageTag; +} + +void SfxLokHelper::setDefaultLanguage(const OUString& rBcp47LanguageTag) +{ + g_defaultLanguageTag = LanguageTag(rBcp47LanguageTag, true); +} + void SfxLokHelper::setViewLanguage(int nId, const OUString& rBcp47LanguageTag) { SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); @@ -180,6 +196,20 @@ void SfxLokHelper::setViewLanguage(int nId, const OUString& rBcp47LanguageTag) } } +void SfxLokHelper::setViewLocale(int nId, const OUString& rBcp47LanguageTag) +{ + SfxViewShellArr_Impl& rViewArr = SfxGetpApp()->GetViewShells_Impl(); + + for (SfxViewShell* pViewShell : rViewArr) + { + if (pViewShell->GetViewShellId() == ViewShellId(nId)) + { + pViewShell->SetLOKLocale(rBcp47LanguageTag); + return; + } + } +} + static OString lcl_escapeQuotes(const OString &rStr) { if (rStr.getLength() < 1) diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 10f149dff58a..a28dc663ade9 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1069,7 +1069,8 @@ SfxViewShell::SfxViewShell , pWindow(nullptr) , bNoNewWindow( nFlags & SfxViewShellFlags::NO_NEWWINDOW ) , mbPrinterSettingsModified(false) -, maLOKLanguageTag("en-US", true) +, maLOKLanguageTag(LANGUAGE_NONE) +, maLOKLocale(LANGUAGE_NONE) { SetMargin( pViewFrame->GetMargin_Impl() ); @@ -1083,6 +1084,9 @@ SfxViewShell::SfxViewShell if (comphelper::LibreOfficeKit::isActive()) { + maLOKLanguageTag = SfxLokHelper::getDefaultLanguage(); + maLOKLocale = SfxLokHelper::getDefaultLanguage(); + vcl::Window* pFrameWin = pViewFrame->GetWindow().GetFrameWindow(); if (pFrameWin && !pFrameWin->GetLOKNotifier()) pFrameWin->SetLOKNotifier(this, true); @@ -1506,6 +1510,11 @@ void SfxViewShell::SetLOKLanguageTag(const OUString& rBcp47LanguageTag) maLOKLanguageTag = aFallbackTag; } +void SfxViewShell::SetLOKLocale(const OUString& rBcp47LanguageTag) +{ + maLOKLocale = LanguageTag(rBcp47LanguageTag, true).makeFallback(); +} + void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const { } |