diff options
author | Noel Grandin <noel@peralex.com> | 2012-06-28 11:02:42 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-04 23:23:22 +0200 |
commit | ebde6c7e3e816980dfe32086783a165f3d0019b1 (patch) | |
tree | 03d4bf793e73cef523937021d593d3d460436da2 | |
parent | a87c24fcfe1d8842d892185d6f9f2e07c52c3804 (diff) |
Convert aItems field of SvLBoxEntry class from SvPtrarr to std::vector
Change-Id: I96d676ded52ebdf0f68b051b06cecf717d56e813
-rw-r--r-- | svtools/inc/svtools/svlbox.hxx | 16 | ||||
-rw-r--r-- | svtools/source/contnr/svlbox.cxx | 13 |
2 files changed, 16 insertions, 13 deletions
diff --git a/svtools/inc/svtools/svlbox.hxx b/svtools/inc/svtools/svlbox.hxx index 92aa9460e692..ea18d052dbfd 100644 --- a/svtools/inc/svtools/svlbox.hxx +++ b/svtools/inc/svtools/svlbox.hxx @@ -183,24 +183,28 @@ class SVT_DLLPUBLIC SvLBoxEntry : public SvListEntry { friend class SvLBox; - SvPtrarr aItems; - void* pUserData; - sal_uInt16 nEntryFlags; + std::vector<SvLBoxItem*> aItems; + void* pUserData; + sal_uInt16 nEntryFlags; SVT_DLLPRIVATE void DeleteItems_Impl(); public: SvLBoxEntry(); virtual ~SvLBoxEntry(); - sal_uInt16 ItemCount() const { return (sal_uInt16)aItems.Count(); } + sal_uInt16 ItemCount() const { return (sal_uInt16)aItems.size(); } // DARF NUR GERUFEN WERDEN, WENN DER EINTRAG NOCH NICHT IM MODEL // EINGEFUEGT IST, DA SONST FUER DAS ITEM KEINE VIEW-ABHAENGIGEN // DATEN ALLOZIERT WERDEN! void AddItem( SvLBoxItem* pItem ); void ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos ); - SvLBoxItem* GetItem( sal_uInt16 nPos ) const { return (SvLBoxItem*)aItems.GetObject(nPos ); } + SvLBoxItem* GetItem( sal_uInt16 nPos ) const { return aItems[nPos]; } SvLBoxItem* GetFirstItem( sal_uInt16 nId ); - sal_uInt16 GetPos( SvLBoxItem* pItem ) const { return aItems.GetPos( pItem ); } + sal_uInt16 GetPos( SvLBoxItem* pItem ) const + { + std::vector<SvLBoxItem*>::const_iterator it = std::find( aItems.begin(), aItems.end(), pItem ); + return it == aItems.end() ? USHRT_MAX : it - aItems.begin(); + } void* GetUserData() const { return pUserData; } void SetUserData( void* pPtr ) { pUserData = pPtr; } virtual void Clone( SvListEntry* pSource ); diff --git a/svtools/source/contnr/svlbox.cxx b/svtools/source/contnr/svlbox.cxx index 617428d60937..d0d30adbdc41 100644 --- a/svtools/source/contnr/svlbox.cxx +++ b/svtools/source/contnr/svlbox.cxx @@ -408,21 +408,21 @@ SvLBoxEntry::~SvLBoxEntry() void SvLBoxEntry::DeleteItems_Impl() { DBG_CHKTHIS(SvLBoxEntry,0); - sal_uInt16 nCount = aItems.Count(); + sal_uInt16 nCount = aItems.size(); while( nCount ) { nCount--; - SvLBoxItem* pItem = (SvLBoxItem*)aItems.GetObject( nCount ); + SvLBoxItem* pItem = aItems[ nCount ]; delete pItem; } - aItems.Remove(0, aItems.Count() ); + aItems.clear(); } void SvLBoxEntry::AddItem( SvLBoxItem* pItem ) { DBG_CHKTHIS(SvLBoxEntry,0); - aItems.Insert( pItem, aItems.Count() ); + aItems.push_back( pItem ); } void SvLBoxEntry::Clone( SvListEntry* pSource ) @@ -461,15 +461,14 @@ void SvLBoxEntry::ReplaceItem( SvLBoxItem* pNewItem, sal_uInt16 nPos ) SvLBoxItem* pOld = GetItem( nPos ); if ( pOld ) { - aItems.Remove( nPos ); - aItems.Insert( pNewItem, nPos ); + aItems[ nPos ] = pNewItem; delete pOld; } } SvLBoxItem* SvLBoxEntry::GetFirstItem( sal_uInt16 nId ) { - sal_uInt16 nCount = aItems.Count(); + sal_uInt16 nCount = aItems.size(); sal_uInt16 nCur = 0; SvLBoxItem* pItem; while( nCur < nCount ) |