sc/source/ui/inc/content.hxx | 2 ++ sc/source/ui/navipi/content.cxx | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
New commits: commit a9a578610f51f708725afa698a946b6837c0d9ef Author: Attila Szűcs <attila.sz...@collabora.com> AuthorDate: Tue Nov 7 15:03:33 2023 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Jan 17 11:30:55 2024 +0100 SC navigator: fix changing language of contenttree 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 <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> 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<ScContentId, sal_uInt16> pPosList; // for the sequence + std::unique_ptr<std::locale> 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 89d77642558a..d16f61411016 100644 --- a/sc/source/ui/navipi/content.cxx +++ b/sc/source/ui/navipi/content.cxx @@ -186,7 +186,23 @@ void ScContentTree::InitRoot( ScContentId nType ) } auto const & aImage = aContentBmps[static_cast<int>(nType) - 1]; - OUString aName(ScResId(SCSTR_CONTENT_ARY[static_cast<int>(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<std::locale>(SC_MOD()->GetResLocale()); + } + aName = Translate::get(SCSTR_CONTENT_ARY[static_cast<int>(nType)], *m_pResLocaleForLOK); + } + else + { + aName = ScResId(SCSTR_CONTENT_ARY[static_cast<int>(nType)]); + } // back to the correct position: sal_uInt16 nPos = nRootType != ScContentId::ROOT ? 0 : pPosList[nType]-1; m_aRootNodes[nType] = m_xTreeView->make_iterator();