editeng/inc/editattr.hxx            |    2 +
 editeng/inc/editdoc.hxx             |    1 
 editeng/source/editeng/editdoc.cxx  |   13 +++++++++
 editeng/source/editeng/impedit3.cxx |    6 +++-
 sfx2/source/view/lokhelper.cxx      |   49 ++++++++++++++++++++++--------------
 5 files changed, 51 insertions(+), 20 deletions(-)

New commits:
commit 5bbda05d6f2abf87422190a3790db014edd748d1
Author:     Attila Szűcs <attila.sz...@collabora.com>
AuthorDate: Tue Jan 9 17:45:19 2024 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed Jan 17 11:36:08 2024 +0100

    tdf#154248 Impress: fix color of hyperlink
    
    Added a new FindAttrib method that searches in the attribs
    a bit different.
    The original FindAttrib searches in attribs as if their position
    intervals are closed from both side [Start,End].
    However, the actual attribs array was created using PaMs as positions,
    and these are right-opened intervals [Start,End)
    
    Change-Id: I9a46b6b27ce447366fc20af1b46fd60b5c745359
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161836
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/editeng/inc/editattr.hxx b/editeng/inc/editattr.hxx
index 3a619a5e85b8..985a586c7fe3 100644
--- a/editeng/inc/editattr.hxx
+++ b/editeng/inc/editattr.hxx
@@ -105,6 +105,8 @@ public:
 
     bool    IsIn( sal_Int32 nIndex ) const
                 { return ( ( nStart <= nIndex ) && ( nEnd >= nIndex ) ); }
+    bool    IsInLeftClosedRightOpen( sal_Int32 nIndex ) const
+                { return ( ( nStart <= nIndex ) && ( nEnd > nIndex ) ); }
     bool    IsInside( sal_Int32 nIndex ) const
                 { return ( ( nStart < nIndex ) && ( nEnd > nIndex ) ); }
     bool        IsEmpty() const
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 16eaf157a91f..80e3cc34243c 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -199,6 +199,7 @@ public:
 
     const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) 
const;
     EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos );
+    EditCharAttrib* FindAttribRightOpen( sal_uInt16 nWhich, sal_Int32 nPos );
     const EditCharAttrib* FindNextAttrib( sal_uInt16 nWhich, sal_Int32 
nFromPos ) const;
     EditCharAttrib* FindEmptyAttrib( sal_uInt16 nWhich, sal_Int32 nPos );
     const EditCharAttrib* FindFeature( sal_Int32 nPos ) const;
diff --git a/editeng/source/editeng/editdoc.cxx 
b/editeng/source/editeng/editdoc.cxx
index d892bd1c3a25..2472d8362957 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2841,6 +2841,19 @@ EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 
nWhich, sal_Int32 nPos )
     return nullptr;
 }
 
+EditCharAttrib* CharAttribList::FindAttribRightOpen( sal_uInt16 nWhich, 
sal_Int32 nPos )
+{
+    AttribsType::reverse_iterator it = std::find_if(aAttribs.rbegin(), 
aAttribs.rend(),
+        [&nWhich, &nPos](AttribsType::value_type& rxAttr) {
+            return rxAttr->Which() == nWhich && 
rxAttr->IsInLeftClosedRightOpen(nPos); });
+    if (it != aAttribs.rend())
+    {
+        EditCharAttrib& rAttr = **it;
+        return &rAttr;
+    }
+    return nullptr;
+}
+
 const EditCharAttrib* CharAttribList::FindNextAttrib( sal_uInt16 nWhich, 
sal_Int32 nFromPos ) const
 {
     assert(nWhich);
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index b24cc004011c..17699870c6e4 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2939,7 +2939,11 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, 
sal_Int32 nPos, SvxFont& rFo
                     // #i1550# hard color attrib should win over text color 
from field
                     if ( pAttrib->Which() == EE_FEATURE_FIELD )
                     {
-                        EditCharAttrib* pColorAttr = 
pNode->GetCharAttribs().FindAttrib( EE_CHAR_COLOR, nPos );
+                        // These Attribs positions come from PaMs, so their 
interval is right-open and left-closed
+                        // when SeekCursor is called, nPos is incremented by 
1. I do not know why...
+                        // probably designed to be a nEndPos, and like in a 
PaM, it is the position after the actual character.
+                        sal_Int32 nPosActual = nPos > 0 ? nPos - 1 : 0;
+                        EditCharAttrib* pColorAttr = 
pNode->GetCharAttribs().FindAttribRightOpen( EE_CHAR_COLOR, nPosActual );
                         if ( pColorAttr )
                             pColorAttr->SetFont( rFont, pOut );
                     }
commit b97af5c60f379f45021bc6692dcba890dc80dc97
Author:     Aron Budea <aron.bu...@collabora.com>
AuthorDate: Tue Jan 9 12:39:56 2024 +1030
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed Jan 17 11:34:45 2024 +0100

    lok: Replace loop with std::find_if(...)
    
    Change-Id: Icfe912f7b79454b9d208c39382ba187d0a0c16c5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161810
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Attila Szűcs <attila.sz...@collabora.com>
    Reviewed-by: Aron Budea <aron.bu...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162045
    Tested-by: Jenkins

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 02cc7fe25230..2106168f459e 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -184,44 +184,41 @@ void SfxLokHelper::setView(int nId)
     const ViewShellId nViewShellId(nId);
     std::vector<SfxViewShell*>& rViewArr = pApp->GetViewShells_Impl();
 
-    for (const SfxViewShell* pViewShell : rViewArr)
-    {
-        if (pViewShell->GetViewShellId() == nViewShellId)
-        {
-            DisableCallbacks dc;
+    const auto itViewShell = std::find_if(rViewArr.begin(), rViewArr.end(), 
[nViewShellId](SfxViewShell* pViewShell){ return pViewShell->GetViewShellId() 
== nViewShellId; });
+    if (itViewShell == rViewArr.end())
+        return;
 
-            bool bIsCurrShell = (pViewShell == SfxViewShell::Current());
-            if (bIsCurrShell && 
comphelper::LibreOfficeKit::getLanguageTag().getBcp47() == 
pViewShell->GetLOKLanguageTag().getBcp47())
-                return;
+    const SfxViewShell* pViewShell = *itViewShell;
+    DisableCallbacks dc;
 
-            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());
-            }
+    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());
+    }
 
