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:
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user