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 657de5fba1)

Change-Id: I536b2660c97501be896203403cdd5e2f2015e816
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181946
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
Michael Stahl
2025-02-20 18:24:37 +01:00
parent 8ff1892730
commit 21bc6e075d
2 changed files with 23 additions and 0 deletions
+13
View File
@@ -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<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)
+10
View File
@@ -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)
{