-            if (bIsCurrShell)
-                return;
+    // update the current LOK language and locale for the dialog tunneling
+    
comphelper::LibreOfficeKit::setLanguageTag(pViewShell->GetLOKLanguageTag());
+    comphelper::LibreOfficeKit::setLocale(pViewShell->GetLOKLocale());
 
-            SfxViewFrame& rViewFrame = pViewShell->GetViewFrame();
-            rViewFrame.MakeActive_Impl(false);
+    if (bIsCurrShell)
+        return;
 
-            // Make comphelper::dispatchCommand() find the correct frame.
-            uno::Reference<frame::XFrame> xFrame = 
rViewFrame.GetFrame().GetFrameInterface();
-            uno::Reference<frame::XDesktop2> xDesktop = 
frame::Desktop::create(comphelper::getProcessComponentContext());
-            xDesktop->setActiveFrame(xFrame);
-            return;
-        }
-    }
+    SfxViewFrame& rViewFrame = pViewShell->GetViewFrame();
+    rViewFrame.MakeActive_Impl(false);
 
+    // Make comphelper::dispatchCommand() find the correct frame.
+    uno::Reference<frame::XFrame> xFrame = 
rViewFrame.GetFrame().GetFrameInterface();
+    uno::Reference<frame::XDesktop2> xDesktop = 
frame::Desktop::create(comphelper::getProcessComponentContext());
+    xDesktop->setActiveFrame(xFrame);
 }
 
 SfxViewShell* SfxLokHelper::getViewOfId(int nId)
commit 5ebb1ee65775776dd382074b1a85e338c272e1bb
Author:     Attila Szűcs <attila.sz...@collabora.com>
AuthorDate: Tue Jan 9 20:23:44 2024 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed Jan 17 11:34:30 2024 +0100

    LOK: fix language warning in setView
    
    Made the warning before the new language set.
    This way we log the old (wrong) and new (good) language.
    
    Elseway we could save the old languages to a temporal variable,
    set the language, and do the warning with the saved variable, but
    i think the extra variables would be a waste of memory.
    
    Change-Id: I0b69f49d07e9130bf1538c2c8e1d0b09cf82091f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161841
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit e09b3f5f4cd662a596b5d8d6ad4d5e2778e315f4)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161916
    Tested-by: Jenkins

diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 711e12209e8a..02cc7fe25230 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -194,10 +194,6 @@ void SfxLokHelper::setView(int nId)
             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.
@@ -206,9 +202,15 @@ void SfxLokHelper::setView(int nId)
                 SAL_WARN("lok", "LANGUAGE mismatch at setView! ... old (wrong) 
lang:"
                                 << 
comphelper::LibreOfficeKit::getLanguageTag().getBcp47()
                                 << " new lang:" << 
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)
+                return;
+
             SfxViewFrame& rViewFrame = pViewShell->GetViewFrame();
             rViewFrame.MakeActive_Impl(false);
 
commit 16c7562b2ebdd5c7d7b76c1e8996b2d0253b28d9
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: Wed Jan 17 11:33: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);
 

Reply via email to