sw/qa/extras/layout/layout2.cxx | 13 +++++++++++++ sw/source/core/text/redlnitr.cxx | 10 ++++++++++ 2 files changed, 23 insertions(+)
New commits: commit 16986abb742908fc5036335e05c1858e41811b0d Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Feb 19 16:20:56 2025 +0100 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Wed Feb 26 13:21:06 2025 +0100 sw: fix bug with redline following fieldmark or hidden break It is now possible for HideIterator to move to another node without a redline being involved, but if this happens and there was no redline on the previous node, GetRedlinePos() had already returned SwRedlineTable::npos and now no redlines can be found in the new node. (regression from commit 657de5fba12b0e9afcdee361654d2a2d0dbd7311) Change-Id: I536b2660c97501be896203403cdd5e2f2015e816 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181946 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 21bc6e075d8b004bce7bf7d9305f5fdcff2df24d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182193 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 8c069e76374a..06819b3caf68 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -1151,6 +1151,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<SwTextFrame*>(pBody->GetLower()); + for (int i = 0; i < 18; ++i) + { + pTextFrame = dynamic_cast<SwTextFrame*>(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<SwTextFrame*>(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 53b9b9641699..098c77b9c557 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -77,6 +77,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; } @@ -94,6 +95,7 @@ public: , m_RedlineIndex(isHideRedlines ? m_rIDRA.GetRedlinePos(rTextNode, RedlineType::Any) : SwRedlineTable::npos) , m_pStartPos(nullptr) , m_pEndPos(&m_Start) + , m_pCurrentRedlineNode(&rTextNode) { } @@ -107,6 +109,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) {