diff options
author | Attila Szűcs <attila.szucs@collabora.com> | 2024-01-09 17:45:19 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-01-16 12:06:45 +0100 |
commit | acd3f201a93ddac406a1e86f8b055fdbd2a64400 (patch) | |
tree | b2380dec5b0eb11bafbb94851e09d53939597f3b /editeng | |
parent | 2188f940b0006e9ab421cae016f81fe366a4d649 (diff) |
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 <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162158
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/inc/ContentNode.hxx | 1 | ||||
-rw-r--r-- | editeng/inc/editattr.hxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/ContentNode.cxx | 13 | ||||
-rw-r--r-- | editeng/source/editeng/impedit3.cxx | 6 |
4 files changed, 21 insertions, 1 deletions
diff --git a/editeng/inc/ContentNode.hxx b/editeng/inc/ContentNode.hxx index 391953d7f4ae..308d3ef9d1e0 100644 --- a/editeng/inc/ContentNode.hxx +++ b/editeng/inc/ContentNode.hxx @@ -77,6 +77,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/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/source/editeng/ContentNode.cxx b/editeng/source/editeng/ContentNode.cxx index 0cc3a72da65c..a02a3fde0d39 100644 --- a/editeng/source/editeng/ContentNode.cxx +++ b/editeng/source/editeng/ContentNode.cxx @@ -849,6 +849,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(maAttribs.rbegin(), maAttribs.rend(), + [&nWhich, &nPos](AttribsType::value_type& rxAttr) { + return rxAttr->Which() == nWhich && rxAttr->IsInLeftClosedRightOpen(nPos); }); + if (it != maAttribs.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 350a533eb147..30462d21b169 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -2948,7 +2948,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 ); } |