summaryrefslogtreecommitdiffstats
path: root/svtools
diff options
context:
space:
mode:
authorJoseph Powers <jpowers27@cox.net>2011-05-30 11:17:25 -0700
committerJoseph Powers <jpowers27@cox.net>2011-06-01 04:55:18 -0700
commit3c160621091530d2e3cc610adcfe150e760a8c51 (patch)
treec51334ebfc16a60871af62bc5a44cacc934d8933 /svtools
parentremove unused l10ntools (diff)
downloadcore-3c160621091530d2e3cc610adcfe150e760a8c51.tar.gz
core-3c160621091530d2e3cc610adcfe150e760a8c51.zip
Replace List in SvTreeList with a vector<>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/inc/svtools/treelist.hxx11
-rw-r--r--svtools/source/contnr/treelist.cxx37
2 files changed, 28 insertions, 20 deletions
diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index c9845b1c4df5..1921687061a3 100644
--- a/svtools/inc/svtools/treelist.hxx
+++ b/svtools/inc/svtools/treelist.hxx
@@ -32,6 +32,7 @@
#include "svtools/svtdllapi.h"
#include <tools/solar.h>
#include <tools/list.hxx>
+#include <vector>
#include <tools/table.hxx>
#include <tools/link.hxx>
@@ -183,11 +184,13 @@ struct SvSortData
SvListEntry* pRight;
};
+typedef ::std::vector< SvListView* > SvListView_impl;
+
class SVT_DLLPUBLIC SvTreeList
{
friend class SvListView;
- List aViewList;
+ SvListView_impl aViewList;
sal_uLong nEntryCount;
Link aCloneLink;
@@ -253,10 +256,10 @@ public:
void InsertView( SvListView* );
void RemoveView( SvListView* );
sal_uLong GetViewCount() const
- { return aViewList.Count(); }
+ { return aViewList.size(); }
- SvListView* GetView(sal_uLong nPos) const
- { return (SvListView*)aViewList.GetObject(nPos); }
+ SvListView* GetView( sal_uLong nPos ) const
+ { return ( nPos < aViewList.size() ) ? aViewList[ nPos ] : NULL; }
void Broadcast(
sal_uInt16 nActionId,
diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx
index 90ff4e7182be..67752fdcb52c 100644
--- a/svtools/source/contnr/treelist.cxx
+++ b/svtools/source/contnr/treelist.cxx
@@ -173,35 +173,40 @@ SvTreeList::~SvTreeList()
|*
*************************************************************************/
-void SvTreeList::Broadcast( sal_uInt16 nActionId, SvListEntry* pEntry1,
- SvListEntry* pEntry2, sal_uLong nPos )
-{
- sal_uLong nViewCount = aViewList.Count();
+void SvTreeList::Broadcast(
+ sal_uInt16 nActionId,
+ SvListEntry* pEntry1,
+ SvListEntry* pEntry2,
+ sal_uLong nPos
+) {
+ sal_uLong nViewCount = aViewList.size();
for( sal_uLong nCurView = 0; nCurView < nViewCount; nCurView++ )
{
- SvListView* pView = (SvListView*)aViewList.GetObject( nCurView );
+ SvListView* pView = aViewList[ nCurView ];
if( pView )
pView->ModelNotification( nActionId, pEntry1, pEntry2, nPos );
}
}
-void SvTreeList::InsertView( SvListView* pView)
+void SvTreeList::InsertView( SvListView* pView )
{
- sal_uLong nPos = aViewList.GetPos( pView );
- if ( nPos == LIST_ENTRY_NOTFOUND )
- {
- aViewList.Insert( pView, LIST_APPEND );
- nRefCount++;
+ for ( sal_uLong i = 0, n = aViewList.size(); i < n; ++i ) {
+ if ( aViewList[ i ] == pView ) {
+ return;
+ }
}
+ aViewList.push_back( pView );
+ nRefCount++;
}
void SvTreeList::RemoveView( SvListView* pView )
{
- sal_uLong nPos = aViewList.GetPos( pView );
- if ( nPos != LIST_ENTRY_NOTFOUND )
- {
- aViewList.Remove( pView );
- nRefCount--;
+ for ( SvListView_impl::iterator it = aViewList.begin(); it < aViewList.end(); ++it ) {
+ if ( *it == pView ) {
+ aViewList.erase( it );
+ nRefCount--;
+ break;
+ }
}
}