sc/inc/scmod.hxx | 1 + sc/qa/unit/tiledrendering/tiledrendering2.cxx | 17 +++++++++++++++++ sc/source/ui/app/scmod.cxx | 9 ++++++++- sc/source/ui/view/cellsh3.cxx | 8 ++++---- sfx2/source/view/viewsh.cxx | 6 ++++++ 5 files changed, 36 insertions(+), 5 deletions(-)
New commits: commit d01737cb12654f488bb88235cdc562d3cf68d7db Author: Jaume Pujantell <jaume.pujant...@collabora.com> AuthorDate: Thu Apr 24 16:36:21 2025 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Apr 29 08:35:06 2025 +0200 cool#11739 lok: sc: change dialog units per user On lok different users might have different locales so they need different field units in their dialogues. Right now the metric used is always the one stored in the ScModule's AppOptions for all users. With this change, for lok SfxModule::GetFieldUnit is used because it already has the correct metric per lok user. Change-Id: If2b047874a26deecc7c43936ab267b75eae101e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184567 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx index 3811a9334fa6..f8a6122fd839 100644 --- a/sc/inc/scmod.hxx +++ b/sc/inc/scmod.hxx @@ -186,6 +186,7 @@ public: svtools::ColorConfig& GetColorConfig(); static bool IsLOKViewInDarkMode(); SC_DLLPUBLIC SvtUserOptions& GetUserOptions(); + SC_DLLPUBLIC FieldUnit GetMetric(); void ModifyOptions( const SfxItemSet& rOptSet ); diff --git a/sc/qa/unit/tiledrendering/tiledrendering2.cxx b/sc/qa/unit/tiledrendering/tiledrendering2.cxx index b3625d3128e6..41fdcb17b936 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering2.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering2.cxx @@ -19,6 +19,7 @@ #include <sctestviewcallback.hxx> #include <docuno.hxx> +#include <scmod.hxx> #include <tabvwsh.hxx> using namespace com::sun::star; @@ -148,6 +149,22 @@ CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testDecimalSeparatorInfo) CPPUNIT_ASSERT_EQUAL(std::string(","), aView1.decimalSeparator); } +CPPUNIT_TEST_FIXTURE(ScTiledRenderingTest, testCool11739LocaleDialogFieldUnit) +{ + createDoc("empty.ods"); + SfxViewShell* pView1 = SfxViewShell::Current(); + pView1->SetLOKLocale(u"fr-FR"_ustr); + + ScModule* pMod = ScModule::get(); + FieldUnit eMetric = pMod->GetMetric(); + + // Without the fix, it fails with + // - Expected: 2 + // - Actual : 8 + // where 2 is FieldUnit::CM and 8 is FieldUnit::INCH + CPPUNIT_ASSERT_EQUAL(FieldUnit::CM, eMetric); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 4817f793f037..1d7266e88572 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -567,7 +567,7 @@ void ScModule::GetState( SfxItemSet& rSet ) rSet.Put( SfxUInt32Item( nWhich, GetAppOptions().GetStatusFunc() ) ); break; case SID_ATTR_METRIC: - rSet.Put( SfxUInt16Item( nWhich, sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) ); + rSet.Put(SfxUInt16Item(nWhich, sal::static_int_cast<sal_uInt16>(GetMetric()))); break; case SID_AUTOSPELL_CHECK: rSet.Put( SfxBoolItem( nWhich, pTabViewShell->IsAutoSpell()) ); @@ -919,6 +919,13 @@ SvtUserOptions& ScModule::GetUserOptions() return *m_pUserOptions; } +FieldUnit ScModule::GetMetric() +{ + if (comphelper::LibreOfficeKit::isActive()) + return SfxModule::GetFieldUnit(); + return GetAppOptions().GetAppMetric(); +} + LanguageType ScModule::GetOptDigitLanguage() { SvtCTLOptions::TextNumerals eNumerals = SvtCTLOptions::GetCTLTextNumerals(); diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index 033ecf8982cb..2a9d6b94ebd4 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -727,7 +727,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) else { ScViewData& rData = GetViewData(); - FieldUnit eMetric = pScMod->GetAppOptions().GetAppMetric(); + FieldUnit eMetric = pScMod->GetMetric(); sal_uInt16 nCurHeight = rData.GetDocument(). GetRowHeight( rData.GetCurY(), rData.GetTabNo() ); @@ -770,7 +770,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) } else { - FieldUnit eMetric = pScMod->GetAppOptions().GetAppMetric(); + FieldUnit eMetric = pScMod->GetMetric(); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); VclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( @@ -832,7 +832,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) } else { - FieldUnit eMetric = pScMod->GetAppOptions().GetAppMetric(); + FieldUnit eMetric = pScMod->GetMetric(); ScViewData& rData = GetViewData(); sal_uInt16 nCurHeight = rData.GetDocument(). GetColWidth( rData.GetCurX(), @@ -875,7 +875,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) } else { - FieldUnit eMetric = pScMod->GetAppOptions().GetAppMetric(); + FieldUnit eMetric = pScMod->GetMetric(); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); VclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 10dcb366eefc..5a5f642a5077 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -3506,6 +3506,12 @@ void SfxViewShell::SetLOKAccessibilityState(bool bEnabled) void SfxViewShell::SetLOKLocale(const OUString& rBcp47LanguageTag) { maLOKLocale = LanguageTag(rBcp47LanguageTag, true).makeFallback(); + if (this == Current()) + { + // update the current LOK language and locale for the dialog tunneling + comphelper::LibreOfficeKit::setLanguageTag(GetLOKLanguageTag()); + comphelper::LibreOfficeKit::setLocale(GetLOKLocale()); + } } void SfxViewShell::NotifyCursor(SfxViewShell* /*pViewShell*/) const