Kaydet (Commit) b4b07e4d authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 83487b49
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment