sfx2/source/view/lokhelper.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 494161a9c8a9acca4d200d06c44ef6db794c0bea
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Tue Apr 16 17:59:25 2024 +0200
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Thu Jun 20 10:57:18 2024 +0200

    cool#9309 lok: sync language in comphelper::LibreOfficeKit on view creation
    
    If new view is created using createViewWithOptions API call
    we pass language of that view. We do a setup of that language
    in SfxLokHelper::setViewLanguage but it was only set inside
    ViewShell.
    
    Unfortunately just after we create the view we call setView which
    later checks if comphelper::LibreOfficeKit::getLanguageTag()
    has matching value with ViewShell field.
    It was showing warning in the logs:
    warn:lok:31748:31654:sfx2/source/view/lokhelper.cxx:206: LANGUAGE mismatch 
at setView! ... old (wrong) lang:de new lang:fr
    
    Let's check if the view we try to modify is the current one and
    in that case synchronize value we can get using global
    comphelper::LibreOfficeKit function.
    
    Signed-off-by: Szymon Kłos <szymon.k...@collabora.com>
    Change-Id: Icddfda003522dda661066c4d1c43ca1dec9e5c55
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169107
    (cherry picked from commit 800d8580ec8d99f5c610727a9d53ab143019c014)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169144
    Tested-by: Jenkins

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 549f43906908..131561504e1b 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -338,6 +338,10 @@ void SfxLokHelper::setViewLanguage(int nId, const 
OUString& rBcp47LanguageTag)
         if (pViewShell->GetViewShellId() == ViewShellId(nId))
         {
             pViewShell->SetLOKLanguageTag(rBcp47LanguageTag);
+            // sync also global getter if we are the current view
+            bool bIsCurrShell = (pViewShell == SfxViewShell::Current());
+            if (bIsCurrShell)
+                
comphelper::LibreOfficeKit::setLanguageTag(LanguageTag(rBcp47LanguageTag));
             return;
         }
     }

Reply via email to