[Libreoffice-commits] .: filter/source

Joseph Powers jpowers at kemper.freedesktop.org
Fri Jun 10 23:01:37 PDT 2011


 filter/source/graphicfilter/icgm/elements.cxx |   49 +++++++++++++-------------
 filter/source/graphicfilter/icgm/elements.hxx |   23 ++++++------
 2 files changed, 38 insertions(+), 34 deletions(-)

New commits:
commit f21551195ccd576903a100021612660cffb0fa56
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Fri Jun 10 23:01:24 2011 -0700

    Replace List with vector< BUndle* >

diff --git a/filter/source/graphicfilter/icgm/elements.cxx b/filter/source/graphicfilter/icgm/elements.cxx
index 9e1debb..c23a3cc 100644
--- a/filter/source/graphicfilter/icgm/elements.cxx
+++ b/filter/source/graphicfilter/icgm/elements.cxx
@@ -329,36 +329,32 @@ void CGMElements::DeleteTable( Table& rTable )
 
 // ---------------------------------------------------------------
 
-void CGMElements::DeleteAllBundles( List& rList )
+void CGMElements::DeleteAllBundles( BundleList& rList )
 {
-    void* pPtr = rList.First();
-    while( pPtr )
-    {
-        delete (Bundle*)pPtr;
-        pPtr = rList.Next();
+    for ( size_t i = 0, n = rList.size(); i < n; ++i ) {
+        delete rList[ i ];
     }
+    rList.clear();
 };
 
 
 // ---------------------------------------------------------------
 
-void CGMElements::CopyAllBundles( List& rSource, List& rDest )
+void CGMElements::CopyAllBundles( BundleList& rSource, BundleList& rDest )
 {
     DeleteAllBundles( rDest );
-    rDest.Clear();
 
-    void* pPtr = rSource.First();
-    while( pPtr )
+    for ( size_t i = 0, n = rSource.size(); i < n; ++i )
     {
-        Bundle* pTempBundle = ( (Bundle*)pPtr)->Clone();
-        rDest.Insert( pTempBundle, LIST_APPEND );
-        pPtr = rSource.Next();
+        Bundle* pPtr = rSource[ i ];
+        Bundle* pTempBundle = pPtr->Clone();
+        rDest.push_back( pTempBundle );
     }
 };
 
 // ---------------------------------------------------------------
 
-Bundle* CGMElements::GetBundleIndex( sal_uInt32 nIndex, List& rList, Bundle& rBundle )
+Bundle* CGMElements::GetBundleIndex( long nIndex, BundleList& rList, Bundle& rBundle )
 {
     rBundle.SetIndex( nIndex );
     Bundle* pBundle = GetBundle( rList, nIndex );
@@ -369,28 +365,33 @@ Bundle* CGMElements::GetBundleIndex( sal_uInt32 nIndex, List& rList, Bundle& rBu
 
 // ---------------------------------------------------------------
 
-Bundle* CGMElements::GetBundle( List& rList, long nIndex )
+Bundle* CGMElements::GetBundle( BundleList& rList, long nIndex )
 {
-    Bundle* pBundle = (Bundle*)rList.First();
-    while( pBundle && ( pBundle->GetIndex() != nIndex ) )
-    {
-        pBundle = (Bundle*)rList.Next();
+    for ( size_t i = 0, n = rList.size(); i < n; ++i ) {
+        if ( rList[ i ]->GetIndex() == nIndex ) {
+            return rList[ i ];
+        }
     }
-    return pBundle;
+    return NULL;
 }
 
 // ---------------------------------------------------------------
 
-Bundle* CGMElements::InsertBundle( List& rList, Bundle& rBundle )
+Bundle* CGMElements::InsertBundle( BundleList& rList, Bundle& rBundle )
 {
     Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() );
     if ( pBundle )
     {
-        rList.Remove( pBundle );
-        delete pBundle;
+        for ( BundleList::iterator it = rList.begin(); it < rList.end(); ++it ) {
+            if ( *it == pBundle ) {
+                rList.erase( it );
+                delete pBundle;
+                break;
+            }
+        }
     }
     pBundle = rBundle.Clone();
-    rList.Insert( pBundle, LIST_APPEND );
+    rList.push_back( pBundle );
     return pBundle;
 };
 
diff --git a/filter/source/graphicfilter/icgm/elements.hxx b/filter/source/graphicfilter/icgm/elements.hxx
index 4ff4100..c378ac5 100644
--- a/filter/source/graphicfilter/icgm/elements.hxx
+++ b/filter/source/graphicfilter/icgm/elements.hxx
@@ -30,9 +30,12 @@
 
 #include "main.hxx"
 #include <tools/table.hxx>
+#include <vector>
 
 #define nBackGroundColor    aColorTable[ 0 ]
 
+typedef ::std::vector< Bundle* > BundleList;
+
 class CGMElements
 {
         void                ImplInsertHatch( sal_Int32 Key, int Style, long Distance, long Angle );
@@ -84,25 +87,25 @@ class CGMElements
 
         LineBundle*         pLineBundle;        // Pointer to the current LineBundleIndex
         LineBundle          aLineBundle;
-        List                aLineList;
+        BundleList          aLineList;
         SpecMode            eLineWidthSpecMode;
         LineCapType         eLineCapType;
         LineJoinType        eLineJoinType;
 
         MarkerBundle*       pMarkerBundle;      // Pointer to the current MarkerBundleIndex
         MarkerBundle        aMarkerBundle;
-        List                aMarkerList;
+        BundleList          aMarkerList;
         SpecMode            eMarkerSizeSpecMode;
 
         EdgeBundle*         pEdgeBundle;        // Pointer to the current EdgeBundleIndex
         EdgeBundle          aEdgeBundle;
-        List                aEdgeList;
+        BundleList          aEdgeList;
         EdgeVisibility      eEdgeVisibility;
         SpecMode            eEdgeWidthSpecMode;
 
         TextBundle*         pTextBundle;        // Pointer to the current TextBundleIndex
         TextBundle          aTextBundle;
-        List                aTextList;
+        BundleList          aTextList;
         double              nCharacterHeight;
         double              nCharacterOrientation[ 4 ];
         UnderlineMode       eUnderlineMode;
@@ -119,7 +122,7 @@ class CGMElements
 
         FillBundle*         pFillBundle;        // Pointer to the current EdgeBundleIndex
         FillBundle          aFillBundle;
-        List                aFillList;
+        BundleList          aFillList;
         FloatPoint          aFillRefPoint;
         Table               aHatchTable;
 
@@ -135,11 +138,11 @@ class CGMElements
         CGMElements&        operator=( CGMElements& );
         void                Init();
         void                DeleteTable( Table& );
-        Bundle*             GetBundleIndex( sal_uInt32 nIndex, List&, Bundle& );
-        Bundle*             GetBundle( List& rList, long nIndex );
-        Bundle*             InsertBundle( List&, Bundle& );
-        void                DeleteAllBundles( List& );
-        void                CopyAllBundles( List& Source, List& Dest );
+        Bundle*             GetBundleIndex( long nIndex, BundleList&, Bundle& );
+        Bundle*             GetBundle( BundleList& rList, long nIndex );
+        Bundle*             InsertBundle( BundleList&, Bundle& );
+        void                DeleteAllBundles( BundleList& );
+        void                CopyAllBundles( BundleList& Source, BundleList& Dest );
 };
 
 #endif


More information about the Libreoffice-commits mailing list