diff options
| author | Michael Stahl <Michael.Stahl@cib.de> | 2018-08-09 15:10:13 +0200 |
|---|---|---|
| committer | Michael Stahl <Michael.Stahl@cib.de> | 2018-09-19 10:18:24 +0200 |
| commit | 0996bff80cb4f4f6803bce925f2df7a310317820 (patch) | |
| tree | 8e3aaf6b38b37123ec984803310eac2ff8bf7761 | |
| parent | ad067c367fbca9eb7a0f5c8adbe6be243950569e (diff) | |
sw_redlinehide_2: fix ordering of SplitNode usage of ContentIdxStore 2
The flys have their anchor positions updated, and that causes lookups
from the layout frame to the anchor SwTextFrame, but that isn't updated
yet; it looks like the fly restore must be done after adapting the
SwTextFrames, while the redline restore must be done before.
Also RegisterToNode must call Check only for the 1st node.
Change-Id: If87a62108f1bcaf794e5be1cc38dc936f08cd69e
| -rw-r--r-- | sw/inc/ndtxt.hxx | 4 | ||||
| -rw-r--r-- | sw/source/core/doc/CntntIdxStore.cxx | 36 | ||||
| -rw-r--r-- | sw/source/core/doc/DocumentContentOperationsManager.cxx | 12 | ||||
| -rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 6 | ||||
| -rw-r--r-- | sw/source/core/inc/mvsave.hxx | 12 | ||||
| -rw-r--r-- | sw/source/core/layout/ssfrm.cxx | 9 | ||||
| -rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 14 | ||||
| -rw-r--r-- | sw/source/core/undo/untbl.cxx | 6 |
8 files changed, 68 insertions, 31 deletions
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 98f1af0de448..41c088a91f9e 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -62,6 +62,8 @@ class SwGrammarMarkUp; struct SwDocStat; struct SwParaIdleData_Impl; +namespace sw { namespace mark { enum class RestoreMode; } } + namespace com { namespace sun { namespace star { namespace uno { template < class > class Sequence; @@ -349,7 +351,7 @@ public: /// Virtual methods from ContentNode. virtual SwContentFrame *MakeFrame( SwFrame* ) override; SwTextNode * SplitContentNode(const SwPosition &, - std::function<void (SwTextNode *)> const* pContentIndexRestore); + std::function<void (SwTextNode *, sw::mark::RestoreMode)> const* pContentIndexRestore); virtual SwContentNode *JoinNext() override; void JoinPrev(); diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx index 68a8c29ea888..7703c1175094 100644 --- a/sw/source/core/doc/CntntIdxStore.cxx +++ b/sw/source/core/doc/CntntIdxStore.cxx @@ -152,26 +152,38 @@ namespace SaveUnoCursors(pDoc, nNode, nContent); SaveShellCursors(pDoc, nNode, nContent); } - virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false) override + virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false, RestoreMode eMode = RestoreMode::All) override { SwContentNode* pCNd = pDoc->GetNodes()[ nNode ]->GetContentNode(); updater_t aUpdater = OffsetUpdater(pCNd, nOffset); - RestoreBkmks(pDoc, aUpdater); - RestoreRedlines(pDoc, aUpdater); - RestoreFlys(pDoc, aUpdater, bAuto); - RestoreUnoCursors(aUpdater); - RestoreShellCursors(aUpdater); + if (eMode & RestoreMode::NonFlys) + { + RestoreBkmks(pDoc, aUpdater); + RestoreRedlines(pDoc, aUpdater); + RestoreUnoCursors(aUpdater); + RestoreShellCursors(aUpdater); + } + if (eMode & RestoreMode::Flys) + { + RestoreFlys(pDoc, aUpdater, bAuto); + } } - virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen) override + virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen, RestoreMode eMode = RestoreMode::All) override { SwContentNode* pCNd = rNd.GetContentNode(); SwDoc* pDoc = rNd.GetDoc(); updater_t aUpdater = LimitUpdater(pCNd, nLen, nCorrLen); - RestoreBkmks(pDoc, aUpdater); - RestoreRedlines(pDoc, aUpdater); - RestoreFlys(pDoc, aUpdater, false); - RestoreUnoCursors(aUpdater); - RestoreShellCursors(aUpdater); + if (eMode & RestoreMode::NonFlys) + { + RestoreBkmks(pDoc, aUpdater); + RestoreRedlines(pDoc, aUpdater); + RestoreUnoCursors(aUpdater); + RestoreShellCursors(aUpdater); + } + if (eMode & RestoreMode::Flys) + { + RestoreFlys(pDoc, aUpdater, false); + } } private: diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 197d3f5fd02a..47a5287c7927 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -1992,12 +1992,12 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos, assert(aSavePam.GetPoint()->nNode == rPos.nNode.GetIndex()); assert(rPos.nNode.GetIndex() == pOrigNode->GetIndex()); - std::function<void (SwTextNode *)> restoreFunc( - [&](SwTextNode *const) + std::function<void (SwTextNode *, sw::mark::RestoreMode)> restoreFunc( + [&](SwTextNode *const, sw::mark::RestoreMode const eMode) { if (!pContentStore->Empty()) { - pContentStore->Restore(&m_rDoc, pOrigNode->GetIndex()-1, 0, true); + pContentStore->Restore(&m_rDoc, pOrigNode->GetIndex()-1, 0, true, eMode); } }); pTNd = pTNd->SplitContentNode(rPos, &restoreFunc)->GetTextNode(); @@ -2947,12 +2947,12 @@ bool DocumentContentOperationsManager::SplitNode( const SwPosition &rPos, bool b const std::shared_ptr<sw::mark::ContentIdxStore> pContentStore(sw::mark::ContentIdxStore::Create()); pContentStore->Save( &m_rDoc, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), true ); assert(pNode->IsTextNode()); - std::function<void (SwTextNode *)> restoreFunc( - [&](SwTextNode *const) + std::function<void (SwTextNode *, sw::mark::RestoreMode)> restoreFunc( + [&](SwTextNode *const, sw::mark::RestoreMode const eMode) { if (!pContentStore->Empty()) { // move all bookmarks, TOXMarks, FlyAtCnt - pContentStore->Restore(&m_rDoc, rPos.nNode.GetIndex()-1, 0, true); + pContentStore->Restore(&m_rDoc, rPos.nNode.GetIndex()-1, 0, true, eMode); } }); pNode = pNode->GetTextNode()->SplitContentNode(rPos, &restoreFunc); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 065f31d28315..c188dfeffdac 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1070,12 +1070,12 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh, if (pTextNd->GetText()[nChPos] == cCh) { aCntPos.nContent = nChPos; - std::function<void (SwTextNode *)> restoreFunc( - [&](SwTextNode *const pNewNode) + std::function<void (SwTextNode *, sw::mark::RestoreMode)> restoreFunc( + [&](SwTextNode *const pNewNode, sw::mark::RestoreMode const eMode) { if (!pContentStore->Empty()) { - pContentStore->Restore(*pNewNode, nChPos, nChPos + 1); + pContentStore->Restore(*pNewNode, nChPos, nChPos + 1, eMode); } }); SwContentNode *const pNewNd = diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx index 1279617ef313..ec0a1e412787 100644 --- a/sw/source/core/inc/mvsave.hxx +++ b/sw/source/core/inc/mvsave.hxx @@ -23,6 +23,7 @@ #include <IDocumentMarkAccess.hxx> #include <vector> #include <deque> +#include <o3tl/typed_flags_set.hxx> namespace sfx2 { class MetadatableUndo; @@ -66,20 +67,27 @@ namespace sw { namespace mark std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; }; + enum class RestoreMode { Flys = 1, NonFlys = 2, All = 3 }; + /// Takes care of storing relevant attributes of an SwTextNode before split, then restore them on the new node. class ContentIdxStore { public: + virtual void Clear() =0; virtual bool Empty() =0; virtual void Save(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nContent, bool bSaveFlySplit=false) =0; - virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false) =0; - virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen) =0; + virtual void Restore(SwDoc* pDoc, sal_uLong nNode, sal_Int32 nOffset=0, bool bAuto = false, RestoreMode = RestoreMode::All) =0; + virtual void Restore(SwNode& rNd, sal_Int32 nLen, sal_Int32 nCorrLen, RestoreMode = RestoreMode::All) =0; virtual ~ContentIdxStore() {}; static std::shared_ptr<ContentIdxStore> Create(); }; }} +namespace o3tl { + template<> struct typed_flags<sw::mark::RestoreMode> : is_typed_flags<sw::mark::RestoreMode, 3> {}; +} + void DelBookmarks(const SwNodeIndex& rStt, const SwNodeIndex& rEnd, std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =nullptr, diff --git a/sw/source/core/layout/ssfrm.cxx b/sw/source/core/layout/ssfrm.cxx index abe62e8b3968..3a37ae92bc7f 100644 --- a/sw/source/core/layout/ssfrm.cxx +++ b/sw/source/core/layout/ssfrm.cxx @@ -443,8 +443,15 @@ SwContentFrame::~SwContentFrame() void SwTextFrame::RegisterToNode(SwTextNode & rNode) { assert(&rNode != GetDep()); + assert(!m_pMergedPara + || (m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex()) + || (rNode.GetIndex() + 1 == m_pMergedPara->pFirstNode->GetIndex())); + SwTextNode & rFirstNode( + (m_pMergedPara && m_pMergedPara->pFirstNode->GetIndex() < rNode.GetIndex()) + ? *m_pMergedPara->pFirstNode + : rNode); // sw_redlinehide: use New here, because the only caller also calls lcl_ChangeFootnoteRef - m_pMergedPara = sw::CheckParaRedlineMerge(*this, rNode, sw::FrameMode::New); + m_pMergedPara = sw::CheckParaRedlineMerge(*this, rFirstNode, sw::FrameMode::New); if (!m_pMergedPara) { rNode.Add(this); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 5c1bf1e97f77..38d1cbe0d973 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -366,7 +366,7 @@ static void lcl_ChangeFootnoteRef( SwTextNode &rNode ) } SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, - std::function<void (SwTextNode *)> const*const pContentIndexRestore) + std::function<void (SwTextNode *, sw::mark::RestoreMode)> const*const pContentIndexRestore) { bool parentIsOutline = IsOutline(); @@ -479,7 +479,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, if (pContentIndexRestore) { // call before making frames and before RegisterToNode - (*pContentIndexRestore)(pNode); + (*pContentIndexRestore)(pNode, sw::mark::RestoreMode::NonFlys); } SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(*this); @@ -526,6 +526,10 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, } pNode->MakeFramesForAdjacentContentNode(*this); lcl_ChangeFootnoteRef( *this ); + if (pContentIndexRestore) + { // call after making frames; listeners will take care of adding to the right frame + (*pContentIndexRestore)(pNode, sw::mark::RestoreMode::Flys); + } } else { @@ -583,7 +587,7 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, if (pContentIndexRestore) { // call before making frames - (*pContentIndexRestore)(pNode); + (*pContentIndexRestore)(pNode, sw::mark::RestoreMode::NonFlys); } if ( HasWriterListeners() ) @@ -591,6 +595,10 @@ SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos, MakeFramesForAdjacentContentNode(*pNode); } lcl_ChangeFootnoteRef( *pNode ); + if (pContentIndexRestore) + { // call after making frames; listeners will take care of adding to the right frame + (*pContentIndexRestore)(pNode, sw::mark::RestoreMode::Flys); + } } { diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 2f76935b360a..0700c917a696 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -557,12 +557,12 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd, pTextNd->EraseText( aCntPos, 1 ); - std::function<void (SwTextNode *)> restoreFunc( - [&](SwTextNode *const pNewNode) + std::function<void (SwTextNode *, sw::mark::RestoreMode)> restoreFunc( + [&](SwTextNode *const pNewNode, sw::mark::RestoreMode const eMode) { if (!pContentStore->Empty()) { - pContentStore->Restore(*pNewNode, pSave->m_nContent, pSave->m_nContent + 1); + pContentStore->Restore(*pNewNode, pSave->m_nContent, pSave->m_nContent + 1, eMode); } }); pTextNd->SplitContentNode( |
