summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-08-24 19:29:14 +0200
committerMichael Stahl <michael.stahl@cib.de>2020-08-25 16:31:30 +0200
commit0bbc397dc5b4440144627330c2b6ee479bdcf074 (patch)
treeb2fa74331f6165daf444affccfaee8b37b5166d1
parent15988fe00c4f49ae32ab2d5cf3c16495ab6e1d59 (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>
-rw-r--r--sw/source/core/doc/DocumentRedlineManager.cxx54
1 files changed, 38 insertions, 16 deletions
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