summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-02-24 08:07:12 +0100
committerMichael Meeks <michael.meeks@collabora.com>2020-05-28 09:19:17 +0100
commit1d0bee586523cb90fcf4546cc4b3960019888a69 (patch)
treeb8c48015900219a02281fb5fa25e229be5c4d359 /sfx2
parentde308f52d7288da667d6b8e5fac357c468cdff3f (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')
-rw-r--r--sfx2/source/view/lokhelper.cxx32
-rw-r--r--sfx2/source/view/viewsh.cxx11
2 files changed, 41 insertions, 2 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 004b2c58bf90..576c364e72c5 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -62,6 +62,11 @@ private:
int DisableCallbacks::m_nDisabled = 0;
}
+namespace
+{
+static LanguageTag g_defaultLanguageTag("en-US", true);
+}
+
int SfxLokHelper::createView()
{
SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
@@ -111,8 +116,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;
@@ -165,6 +171,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();
@@ -179,6 +195,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 962d94b46d51..0109448d1b79 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1081,7 +1081,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() );
@@ -1095,6 +1096,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);
@@ -1521,6 +1525,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
{
}