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

Joseph Powers jpowers at kemper.freedesktop.org
Wed Jun 22 19:57:02 PDT 2011


 svx/inc/svx/xtable.hxx          |    3 +-
 svx/source/xoutdev/xtabdash.cxx |   14 ++++++++---
 svx/source/xoutdev/xtabgrdt.cxx |   14 ++++++++---
 svx/source/xoutdev/xtabhtch.cxx |   14 ++++++++---
 svx/source/xoutdev/xtable.cxx   |   48 +++++++++++++++++++++++++---------------
 svx/source/xoutdev/xtablend.cxx |   14 ++++++++---
 6 files changed, 72 insertions(+), 35 deletions(-)

New commits:
commit 2e7905a365b7f6d93b036878636d259f5248e2f9
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Wed Jun 22 18:19:57 2011 -0700

    Replace List with std::vector< Bitmap* >

diff --git a/svx/inc/svx/xtable.hxx b/svx/inc/svx/xtable.hxx
index a8df5a7..bd82070 100644
--- a/svx/inc/svx/xtable.hxx
+++ b/svx/inc/svx/xtable.hxx
@@ -244,6 +244,7 @@ public:
 // --------------------
 
 typedef ::std::vector< XPropertyEntry* > XPropertyEntryList_impl;
+typedef ::std::vector< Bitmap* > BitmapList_impl;
 class SVX_DLLPUBLIC XPropertyList
 {
 protected:
@@ -252,7 +253,7 @@ protected:
     XOutdevItemPool*    pXPool;
 
     XPropertyEntryList_impl aList;
-    List*               pBmpList;
+    BitmapList_impl*        pBmpList;
 
     sal_Bool            bListDirty;
     sal_Bool            bBitmapsDirty;
diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx
index 5c405a1..9571ee4 100644
--- a/svx/source/xoutdev/xtabdash.cxx
+++ b/svx/source/xoutdev/xtabdash.cxx
@@ -243,12 +243,12 @@ void XDashList::impDestroy()
 XDashList::XDashList(
     const String& rPath,
     XOutdevItemPool* pInPool,
-    sal_uInt16 nInitSize,
-    sal_uInt16 nReSize
+    sal_uInt16 /* nInitSize */,
+    sal_uInt16 /* nReSize */
 ) : XPropertyList( rPath, pInPool ),
     mpData(0)
 {
-    pBmpList = new List(nInitSize, nReSize);
+    pBmpList = new BitmapList_impl();
 }
 
 XDashList::~XDashList()
@@ -341,7 +341,13 @@ sal_Bool XDashList::CreateBitmapsForUI()
         DBG_ASSERT( pBmp, "XDashList: Bitmap(UI) konnte nicht erzeugt werden!" );
 
         if( pBmp )
-            pBmpList->Insert( pBmp, i );
+        {
+            if ( (size_t)i < pBmpList->size() ) {
+                pBmpList->insert( pBmpList->begin() + i, pBmp );
+            } else {
+                pBmpList->push_back( pBmp );
+            }
+        }
     }
 
     impDestroy();
diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx
index 0e048b1..868fce0 100644
--- a/svx/source/xoutdev/xtabgrdt.cxx
+++ b/svx/source/xoutdev/xtabgrdt.cxx
@@ -225,12 +225,12 @@ void XGradientList::impDestroy()
 XGradientList::XGradientList(
     const String& rPath,
     XOutdevItemPool* pInPool,
-    sal_uInt16 nInitSize,
-    sal_uInt16 nReSize
+    sal_uInt16 /* nInitSize */,
+    sal_uInt16 /* nReSize */
 ) : XPropertyList( rPath, pInPool ),
     mpData(0)
 {
-    pBmpList = new List(nInitSize, nReSize);
+    pBmpList = new BitmapList_impl();
 }
 
 XGradientList::~XGradientList()
@@ -334,7 +334,13 @@ sal_Bool XGradientList::CreateBitmapsForUI()
         DBG_ASSERT( pBmp, "XGradientList: Bitmap(UI) konnte nicht erzeugt werden!" );
 
         if( pBmp )
-            pBmpList->Insert( pBmp, i );
+        {
+            if ( (size_t)i < pBmpList->size() ) {
+                pBmpList->insert( pBmpList->begin() + i, pBmp );
+            } else {
+                pBmpList->push_back( pBmp );
+            }
+        }
     }
 
     impDestroy();
diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx
index 89970d4..f88f012 100644
--- a/svx/source/xoutdev/xtabhtch.cxx
+++ b/svx/source/xoutdev/xtabhtch.cxx
@@ -233,12 +233,12 @@ void XHatchList::impDestroy()
 XHatchList::XHatchList(
     const String& rPath,
     XOutdevItemPool* pInPool,
-    sal_uInt16 nInitSize,
-    sal_uInt16 nReSize
+    sal_uInt16 /* nInitSize */,
+    sal_uInt16 /* nReSize */
 ) : XPropertyList( rPath, pInPool ),
     mpData(0)
 {
-    pBmpList = new List(nInitSize, nReSize);
+    pBmpList = new BitmapList_impl();
 }
 
 XHatchList::~XHatchList()
@@ -335,7 +335,13 @@ sal_Bool XHatchList::CreateBitmapsForUI()
         DBG_ASSERT( pBmp, "XHatchList: Bitmap(UI) konnte nicht erzeugt werden!" );
 
         if( pBmp )
