[Libreoffice-commits] .: forms/source

Joseph Powers jpowers at kemper.freedesktop.org
Wed Mar 9 19:47:59 PST 2011


 forms/source/component/imgprod.cxx |   94 +++++++++----------------------------
 forms/source/component/imgprod.hxx |    7 +-
 2 files changed, 30 insertions(+), 71 deletions(-)

New commits:
commit b9be32dd90aecb51341824e510c153f3d715c19d
Author: Rafael Dominguez <venccsralph at gmail.com>
Date:   Wed Mar 9 19:47:53 2011 -0800

    Remove List container in components/imgprod

diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx
index 4c154f9..518a205 100644
--- a/forms/source/component/imgprod.cxx
+++ b/forms/source/component/imgprod.cxx
@@ -204,9 +204,6 @@ ImageProducer::~ImageProducer()
 
     delete mpStm;
     mpStm = NULL;
-
-    for( void* pCons = maConsList.First(); pCons; pCons = maConsList.Next() )
-        delete (::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons;
 }
 
 // ------------------------------------------------------------
@@ -226,24 +223,17 @@ void ImageProducer::addConsumer( const ::com::sun::star::uno::Reference< ::com::
 {
     DBG_ASSERT( rxConsumer.is(), "::AddConsumer(...): No consumer referenced!" );
     if( rxConsumer.is() )
-        maConsList.Insert( new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > ( rxConsumer ), LIST_APPEND );
+        maConsList.push_back( new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > ( rxConsumer ));
 }
 
 // ------------------------------------------------------------
 
 void ImageProducer::removeConsumer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer >& rxConsumer ) throw(::com::sun::star::uno::RuntimeException)
 {
-    for( sal_uInt32 n = maConsList.Count(); n; )
-    {
-        ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > * pRef = (::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) maConsList.GetObject( --n );
+    ConsumerList_t::reverse_iterator riter = std::find(maConsList.rbegin(),maConsList.rend(),rxConsumer);
 
-        if( *pRef == rxConsumer )
-        {
-            delete pRef;
-            maConsList.Remove( n );
-            break;
-        }
-    }
+    if (riter != maConsList.rend())
+        maConsList.erase(riter.base()-1);
 }
 
 // ------------------------------------------------------------
