summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-12-20 13:32:21 +0100
committerMichael Stahl <mstahl@redhat.com>2012-12-20 14:11:45 +0100
commitcdceee72ae4f1642d50b6df9e0afc2fd365bc7d6 (patch)
tree093e66c9bdba65be2eb7657acfc9146c4a1f39aa
parent72e3dd4d8ab6fe4368972a761c70185d1742855d (diff)
SwUndoInsert: replace SwPosition with SwNodeIndex here too
See previous SwUndoInserts commit. Change-Id: I8d255e85a72bb93be280f87bab096d69f1e9f573
-rw-r--r--sw/source/core/inc/UndoInsert.hxx3
-rw-r--r--sw/source/core/undo/unins.cxx36
2 files changed, 16 insertions, 23 deletions
diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx
index d665025353d4..d24359bbdee5 100644
--- a/sw/source/core/inc/UndoInsert.hxx
+++ b/sw/source/core/inc/UndoInsert.hxx
@@ -32,7 +32,8 @@ class SwUndoFmtAttr;
class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt
{
- SwPosition *pPos; // Inhalt fuers Redo
+ /// start of Content in UndoNodes for Redo
+ ::boost::scoped_ptr<SwNodeIndex> m_pUndoNodeIndex;
String *pTxt, *pUndoTxt;
SwRedlineData* pRedlData;
sal_uLong nNode;
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index d1cef8478d80..4b8ce61009a1 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -102,7 +102,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, xub_StrLen nCnt,
xub_StrLen nL,
const IDocumentContentOperations::InsertFlags nInsertFlags,
sal_Bool bWDelim )
- : SwUndo(UNDO_TYPING), pPos( 0 ), pTxt( 0 ), pRedlData( 0 ),
+ : SwUndo(UNDO_TYPING), pTxt( 0 ), pRedlData( 0 ),
nNode( rNd.GetIndex() ), nCntnt(nCnt), nLen(nL),
bIsWordDelim( bWDelim ), bIsAppend( sal_False )
, m_nInsertFlags(nInsertFlags)
@@ -112,7 +112,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, xub_StrLen nCnt,
// #111827#
SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd )
- : SwUndo(UNDO_SPLITNODE), pPos( 0 ), pTxt( 0 ),
+ : SwUndo(UNDO_SPLITNODE), pTxt( 0 ),
pRedlData( 0 ), nNode( rNd.GetIndex() ), nCntnt(0), nLen(1),
bIsWordDelim( sal_False ), bIsAppend( sal_True )
, m_nInsertFlags(IDocumentContentOperations::INS_EMPTYEXPAND)
@@ -184,21 +184,13 @@ sal_Bool SwUndoInsert::CanGrouping( const SwPosition& rPos )
SwUndoInsert::~SwUndoInsert()
{
- if( pPos ) // delete the section from UndoNodes array
+ if (m_pUndoNodeIndex) // delete the section from UndoNodes array
{
// Insert saves the content in IconSection
- SwNodes& rUNds = pPos->nNode.GetNode().GetNodes();
- if( pPos->nContent.GetIndex() ) // do not delete the whole node
- {
- SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode();
- OSL_ENSURE( pTxtNd, "no TextNode to delete from" );
- pTxtNd->EraseText( pPos->nContent );
- pPos->nNode++;
- }
- pPos->nContent.Assign( 0, 0 );
- rUNds.Delete( pPos->nNode, rUNds.GetEndOfExtras().GetIndex() -
- pPos->nNode.GetIndex() );
- delete pPos;
+ SwNodes& rUNds = m_pUndoNodeIndex->GetNodes();
+ rUNds.Delete(*m_pUndoNodeIndex,
+ rUNds.GetEndOfExtras().GetIndex() - m_pUndoNodeIndex->GetIndex());
+ m_pUndoNodeIndex.reset();
}
else if( pTxt ) // the inserted text
delete pTxt;
@@ -264,8 +256,9 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext)
if( !pTxt )
{
- pPos = new SwPosition( *aPaM.GetPoint() );
- MoveToUndoNds( aPaM, &pPos->nNode, &pPos->nContent );
+ m_pUndoNodeIndex.reset(
+ new SwNodeIndex(pDoc->GetNodes().GetEndOfContent()));
+ MoveToUndoNds(aPaM, m_pUndoNodeIndex.get(), 0);
}
nNode = aPaM.GetPoint()->nNode.GetIndex();
nCntnt = aPaM.GetPoint()->nContent.GetIndex();
@@ -332,11 +325,10 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext)
}
else
{
- // re-insert content (log out pPos before!)
- sal_uLong nMvNd = pPos->nNode.GetIndex();
- xub_StrLen nMvCnt = pPos->nContent.GetIndex();
- DELETEZ( pPos );
- MoveFromUndoNds( *pTmpDoc, nMvNd, nMvCnt, *pPam->GetMark() );
+ // re-insert content again (first detach m_pUndoNodeIndex!)
+ sal_uLong const nMvNd = m_pUndoNodeIndex->GetIndex();
+ m_pUndoNodeIndex.reset();
+ MoveFromUndoNds(*pTmpDoc, nMvNd, 0, *pPam->GetMark());
}
nNode = pPam->GetMark()->nNode.GetIndex();
nCntnt = pPam->GetMark()->nContent.GetIndex();