sw/source/filter/xml/XMLRedlineImportHelper.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
New commits: commit 477e489e71b4a96ff10d9f2d2b802d91dec3e319 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Aug 17 12:17:50 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Aug 17 14:04:42 2022 +0200 forcepoint#108 sw: tweak a bit * the fly-at-fly case didn't work, iteration also skips it * delete the bad redline section in the nodes array Change-Id: I21d3635fb53068e79984b0ea74a0a0913513bd51 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138434 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index a1c57a2d8262..c5c8b5b41927 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -567,7 +567,7 @@ inline bool XMLRedlineImportHelper::IsReady(const RedlineInfo* pRedline) !pRedline->bNeedsAdjustment ); } -/// recursively check if rPos or its anchor (if in fly or footnote) is in rPam +/// recursively check if rPos or its anchor (if in fly or footnote) is in redline section static auto RecursiveContains(SwStartNode const& rRedlineSection, SwNode const& rPos) -> bool { if (rRedlineSection.GetIndex() <= rPos.GetIndex() @@ -596,10 +596,13 @@ static auto RecursiveContains(SwStartNode const& rRedlineSection, SwNode const& return false; } else if (rAnchor.GetAnchorId() == RndStdIds::FLY_AT_FLY) - { // anchor is on a start node - loop! recursion will take *its* start node and skip it. + { // anchor is on a start node, avoid skipping it: pStartNode = rAnchor.GetContentAnchor()->GetNode().GetStartNode(); assert(pStartNode); - continue; + // pass the next node to recursive call - it will call + // call StartOfSectionNode on it and go back to pStartNode + SwNodeIndex const next(*pStartNode, +1); + return RecursiveContains(rRedlineSection, next.GetNode()); } else { @@ -623,6 +626,9 @@ static auto RecursiveContains(SwStartNode const& rRedlineSection, SwNode const& case SwFooterStartNode: return false; // headers aren't anchored break; + default: + assert(false); + break; } } return false; @@ -709,7 +715,12 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) // should be enough to check 1 position of aPaM bc CheckNodesRange() above && RecursiveContains(*pRedlineInfo->pContentIndex->GetNode().GetStartNode(), aPaM.GetPoint()->GetNode())) { - SAL_WARN("sw", "Recursive change tracking, ignoring"); + SAL_WARN("sw.xml", "Recursive change tracking, removing"); + // reuse aPaM to remove it from nodes that will be deleted + *aPaM.GetPoint() = SwPosition(pRedlineInfo->pContentIndex->GetNode()); + aPaM.SetMark(); + *aPaM.GetMark() = SwPosition(*pRedlineInfo->pContentIndex->GetNode().EndOfSectionNode()); + pDoc->getIDocumentContentOperations().DeleteRange(aPaM); } else {