sw/source/core/doc/DocumentRedlineManager.cxx | 54 ++++++++++++++++++-------- 1 file changed, 38 insertions(+), 16 deletions(-)
New commits: commit 0bbc397dc5b4440144627330c2b6ee479bdcf074 Author: Michael Stahl <michael.st...@cib.de> AuthorDate: Mon Aug 24 19:29:14 2020 +0200 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Tue Aug 25 16:31:30 2020 +0200 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.st...@cib.de> diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 52bd17fd5230..8b9eaf0179c6 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits