diff options
author | Michael Stahl <mst@openoffice.org> | 2010-12-15 09:14:12 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2010-12-15 09:14:12 +0100 |
commit | 16045587b5442195b4a3936437d780d62f7c42bc (patch) | |
tree | 934898840612b43e3fb299530bd4cb2f6d225364 | |
parent | 65a3c2385c45d2f7fc4bfdbe97be2d3de46bc3af (diff) |
undoapi: #i115383#: replace SwUndos with STL vector
-rw-r--r-- | sw/inc/dbgoutsw.hxx | 2 | ||||
-rw-r--r-- | sw/inc/docary.hxx | 7 | ||||
-rw-r--r-- | sw/inc/undobj.hxx | 12 | ||||
-rw-r--r-- | sw/source/core/doc/dbgoutsw.cxx | 35 | ||||
-rw-r--r-- | sw/source/core/undo/makefile.mk | 3 | ||||
-rw-r--r-- | sw/source/core/undo/undobj.cxx | 1 | ||||
-rw-r--r-- | sw/source/core/undo/untbl.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/undo/untblk.cxx | 26 |
8 files changed, 29 insertions, 75 deletions
diff --git a/sw/inc/dbgoutsw.hxx b/sw/inc/dbgoutsw.hxx index e1822bd4ace9..1a33f41f69d3 100644 --- a/sw/inc/dbgoutsw.hxx +++ b/sw/inc/dbgoutsw.hxx @@ -46,7 +46,6 @@ struct SwPosition; class SwPaM; class SwNodeNum; class SwUndo; -class SwUndos; class SwRect; class SwFrmFmt; class SwFrmFmts; @@ -86,7 +85,6 @@ SW_DLLPUBLIC const char * dbg_out(const SwPosition & rPos); SW_DLLPUBLIC const char * dbg_out(const SwPaM & rPam); SW_DLLPUBLIC const char * dbg_out(const SwNodeNum & rNum); SW_DLLPUBLIC const char * dbg_out(const SwUndo & rUndo); -SW_DLLPUBLIC const char * dbg_out(const SwUndos & rUndos); SW_DLLPUBLIC const char * dbg_out(const SwRewriter & rRewriter); SW_DLLPUBLIC const char * dbg_out(const SwNumRule & rRule); SW_DLLPUBLIC const char * dbg_out(const SwTxtFmtColl & rFmt); diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 2b5ad3fd5203..379db4ca0559 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -71,13 +71,6 @@ SV_DECL_PTRARR_DEL( SwFldTypes, SwFldTypePtr, INIT_FLDTYPES, GROW_FLDTYPES ) typedef SwTOXType* SwTOXTypePtr; SV_DECL_PTRARR_DEL( SwTOXTypes, SwTOXTypePtr, 0, 1 ) -// Undo -#define INIT_UNDOS 5 -#define GROW_UNDOS 5 -// Das Array der Undo-History -typedef SwUndo* SwUndoPtr; -SV_DECL_PTRARR_DEL( SwUndos, SwUndoPtr, INIT_UNDOS, GROW_UNDOS ) - typedef SwSectionFmt* SwSectionFmtPtr; SV_DECL_PTRARR_DEL(SwSectionFmts,SwSectionFmtPtr,0,4) diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index 6cf431f0df31..8becca4114ba 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -79,7 +79,6 @@ class SvxTabStopItem; class SwDDEFieldType; class Graphic; class SwGrfNode; -class SwUndos; class SwFtnInfo; class SwEndNoteInfo; class SwNodeIndex; @@ -795,12 +794,15 @@ public: }; -// Basis-Klasse fuer Insert von Dokument, Glossaries und Kopieren + +class SwUndoInsLayFmt; + +// base class for insertion of Document, Glossaries and Copy class SwUndoInserts : public SwUndo, public SwUndRng, private SwUndoSaveCntnt { SwTxtFmtColl *pTxtFmtColl, *pLastNdColl; SvPtrarr* pFrmFmts; - SwUndos* pFlyUndos; + ::std::vector< ::boost::shared_ptr<SwUndoInsLayFmt> > m_FlyUndos; SwRedlineData* pRedlData; BOOL bSttWasTxtNd; protected: @@ -928,11 +930,13 @@ public: virtual void RedoImpl( ::sw::UndoRedoContext & ); }; +class SwUndoTblNumFmt; + class SwUndoTblAutoFmt : public SwUndo { ULONG nSttNode; _SaveTable* pSaveTbl; - SwUndos* pUndos; + ::std::vector< ::boost::shared_ptr<SwUndoTblNumFmt> > m_Undos; BOOL bSaveCntntAttr; void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext); diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index 91d021402965..705bd08e7989 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -843,41 +843,6 @@ SW_DLLPUBLIC const char * dbg_out(SwOutlineNodes & rNodes) return dbg_out(lcl_dbg_out(rNodes)); } -#if 0 -String lcl_dbg_out(const SwUndos & rUndos) -{ - USHORT nIndent = 0; - - String aStr("[\n", RTL_TEXTENCODING_ASCII_US); - - for (USHORT n = 0; n < rUndos.Count(); n++) - { - SwUndo * pUndo = rUndos[n]; - - if (pUndo->GetId() == UNDO_END) - nIndent--; - - for (USHORT nI = 0; n < nIndent; nI++) - aStr += String(" ", RTL_TEXTENCODING_ASCII_US); - - aStr += lcl_dbg_out(*pUndo); - aStr += String("\n", RTL_TEXTENCODING_ASCII_US); - - if (pUndo->GetId() == UNDO_START) - nIndent++; - } - - aStr += String("]\n", RTL_TEXTENCODING_ASCII_US); - - return aStr; -} - -SW_DLLPUBLIC const char * dbg_out(const SwUndos & rUndos) -{ - return dbg_out(lcl_dbg_out(rUndos)); -} -#endif - String lcl_dbg_out(const SwRewriter & rRewriter) { (void) rRewriter; diff --git a/sw/source/core/undo/makefile.mk b/sw/source/core/undo/makefile.mk index 38285c909187..e14b7042720c 100644 --- a/sw/source/core/undo/makefile.mk +++ b/sw/source/core/undo/makefile.mk @@ -52,7 +52,8 @@ EXCEPTIONSFILES = \ $(SLO)$/undraw.obj \ $(SLO)$/unnum.obj \ $(SLO)$/unovwr.obj \ - $(SLO)$/untbl.obj + $(SLO)$/untbl.obj \ + $(SLO)$/untblk.obj \ SLOFILES = \ $(SLO)$/SwRewriter.obj \ diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 144b15c6b725..f2219822d5dc 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -68,7 +68,6 @@ public: #endif }; -SV_IMPL_PTRARR( SwUndos, SwUndo*) SV_IMPL_PTRARR( SwRedlineSaveDatas, SwRedlineSaveDataPtr ) diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 1f274a7e6c9e..e30c80c26ad6 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -1473,7 +1473,7 @@ void SwUndoAttrTbl::RedoImpl(::sw::UndoRedoContext & rContext) SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& rAFmt ) : SwUndo( UNDO_TABLE_AUTOFMT ), - nSttNode( rTblNd.GetIndex() ), pUndos( 0 ), + nSttNode( rTblNd.GetIndex() ), bSaveCntntAttr( FALSE ) { pSaveTbl = new _SaveTable( rTblNd.GetTable() ); @@ -1489,16 +1489,13 @@ SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd, SwUndoTblAutoFmt::~SwUndoTblAutoFmt() { - delete pUndos; delete pSaveTbl; } void SwUndoTblAutoFmt::SaveBoxCntnt( const SwTableBox& rBox ) { - SwUndoTblNumFmt* p = new SwUndoTblNumFmt( rBox ); - if( !pUndos ) - pUndos = new SwUndos( 8, 8 ); - pUndos->Insert( p, pUndos->Count() ); + ::boost::shared_ptr<SwUndoTblNumFmt> const p(new SwUndoTblNumFmt(rBox)); + m_Undos.push_back(p); } @@ -1515,12 +1512,13 @@ SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext) if( bSaveCntntAttr ) pOrig->SaveCntntAttrs( &rDoc ); - if( pUndos && bUndo ) - for( USHORT n = pUndos->Count(); n; ) + if (bUndo) + { + for (size_t n = m_Undos.size(); 0 < n; --n) { - static_cast<SwUndoTblNumFmt*>(pUndos->GetObject( --n )) - ->UndoImpl(rContext); + m_Undos.at(n-1)->UndoImpl(rContext); } + } pSaveTbl->RestoreAttr( pTblNd->GetTable(), !bUndo ); delete pSaveTbl; diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index a32ef2c8b443..e0d26f1255c6 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -45,7 +45,7 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) : SwUndo( nUndoId ), SwUndRng( rPam ), - pTxtFmtColl( 0 ), pLastNdColl(0), pFrmFmts( 0 ), pFlyUndos(0), pRedlData( 0 ), + pTxtFmtColl( 0 ), pLastNdColl(0), pFrmFmts( 0 ), pRedlData( 0 ), bSttWasTxtNd( TRUE ), nNdDiff( 0 ), pPos( 0 ), nSetPos( 0 ) { pHistory = new SwHistory; @@ -116,7 +116,6 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, BOOL bScanFlys, { // dann alle neuen Flys zusammen sammeln !! SwDoc* pDoc = (SwDoc*)rPam.GetDoc(); - pFlyUndos = new SwUndos(); USHORT nFndPos, nArrLen = pDoc->GetSpzFrmFmts()->Count(); for( USHORT n = 0; n < nArrLen; ++n ) { @@ -130,16 +129,15 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, BOOL bScanFlys, if( !pFrmFmts || USHRT_MAX == ( nFndPos = pFrmFmts->GetPos( pFmt ) ) ) { - SwUndoInsLayFmt* pFlyUndo = new SwUndoInsLayFmt( pFmt,0,0 ); - pFlyUndos->Insert( pFlyUndo, pFlyUndos->Count() ); + ::boost::shared_ptr<SwUndoInsLayFmt> const pFlyUndo( + new SwUndoInsLayFmt(pFmt, 0, 0)); + m_FlyUndos.push_back(pFlyUndo); } else pFrmFmts->Remove( nFndPos ); } } delete pFrmFmts, pFrmFmts = 0; - if( !pFlyUndos->Count() ) - delete pFlyUndos, pFlyUndos = 0; } } @@ -166,7 +164,6 @@ SwUndoInserts::~SwUndoInserts() delete pPos; } delete pFrmFmts; - delete pFlyUndos; delete pRedlData; } @@ -215,12 +212,12 @@ void SwUndoInserts::UndoImpl(::sw::UndoRedoContext & rContext) } } - if( pFlyUndos ) + if (m_FlyUndos.size()) { ULONG nTmp = pPam->GetPoint()->nNode.GetIndex(); - for( USHORT n = pFlyUndos->Count(); n; ) + for (size_t n = m_FlyUndos.size(); 0 < n; --n) { - (*pFlyUndos)[ --n ]->UndoImpl(rContext); + m_FlyUndos[ n-1 ]->UndoImpl(rContext); } nNdDiff += nTmp - pPam->GetPoint()->nNode.GetIndex(); } @@ -316,11 +313,10 @@ void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext) pTxtNd->ChgFmtColl( pLastNdColl ); } - if( pFlyUndos ) - for( USHORT n = pFlyUndos->Count(); n; ) - { - (*pFlyUndos)[ --n ]->RedoImpl(rContext); - } + for (size_t n = m_FlyUndos.size(); 0 < n; --n) + { + m_FlyUndos[ n-1 ]->RedoImpl(rContext); + } pHistory->Rollback( pDoc, nSetPos ); |