diff options
author | Noel Grandin <noel@peralex.com> | 2012-05-22 10:54:29 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-05-25 00:17:06 +0200 |
commit | da9bf1ee2f712748dd94080fe8fc7fd90348d08f (patch) | |
tree | 4dc647ffa6977945180b41cde7016b3ee39c7a84 /sw | |
parent | 74dc44a67c556462185f969f694ef2d3df1f893e (diff) |
Convert SV_DECL_PTRARR_DEL(SwPageDescs) to std::vector
Change-Id: I2301c1f237b1b08926c80942f459ba6062ed457d
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/doc.hxx | 10 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/docdesc.cxx | 16 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/doc/poolfmt.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/pagedesc.cxx | 6 |
7 files changed, 37 insertions, 25 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 2552022aee12..a8c5c2e5450b 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -240,8 +240,12 @@ namespace sfx2 { } // PageDescriptor-interface, Array because of inlines. -typedef SwPageDesc* SwPageDescPtr; -SV_DECL_PTRARR_DEL( SwPageDescs, SwPageDescPtr, 4 ) +class SwPageDescs : public std::vector<SwPageDesc*> +{ +public: + // the destructor will free all objects still in the vector + ~SwPageDescs(); +}; // forward declaration void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem ); @@ -1332,7 +1336,7 @@ public: sal_Int32 nDocPageCount ); // PageDescriptor interface. - sal_uInt16 GetPageDescCnt() const { return aPageDescs.Count(); } + sal_uInt16 GetPageDescCnt() const { return aPageDescs.size(); } const SwPageDesc& GetPageDesc( const sal_uInt16 i ) const { return *aPageDescs[i]; } SwPageDesc* FindPageDescByName( const String& rName, sal_uInt16* pPos = 0 ) const; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index f9b829fe1766..b7414dbedc02 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -142,9 +142,6 @@ using namespace ::com::sun::star; using ::rtl::OUString; -// Page descriptors -SV_IMPL_PTRARR(SwPageDescs,SwPageDescPtr); - /* IInterface */ sal_Int32 SwDoc::acquire() { diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 0ca72d72d0b9..4d26645327d2 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -187,7 +187,7 @@ void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest, void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged ) { - OSL_ENSURE( i < aPageDescs.Count(), "PageDescs is out of range." ); + OSL_ENSURE( i < aPageDescs.size(), "PageDescs is out of range." ); SwPageDesc *pDesc = aPageDescs[i]; SwRootFrm* pTmpRoot = GetCurrentLayout(); @@ -452,7 +452,7 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel) } } - for ( sal_uInt16 j = 0; j < aPageDescs.Count(); ++j ) + for ( sal_uInt16 j = 0; j < aPageDescs.size(); ++j ) { if ( aPageDescs[j]->GetFollow() == pDel ) { @@ -486,7 +486,7 @@ void SwDoc::BroadcastStyleOperation(String rName, SfxStyleFamily eFamily, void SwDoc::DelPageDesc( sal_uInt16 i, sal_Bool bBroadcast ) { - OSL_ENSURE( i < aPageDescs.Count(), "PageDescs is out of range." ); + OSL_ENSURE( i < aPageDescs.size(), "PageDescs is out of range." ); OSL_ENSURE( i != 0, "You cannot delete the default Pagedesc."); if ( i == 0 ) return; @@ -505,7 +505,7 @@ void SwDoc::DelPageDesc( sal_uInt16 i, sal_Bool bBroadcast ) PreDelPageDesc(pDel); // #i7983# - aPageDescs.Remove( i ); + aPageDescs.erase( aPageDescs.begin() + i ); delete pDel; SetModified(); } @@ -546,7 +546,7 @@ sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy, pNew->GetMaster().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) ); pNew->GetLeft().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) ); } - aPageDescs.Insert( pNew, aPageDescs.Count() ); + aPageDescs.push_back( pNew ); if (bBroadcast) BroadcastStyleOperation(rName, SFX_STYLE_FAMILY_PAGE, @@ -558,7 +558,7 @@ sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy, } SetModified(); - return (aPageDescs.Count()-1); + return (aPageDescs.size()-1); } SwPageDesc* SwDoc::FindPageDescByName( const String& rName, sal_uInt16* pPos ) const @@ -566,7 +566,7 @@ SwPageDesc* SwDoc::FindPageDescByName( const String& rName, sal_uInt16* pPos ) c SwPageDesc* pRet = 0; if( pPos ) *pPos = USHRT_MAX; - for( sal_uInt16 n = 0, nEnd = aPageDescs.Count(); n < nEnd; ++n ) + for( sal_uInt16 n = 0, nEnd = aPageDescs.size(); n < nEnd; ++n ) if( aPageDescs[ n ]->GetName() == rName ) { pRet = aPageDescs[ n ]; @@ -781,7 +781,7 @@ sal_Bool SwDoc::FindPageDesc( const String & rName, sal_uInt16 * pFound) { sal_Bool bResult = sal_False; sal_uInt16 nI; - for (nI = 0; nI < aPageDescs.Count(); nI++) + for (nI = 0; nI < aPageDescs.size(); nI++) { if (aPageDescs[nI]->GetName() == rName) { diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index ab4e43b9e22e..751c3ad77ca8 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -1888,7 +1888,7 @@ SwGrfFmtColl* SwDoc::CopyGrfColl( const SwGrfFmtColl& rColl ) SwPageDesc* lcl_FindPageDesc( const SwPageDescs& rArr, const String& rName ) { - for( sal_uInt16 n = rArr.Count(); n; ) + for( sal_uInt16 n = rArr.size(); n; ) { SwPageDesc* pDesc = rArr[ --n ]; if( pDesc->GetName() == rName ) @@ -2157,7 +2157,7 @@ void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles ) if (bIncludePageStyles) { // and now the page templates - nCnt = rSource.aPageDescs.Count(); + nCnt = rSource.aPageDescs.size(); if( nCnt ) { // a different Doc -> Number formatter needs to be merged @@ -2172,7 +2172,7 @@ void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles ) } // 2nd step: Copy all attributes, set the right parents - for( nCnt = rSource.aPageDescs.Count(); nCnt; ) + for( nCnt = rSource.aPageDescs.size(); nCnt; ) { SwPageDesc *pSrc = rSource.aPageDescs[ --nCnt ]; CopyPageDesc( *pSrc, *::lcl_FindPageDesc( aPageDescs, pSrc->GetName() )); diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 52e27b845bae..3ed8f0aae473 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -98,6 +98,7 @@ #include <MarkManager.hxx> #include <UndoManager.hxx> #include <unochart.hxx> +#include <fldbas.hxx> #include <cmdid.h> // for the default printer in SetJob @@ -385,7 +386,7 @@ SwDoc::SwDoc() pGrfFmtCollTbl->Insert(pDfltGrfFmtColl, 0 ); // Create PageDesc, EmptyPageFmt and ColumnFmt - if ( !aPageDescs.Count() ) + if ( aPageDescs.empty() ) GetPageDescFromPool( RES_POOLPAGE_STANDARD ); // Set to "Empty Page" @@ -566,7 +567,9 @@ SwDoc::~SwDoc() // there are still Flys registered at that point, we have a problem. // (This comment might have been translated incorrectly. Blame the bad // German original) - aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() ); + BOOST_FOREACH(SwPageDesc *pPageDesc, aPageDescs) + delete pPageDesc; + aPageDescs.clear(); // Delete content selections. // Don't wait for the SwNodes dtor to destroy them; so that Formats @@ -818,8 +821,10 @@ void SwDoc::ClearDoc() pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) ); // remove the dummy pagedec from the array and delete all the old ones - aPageDescs.Remove( nDummyPgDsc ); - aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() ); + aPageDescs.erase( aPageDescs.begin() + nDummyPgDsc ); + BOOST_FOREACH(SwPageDesc *pPageDesc, aPageDescs) + delete pPageDesc; + aPageDescs.clear(); // Delete for Collections // So that we get rid of the dependencies @@ -856,8 +861,8 @@ void SwDoc::ClearDoc() GetPageDescFromPool( RES_POOLPAGE_STANDARD ); pFirstNd->ChgFmtColl( GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); - nDummyPgDsc = aPageDescs.Count(); - aPageDescs.Insert( pDummyPgDsc, nDummyPgDsc ); + nDummyPgDsc = aPageDescs.size(); + aPageDescs.push_back( pDummyPgDsc ); // set the layout back to the new standard pagedesc pFirstNd->ResetAllAttr(); // delete now the dummy pagedesc diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index 6d7fb9c6bc1b..467bb384f692 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -1436,7 +1436,7 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage ) SwPageDesc *pNewPgDsc; sal_uInt16 n; - for( n = 0; n < aPageDescs.Count(); ++n ) + for( n = 0; n < aPageDescs.size(); ++n ) if( nId == ( pNewPgDsc = aPageDescs[ n ] )->GetPoolFmtId() ) { return pNewPgDsc; @@ -2274,7 +2274,7 @@ bool SwDoc::IsPoolPageDescUsed( sal_uInt16 nId ) const "Wrong AutoFormat Id" ); SwPageDesc *pNewPgDsc = 0; sal_Bool bFnd = sal_False; - for( sal_uInt16 n = 0; !bFnd && n < aPageDescs.Count(); ++n ) + for( sal_uInt16 n = 0; !bFnd && n < aPageDescs.size(); ++n ) { pNewPgDsc = aPageDescs[ n ]; if( nId == pNewPgDsc->GetPoolFmtId() ) diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx index 04fd78cdbffa..ffe37a8d6945 100644 --- a/sw/source/core/layout/pagedesc.cxx +++ b/sw/source/core/layout/pagedesc.cxx @@ -479,4 +479,10 @@ SwPageDescExt::operator SwPageDesc() const return aResult; } +SwPageDescs::~SwPageDescs() +{ + for(const_iterator it = begin(); it != end(); ++it) + delete *it; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |