From 3e7cc992732fa58271db42ce3c82dc6a07c33223 Mon Sep 17 00:00:00 2001 From: Joseph Powers Date: Wed, 13 Jul 2011 19:59:10 -0700 Subject: [PATCH] Replace List with std::vector< GraphicObject* > --- svtools/inc/svtools/grfmgr.hxx | 8 +++++--- svtools/source/graphic/grfmgr2.cxx | 14 ++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/svtools/inc/svtools/grfmgr.hxx b/svtools/inc/svtools/grfmgr.hxx index d48d82851851..f7560058c458 100644 --- a/svtools/inc/svtools/grfmgr.hxx +++ b/svtools/inc/svtools/grfmgr.hxx @@ -548,6 +548,8 @@ public: // - GraphicManager - // ------------------ +typedef ::std::vector< GraphicObject* > GraphicObjectList_impl; + class SVT_DLLPUBLIC GraphicManager { friend class GraphicObject; @@ -555,8 +557,8 @@ class SVT_DLLPUBLIC GraphicManager private: - List maObjList; - GraphicCache* mpCache; + GraphicObjectList_impl maObjList; + GraphicCache* mpCache; GraphicManager( const GraphicManager& ) {} GraphicManager& operator=( const GraphicManager& ) { return *this; } @@ -652,7 +654,7 @@ private: const GraphicObject* pCopyObj = NULL ); void SVT_DLLPRIVATE ImplUnregisterObj( const GraphicObject& rObj ); - inline sal_Bool SVT_DLLPRIVATE ImplHasObjects() const { return( maObjList.Count() > 0UL ); } + inline sal_Bool SVT_DLLPRIVATE ImplHasObjects() const { return !maObjList.empty(); } // Only used in swap case by GraphicObject void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj ); diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx index fbd00913607b..b5d7b2bcda15 100644 --- a/svtools/source/graphic/grfmgr2.cxx +++ b/svtools/source/graphic/grfmgr2.cxx @@ -122,8 +122,8 @@ GraphicManager::GraphicManager( sal_uLong nCacheSize, sal_uLong nMaxObjCacheSize GraphicManager::~GraphicManager() { - for( void* pObj = maObjList.First(); pObj; pObj = maObjList.Next() ) - ( (GraphicObject*) pObj )->GraphicManagerDestroyed(); + for( size_t i = 0, n = maObjList.size(); i < n; ++i ) + maObjList[ i ]->GraphicManagerDestroyed(); delete mpCache; } @@ -271,7 +271,7 @@ sal_Bool GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Si void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute, const ByteString* pID, const GraphicObject* pCopyObj ) { - maObjList.Insert( (void*) &rObj, LIST_APPEND ); + maObjList.push_back( (GraphicObject*)&rObj ); mpCache->AddGraphicObject( rObj, rSubstitute, pID, pCopyObj ); } @@ -280,7 +280,13 @@ void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubst void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj ) { mpCache->ReleaseGraphicObject( rObj ); - maObjList.Remove( (void*) &rObj ); + for( GraphicObjectList_impl::iterator it = maObjList.begin(); it < maObjList.end(); ++it ) + { + if ( *it == &rObj ) { + maObjList.erase( it ); + break; + } + } } // -----------------------------------------------------------------------------