@@ -307,7 +297,7 @@ void ImageProducer::NewDataAvailable()
 
 void ImageProducer::startProduction() throw(::com::sun::star::uno::RuntimeException)
 {
-    if( maConsList.Count() || maDoneHdl.IsSet() )
+    if( !maConsList.empty() || maDoneHdl.IsSet() )
     {
         bool bNotifyEmptyGraphics = false;
 
@@ -333,24 +323,16 @@ void ImageProducer::startProduction() throw(::com::sun::star::uno::RuntimeExcept
         if ( bNotifyEmptyGraphics )
         {
             // reset image
-            List	aTmp;
-            void*	pCons;
-
             // create temporary list to hold interfaces
-            for( pCons = maConsList.First(); pCons; pCons = maConsList.Next() )
-                aTmp.Insert( new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons ), LIST_APPEND );
+            ConsumerList_t aTmp = maConsList;
 
             // iterate through interfaces
-            for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
+            for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter )
             {
-                ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->init( 0, 0 );
-                ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->complete( ::com::sun::star::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
+                (*iter)->init( 0, 0 );
+                (*iter)->complete( ::com::sun::star::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
             }
 
-            // delete interfaces in temporary list
-            for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
-                delete (::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons;
-
             if ( maDoneHdl.IsSet() )
                 maDoneHdl.Call( NULL );
         }
@@ -380,25 +362,17 @@ void ImageProducer::ImplUpdateData( const Graphic& rGraphic )
 {
     ImplInitConsumer( rGraphic );
 
-    if( mbConsInit && maConsList.Count() )
+    if( mbConsInit && !maConsList.empty() )
     {
-        List	aTmp;
-        void*	pCons;
+        // create temporary list to hold interfaces
+        ConsumerList_t aTmp = maConsList;
 
         ImplUpdateConsumer( rGraphic );
         mbConsInit = sal_False;
 
-        // create temporary list to hold interfaces
-        for( pCons = maConsList.First(); pCons; pCons = maConsList.Next() )
-            aTmp.Insert( new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons ), LIST_APPEND );
-
         // iterate through interfaces
-        for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
-            ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->complete( ::com::sun::star::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
-
-        // delete interfaces in temporary list
-        for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
-            delete (::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons;
+        for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter )
+            (*iter)->complete( ::com::sun::star::awt::ImageStatus::IMAGESTATUS_STATICIMAGEDONE, this );
     }
 }
 
@@ -411,8 +385,6 @@ void ImageProducer::ImplInitConsumer( const Graphic& rGraphic )
 
     if(	pBmpAcc )
     {
-        List             aTmp;
-        void *           pCons;
         sal_uInt16       nPalCount = 0;
         sal_uInt32       nRMask = 0;
         sal_uInt32       nGMask = 0;
@@ -461,21 +433,15 @@ void ImageProducer::ImplInitConsumer( const Graphic& rGraphic )
         }
 
         // create temporary list to hold interfaces
-        for( pCons = maConsList.First(); pCons; pCons = maConsList.Next() )
-            aTmp.Insert( new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons ), LIST_APPEND );
+        ConsumerList_t aTmp = maConsList;
 
         // iterate through interfaces
-        for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
+        for( ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
         {
-            ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->init( pBmpAcc->Width(), pBmpAcc->Height() );
-            ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->setColorModel( pBmpAcc->GetBitCount(),
-                                                       aRGBPal, nRMask, nGMask, nBMask, nAMask );
+            (*iter)->init( pBmpAcc->Width(), pBmpAcc->Height() );
+            (*iter)->setColorModel( pBmpAcc->GetBitCount(),aRGBPal, nRMask, nGMask, nBMask, nAMask );
         }
 
-        // delete interfaces in temporary list
-        for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
-            delete (::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons;
-
         aBmp.ReleaseAccess( pBmpAcc );
         mbConsInit = sal_True;
     }
@@ -491,8 +457,6 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
 
     if( pBmpAcc )
     {
-        List				aTmp;
-        void*				pCons;
         Bitmap				aMask( aBmpEx.GetMask() );
         BitmapReadAccess*	pMskAcc = !!aMask ? aMask.AcquireReadAccess() : NULL;
         const long			nWidth = pBmpAcc->Width();
@@ -512,8 +476,7 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
         }
 
         // create temporary list to hold interfaces
-        for( pCons = maConsList.First(); pCons; pCons = maConsList.Next() )
-            aTmp.Insert( new ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons ), LIST_APPEND );
+        ConsumerList_t aTmp = maConsList;
 
         if( pBmpAcc->HasPalette() )
         {
@@ -537,9 +500,8 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
                 }
 
                 // iterate through interfaces
-                for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
-                    ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->setPixelsByBytes( nStartX, nStartY, nPartWidth, nPartHeight,
-                                                                       aData, 0UL, nPartWidth );
+                for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
+                    (*iter)->setPixelsByBytes( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
             }
             else
             {
@@ -558,9 +520,8 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
                 }
 
                 // iterate through interfaces
-                for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
-                    ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight,
-                                                                       aData, 0UL, nPartWidth );
+                for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
+                    (*iter)->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
             }
         }
         else
@@ -585,15 +546,10 @@ void ImageProducer::ImplUpdateConsumer( const Graphic& rGraphic )
             }
 
             // iterate through interfaces
-            for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
-                ( *(::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons )->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight,
-                                                                   aData, 0UL, nPartWidth );
+                for (ConsumerList_t::iterator iter = aTmp.begin(); iter != aTmp.end(); ++iter)
+                    (*iter)->setPixelsByLongs( nStartX, nStartY, nPartWidth, nPartHeight, aData, 0UL, nPartWidth );
         }
 
-        // delete interfaces in temporary list
-        for( pCons = aTmp.First(); pCons; pCons = aTmp.Next() )
-            delete (::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > *) pCons;
-
         aBmp.ReleaseAccess( pBmpAcc );
         aMask.ReleaseAccess( pMskAcc );
     }
diff --git a/forms/source/component/imgprod.hxx b/forms/source/component/imgprod.hxx
index 58f4583..f37c245 100644
--- a/forms/source/component/imgprod.hxx
+++ b/forms/source/component/imgprod.hxx
@@ -29,9 +29,10 @@
 #ifndef _PRODUCE_HXX
 #define _PRODUCE_HXX
 
+#include <boost/ptr_container/ptr_vector.hpp>
+
 #include <tools/link.hxx>
 #include <tools/string.hxx>
-#include <tools/list.hxx>
 #include <com/sun/star/awt/ImageStatus.hpp>
 #include <com/sun/star/awt/XImageConsumer.hpp>
 #include <com/sun/star/awt/XImageProducer.hpp>
@@ -61,8 +62,10 @@ class ImageProducer :	public ::com::sun::star::awt::XImageProducer,
 {
 private:
 
+    typedef boost::ptr_vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XImageConsumer > > ConsumerList_t;
+
     ::rtl::OUString	maURL;
-    List			maConsList;
+    ConsumerList_t	maConsList;
     Graphic*		mpGraphic;
     SvStream*		mpStm;
     sal_uInt32		mnTransIndex;


More information about the Libreoffice-commits mailing list