summaryrefslogtreecommitdiff
path: root/sw/source/core/layout
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2020-04-02 17:18:37 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2020-04-05 00:23:34 +0200
commitf7aa951014c283bc629eaea14da2ca0d68f99431 (patch)
treedd07ecb79865e5417d2372c5bdac1edc06582d67 /sw/source/core/layout
parentc7c157c905b8b70aa3e426a6e4d2ba40963caf1a (diff)
tdf#130685 sw_redlinehide: fix copying to position following redline
In DocumentContentOperationsManager::CopyWithFlyInFly(), first CopyNodes() also creates all layout frames, then SaveRedlEndPosForRestore fixes the end position of all redlines that were moved by CopyNodes() (they were moved not by changing their position but by inserting new nodes before their end position). Of course this means that the layout frames are created with redlines that have only a temporary end position, and then things go wrong when the end positions are adjusted, so add something similar to SwUndoDelete::UndoImpl() to recreate the frames in CopyWithFlyInFly(). This hit the assert: sw/source/core/text/redlnitr.cxx:94: std::unique_ptr<sw::MergedPara> sw::CheckParaRedlineMerge(SwTextFrame&, SwTextNode&, sw::FrameMode): Assertion `pNode != &rTextNode || &pStart->nNode.GetNode() == &rTextNode' failed. (regression from ... sw_redlinehide) Change-Id: I82e0f5b320cab201e762f58800f83e08f4f01048 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91596 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de> (cherry picked from commit 166b5010b402a41b192b1659093a25acf9065fd9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91523 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'sw/source/core/layout')
-rw-r--r--sw/source/core/layout/frmtool.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index eafc4fd48a49..5c6e6cc4dd44 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -1356,6 +1356,38 @@ void AppendAllObjs(const SwFrameFormats* pTable, const SwFrame* pSib)
}
}
+namespace sw {
+
+void RecreateStartTextFrames(SwTextNode & rNode)
+{
+ std::vector<SwTextFrame*> frames;
+ SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(rNode);
+ for (SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
+ {
+ if (pFrame->getRootFrame()->IsHideRedlines())
+ {
+ frames.push_back(pFrame);
+ }
+ }
+ auto eMode(sw::FrameMode::Existing);
+ for (SwTextFrame * pFrame : frames)
+ {
+ // SplitNode could have moved the original frame to the start node
+ // & created a new one on end, or could have created new frame on
+ // start node... grab start node's frame and recreate MergedPara.
+ SwTextNode & rFirstNode(pFrame->GetMergedPara()
+ ? *pFrame->GetMergedPara()->pFirstNode
+ : rNode);
+ assert(rFirstNode.GetIndex() <= rNode.GetIndex());
+ pFrame->SetMergedPara(sw::CheckParaRedlineMerge(
+ *pFrame, rFirstNode, eMode));
+ eMode = sw::FrameMode::New; // Existing is not idempotent!
+ // note: this may or may not delete frames on the end node
+ }
+}
+
+} // namespace sw
+
/** local method to set 'working' position for newly inserted frames
OD 12.08.2003 #i17969#