From ebda38ef860970bea2996f3122660339ef2ddacd Mon Sep 17 00:00:00 2001 From: Attila Szűcs Date: Tue, 7 Nov 2023 15:03:33 +0100 Subject: SC navigator: fix changing language of contenttree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Save the actual language, when ScContentTree is created, and use that language to localise its text. Note: Saving language in ScContentTree::ScContentTree caused problems, so it is better to save the language when this tree is filled with text the first time. In case of LOK, there can be separate views, with different languages, that means there can be 2+ ScContentTrees, e.g. one has text in English and the other in German. When a new item is created that is listed in navigator, then every ScContentTree is updated at once... but that would use the global language, not the one what was used when the actual ScContentTree was created. Change-Id: I2dedf293e0ad9fb8f3cdd1090e1e1707a9f6cfa4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159077 Tested-by: Jenkins CollaboraOffice Reviewed-by: Tomaž Vajngerl Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162192 Reviewed-by: Andras Timar Tested-by: Andras Timar --- sc/source/ui/inc/content.hxx | 2 ++ sc/source/ui/navipi/content.cxx | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sc/source/ui/inc/content.hxx b/sc/source/ui/inc/content.hxx index 2e8c6757e202..b57e49eb55f2 100644 --- a/sc/source/ui/inc/content.hxx +++ b/sc/source/ui/inc/content.hxx @@ -55,6 +55,8 @@ class ScContentTree o3tl::enumarray pPosList; // for the sequence + std::unique_ptr m_pResLocaleForLOK; //it needed only in case of LOK + ScDocShell* GetManualOrCurrent(); void InitRoot(ScContentId nType); diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx index af8b64b6fdba..588476d97ed9 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -188,7 +188,23 @@ void ScContentTree::InitRoot( ScContentId nType ) } auto const & aImage = aContentBmps[static_cast(nType) - 1]; - OUString aName(ScResId(SCSTR_CONTENT_ARY[static_cast(nType)])); + + OUString aName; + if(comphelper::LibreOfficeKit::isActive()) + { + //In case of LOK we may have many different ScContentTrees in different languages. + //At creation time, we store what language we use, and then use it later too. + //It does not work in the constructor, that is why it is here. + if (!m_pResLocaleForLOK) + { + m_pResLocaleForLOK = std::make_unique(SC_MOD()->GetResLocale()); + } + aName = Translate::get(SCSTR_CONTENT_ARY[static_cast(nType)], *m_pResLocaleForLOK); + } + else + { + aName = ScResId(SCSTR_CONTENT_ARY[static_cast(nType)]); + } // back to the correct position: sal_uInt16 nPos = nRootType != ScContentId::ROOT ? 0 : pPosList[nType]-1; m_aRootNodes[nType] = m_xTreeView->make_iterator(); -- cgit