sc/inc/defaultsoptions.hxx | 5 +++-- sc/source/core/data/document.cxx | 4 ++-- sc/source/core/tool/defaultsoptions.cxx | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-)
New commits: commit af762d820294e891869a32b5ff138e0773d30508 Author: Jaume Pujantell <jaume.pujant...@collabora.com> AuthorDate: Thu May 8 15:03:02 2025 +0200 Commit: Jaume Pujantell <jaume.pujant...@collabora.com> CommitDate: Mon May 12 09:06:38 2025 +0200 cool#11885 lok: sc: translate TabPrefix by user In LOKit different users can have different locales on the same file, so when creating a new sheet with the default name, we must ensure that the proper localized name is used. Otherwise the language with which the module is first loaded is always used. A test cannot be added since to test this multiple languages have to be enabled and in Jenkins right now only English is enabled. Change-Id: I6aa4caacc7d079fbf9b14ddf9e27428d77411adf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185055 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 76a02119f39ffdf9dde8f6122707da95490f2253) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185094 Tested-by: Jenkins Reviewed-by: Jaume Pujantell <jaume.pujant...@collabora.com> diff --git a/sc/inc/defaultsoptions.hxx b/sc/inc/defaultsoptions.hxx index 094dc066ec74..0f20b8423af4 100644 --- a/sc/inc/defaultsoptions.hxx +++ b/sc/inc/defaultsoptions.hxx @@ -21,6 +21,7 @@ private: SCTAB nInitTabCount; // number of Tabs for new Spreadsheet doc OUString aInitTabPrefix; // The Tab prefix name in new Spreadsheet doc bool bJumboSheets; + bool bInitTabPrefixChanged; public: ScDefaultsOptions(); @@ -29,8 +30,8 @@ public: SCTAB GetInitTabCount() const { return nInitTabCount; } void SetInitTabCount( SCTAB nTabs) { nInitTabCount = nTabs; } - void SetInitTabPrefix(const OUString& aPrefix) { aInitTabPrefix = aPrefix; } - const OUString& GetInitTabPrefix() const { return aInitTabPrefix; } + void SetInitTabPrefix(const OUString& aPrefix); + OUString GetInitTabPrefix() const; bool GetInitJumboSheets() const { return bJumboSheets; } #if HAVE_FEATURE_JUMBO_SHEETS void SetInitJumboSheets( bool b) { bJumboSheets = b; } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index a1d3cb27431f..c1fcaff47ab3 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -386,7 +386,7 @@ void ScDocument::CreateValidTabName(OUString& rName) const // Get Custom prefix const ScDefaultsOptions& rOpt = ScModule::get()->GetDefaultsOptions(); - const OUString& aStrTable = rOpt.GetInitTabPrefix(); + const OUString aStrTable = rOpt.GetInitTabPrefix(); bool bOk = false; @@ -429,7 +429,7 @@ void ScDocument::CreateValidTabNames(std::vector<OUString>& aNames, SCTAB nCount // Get Custom prefix const ScDefaultsOptions& rOpt = ScModule::get()->GetDefaultsOptions(); - const OUString& aStrTable = rOpt.GetInitTabPrefix(); + const OUString aStrTable = rOpt.GetInitTabPrefix(); OUStringBuffer rName; diff --git a/sc/source/core/tool/defaultsoptions.cxx b/sc/source/core/tool/defaultsoptions.cxx index 098cc11e6230..5caaa4f61832 100644 --- a/sc/source/core/tool/defaultsoptions.cxx +++ b/sc/source/core/tool/defaultsoptions.cxx @@ -15,6 +15,7 @@ #include <scresid.hxx> #include <sc.hrc> #include <utility> +#include <comphelper/lok.hxx> using namespace utl; using namespace com::sun::star::uno; @@ -30,6 +31,27 @@ void ScDefaultsOptions::SetDefaults() nInitTabCount = 1; aInitTabPrefix = ScResId(STR_TABLE_DEF); // Default Prefix "Sheet" bJumboSheets = false; + bInitTabPrefixChanged = false; +} + +void ScDefaultsOptions::SetInitTabPrefix(const OUString& aPrefix) +{ + if (aInitTabPrefix != aPrefix) + { + bInitTabPrefixChanged = true; + aInitTabPrefix = aPrefix; + } +} + +OUString ScDefaultsOptions::GetInitTabPrefix() const +{ + if (comphelper::LibreOfficeKit::isActive() && !bInitTabPrefixChanged) + { + // LOKit may have different users with different locales, so the proper + // translation of the defualt TabPrefix has to be fetched each time + return ScResId(STR_TABLE_DEF); + } + return aInitTabPrefix; } bool ScDefaultsOptions::operator==( const ScDefaultsOptions& rOpt ) const