[Libreoffice-commits] core.git: Branch 'private/mst/sw_redlinehide_2' - 4 commits - sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Aug 16 08:38:57 UTC 2018
sw/source/core/doc/DocumentRedlineManager.cxx | 18 +++
sw/source/core/txtnode/ndtxt.cxx | 125 ++++++++++++++++++++++++++
2 files changed, 143 insertions(+)
New commits:
commit cd7e089271c4e848f9612412fd843f6e5da00563
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Aug 15 18:52:39 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Aug 15 18:52:39 2018 +0200
sw_redlinehide_2: JoinNext/JoinPrev may need to recreate MergedPara
Change-Id: I17cde9fab29cf54837904db3c6e64d609aed83b0
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index df87b2a7cd34..00df05638c78 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -814,9 +814,27 @@ void SwTextNode::MoveTextAttr_To_AttrSet()
namespace {
-void CheckResetRedlineMergeFlag(SwTextNode & rNode)
+void CheckResetRedlineMergeFlag(SwTextNode & rNode, bool const bRecreateMerged)
{
- if (rNode.GetRedlineMergeFlag() != SwNode::Merge::None)
+ if (bRecreateMerged)
+ {
+ std::vector<SwTextFrame*> frames;
+ SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(rNode);
+ for (SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
+ {
+ frames.push_back(pFrame);
+ }
+ for (SwTextFrame * pFrame : frames)
+ {
+ SwTextNode & rFirstNode(pFrame->GetMergedPara()
+ ? *pFrame->GetMergedPara()->pFirstNode
+ : rNode);
+ assert(rFirstNode.GetIndex() <= rNode.GetIndex());
+ pFrame->SetMergedPara(sw::CheckParaRedlineMerge(
+ *pFrame, rFirstNode, sw::FrameMode::Existing));
+ }
+ }
+ else if (rNode.GetRedlineMergeFlag() != SwNode::Merge::None)
{
SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(rNode);
for (SwTextFrame * pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
@@ -922,12 +940,13 @@ SwContentNode *SwTextNode::JoinNext()
// move all ShellCursor/StackCursor/UnoCursor out of delete range
pDoc->CorrAbs( aIdx, SwPosition( *this ), nOldLen, true );
}
+ SwNode::Merge const eOldMergeFlag(pTextNode->GetRedlineMergeFlag());
rNds.Delete(aIdx);
SetWrong( pList, false );
SetGrammarCheck( pList3, false );
SetSmartTags( pList2, false );
InvalidateNumRule();
- CheckResetRedlineMergeFlag(*this);
+ CheckResetRedlineMergeFlag(*this, eOldMergeFlag == SwNode::Merge::First);
}
else {
OSL_FAIL( "No TextNode." );
@@ -1017,12 +1036,13 @@ void SwTextNode::JoinPrev()
// move all ShellCursor/StackCursor/UnoCursor out of delete range
pDoc->CorrAbs( aIdx, SwPosition( *this ), nLen, true );
}
+ SwNode::Merge const eOldMergeFlag(pTextNode->GetRedlineMergeFlag());
rNds.Delete(aIdx);
SetWrong( pList, false );
SetGrammarCheck( pList3, false );
SetSmartTags( pList2, false );
InvalidateNumRule();
- CheckResetRedlineMergeFlag(*this);
+ CheckResetRedlineMergeFlag(*this, eOldMergeFlag == SwNode::Merge::NonFirst);
}
else {
OSL_FAIL( "No TextNode." );
commit b61da3820ea58664904f244624f475238fded321
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Aug 15 17:15:26 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Aug 15 17:15:26 2018 +0200
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
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 726e5a84bdea..df87b2a7cd34 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -364,6 +364,66 @@ 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)
+{
+ int nLevel(0);
+ for (sal_uLong nIndex = rSecondNode.GetIndex() + 1; ; ++nIndex)
+ {
+ SwNode *const pTmp(rSecondNode.GetNodes()[nIndex]);
+ if (pTmp->IsCreateFrameWhenHidingRedlines())
+ {
+ break;
+ }
+ else if (pTmp->IsStartNode())
+ {
+ ++nLevel;
+ }
+ else if (pTmp->IsEndNode())
+ {
+ --nLevel;
+ }
+ else if (nLevel == 0
+ && 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(
+ const_cast<SwFormatAnchor*>(&rAnchor),
+ const_cast<SwFormatAnchor*>(&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)
{
@@ -486,9 +546,14 @@ 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())
{
+ frames.push_back(pFrame);
+ }
+ for (SwTextFrame * pFrame : frames)
+ {
pFrame->RegisterToNode( *pNode );
if (!pFrame->IsFollow() && pFrame->GetOfst())
{
@@ -535,6 +600,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
{
@@ -650,6 +719,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);
+ }
}
{
commit 10e3fe0ebd81e479ec7fb5bb2b4bbc35f9101c39
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Aug 15 14:19:47 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Aug 15 14:19:47 2018 +0200
sw_redlinehide_2: reset node's merge flag in SwTextNode::JoinNext/JoinPrev
... if the deleted node was the only one it was merged with.
Change-Id: I7b73bb3bfa92d285c06cfb24e0bae4e81708dbb8
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index a77cfe42382e..726e5a84bdea 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -738,6 +738,35 @@ void SwTextNode::MoveTextAttr_To_AttrSet()
}
+namespace {
+
+void CheckResetRedlineMergeFlag(SwTextNode & rNode)
+{
+ if (rNode.GetRedlineMergeFlag() != SwNode::Merge::None)
+ {
+ SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(rNode);
+ for (SwTextFrame * pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
+ {
+ if (auto const pMergedPara = pFrame->GetMergedPara())
+ {
+ if (pMergedPara->pFirstNode == pMergedPara->pLastNode)
+ {
+ assert(pMergedPara->pFirstNode == &rNode);
+ rNode.SetRedlineMergeFlag(SwNode::Merge::None);
+ }
+ break; // checking once is enough
+ }
+ else if (pFrame->getRootFrame()->IsHideRedlines())
+ {
+ rNode.SetRedlineMergeFlag(SwNode::Merge::None);
+ break; // checking once is enough
+ }
+ }
+ }
+}
+
+} // namespace
+
SwContentNode *SwTextNode::JoinNext()
{
SwNodes& rNds = GetNodes();
@@ -824,6 +853,7 @@ SwContentNode *SwTextNode::JoinNext()
SetGrammarCheck( pList3, false );
SetSmartTags( pList2, false );
InvalidateNumRule();
+ CheckResetRedlineMergeFlag(*this);
}
else {
OSL_FAIL( "No TextNode." );
@@ -918,6 +948,7 @@ void SwTextNode::JoinPrev()
SetGrammarCheck( pList3, false );
SetSmartTags( pList2, false );
InvalidateNumRule();
+ CheckResetRedlineMergeFlag(*this);
}
else {
OSL_FAIL( "No TextNode." );
commit 97266bebcd7f85e5955286f56e7aec606b1d2bf1
Author: Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Aug 15 13:49:52 2018 +0200
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Aug 15 13:49:52 2018 +0200
sw_redlinehide_2: prevent SetRedlineFlags from messing things up
Unfortunately it doesn't work to just let the content editing
functions that are called by the SwRangeRedline Show function
set up the frames because they can't do it correctly, as the redline
that is currently being Shown doesn't have a correct position;
the position is only patched up afterwards in MoveFromSection.
Change-Id: Ie94a2eea44befce55ad16db1f9349b1582a7f73e
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 1686b2deb56e..c056c1c7a113 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -18,6 +18,7 @@
*/
#include <DocumentRedlineManager.hxx>
#include <frmfmt.hxx>
+#include <rootfrm.hxx>
#include <doc.hxx>
#include <IDocumentUndoRedo.hxx>
#include <IDocumentState.hxx>
@@ -666,6 +667,23 @@ void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode )
CheckAnchoredFlyConsistency(m_rDoc);
CHECK_REDLINE( *this )
m_rDoc.SetInXMLImport( bSaveInXMLImportFlag );
+ if (eShowMode == (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete))
+ {
+ // sw_redlinehide: the problem here is that MoveFromSection
+ // creates the frames wrongly (non-merged), because its own
+ // SwRangeRedline has wrong positions until after the nodes
+ // are all moved, so fix things up by force by re-creating
+ // all merged frames from scratch.
+ std::set<SwRootFrame *> const layouts(m_rDoc.GetAllLayouts());
+ for (SwRootFrame *const pLayout : layouts)
+ {
+ if (pLayout->IsHideRedlines())
+ {
+ pLayout->SetHideRedlines(false);
+ pLayout->SetHideRedlines(true);
+ }
+ }
+ }
}
meRedlineFlags = eMode;
m_rDoc.getIDocumentState().SetModified();
More information about the Libreoffice-commits
mailing list