[Libreoffice-commits] .: svtools/inc svtools/source

Joseph Powers jpowers at kemper.freedesktop.org
Wed Jun 1 04:55:23 PDT 2011


 svtools/inc/svtools/treelist.hxx   |   11 +++++++----
 svtools/source/contnr/treelist.cxx |   37 +++++++++++++++++++++----------------
 2 files changed, 28 insertions(+), 20 deletions(-)

New commits:
commit 865190bf5d164045d00607d8eef3e572ef05002c
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Mon May 30 11:17:25 2011 -0700

    Replace List in SvTreeList with a vector<>

diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx
index 4eb2df2..b355290 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 4ea1867..0301229 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;
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list