sfx2/source/view/lokhelper.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
New commits: commit 12bb3f3dd5bd29718b60697aa4f7e76c4698cd96 Author: Attila Szűcs <attila.sz...@collabora.com> AuthorDate: Fri Dec 1 15:20:58 2023 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sun Dec 10 12:33:44 2023 +0100 LOK: fix setView language problem Fix some mis-localization problem by checking for wrong language at setView(...). setView does not change current localization, if the view we want to set is the current view. But in some cases the language - view is not in a consistent state. Maybe the language changed but the view did not, or the current view changed without language change (I found examples for both). Changed setView(...) so that it checks, if the current language matches to the current view, and if it does not, then we set the view, even if we want to set to the current view. This won't fix everything, but hopefully it helps a lot. I think we should make sure that current view - current Language are always changed at the same time (or at least we make sure they always match). Change-Id: Ie177b9b55f7befcbcf7cd1f62e402700f0e1aa60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160219 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 0d3843632f13..2436c7cbe85d 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -180,13 +180,25 @@ void SfxLokHelper::setView(int nId) { DisableCallbacks dc; - if (pViewShell == SfxViewShell::Current()) + bool bIsCurrShell = (pViewShell == SfxViewShell::Current()); + if (bIsCurrShell && comphelper::LibreOfficeKit::getLanguageTag().getBcp47() == pViewShell->GetLOKLanguageTag().getBcp47()) return; // update the current LOK language and locale for the dialog tunneling comphelper::LibreOfficeKit::setLanguageTag(pViewShell->GetLOKLanguageTag()); comphelper::LibreOfficeKit::setLocale(pViewShell->GetLOKLocale()); + if (bIsCurrShell) + { + // If we wanted to set the SfxViewShell that is actually set, we could skip it. + // But it looks like that the language can go wrong, so we have to fix that. + // This can happen, when someone sets the language or SfxViewShell::Current() separately. + SAL_WARN("lok", "LANGUAGE mismatch at setView! ... old (wrong) lang:" + << comphelper::LibreOfficeKit::getLanguageTag().getBcp47() + << " new lang:" << pViewShell->GetLOKLanguageTag().getBcp47()); + return; + } + SfxViewFrame* pViewFrame = pViewShell->GetViewFrame(); pViewFrame->MakeActive_Impl(false);