sfx2/source/view/lokhelper.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
New commits: commit e78bce3c1dbef3bbc0a18d9c17e458a69c2a8e46 Author: Attila Szűcs <attila.sz...@collabora.com> AuthorDate: Fri Dec 1 15:20:58 2023 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Jan 11 14:54:51 2024 +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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161915 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index f21457e1b16d..711e12209e8a 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -190,13 +190,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& rViewFrame = pViewShell->GetViewFrame(); rViewFrame.MakeActive_Impl(false);