diff options
author | Michael Stahl <Michael.Stahl@cib.de> | 2020-08-24 19:29:14 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2020-08-31 07:17:49 +0200 |
commit | f3f00457ade56962af0de0499822750c15d96a03 (patch) | |
tree | 047fbcc5990769157ecb23af673d1853fb7199fc /sw | |
parent | d9fc5fa077212a09aebe373eb478405be4a5c3bd (diff) |
tdf#132160 sw_redlinehide: more pathological redline problems
This is similar to 63dba5203e8bc7fc390943cb8208ae904f18e3bb except here
the redline starts with a section (in particular an entire alphabetical
index); this one is at node 13489 to node 14206.
There's another fun one, starts with a table but has a text node
following it, at node 8222 to 8231; this case also wasn't handled
correctly at least in one direction. Fix that by continuing iteration
of text-nodes once table/section at the start are handled.
(regression from d258fc29560baa5ecae03ebc2740e11420643e27)
Change-Id: I3f75ad473881f01be80d2c3804b9ac209f430bdf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101287
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 0bbc397dc5b4440144627330c2b6ee479bdcf074)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101350
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index d933de736cb1..8e026a876dc9 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -140,24 +140,38 @@ void UpdateFramesForAddDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) // no need to call UpdateFootnoteNums for FTNNUM_PAGE: // the AppendFootnote/RemoveFootnote will do it by itself! rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->nNode); - SwTextNode *const pStartNode(rPam.Start()->nNode.GetNode().GetTextNode()); - if (!pStartNode) + SwPosition currentStart(*rPam.Start()); + SwTextNode * pStartNode(rPam.Start()->nNode.GetNode().GetTextNode()); + while (!pStartNode) { - SwTableNode *const pTableNode(rPam.Start()->nNode.GetNode().GetTableNode()); - assert(pTableNode); // known pathology - for (sal_uLong j = pTableNode->GetIndex(); j <= pTableNode->EndOfSectionIndex(); ++j) + SwStartNode *const pTableOrSectionNode( + currentStart.nNode.GetNode().IsTableNode() + ? static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetTableNode()) + : static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetSectionNode())); + assert(pTableOrSectionNode); // known pathology + for (sal_uLong j = pTableOrSectionNode->GetIndex(); j <= pTableOrSectionNode->EndOfSectionIndex(); ++j) { - pTableNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::Hidden); + pTableOrSectionNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::Hidden); } for (SwRootFrame const*const pLayout : rDoc.GetAllLayouts()) { if (pLayout->IsHideRedlines()) { - pTableNode->DelFrames(pLayout); + if (pTableOrSectionNode->IsTableNode()) + { + static_cast<SwTableNode*>(pTableOrSectionNode)->DelFrames(pLayout); + } + else + { + static_cast<SwSectionNode*>(pTableOrSectionNode)->DelFrames(pLayout); + } } } + currentStart.nNode = pTableOrSectionNode->EndOfSectionIndex() + 1; + currentStart.nContent.Assign(currentStart.nNode.GetNode().GetContentNode(), 0); + pStartNode = currentStart.nNode.GetNode().GetTextNode(); } - else + if (currentStart < *rPam.End()) { SwTextNode * pNode(pStartNode); do @@ -221,24 +235,32 @@ void UpdateFramesForRemoveDeleteRedline(SwDoc & rDoc, SwPaM const& rPam) { bool isAppendObjsCalled(false); rDoc.GetFootnoteIdxs().UpdateFootnote(rPam.Start()->nNode); - SwTextNode *const pStartNode(rPam.Start()->nNode.GetNode().GetTextNode()); - if (!pStartNode) + SwPosition currentStart(*rPam.Start()); + SwTextNode * pStartNode(rPam.Start()->nNode.GetNode().GetTextNode()); + while (!pStartNode) { - SwTableNode const*const pTableNode(rPam.Start()->nNode.GetNode().GetTableNode()); - assert(pTableNode); // known pathology - for (sal_uLong j = pTableNode->GetIndex(); j <= pTableNode->EndOfSectionIndex(); ++j) + SwStartNode const*const pTableOrSectionNode( + currentStart.nNode.GetNode().IsTableNode() + ? static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetTableNode()) + : static_cast<SwStartNode*>(currentStart.nNode.GetNode().GetSectionNode())); + assert(pTableOrSectionNode); // known pathology + for (sal_uLong j = pTableOrSectionNode->GetIndex(); j <= pTableOrSectionNode->EndOfSectionIndex(); ++j) { - pTableNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::None); + pTableOrSectionNode->GetNodes()[j]->SetRedlineMergeFlag(SwNode::Merge::None); } if (rDoc.getIDocumentLayoutAccess().GetCurrentLayout()->IsHideRedlines()) { // note: this will also create frames for all currently hidden flys // because it calls AppendAllObjs - ::MakeFrames(&rDoc, rPam.Start()->nNode, rPam.End()->nNode); + SwNodeIndex const end(*pTableOrSectionNode->EndOfSectionNode()); + ::MakeFrames(&rDoc, currentStart.nNode, end); isAppendObjsCalled = true; } + currentStart.nNode = pTableOrSectionNode->EndOfSectionIndex() + 1; + currentStart.nContent.Assign(currentStart.nNode.GetNode().GetContentNode(), 0); + pStartNode = currentStart.nNode.GetNode().GetTextNode(); } - else + if (currentStart < *rPam.End()) { SwTextNode * pNode(pStartNode); do |