Replace List with std::vector< GraphicObject* >
I also replaced sal_Bool with bool. It's a private class so this is safe; only salBool GraphicCache::FillSwappedGraphicObject() leaks to bool to the world.
This commit is contained in:
@@ -162,15 +162,16 @@ class GraphicCacheEntry
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
List maGraphicObjectList;
|
GraphicObjectList_impl maGraphicObjectList;
|
||||||
|
|
||||||
GraphicID maID;
|
GraphicID maID;
|
||||||
GfxLink maGfxLink;
|
GfxLink maGfxLink;
|
||||||
BitmapEx* mpBmpEx;
|
BitmapEx* mpBmpEx;
|
||||||
GDIMetaFile* mpMtf;
|
GDIMetaFile* mpMtf;
|
||||||
Animation* mpAnimation;
|
Animation* mpAnimation;
|
||||||
sal_Bool mbSwappedAll;
|
bool mbSwappedAll;
|
||||||
|
|
||||||
sal_Bool ImplInit( const GraphicObject& rObj );
|
bool ImplInit( const GraphicObject& rObj );
|
||||||
void ImplFillSubstitute( Graphic& rSubstitute );
|
void ImplFillSubstitute( Graphic& rSubstitute );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -181,13 +182,13 @@ public:
|
|||||||
const GraphicID& GetID() const { return maID; }
|
const GraphicID& GetID() const { return maID; }
|
||||||
|
|
||||||
void AddGraphicObjectReference( const GraphicObject& rObj, Graphic& rSubstitute );
|
void AddGraphicObjectReference( const GraphicObject& rObj, Graphic& rSubstitute );
|
||||||
sal_Bool ReleaseGraphicObjectReference( const GraphicObject& rObj );
|
bool ReleaseGraphicObjectReference( const GraphicObject& rObj );
|
||||||
sal_uLong GetGraphicObjectReferenceCount() { return maGraphicObjectList.Count(); }
|
size_t GetGraphicObjectReferenceCount() { return maGraphicObjectList.size(); }
|
||||||
sal_Bool HasGraphicObjectReference( const GraphicObject& rObj );
|
bool HasGraphicObjectReference( const GraphicObject& rObj );
|
||||||
|
|
||||||
void TryToSwapIn();
|
void TryToSwapIn();
|
||||||
void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
|
void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
|
||||||
sal_Bool FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
|
bool FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
|
||||||
void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
|
void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -200,14 +201,17 @@ GraphicCacheEntry::GraphicCacheEntry( const GraphicObject& rObj ) :
|
|||||||
mpAnimation ( NULL ),
|
mpAnimation ( NULL ),
|
||||||
mbSwappedAll ( !ImplInit( rObj ) )
|
mbSwappedAll ( !ImplInit( rObj ) )
|
||||||
{
|
{
|
||||||
maGraphicObjectList.Insert( (void*) &rObj, LIST_APPEND );
|
maGraphicObjectList.push_back( (GraphicObject*)&rObj );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
GraphicCacheEntry::~GraphicCacheEntry()
|
GraphicCacheEntry::~GraphicCacheEntry()
|
||||||
{
|
{
|
||||||
DBG_ASSERT( !maGraphicObjectList.Count(), "GraphicCacheEntry::~GraphicCacheEntry(): Not all GraphicObjects are removed from this entry" );
|
DBG_ASSERT(
|
||||||
|
maGraphicObjectList.empty(),
|
||||||
|
"GraphicCacheEntry::~GraphicCacheEntry(): Not all GraphicObjects are removed from this entry"
|
||||||
|
);
|
||||||
|
|
||||||
delete mpBmpEx;
|
delete mpBmpEx;
|
||||||
delete mpMtf;
|
delete mpMtf;
|
||||||
@@ -216,9 +220,9 @@ GraphicCacheEntry::~GraphicCacheEntry()
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
sal_Bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
|
bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
|
||||||
{
|
{
|
||||||
sal_Bool bRet;
|
bool bRet = false;
|
||||||
|
|
||||||
if( !rObj.IsSwappedOut() )
|
if( !rObj.IsSwappedOut() )
|
||||||
{
|
{
|
||||||
@@ -260,10 +264,8 @@ sal_Bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
|
|||||||
else
|
else
|
||||||
maGfxLink = GfxLink();
|
maGfxLink = GfxLink();
|
||||||
|
|
||||||
bRet = sal_True;
|
bRet = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
bRet = sal_False;
|
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
@@ -277,9 +279,9 @@ void GraphicCacheEntry::ImplFillSubstitute( Graphic& rSubstitute )
|
|||||||
const MapMode aPrefMapMode( rSubstitute.GetPrefMapMode() );
|
const MapMode aPrefMapMode( rSubstitute.GetPrefMapMode() );
|
||||||
const Link aAnimationNotifyHdl( rSubstitute.GetAnimationNotifyHdl() );
|
const Link aAnimationNotifyHdl( rSubstitute.GetAnimationNotifyHdl() );
|
||||||
const String aDocFileName( rSubstitute.GetDocFileName() );
|
const String aDocFileName( rSubstitute.GetDocFileName() );
|
||||||
const sal_uLong nDocFilePos = rSubstitute.GetDocFilePos();
|
const sal_uLong nDocFilePos = rSubstitute.GetDocFilePos();
|
||||||
const GraphicType eOldType = rSubstitute.GetType();
|
const GraphicType eOldType = rSubstitute.GetType();
|
||||||
const sal_Bool bDefaultType = ( rSubstitute.GetType() == GRAPHIC_DEFAULT );
|
const bool bDefaultType = ( rSubstitute.GetType() == GRAPHIC_DEFAULT );
|
||||||
|
|
||||||
if( rSubstitute.IsLink() && ( GFX_LINK_TYPE_NONE == maGfxLink.GetType() ) )
|
if( rSubstitute.IsLink() && ( GFX_LINK_TYPE_NONE == maGfxLink.GetType() ) )
|
||||||
maGfxLink = rSubstitute.GetLink();
|
maGfxLink = rSubstitute.GetLink();
|
||||||
@@ -316,21 +318,24 @@ void GraphicCacheEntry::AddGraphicObjectReference( const GraphicObject& rObj, Gr
|
|||||||
mbSwappedAll = !ImplInit( rObj );
|
mbSwappedAll = !ImplInit( rObj );
|
||||||
|
|
||||||
ImplFillSubstitute( rSubstitute );
|
ImplFillSubstitute( rSubstitute );
|
||||||
maGraphicObjectList.Insert( (void*) &rObj, LIST_APPEND );
|
maGraphicObjectList.push_back( (GraphicObject*) &rObj );
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
sal_Bool GraphicCacheEntry::ReleaseGraphicObjectReference( const GraphicObject& rObj )
|
bool GraphicCacheEntry::ReleaseGraphicObjectReference( const GraphicObject& rObj )
|
||||||
{
|
{
|
||||||
sal_Bool bRet = sal_False;
|
bool bRet = false;
|
||||||
|
|
||||||
for( void* pObj = maGraphicObjectList.First(); !bRet && pObj; pObj = maGraphicObjectList.Next() )
|
for(
|
||||||
{
|
GraphicObjectList_impl::iterator it = maGraphicObjectList.begin();
|
||||||
if( &rObj == (GraphicObject*) pObj )
|
( it < maGraphicObjectList.end() ) && !bRet;
|
||||||
|
++it
|
||||||
|
) {
|
||||||
|
if( &rObj == *it )
|
||||||
{
|
{
|
||||||
maGraphicObjectList.Remove( pObj );
|
maGraphicObjectList.erase( it );
|
||||||
bRet = sal_True;
|
bRet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,13 +344,13 @@ sal_Bool GraphicCacheEntry::ReleaseGraphicObjectReference( const GraphicObject&
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
sal_Bool GraphicCacheEntry::HasGraphicObjectReference( const GraphicObject& rObj )
|
bool GraphicCacheEntry::HasGraphicObjectReference( const GraphicObject& rObj )
|
||||||
{
|
{
|
||||||
sal_Bool bRet = sal_False;
|
bool bRet = false;
|
||||||
|
|
||||||
for( void* pObj = maGraphicObjectList.First(); !bRet && pObj; pObj = maGraphicObjectList.Next() )
|
for( size_t i = 0, n = maGraphicObjectList.size(); ( i < n ) && !bRet; ++i )
|
||||||
if( &rObj == (GraphicObject*) pObj )
|
if( &rObj == maGraphicObjectList[ i ] )
|
||||||
bRet = sal_True;
|
bRet = true;
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
@@ -354,19 +359,19 @@ sal_Bool GraphicCacheEntry::HasGraphicObjectReference( const GraphicObject& rObj
|
|||||||
|
|
||||||
void GraphicCacheEntry::TryToSwapIn()
|
void GraphicCacheEntry::TryToSwapIn()
|
||||||
{
|
{
|
||||||
if( mbSwappedAll && maGraphicObjectList.Count() )
|
if( mbSwappedAll && !maGraphicObjectList.empty() )
|
||||||
( (GraphicObject*) maGraphicObjectList.First() )->FireSwapInRequest();
|
maGraphicObjectList.front()->FireSwapInRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& /*rObj*/ )
|
void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& /*rObj*/ )
|
||||||
{
|
{
|
||||||
mbSwappedAll = sal_True;
|
mbSwappedAll = true;
|
||||||
|
|
||||||
for( void* pObj = maGraphicObjectList.First(); mbSwappedAll && pObj; pObj = maGraphicObjectList.Next() )
|
for( size_t i = 0, n = maGraphicObjectList.size(); ( i < n ) && mbSwappedAll; ++i )
|
||||||
if( !( (GraphicObject*) pObj )->IsSwappedOut() )
|
if( !maGraphicObjectList[ i ]->IsSwappedOut() )
|
||||||
mbSwappedAll = sal_False;
|
mbSwappedAll = false;
|
||||||
|
|
||||||
if( mbSwappedAll )
|
if( mbSwappedAll )
|
||||||
{
|
{
|
||||||
@@ -378,17 +383,15 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& /*rObj*
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
sal_Bool GraphicCacheEntry::FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
|
bool GraphicCacheEntry::FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
|
||||||
{
|
{
|
||||||
sal_Bool bRet;
|
bool bRet = false;
|
||||||
|
|
||||||
if( !mbSwappedAll && rObj.IsSwappedOut() )
|
if( !mbSwappedAll && rObj.IsSwappedOut() )
|
||||||
{
|
{
|
||||||
ImplFillSubstitute( rSubstitute );
|
ImplFillSubstitute( rSubstitute );
|
||||||
bRet = sal_True;
|
bRet = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
bRet = sal_False;
|
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
@@ -676,7 +679,7 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
|
|||||||
{
|
{
|
||||||
// Release cached object
|
// Release cached object
|
||||||
GraphicCacheEntry* pEntry = (GraphicCacheEntry*) maGraphicCache.First();
|
GraphicCacheEntry* pEntry = (GraphicCacheEntry*) maGraphicCache.First();
|
||||||
sal_Bool bRemoved = sal_False;
|
bool bRemoved = false;
|
||||||
|
|
||||||
while( !bRemoved && pEntry )
|
while( !bRemoved && pEntry )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user