writerfilter/source/rtftok/rtfsprm.cxx | 20 +++++++++++++++----- writerfilter/source/rtftok/rtfsprm.hxx | 2 +- writerfilter/source/rtftok/rtfvalue.cxx | 4 ++-- 3 files changed, 18 insertions(+), 8 deletions(-)
New commits: commit f6a559ccacaab875d1aa1da70e3011592158e9d4 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jan 16 12:23:38 2024 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Jan 17 09:15:00 2024 +0100 tdf#158950 Paste as RTF loses char color and paragraph alignment from styles This logic partially originated in commit 8e8f9388c323ad3c32cef3f91609ad19386b7d56 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Apr 22 12:53:24 2014 +0200 Related: fdo#77600 RTF import: RTFValue::equals: compare attribute content But it is rather weird to compare RTFSprms this way, comparing each attribute to a parent RTFValue. Making the comparison more "normal" fixes the reported bug while not breaking fdo#77600 Change-Id: Iee224c7bc9542c359f8a71086230e4b53c1c3e16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162164 Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/writerfilter/source/rtftok/rtfsprm.cxx b/writerfilter/source/rtftok/rtfsprm.cxx index 5d57348f204e..148d39c2e48b 100644 --- a/writerfilter/source/rtftok/rtfsprm.cxx +++ b/writerfilter/source/rtftok/rtfsprm.cxx @@ -437,12 +437,22 @@ RTFSprms RTFSprms::cloneAndDeduplicate(RTFSprms& rReference, Id const nStyleType return ret; } -bool RTFSprms::equals(const RTFValue& rOther) const +bool RTFSprms::equals(const RTFSprms& rOther) const { - return std::all_of(m_pSprms->cbegin(), m_pSprms->cend(), - [&](const std::pair<Id, RTFValue::Pointer_t>& raPair) -> bool { - return raPair.second->equals(rOther); - }); + auto it1 = m_pSprms->cbegin(); + auto it1End = m_pSprms->cend(); + auto it2 = rOther.m_pSprms->cbegin(); + auto it2End = rOther.m_pSprms->cend(); + while (it1 != it1End && it2 != it2End) + { + if (it1->first != it2->first) + return false; + if (!it1->second->equals(*it2->second)) + return false; + ++it1; + ++it2; + } + return it1 == it1End && it2 == it2End; } void RTFSprms::ensureCopyBeforeWrite() diff --git a/writerfilter/source/rtftok/rtfsprm.hxx b/writerfilter/source/rtftok/rtfsprm.hxx index 9f3bbd78b37a..132a2bbcbeb2 100644 --- a/writerfilter/source/rtftok/rtfsprm.hxx +++ b/writerfilter/source/rtftok/rtfsprm.hxx @@ -73,7 +73,7 @@ public: Iterator_t begin() { return m_pSprms->begin(); } Iterator_t end() { return m_pSprms->end(); } void clear(); - bool equals(const RTFValue& rOther) const; + bool equals(const RTFSprms& rOther) const; private: void ensureCopyBeforeWrite(); diff --git a/writerfilter/source/rtftok/rtfvalue.cxx b/writerfilter/source/rtftok/rtfvalue.cxx index 373fb7521b13..7a9137f5db4a 100644 --- a/writerfilter/source/rtftok/rtfvalue.cxx +++ b/writerfilter/source/rtftok/rtfvalue.cxx @@ -172,7 +172,7 @@ bool RTFValue::equals(const RTFValue& rOther) const { if (m_pAttributes->size() != rOther.m_pAttributes->size()) return false; - if (!m_pAttributes->equals(rOther)) + if (!m_pAttributes->equals(*rOther.m_pAttributes)) return false; } else if (m_pAttributes && m_pAttributes->size()) @@ -188,7 +188,7 @@ bool RTFValue::equals(const RTFValue& rOther) const { if (m_pSprms->size() != rOther.m_pSprms->size()) return false; - if (!m_pSprms->equals(rOther)) + if (!m_pSprms->equals(*rOther.m_pSprms)) return false; } else if (m_pSprms && m_pSprms->size())