-            pBmpList->Insert( pBmp, i );
+        {
+            if ( (size_t)i < pBmpList->size() ) {
+                pBmpList->insert( pBmpList->begin() + i, pBmp );
+            } else {
+                pBmpList->push_back( pBmp );
+            }
+        }
     }
 
     impDestroy();
diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx
index e04aa6e..3964b49 100644
--- a/svx/source/xoutdev/xtable.cxx
+++ b/svx/source/xoutdev/xtable.cxx
@@ -331,16 +331,12 @@ XPropertyList::~XPropertyList()
     }
     aList.clear();
 
-    Bitmap* pBitmap = NULL;
     if( pBmpList )
     {
-        pBitmap = (Bitmap*) pBmpList->First();
-
-        for( sal_uIntPtr nIndex = 0; nIndex < pBmpList->Count(); nIndex++ )
-        {
-            delete pBitmap;
-            pBitmap = (Bitmap*) pBmpList->Next();
+        for ( size_t i = 0, n = pBmpList->size(); i < n; ++i ) {
+            delete (*pBmpList)[ i ];
         }
+        pBmpList->clear();
         delete pBmpList;
         pBmpList = NULL;
     }
@@ -364,7 +360,12 @@ void XPropertyList::Clear()
     }
     aList.clear();
     if( pBmpList )
-        pBmpList->Clear();
+    {
+        for ( size_t i = 0, n = pBmpList->size(); i < n; ++i ) {
+            delete (*pBmpList)[ i ];
+        }
+        pBmpList->clear();
+    }
 }
 
 /************************************************************************/
@@ -435,10 +436,10 @@ Bitmap* XPropertyList::GetBitmap( long nIndex ) const
             ( (XPropertyList*) this )->bBitmapsDirty = sal_False;
             ( (XPropertyList*) this )->CreateBitmapsForUI();
         }
-        if( pBmpList->Count() >= (sal_uIntPtr) nIndex )
-            return (Bitmap*) pBmpList->GetObject( (sal_uIntPtr) nIndex );
+        if( (size_t)nIndex < pBmpList->size() )
+            return (*pBmpList)[ nIndex ];
     }
-    return( NULL );
+    return NULL;
 }
 
 /*************************************************************************
@@ -460,7 +461,11 @@ void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex )
         Bitmap* pBmp = CreateBitmapForUI(
             (size_t)nIndex < aList.size() ? nIndex : aList.size() - 1
         );
-        pBmpList->Insert( pBmp, (sal_uIntPtr) nIndex );
+        if ( (size_t)nIndex < pBmpList->size() ) {
+            pBmpList->insert( pBmpList->begin() + nIndex, pBmp );
+        } else {
+            pBmpList->push_back( pBmp );
+        }
     }
 }
 
@@ -480,9 +485,14 @@ XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex )
     if( pBmpList && !bBitmapsDirty )
     {
         Bitmap* pBmp = CreateBitmapForUI( (sal_uIntPtr) nIndex );
-        Bitmap* pOldBmp = (Bitmap*) pBmpList->Replace( pBmp, (sal_uIntPtr) nIndex );
-        if( pOldBmp )
-            delete pOldBmp;
+        if ( (size_t)nIndex < pBmpList->size() )
+        {
+            delete (*pBmpList)[ nIndex ];
+            (*pBmpList)[ nIndex ] = pBmp;
+        }
+        else {
+            pBmpList->push_back( pBmp );
+        }
     }
     return pOldEntry;
 }
@@ -497,9 +507,11 @@ XPropertyEntry* XPropertyList::Remove( long nIndex )
 {
     if( pBmpList && !bBitmapsDirty )
     {
-        Bitmap* pOldBmp = (Bitmap*) pBmpList->Remove( (sal_uIntPtr) nIndex );
-        if( pOldBmp )
-            delete pOldBmp;
+        if ( (size_t)nIndex < pBmpList->size() )
+        {
+            delete (*pBmpList)[ nIndex ];
+            pBmpList->erase( pBmpList->begin() + nIndex );
+        }
     }
 
     XPropertyEntry* pEntry = NULL;
diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx
index f40f8d3..6326eee 100644
--- a/svx/source/xoutdev/xtablend.cxx
+++ b/svx/source/xoutdev/xtablend.cxx
@@ -250,12 +250,12 @@ void XLineEndList::impDestroy()
 XLineEndList::XLineEndList(
     const String& rPath,
     XOutdevItemPool* _pXPool,
-    sal_uInt16 nInitSize,
-    sal_uInt16 nReSize
+    sal_uInt16 /* nInitSize */,
+    sal_uInt16 /* nReSize */
 ) :	XPropertyList( rPath, _pXPool ),
     mpData(0)
 {
-    pBmpList = new List(nInitSize, nReSize);
+    pBmpList = new BitmapList_impl();
 }
 
 XLineEndList::~XLineEndList()
@@ -355,7 +355,13 @@ sal_Bool XLineEndList::CreateBitmapsForUI()
         OSL_ENSURE(0 != pBmp, "XLineEndList: Bitmap(UI) could not be created!" );
 
         if( pBmp )
-            pBmpList->Insert( pBmp, i );
+        {
+            if ( (size_t)i < pBmpList->size() ) {
+                pBmpList->insert( pBmpList->begin() + i, pBmp );
+            } else {
+                pBmpList->push_back( pBmp );
+            }
+        }
     }
 
     impDestroy();


More information about the Libreoffice-commits mailing list