sw/qa/extras/ooxmlexport/ooxmlexport12.cxx | 2 - sw/source/core/doc/DocumentRedlineManager.cxx | 30 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-)
New commits: commit ea0e5148d0b6f9365ed74b4b8547e5171d7fad43 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Feb 24 16:02:33 2025 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Tue Feb 25 17:43:07 2025 +0100 tdf#165322 sw: GetRedline() binary search doesn't work with overlaps Change-Id: I6d7a271eb96f55abdd6d53a153b277083868109b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182117 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins (cherry picked from commit c5f7619d6eebe478332ae4dcb27fde85df6278a9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182152 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx index f9c84c09a3ed..a929f37a1eae 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx @@ -1644,7 +1644,7 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf125546) loadAndSave("tdf125546.docx"); xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr); // compress redlines (it was 15) - assertXPath(pXmlDoc, "//w:rPrChange"_ostr, 2); + assertXPath(pXmlDoc, "//w:rPrChange"_ostr, 3); } CPPUNIT_TEST_FIXTURE(Test, testLabelWidthAndPosition_Left_FirstLineIndent) diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 9ae003980701..483e9229adca 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -2924,6 +2924,36 @@ bool DocumentRedlineManager::HasRedline( const SwPaM& rPam, RedlineType nType, b const SwRangeRedline* DocumentRedlineManager::GetRedline( const SwPosition& rPos, SwRedlineTable::size_type* pFndPos ) const { + if (maRedlineTable.HasOverlappingElements()) + { + for (auto it = maRedlineTable.begin(), itEnd = maRedlineTable.end(); it != itEnd; ++it) + { + auto [pStart, pEnd] = (**it).StartEnd(); + if (rPos < *pStart) + { + if (pFndPos) + { + *pFndPos = std::distance(maRedlineTable.begin(), it); + } + return nullptr; + } + if (pEnd == pStart + ? *pStart == rPos + : (*pStart <= rPos && rPos < *pEnd)) + { + if (pFndPos) + { + *pFndPos = std::distance(maRedlineTable.begin(), it); + } + return *it; + } + } + if (pFndPos) + { + *pFndPos = maRedlineTable.size(); + } + return nullptr; + } SwRedlineTable::size_type nO = maRedlineTable.size(), nM, nU = 0; if( nO > 0 ) {