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.stahl@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Michael Stahl
2025-02-25 10:51:36 +01:00
parent 0ab638e421
commit c5f7619d6e
2 changed files with 31 additions and 1 deletions
+1 -1
View File
@@ -1608,7 +1608,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", 2);
assertXPath(pXmlDoc, "//w:rPrChange", 3);
}
CPPUNIT_TEST_FIXTURE(Test, testLabelWidthAndPosition_Left_FirstLineIndent)
@@ -2968,6 +2968,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 )
{