diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 9364add9ecaf..1e73f97af75e 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -959,6 +959,19 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testHiddenParaProps) CPPUNIT_ASSERT_EQUAL( SvxAdjust::Left, pTextFrame->GetTextNodeForParaProps()->GetSwAttrSet().Get(RES_PARATR_ADJUST).GetAdjust()); + + dispatchCommand(mxComponent, u".uno:ShowTrackedChanges"_ustr, {}); + + pTextFrame = dynamic_cast(pBody->GetLower()); + for (int i = 0; i < 18; ++i) + { + pTextFrame = dynamic_cast(pTextFrame->GetNext()); + } + // the problem was that this redline (following hidden) wasn't merged + CPPUNIT_ASSERT_EQUAL(u"10 visible, hidden-merge, visible, delete-merge, visible"_ustr, + pTextFrame->GetText()); + pTextFrame = dynamic_cast(pTextFrame->GetNext()); + CPPUNIT_ASSERT_EQUAL(u"abcdefghi"_ustr, pTextFrame->GetText()); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf151954) diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index ab9dfb59cea0..8b583d6860d8 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -78,6 +78,7 @@ private: /// current start/end pair SwPosition const* m_pStartPos; SwPosition const* m_pEndPos; + SwNode const* m_pCurrentRedlineNode; public: SwPosition const* GetStartPos() const { return m_pStartPos; } @@ -95,6 +96,7 @@ public: , m_RedlineIndex(isHideRedlines ? m_rIDRA.GetRedlinePos(rTextNode, RedlineType::Any) : SwRedlineTable::npos) , m_pStartPos(nullptr) , m_pEndPos(&m_Start) + , m_pCurrentRedlineNode(&rTextNode) { } @@ -108,6 +110,14 @@ public: assert(m_pEndPos); if (m_isHideRedlines) { + // GetRedlinePos() returns npos if there is no redline on the + // node but something else could have merged nodes so search again! + if (m_RedlineIndex == SwRedlineTable::npos + && &m_pEndPos->GetNode() != m_pCurrentRedlineNode) + { + m_RedlineIndex = m_rIDRA.GetRedlinePos(m_pEndPos->GetNode(), RedlineType::Any); + m_pCurrentRedlineNode = &m_pEndPos->GetNode(); + } // position on current or next redline for (; m_RedlineIndex < m_rIDRA.GetRedlineTable().size(); ++m_RedlineIndex) {