summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/ndgrf.hxx1
-rw-r--r--sw/inc/ndole.hxx2
-rw-r--r--sw/inc/ndtxt.hxx4
-rw-r--r--sw/inc/node.hxx2
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx30
-rw-r--r--sw/source/core/docnode/ndtbl.cxx14
-rw-r--r--sw/source/core/docnode/nodes.cxx4
-rw-r--r--sw/source/core/graphic/ndgrf.cxx5
-rw-r--r--sw/source/core/ole/ndole.cxx7
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx13
-rw-r--r--sw/source/core/undo/untbl.cxx15
11 files changed, 57 insertions, 40 deletions
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index e82061421aa6..0a6c67a65481 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -80,7 +80,6 @@ public:
const Graphic& GetGrf(bool bWait = false) const;
const GraphicObject& GetGrfObj(bool bWait = false) const;
const GraphicObject* GetReplacementGrfObj() const;
- virtual SwContentNode *SplitContentNode( const SwPosition & ) override;
/// isolated only way to set GraphicObject to allow more actions when doing so
void SetGraphic(const Graphic& rGraphic);
diff --git a/sw/inc/ndole.hxx b/sw/inc/ndole.hxx
index 4f6f4596736d..93139c986526 100644
--- a/sw/inc/ndole.hxx
+++ b/sw/inc/ndole.hxx
@@ -111,8 +111,6 @@ public:
SwOLEObj& GetOLEObj() { return maOLEObj; }
virtual ~SwOLENode() override;
- virtual SwContentNode *SplitContentNode( const SwPosition & ) override;
-
/// Is in ndcopy.cxx.
virtual SwContentNode* MakeCopy( SwDoc*, const SwNodeIndex& ) const override;
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index c9e1f2b334ae..98f1af0de448 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -34,6 +34,7 @@
#include <memory>
#include <vector>
#include <set>
+#include <functional>
class SfxHint;
class SwNumRule;
@@ -347,7 +348,8 @@ public:
/// Virtual methods from ContentNode.
virtual SwContentFrame *MakeFrame( SwFrame* ) override;
- virtual SwContentNode *SplitContentNode( const SwPosition & ) override;
+ SwTextNode * SplitContentNode(const SwPosition &,
+ std::function<void (SwTextNode *)> const* pContentIndexRestore);
virtual SwContentNode *JoinNext() override;
void JoinPrev();
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 298143e91b57..44e075cda09a 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -382,8 +382,6 @@ public:
pSib is another SwFrame of the same layout (e.g. the SwRootFrame itself, a sibling, the parent) */
virtual SwContentFrame *MakeFrame( SwFrame* pSib ) = 0;
- virtual SwContentNode *SplitContentNode(const SwPosition & ) = 0;
-
virtual SwContentNode *JoinNext();
/** Is it possible to join two nodes?
In pIdx the second position can be returned. */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index ed75cefaabc7..197d3f5fd02a 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1992,7 +1992,15 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos,
assert(aSavePam.GetPoint()->nNode == rPos.nNode.GetIndex());
assert(rPos.nNode.GetIndex() == pOrigNode->GetIndex());
- pTNd = pTNd->SplitContentNode( rPos )->GetTextNode();
+ std::function<void (SwTextNode *)> restoreFunc(
+ [&](SwTextNode *const)
+ {
+ if (!pContentStore->Empty())
+ {
+ pContentStore->Restore(&m_rDoc, pOrigNode->GetIndex()-1, 0, true);
+ }
+ });
+ pTNd = pTNd->SplitContentNode(rPos, &restoreFunc)->GetTextNode();
//A new node was inserted before the orig pTNd and the content up to
//rPos moved into it. The old node is returned with the remainder
@@ -2012,9 +2020,6 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& rPaM, SwPosition& rPos,
aSavePam.GetPoint()->nContent.Assign(pOrigNode, 0);
rPos = *aSavePam.GetMark() = *aSavePam.GetPoint();
- if( !pContentStore->Empty() )
- pContentStore->Restore( &m_rDoc, rPos.nNode.GetIndex()-1, 0, true );
-
// correct the PaM!
if( rPos.nNode == rPaM.GetMark()->nNode )
{
@@ -2941,15 +2946,18 @@ 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 );
- // FIXME: only SwTextNode has a valid implementation of SplitContentNode!
- OSL_ENSURE(pNode->IsTextNode(), "splitting non-text node?");
- pNode = pNode->SplitContentNode( rPos );
+ assert(pNode->IsTextNode());
+ std::function<void (SwTextNode *)> restoreFunc(
+ [&](SwTextNode *const)
+ {
+ if (!pContentStore->Empty())
+ { // move all bookmarks, TOXMarks, FlyAtCnt
+ pContentStore->Restore(&m_rDoc, rPos.nNode.GetIndex()-1, 0, true);
+ }
+ });
+ pNode = pNode->GetTextNode()->SplitContentNode(rPos, &restoreFunc);
if (pNode)
{
- // move all bookmarks, TOXMarks, FlyAtCnt
- if( !pContentStore->Empty() )
- pContentStore->Restore( &m_rDoc, rPos.nNode.GetIndex()-1, 0, true );
-
// To-Do - add 'SwExtraRedlineTable' also ?
if( m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() || (!m_rDoc.getIDocumentRedlineAccess().IsIgnoreRedline() && !m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty() ))
{
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 57e89741dd03..065f31d28315 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1070,10 +1070,16 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
if (pTextNd->GetText()[nChPos] == cCh)
{
aCntPos.nContent = nChPos;
- SwContentNode* pNewNd = pTextNd->SplitContentNode( aCntPos );
-
- if( !pContentStore->Empty() )
- pContentStore->Restore( *pNewNd, nChPos, nChPos + 1 );
+ std::function<void (SwTextNode *)> restoreFunc(
+ [&](SwTextNode *const pNewNode)
+ {
+ if (!pContentStore->Empty())
+ {
+ pContentStore->Restore(*pNewNode, nChPos, nChPos + 1);
+ }
+ });
+ SwContentNode *const pNewNd =
+ pTextNd->SplitContentNode(aCntPos, &restoreFunc);
// Delete separator and correct search string
pTextNd->EraseText( aCntPos.nContent, 1 );
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index b3866f916a42..5d887ed10e84 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -1512,7 +1512,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes )
}
else
{
- pDestNd->SplitContentNode( rPos );
+ pDestNd->SplitContentNode(rPos, nullptr);
}
if( rPos.nNode == aEndIdx )
@@ -1577,7 +1577,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes )
}
else
{
- pDestNd->SplitContentNode( rPos );
+ pDestNd->SplitContentNode(rPos, nullptr);
}
if ( bCorrEnd )
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index 0f6ce3dcbd36..f7a489bba3bb 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -398,11 +398,6 @@ const GraphicObject* SwGrfNode::GetReplacementGrfObj() const
return mpReplacementGraphic.get();
}
-SwContentNode *SwGrfNode::SplitContentNode( const SwPosition & )
-{
- return this;
-}
-
SwGrfNode * SwNodes::MakeGrfNode( const SwNodeIndex & rWhere,
const OUString& rGrfName,
const OUString& rFltName,
diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx
index ea6c8a19cdf2..c4906f8be6cb 100644
--- a/sw/source/core/ole/ndole.cxx
+++ b/sw/source/core/ole/ndole.cxx
@@ -242,13 +242,6 @@ const Graphic* SwOLENode::GetGraphic()
return nullptr;
}
-SwContentNode *SwOLENode::SplitContentNode( const SwPosition & )
-{
- // Multiply OLE objects?
- OSL_FAIL( "OleNode: can't split." );
- return this;
-}
-
/**
* Loading a OLE object that has been moved to the Undo Area
*/
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 8d715f28219c..5c1bf1e97f77 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -365,7 +365,8 @@ static void lcl_ChangeFootnoteRef( SwTextNode &rNode )
}
}
-SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos )
+SwTextNode *SwTextNode::SplitContentNode(const SwPosition & rPos,
+ std::function<void (SwTextNode *)> const*const pContentIndexRestore)
{
bool parentIsOutline = IsOutline();
@@ -476,6 +477,11 @@ SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos )
}
+ if (pContentIndexRestore)
+ { // call before making frames and before RegisterToNode
+ (*pContentIndexRestore)(pNode);
+ }
+
SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> aIter(*this);
for (SwTextFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
{
@@ -575,6 +581,11 @@ SwContentNode *SwTextNode::SplitContentNode( const SwPosition &rPos )
SetSmartTags( pList2, false );
}
+ if (pContentIndexRestore)
+ { // call before making frames
+ (*pContentIndexRestore)(pNode);
+ }
+
if ( HasWriterListeners() )
{
MakeFramesForAdjacentContentNode(*pNode);
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index b7cc595587d9..2f76935b360a 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -556,10 +556,17 @@ SwTableNode* SwNodes::UndoTableToText( sal_uLong nSttNd, sal_uLong nEndNd,
SwIndex aCntPos( pTextNd, pSave->m_nContent - 1 );
pTextNd->EraseText( aCntPos, 1 );
- SwContentNode* pNewNd = pTextNd->SplitContentNode(
- SwPosition( aSttIdx, aCntPos ));
- if( !pContentStore->Empty() )
- pContentStore->Restore( *pNewNd, pSave->m_nContent, pSave->m_nContent + 1 );
+
+ std::function<void (SwTextNode *)> restoreFunc(
+ [&](SwTextNode *const pNewNode)
+ {
+ if (!pContentStore->Empty())
+ {
+ pContentStore->Restore(*pNewNode, pSave->m_nContent, pSave->m_nContent + 1);
+ }
+ });
+ pTextNd->SplitContentNode(
+ SwPosition(aSttIdx, aCntPos), &restoreFunc);
}
else
{