diff options
author | Noel Grandin <noel@peralex.com> | 2012-07-13 15:35:23 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-17 15:33:39 +0200 |
commit | 5a4796f78f315d8518238f4194b553f671aeadf4 (patch) | |
tree | 87a074ef2cf948e0ba7d727e3a36a23883e9d69c /sw | |
parent | 49f7814515c2dca4ef39e518906f8c802d6c888f (diff) |
Convert SV_DECL_PTRARR_DEL(SwUnoCrsrTbl) to std::set
Change-Id: I0d79505e2d97b1f8608e6d6e72b317bfaa344b1d
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/docary.hxx | 10 | ||||
-rw-r--r-- | sw/source/core/crsr/unocrsr.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docbm.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/doc/doccorr.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 2 |
6 files changed, 36 insertions, 28 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 86b5bd8b33f3..8cedf2ff3318 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -30,7 +30,9 @@ #include <com/sun/star/i18n/ForbiddenCharacters.hpp> #include <vector> +#include <set> #include <algorithm> +#include <svl/svarray.hxx> class SwFieldType; class SwFmt; @@ -51,7 +53,6 @@ namespace com { namespace sun { namespace star { namespace i18n { }}}} #include <swtypes.hxx> -#include <svl/svarray.hxx> // provides some methods for generic operations on lists that contain // SwFmt* subclasses. @@ -174,8 +175,11 @@ public: using _SwRedlineTbl::GetPos; }; -typedef SwUnoCrsr* SwUnoCrsrPtr; -SV_DECL_PTRARR_DEL( SwUnoCrsrTbl, SwUnoCrsrPtr, 0 ) +class SwUnoCrsrTbl : public std::set<SwUnoCrsr*> { +public: + // the destructor will free all objects still in the set + ~SwUnoCrsrTbl(); +}; class SwOLENodes : public std::vector<SwOLENode*> {}; diff --git a/sw/source/core/crsr/unocrsr.cxx b/sw/source/core/crsr/unocrsr.cxx index 10df370c7b05..a86caec73e37 100644 --- a/sw/source/core/crsr/unocrsr.cxx +++ b/sw/source/core/crsr/unocrsr.cxx @@ -32,8 +32,6 @@ #include <docary.hxx> #include <rootfrm.hxx> -SV_IMPL_PTRARR( SwUnoCrsrTbl, SwUnoCrsrPtr ) - IMPL_FIXEDMEMPOOL_NEWDEL( SwUnoCrsr ) SwUnoCrsr::SwUnoCrsr( const SwPosition &rPos, SwPaM* pRing ) @@ -51,12 +49,9 @@ SwUnoCrsr::~SwUnoCrsr() { // then remove cursor from array SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl(); - sal_uInt16 nDelPos = rTbl.GetPos( this ); - - if( USHRT_MAX != nDelPos ) - rTbl.Remove( nDelPos ); - else { - OSL_ENSURE( !this, "UNO cursor not anymore in array" ); + if( !rTbl.erase( this ) ) + { + OSL_ENSURE( !this, "UNO Cursor nicht mehr im Array" ); } } @@ -258,4 +253,13 @@ void SwUnoTableCrsr::MakeBoxSels() } } +SwUnoCrsrTbl::~SwUnoCrsrTbl() +{ + while (!empty()) + { + delete *begin(); + erase( begin() ); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index ed3c4d1f59e7..9d6a3363e5ca 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -2662,7 +2662,7 @@ SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, sal_Bool bTblCrsr ) else pNew = new SwUnoCrsr( rPos ); - pUnoCrsrTbl->Insert( pNew, pUnoCrsrTbl->Count() ); + pUnoCrsrTbl->insert( pNew ); return pNew; } diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 1937bc99b0a1..04074c7e57c7 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1418,15 +1418,15 @@ void _SaveCntntIdx(SwDoc* pDoc, { aSave.SetTypeAndCount( 0x400, 0 ); const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl(); - for( sal_uInt16 n = 0; n < rTbl.Count(); ++n ) + for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it ) { - FOREACHPAM_START( rTbl[ n ] ) + FOREACHPAM_START( *it ) lcl_ChkPaM( rSaveArr, nNode, nCntnt, *PCURCRSR, aSave, sal_False ); aSave.IncCount(); FOREACHPAM_END() SwUnoTableCrsr* pUnoTblCrsr = - dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); + dynamic_cast<SwUnoTableCrsr*>(*it); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -1558,9 +1558,9 @@ void _RestoreCntntIdx(SwDoc* pDoc, { sal_uInt16 nCnt = 0; const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl(); - for( sal_uInt16 i = 0; i < rTbl.Count(); ++i ) + for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it ) { - FOREACHPAM_START( rTbl[ i ] ) + FOREACHPAM_START( *it ) if( aSave.GetCount() == nCnt ) { pPos = &PCURCRSR->GetBound( 0x0400 == @@ -1573,7 +1573,7 @@ void _RestoreCntntIdx(SwDoc* pDoc, break; SwUnoTableCrsr* pUnoTblCrsr = - dynamic_cast<SwUnoTableCrsr*>(rTbl[ i ]); + dynamic_cast<SwUnoTableCrsr*>(*it); if ( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -1718,9 +1718,9 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr, { sal_uInt16 nCnt = 0; const SwUnoCrsrTbl& rTbl = pDoc->GetUnoCrsrTbl(); - for( sal_uInt16 i = 0; i < rTbl.Count(); ++i ) + for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it ) { - FOREACHPAM_START( rTbl[ i ] ) + FOREACHPAM_START( *it ) if( aSave.GetCount() == nCnt ) { pPos = &PCURCRSR->GetBound( 0x0400 == @@ -1733,7 +1733,7 @@ void _RestoreCntntIdx(std::vector<sal_uLong> &rSaveArr, break; SwUnoTableCrsr* pUnoTblCrsr = - dynamic_cast<SwUnoTableCrsr*>(rTbl[ i ]); + dynamic_cast<SwUnoTableCrsr*>(*it); if ( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index 8bcc8ae95a5d..b81204643a8a 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -153,9 +153,9 @@ void PaMCorrAbs( const SwPaM& rRange, { SwUnoCrsrTbl& rTbl = const_cast<SwUnoCrsrTbl&>(pDoc->GetUnoCrsrTbl()); - for( sal_uInt16 n = 0; n < rTbl.Count(); ++n ) + for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it ) { - SwUnoCrsr *const pUnoCursor = rTbl[ n ]; + SwUnoCrsr *const pUnoCursor = *it; bool bChange = false; // has the UNO cursor been corrected? @@ -172,7 +172,7 @@ void PaMCorrAbs( const SwPaM& rRange, FOREACHPAM_END() SwUnoTableCrsr *const pUnoTblCrsr = - dynamic_cast<SwUnoTableCrsr *>(rTbl[ n ]); + dynamic_cast<SwUnoTableCrsr *>(*it); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) @@ -298,14 +298,14 @@ void PaMCorrRel( const SwNodeIndex &rOldNode, } { SwUnoCrsrTbl& rTbl = (SwUnoCrsrTbl&)pDoc->GetUnoCrsrTbl(); - for( sal_uInt16 n = 0; n < rTbl.Count(); ++n ) + for( SwUnoCrsrTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it ) { - FOREACHPAM_START( rTbl[ n ] ) + FOREACHPAM_START( *it ) lcl_PaMCorrRel1( PCURCRSR, pOldNode, aNewPos, nCntIdx ); FOREACHPAM_END() SwUnoTableCrsr* pUnoTblCrsr = - dynamic_cast<SwUnoTableCrsr*>(rTbl[ n ]); + dynamic_cast<SwUnoTableCrsr*>(*it); if( pUnoTblCrsr ) { FOREACHPAM_START( &pUnoTblCrsr->GetSelRing() ) diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 78cf03adcb98..5b14784d034f 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -249,7 +249,7 @@ SwDoc::SwDoc() maListStyleLists(), pRedlineTbl( new SwRedlineTbl ), pAutoFmtRedlnComment( 0 ), - pUnoCrsrTbl( new SwUnoCrsrTbl( 0 ) ), + pUnoCrsrTbl( new SwUnoCrsrTbl() ), pPgPViewPrtData( 0 ), pExtInputRing( 0 ), pLayouter( 0 ), |