diff options
author | Attila Szűcs <attila.szucs@collabora.com> | 2023-11-07 15:03:33 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-01-17 17:32:11 +0100 |
commit | ebda38ef860970bea2996f3122660339ef2ddacd (patch) | |
tree | 5e5caeebd0e2110b00fc446b8db12cbe0cd42403 | |
parent | 12b33dce25a22e99c4f86f1ff139efb8dd144117 (diff) |
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162192
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | sc/source/ui/inc/content.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/navipi/content.cxx | 18 |
2 files changed, 19 insertions, 1 deletions
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 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<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(); |