diff options
author | Noel Grandin <noel@peralex.com> | 2012-07-17 15:54:06 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-25 14:13:46 +0200 |
commit | 31dafba4d7360746abedf93e0476f053e318077c (patch) | |
tree | 397d81b62a722d1b3aa53b9d1d44cc91544c226a | |
parent | 5da921cc53d69ed3f026542af05805decd28553c (diff) |
Convert SV_DECL_PTRARR_DEL(_SwSeqFldList) to std::vector
Change-Id: I40802ba1e7b2e2f6f57c59c4d66b544604d01ce5
-rw-r--r-- | sw/inc/expfld.hxx | 22 | ||||
-rw-r--r-- | sw/source/core/edit/edattr.cxx | 3 | ||||
-rw-r--r-- | sw/source/core/fields/expfld.cxx | 21 | ||||
-rw-r--r-- | sw/source/ui/fldui/fldref.cxx | 3 |
4 files changed, 26 insertions, 23 deletions
diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx index 0663ef5856cc..ed7e9d5e4c05 100644 --- a/sw/inc/expfld.hxx +++ b/sw/inc/expfld.hxx @@ -32,6 +32,7 @@ #include <fldbas.hxx> #include <cellfml.hxx> #include <set> +#include <vector> class SfxPoolItem; class SwTxtNode; @@ -58,15 +59,24 @@ struct _SeqFldLstElem : sDlgEntry( rStr ), nSeqNo( nNo ) {} }; -SV_DECL_PTRARR_DEL( _SwSeqFldList, _SeqFldLstElem*, 10 ) -class SW_DLLPUBLIC SwSeqFldList : public _SwSeqFldList +class SW_DLLPUBLIC SwSeqFldList { + std::vector<_SeqFldLstElem*> maData; public: - SwSeqFldList() : _SwSeqFldList( 10 ) {} - - sal_Bool InsertSort( _SeqFldLstElem* ); - sal_Bool SeekEntry( const _SeqFldLstElem& , sal_uInt16* pPos = 0 ); + ~SwSeqFldList() + { + for( std::vector<_SeqFldLstElem*>::const_iterator it = maData.begin(); it != maData.end(); ++it ) + delete *it; + } + + bool InsertSort(_SeqFldLstElem* pNew); + bool SeekEntry(const _SeqFldLstElem& rNew, sal_uInt16* pPos) const; + + sal_uInt16 Count() { return maData.size(); } + _SeqFldLstElem* operator[](sal_uInt16 nIndex) { return maData[nIndex]; } + const _SeqFldLstElem* operator[](sal_uInt16 nIndex) const { return maData[nIndex]; } + void Clear() { maData.clear(); } }; class SwGetExpFieldType : public SwValueFieldType diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index bea269b44cea..8d78f072c39e 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -338,8 +338,7 @@ bool SwEditShell::HasFtns( bool bEndNotes ) const // gebe Liste aller Fussnoten und deren Anfangstexte sal_uInt16 SwEditShell::GetSeqFtnList( SwSeqFldList& rList, bool bEndNotes ) { - if( rList.Count() ) - rList.Remove( 0, rList.Count() ); + rList.Clear(); sal_uInt16 n, nFtnCnt = pDoc->GetFtnIdxs().Count(); SwTxtFtn* pTxtFtn; diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 29aa92739067..acf402a930d5 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -68,8 +68,6 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::text; using ::rtl::OUString; -SV_IMPL_PTRARR( _SwSeqFldList, _SeqFldLstElem* ) - //----------------------------------------------------------------------------- sal_Int16 lcl_SubTypeToAPI(sal_uInt16 nSubType) { @@ -596,8 +594,7 @@ extern void InsertSort( std::vector<sal_uInt16>& rArr, sal_uInt16 nIdx, sal_uInt sal_uInt16 SwSetExpFieldType::GetSeqFldList( SwSeqFldList& rList ) { - if( rList.Count() ) - rList.Remove( 0, rList.Count() ); + rList.Clear(); SwIterator<SwFmtFld,SwFieldType> aIter( *this ); const SwTxtNode* pNd; @@ -705,7 +702,7 @@ bool SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId ) return true; } -sal_Bool SwSeqFldList::InsertSort( _SeqFldLstElem* pNew ) +bool SwSeqFldList::InsertSort( _SeqFldLstElem* pNew ) { sal_Unicode* p = pNew->sDlgEntry.GetBufferAccess(); while( *p ) @@ -716,15 +713,15 @@ sal_Bool SwSeqFldList::InsertSort( _SeqFldLstElem* pNew ) } sal_uInt16 nPos; - sal_Bool bRet = SeekEntry( *pNew, &nPos ); + bool bRet = SeekEntry( *pNew, &nPos ); if( !bRet ) - C40_INSERT( _SeqFldLstElem, pNew, nPos ); + maData.insert( maData.begin() + nPos, pNew ); return bRet; } -sal_Bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) +bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) const { - sal_uInt16 nO = Count(), nM, nU = 0; + sal_uInt16 nO = maData.size(), nM, nU = 0; if( nO > 0 ) { CollatorWrapper & rCaseColl = ::GetAppCaseCollator(), @@ -746,7 +743,7 @@ sal_Bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) //#59900# Die Sortierung soll die Nummer korrekt einordnen //also "10" nach "9" und nicht "10" nach "1" - const String& rTmp1 = (*((_SeqFldLstElem**)pData + nM))->sDlgEntry; + const String& rTmp1 = maData[nM]->sDlgEntry; xub_StrLen nFndPos1 = 0; String sNum1( rTmp1.GetToken( 0, ' ', nFndPos1 )); sal_Int32 nCmp; @@ -765,7 +762,7 @@ sal_Bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) if( 0 == nCmp ) { if( pP ) *pP = nM; - return sal_True; + return true; } else if( 0 < nCmp ) nU = nM + 1; @@ -776,7 +773,7 @@ sal_Bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP ) } } if( pP ) *pP = nU; - return sal_False; + return false; } /*-------------------------------------------------------------------- diff --git a/sw/source/ui/fldui/fldref.cxx b/sw/source/ui/fldui/fldref.cxx index 2e96d4fc1935..571540e17e7e 100644 --- a/sw/source/ui/fldui/fldref.cxx +++ b/sw/source/ui/fldui/fldref.cxx @@ -50,9 +50,6 @@ #include <IDocumentMarkAccess.hxx> #include <ndtxt.hxx> -// sw/inc/expfld.hxx -SV_IMPL_PTRARR( _SwSeqFldList, _SeqFldLstElem* ) - #define REFFLDFLAG 0x4000 #define REFFLDFLAG_BOOKMARK 0x4800 #define REFFLDFLAG_FOOTNOTE 0x5000 |