summaryrefslogtreecommitdiff
path: root/sfx2
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 /sfx2
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 '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 1ba7d96268d9..012ee8cf633d 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -58,6 +58,11 @@ private:
int DisableCallbacks::m_nDisabled = 0;
+namespace
+{
+static LanguageTag g_defaultLanguageTag("en-US", true);
+}
+
int SfxLokHelper::createView()
{
SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
@@ -107,8 +112,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;
@@ -161,6 +167,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();
@@ -175,6 +191,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 1a022e49f7b2..5ac368075d15 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1067,7 +1067,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() );
@@ -1081,6 +1082,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);
@@ -1540,6 +1544,11 @@ void SfxViewShell::SetLOKLanguageTag(const OUString& rBcp47LanguageTag)
#endif
}
+void SfxViewShell::SetLOKLocale(const OUString& rBcp47LanguageTag)
+{
+ maLOKLocale = LanguageTag(rBcp47LanguageTag, true).makeFallback();
+}
+
void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const
{
}