summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/ndtxt.cxx
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2018-08-15 17:15:26 +0200
committerMichael Stahl <Michael.Stahl@cib.de>2018-09-19 10:18:26 +0200
commitb4b07e4d7d2af6c5f008d24f3ba50162ce1f2d03 (patch)
treea386016302bcd6f1191fe9557a0963fa32fdd4ac /sw/source/core/txtnode/ndtxt.cxx
parent83487b49dc1d7b27185beba2cc6c79db7f1aff1c (diff)
sw_redlinehide_2: SplitContentNode also needs to move flys ...
... and footnotes that are anchored in a node of a merged frame that follows the one that is being split to the new frames of the existing node when the existing frames are moved to the new (preceding) node. Change-Id: I759718c14130e6a3809dc2ca55243f3ff2eec50b
Diffstat (limited to 'sw/source/core/txtnode/ndtxt.cxx')
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx66
1 files changed, 66 insertions, 0 deletions
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 36d6e85cf843..edf331b570d9 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -364,6 +364,58 @@ static void lcl_ChangeFootnoteRef( SwTextNode &rNode )
}
}
+namespace {
+
+// check if there are flys on the existing frames (now on "pNode")
+// that need to be moved to the new frames of "this"
+void MoveMergedFlysAndFootnotes(std::vector<SwTextFrame*> const& rFrames,
+ SwTextNode const& rFirstNode, SwTextNode const& rSecondNode)
+{
+ for (sal_uLong nIndex = rSecondNode.GetIndex() + 1; ; ++nIndex)
+ {
+ SwNode *const pTmp(rSecondNode.GetNodes()[nIndex]);
+ if (pTmp->IsCreateFrameWhenHidingRedlines() || pTmp->IsEndNode())
+ {
+ break;
+ }
+ else if (pTmp->IsStartNode())
+ {
+ nIndex = pTmp->EndOfSectionIndex();
+ }
+ else if (pTmp->GetRedlineMergeFlag() == SwNode::Merge::NonFirst
+ && pTmp->IsTextNode())
+ {
+ lcl_ChangeFootnoteRef(*pTmp->GetTextNode());
+ }
+ }
+ for (SwTextFrame *const pFrame : rFrames)
+ {
+ if (SwSortedObjs *const pObjs = pFrame->GetDrawObjs())
+ {
+ std::vector<SwAnchoredObject*> objs;
+ objs.reserve(pObjs->size());
+ for (SwAnchoredObject *const pObj : *pObjs)
+ {
+ objs.push_back(pObj);
+ }
+ for (SwAnchoredObject *const pObj : objs)
+ {
+ SwFrameFormat & rFormat(pObj->GetFrameFormat());
+ SwFormatAnchor const& rAnchor(rFormat.GetAnchor());
+ if (rFirstNode.GetIndex() < rAnchor.GetContentAnchor()->nNode.GetIndex())
+ {
+ // move it to the new frame of "this"
+ rFormat.NotifyClients(&rAnchor, &rAnchor);
+ // note pObjs will be deleted if it becomes empty
+ assert(!pFrame->GetDrawObjs() || !pObjs->Contains(*pObj));
+ }
+ }
+ }
+ }
+}
+
+} // namespace
+
SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos,
std::function<void (SwTextNode *, sw::mark::RestoreMode)> const*const pContentIndexRestore)
{
@@ -487,6 +539,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos,
SetRedlineMergeFlag(SwNode::Merge::None);
} // now RegisterToNode will set merge flags in both nodes properly!
+ std::vector<SwTextFrame*> frames;
SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(*this);
for (SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
{
@@ -494,6 +547,10 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos,
{
isHide = true;
}
+ frames.push_back(pFrame);
+ }
+ for (SwTextFrame * pFrame : frames)
+ {
pFrame->RegisterToNode( *pNode );
if (!pFrame->IsFollow() && pFrame->GetOfst())
{
@@ -540,6 +597,10 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos,
{ // call after making frames; listeners will take care of adding to the right frame
(*pContentIndexRestore)(pNode, sw::mark::RestoreMode::Flys);
}
+ if (eOldMergeFlag != SwNode::Merge::None)
+ {
+ MoveMergedFlysAndFootnotes(frames, *pNode, *this);
+ }
}
else
{
@@ -666,6 +727,11 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos,
{ // call after making frames; listeners will take care of adding to the right frame
(*pContentIndexRestore)(pNode, sw::mark::RestoreMode::Flys);
}
+
+ if (bRecreateThis)
+ {
+ MoveMergedFlysAndFootnotes(frames, *pNode, *this);
+ }
}
#ifndef NDEBUG