diff options
author | Noel Grandin <noel@peralex.com> | 2012-05-21 15:49:21 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-05-25 00:17:05 +0200 |
commit | 426389981c6eb4231c8889c65e848b615b290b3a (patch) | |
tree | a840bc16107d696b4218c7b85533d26a90f35403 /sw | |
parent | f9adf2b5b395dd443d1edfea1b23cb75f2152358 (diff) |
Convert SV_DECL_PTRARR_DEL(SwTOXTypes) to std::vector
Change-Id: Ibf67e586082132f370659a4c79415d5928758d3a
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/docary.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/tox/tox.cxx | 13 |
5 files changed, 33 insertions, 22 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index ecc6f39614bd..9de2213e9148 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -67,8 +67,12 @@ SV_DECL_PTRARR_DEL(SwCharFmts,SwCharFmtPtr,4) SV_DECL_PTRARR_DEL( SwFldTypes, SwFldTypePtr, INIT_FLDTYPES ) -typedef SwTOXType* SwTOXTypePtr; -SV_DECL_PTRARR_DEL( SwTOXTypes, SwTOXTypePtr, 0 ) +class SwTOXTypes : public std::vector<SwTOXType*> { +public: + // the destructor will free all objects still in the vector + ~SwTOXTypes(); + sal_uInt16 GetPos(const SwTOXType* pTOXType) const; +}; // Array of Undo-history. typedef SwSectionFmt* SwSectionFmtPtr; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 9359420a6188..de9efafd12fa 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -144,8 +144,6 @@ using ::rtl::OUString; // Page descriptors SV_IMPL_PTRARR(SwPageDescs,SwPageDescPtr); -// Table Of ... -SV_IMPL_PTRARR( SwTOXTypes, SwTOXTypePtr ) // Field types SV_IMPL_PTRARR( SwFldTypes, SwFldTypePtr) diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index ed77b8c5d2db..4145b397d65f 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -545,12 +545,12 @@ SwDoc::~SwDoc() // Old - deletion without a Flag is expensive, because we send a Modify // aTOXTypes.DeleteAndDestroy( 0, aTOXTypes.Count() ); { - for( sal_uInt16 n = pTOXTypes->Count(); n; ) + for( sal_uInt16 n = pTOXTypes->size(); n; ) { (*pTOXTypes)[ --n ]->SetInDocDTOR(); delete (*pTOXTypes)[ n ]; } - pTOXTypes->Remove( 0, pTOXTypes->Count() ); + pTOXTypes->clear(); } delete pDefTOXBases; @@ -1038,19 +1038,19 @@ void SwDoc::InitTOXTypes() { ShellResource* pShellRes = ViewShell::GetShellRes(); SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pTOXTypes->push_back( pNew ); pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pTOXTypes->push_back( pNew ); pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pTOXTypes->push_back( pNew ); pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pTOXTypes->push_back( pNew ); pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pTOXTypes->push_back( pNew ); pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pTOXTypes->push_back( pNew ); pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pTOXTypes->push_back( pNew ); } void SwDoc::ReplaceDefaults(const SwDoc& rSource) diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 426ecf83d3a9..11488d743e5c 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -604,28 +604,26 @@ sal_Bool SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, sal_Bool bDelNodes ) --------------------------------------------------------------------*/ sal_uInt16 SwDoc::GetTOXTypeCount(TOXTypes eTyp) const { - const SwTOXTypePtr * ppTTypes = pTOXTypes->GetData(); sal_uInt16 nCnt = 0; - for( sal_uInt16 n = 0; n < pTOXTypes->Count(); ++n, ++ppTTypes ) - if( eTyp == (*ppTTypes)->GetType() ) + for( sal_uInt16 n = 0; n < pTOXTypes->size(); ++n ) + if( eTyp == (*pTOXTypes)[n]->GetType() ) ++nCnt; return nCnt; } const SwTOXType* SwDoc::GetTOXType( TOXTypes eTyp, sal_uInt16 nId ) const { - const SwTOXTypePtr * ppTTypes = pTOXTypes->GetData(); sal_uInt16 nCnt = 0; - for( sal_uInt16 n = 0; n < pTOXTypes->Count(); ++n, ++ppTTypes ) - if( eTyp == (*ppTTypes)->GetType() && nCnt++ == nId ) - return (*ppTTypes); + for( sal_uInt16 n = 0; n < pTOXTypes->size(); ++n ) + if( eTyp == (*pTOXTypes)[n]->GetType() && nCnt++ == nId ) + return (*pTOXTypes)[n]; return 0; } const SwTOXType* SwDoc::InsertTOXType( const SwTOXType& rTyp ) { SwTOXType * pNew = new SwTOXType( rTyp ); - pTOXTypes->Insert( pNew, pTOXTypes->Count() ); + pTOXTypes->push_back( pNew ); return pNew; } diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx index fb47416823cb..06a3ef85153c 100644 --- a/sw/source/core/tox/tox.cxx +++ b/sw/source/core/tox/tox.cxx @@ -551,7 +551,7 @@ SwTOXBase& SwTOXBase::CopyTOXBase( SwDoc* pDoc, const SwTOXBase& rSource ) // type not in pDoc, so create it now const SwTOXTypes& rTypes = pDoc->GetTOXTypes(); sal_Bool bFound = sal_False; - for( sal_uInt16 n = rTypes.Count(); n; ) + for( sal_uInt16 n = rTypes.size(); n; ) { const SwTOXType* pCmp = rTypes[ --n ]; if( pCmp->GetType() == pType->GetType() && @@ -931,4 +931,15 @@ const SwFormTokens& SwForm::GetPattern(sal_uInt16 nLevel) const return aPattern[nLevel]; } +sal_uInt16 SwTOXTypes::GetPos(const SwTOXType* pTOXType) const +{ + const_iterator it = std::find(begin(), end(), pTOXType); + return it == end() ? USHRT_MAX : it - begin(); +} + +SwTOXTypes::~SwTOXTypes() +{ + for(const_iterator it = begin(); it != end(); ++it) + delete *it; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |