From 90398bb61c48a5722591d65b6892baf54c841b48 Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Thu, 23 Apr 2009 12:53:09 +0000 Subject: CWS-TOOLING: integrate CWS aw071_DEV300 2009-04-15 16:59:01 +0200 aw r270855 : #i101016# copy constructor and assignment operator for GraphicObject extended to not need to calculate the ObjectID, but to add to cache directly --- goodies/inc/grfmgr.hxx | 8 +++- goodies/source/graphic/grfcache.cxx | 89 ++++++++++++++++++++++++------------- goodies/source/graphic/grfcache.hxx | 3 +- goodies/source/graphic/grfmgr.cxx | 10 ++--- goodies/source/graphic/grfmgr2.cxx | 5 ++- 5 files changed, 73 insertions(+), 42 deletions(-) (limited to 'goodies') diff --git a/goodies/inc/grfmgr.hxx b/goodies/inc/grfmgr.hxx index ae2bced9377c..b44c27ea65e3 100644 --- a/goodies/inc/grfmgr.hxx +++ b/goodies/inc/grfmgr.hxx @@ -228,7 +228,9 @@ private: void ImplConstruct(); void ImplAssignGraphicData(); - void ImplSetGraphicManager( const GraphicManager* pMgr, const ByteString* pID = NULL ); + void ImplSetGraphicManager( const GraphicManager* pMgr, + const ByteString* pID = NULL, + const GraphicObject* pCopyObj = NULL ); void ImplAutoSwapIn(); BOOL ImplIsAutoSwapped() const { return mbAutoSwapped; } BOOL ImplGetCropParams( OutputDevice* pOut, Point& rPt, Size& rSz, const GraphicAttr* pAttr, @@ -524,7 +526,9 @@ private: const GDIMetaFile& rMtf, const GraphicAttr& rAttr ); // Only used by GraphicObject's Ctor's and Dtor's - void ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute, const ByteString* pID ); + void ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute, + const ByteString* pID = NULL, + const GraphicObject* pCopyObj = NULL ); void ImplUnregisterObj( const GraphicObject& rObj ); inline BOOL ImplHasObjects() const { return( maObjList.Count() > 0UL ); } diff --git a/goodies/source/graphic/grfcache.cxx b/goodies/source/graphic/grfcache.cxx index fb7cb94a964c..1a2af16ed741 100644 --- a/goodies/source/graphic/grfcache.cxx +++ b/goodies/source/graphic/grfcache.cxx @@ -583,54 +583,79 @@ GraphicCache::~GraphicCache() // ----------------------------------------------------------------------------- -void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute, const ByteString* pID ) +void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute, + const ByteString* pID, const GraphicObject* pCopyObj ) { BOOL bInserted = FALSE; - if( !rObj.IsSwappedOut() && ( ( rObj.GetType() != GRAPHIC_NONE ) || pID ) ) + if( !rObj.IsSwappedOut() && + ( pID || ( pCopyObj && ( pCopyObj->GetType() != GRAPHIC_NONE ) ) || ( rObj.GetType() != GRAPHIC_NONE ) ) ) { - GraphicCacheEntry* pEntry = (GraphicCacheEntry*) maGraphicCache.First(); - const GraphicID aID( rObj ); - - while( !bInserted && pEntry ) + if( pCopyObj ) { - const GraphicID& rEntryID = pEntry->GetID(); + GraphicCacheEntry* pEntry = static_cast< GraphicCacheEntry* >( maGraphicCache.First() ); - if( pID ) + while( !bInserted && pEntry ) { - if( rEntryID.GetIDString() == *pID ) + if( pEntry->HasGraphicObjectReference( *pCopyObj ) ) + { + pEntry->AddGraphicObjectReference( rObj, rSubstitute ); + bInserted = TRUE; + } + else { - pEntry->TryToSwapIn(); + pEntry = static_cast< GraphicCacheEntry* >( maGraphicCache.Next() ); + } + } + } + + if( !bInserted ) + { + GraphicCacheEntry* pEntry = static_cast< GraphicCacheEntry* >( maGraphicCache.First() ); + const GraphicID aID( rObj ); - // since pEntry->TryToSwapIn can modify our current list, we have to - // iterate from beginning to add a reference to the appropriate - // CacheEntry object; after this, quickly jump out of the outer iteration - for( pEntry = (GraphicCacheEntry*) maGraphicCache.First(); !bInserted && pEntry; pEntry = (GraphicCacheEntry*) maGraphicCache.Next() ) + while( !bInserted && pEntry ) + { + const GraphicID& rEntryID = pEntry->GetID(); + + if( pID ) + { + if( rEntryID.GetIDString() == *pID ) { - const GraphicID& rID = pEntry->GetID(); + pEntry->TryToSwapIn(); + + // since pEntry->TryToSwapIn can modify our current list, we have to + // iterate from beginning to add a reference to the appropriate + // CacheEntry object; after this, quickly jump out of the outer iteration + for( pEntry = static_cast< GraphicCacheEntry* >( maGraphicCache.First() ); + !bInserted && pEntry; + pEntry = static_cast< GraphicCacheEntry* >( maGraphicCache.Next() ) ) + { + const GraphicID& rID = pEntry->GetID(); + + if( rID.GetIDString() == *pID ) + { + pEntry->AddGraphicObjectReference( rObj, rSubstitute ); + bInserted = TRUE; + } + } - if( rID.GetIDString() == *pID ) + if( !bInserted ) { - pEntry->AddGraphicObjectReference( rObj, rSubstitute ); + maGraphicCache.Insert( new GraphicCacheEntry( rObj ), LIST_APPEND ); bInserted = TRUE; } } - - if( !bInserted ) - { - maGraphicCache.Insert( new GraphicCacheEntry( rObj ), LIST_APPEND ); - bInserted = TRUE; - } } - } - else if( rEntryID == aID ) - { - pEntry->AddGraphicObjectReference( rObj, rSubstitute ); - bInserted = TRUE; - } + else if( rEntryID == aID ) + { + pEntry->AddGraphicObjectReference( rObj, rSubstitute ); + bInserted = TRUE; + } - if( !bInserted ) - pEntry = (GraphicCacheEntry*) maGraphicCache.Next(); + if( !bInserted ) + pEntry = static_cast< GraphicCacheEntry* >( maGraphicCache.Next() ); + } } } @@ -718,7 +743,7 @@ void GraphicCache::GraphicObjectWasSwappedIn( const GraphicObject& rObj ) if( pEntry->GetID().IsEmpty() ) { ReleaseGraphicObject( rObj ); - AddGraphicObject( rObj, (Graphic&) rObj.GetGraphic(), NULL ); + AddGraphicObject( rObj, (Graphic&) rObj.GetGraphic(), NULL, NULL ); } else pEntry->GraphicObjectWasSwappedIn( rObj ); diff --git a/goodies/source/graphic/grfcache.hxx b/goodies/source/graphic/grfcache.hxx index 62c7f4e18521..86b982b01498 100644 --- a/goodies/source/graphic/grfcache.hxx +++ b/goodies/source/graphic/grfcache.hxx @@ -70,7 +70,8 @@ public: public: - void AddGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute, const ByteString* pID ); + void AddGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute, + const ByteString* pID, const GraphicObject* pCopyObj ); void ReleaseGraphicObject( const GraphicObject& rObj ); void GraphicObjectWasSwappedOut( const GraphicObject& rObj ); diff --git a/goodies/source/graphic/grfmgr.cxx b/goodies/source/graphic/grfmgr.cxx index 29ab26a78c5a..bece8389d270 100644 --- a/goodies/source/graphic/grfmgr.cxx +++ b/goodies/source/graphic/grfmgr.cxx @@ -126,7 +126,7 @@ GraphicObject::GraphicObject( const GraphicObject& rGraphicObj, const GraphicMan { ImplConstruct(); ImplAssignGraphicData(); - ImplSetGraphicManager( pMgr ); + ImplSetGraphicManager( pMgr, NULL, &rGraphicObj ); } // ----------------------------------------------------------------------------- @@ -203,7 +203,7 @@ void GraphicObject::ImplAssignGraphicData() // ----------------------------------------------------------------------------- -void GraphicObject::ImplSetGraphicManager( const GraphicManager* pMgr, const ByteString* pID ) +void GraphicObject::ImplSetGraphicManager( const GraphicManager* pMgr, const ByteString* pID, const GraphicObject* pCopyObj ) { if( !mpMgr || ( pMgr != mpMgr ) ) { @@ -235,7 +235,7 @@ void GraphicObject::ImplSetGraphicManager( const GraphicManager* pMgr, const Byt else mpMgr = (GraphicManager*) pMgr; - mpMgr->ImplRegisterObj( *this, maGraphic, pID ); + mpMgr->ImplRegisterObj( *this, maGraphic, pID, pCopyObj ); } } } @@ -407,7 +407,7 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj ) mbAutoSwapped = FALSE; mpMgr = rGraphicObj.mpMgr; - mpMgr->ImplRegisterObj( *this, maGraphic, NULL ); + mpMgr->ImplRegisterObj( *this, maGraphic, NULL, &rGraphicObj ); } return *this; @@ -889,7 +889,7 @@ void GraphicObject::SetGraphic( const Graphic& rGraphic ) delete mpLink, mpLink = NULL; delete mpSimpleCache, mpSimpleCache = NULL; - mpMgr->ImplRegisterObj( *this, maGraphic, NULL ); + mpMgr->ImplRegisterObj( *this, maGraphic ); if( mpSwapOutTimer ) mpSwapOutTimer->Start(); diff --git a/goodies/source/graphic/grfmgr2.cxx b/goodies/source/graphic/grfmgr2.cxx index eb5d2b4ee8dc..f4232a09dadf 100644 --- a/goodies/source/graphic/grfmgr2.cxx +++ b/goodies/source/graphic/grfmgr2.cxx @@ -271,10 +271,11 @@ BOOL GraphicManager::DrawObj( OutputDevice* pOut, const Point& rPt, const Size& // ----------------------------------------------------------------------------- -void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute, const ByteString* pID ) +void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubstitute, + const ByteString* pID, const GraphicObject* pCopyObj ) { maObjList.Insert( (void*) &rObj, LIST_APPEND ); - mpCache->AddGraphicObject( rObj, rSubstitute, pID ); + mpCache->AddGraphicObject( rObj, rSubstitute, pID, pCopyObj ); } // ----------------------------------------------------------------------------- -- cgit