Kaydet (Commit) 93157d28 authored tarafından Noel Grandin's avatar Noel Grandin

convert Link to Typed

and make it statically allocated, no point in dynamically allocating
such a small object

Change-Id: If476bf5dc1e0d535383d16bc49c8d567776f16cd
üst cadac840
...@@ -184,7 +184,7 @@ private: ...@@ -184,7 +184,7 @@ private:
GraphicType meType; GraphicType meType;
GraphicManager* mpMgr; GraphicManager* mpMgr;
OUString maLink; OUString maLink;
Link<>* mpSwapStreamHdl; Link<const GraphicObject*, SvStream*> maSwapStreamHdl;
OUString maUserData; OUString maUserData;
Timer* mpSwapOutTimer; Timer* mpSwapOutTimer;
GrfSimpleCacheObj* mpSimpleCache; GrfSimpleCacheObj* mpSimpleCache;
...@@ -339,9 +339,9 @@ public: ...@@ -339,9 +339,9 @@ public:
bool operator==( const GraphicObject& rCacheObj ) const; bool operator==( const GraphicObject& rCacheObj ) const;
bool operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); } bool operator!=( const GraphicObject& rCacheObj ) const { return !( *this == rCacheObj ); }
bool HasSwapStreamHdl() const { return( mpSwapStreamHdl != NULL && mpSwapStreamHdl->IsSet() ); } bool HasSwapStreamHdl() const { return maSwapStreamHdl.IsSet(); }
void SetSwapStreamHdl(); void SetSwapStreamHdl();
void SetSwapStreamHdl(const Link<>& rHdl); void SetSwapStreamHdl(const Link<const GraphicObject*, SvStream*>& rHdl);
void FireSwapInRequest(); void FireSwapInRequest();
void FireSwapOutRequest(); void FireSwapOutRequest();
......
...@@ -112,7 +112,7 @@ private: ...@@ -112,7 +112,7 @@ private:
void ImpLinkAbmeldung(); void ImpLinkAbmeldung();
bool ImpUpdateGraphicLink( bool bAsynchron = true ) const; bool ImpUpdateGraphicLink( bool bAsynchron = true ) const;
void ImpSetLinkedGraphic( const Graphic& rGraphic ); void ImpSetLinkedGraphic( const Graphic& rGraphic );
DECL_LINK( ImpSwapHdl, GraphicObject* ); DECL_LINK_TYPED( ImpSwapHdl, const GraphicObject*, SvStream* );
void onGraphicChanged(); void onGraphicChanged();
public: public:
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
} }
private: private:
DECL_LINK(getLinkStream, GraphicObject*); DECL_LINK_TYPED(getLinkStream, const GraphicObject*, SvStream*);
private: private:
CPPUNIT_TEST_SUITE(GraphicObjectTest); CPPUNIT_TEST_SUITE(GraphicObjectTest);
...@@ -72,9 +72,9 @@ const Graphic lcl_loadGraphic(const rtl::OUString &rUrl) ...@@ -72,9 +72,9 @@ const Graphic lcl_loadGraphic(const rtl::OUString &rUrl)
return Graphic(aImage.GetBitmapEx()); return Graphic(aImage.GetBitmapEx());
} }
IMPL_LINK(GraphicObjectTest, getLinkStream, GraphicObject*, /*pGraphObj*/) IMPL_LINK_NOARG_TYPED(GraphicObjectTest, getLinkStream, const GraphicObject*, SvStream*)
{ {
return reinterpret_cast<sal_IntPtr>(GRFMGR_AUTOSWAPSTREAM_LINK); return GRFMGR_AUTOSWAPSTREAM_LINK;
} }
void GraphicObjectTest::testSwap() void GraphicObjectTest::testSwap()
......
...@@ -130,14 +130,13 @@ GraphicObject::~GraphicObject() ...@@ -130,14 +130,13 @@ GraphicObject::~GraphicObject()
} }
delete mpSwapOutTimer; delete mpSwapOutTimer;
delete mpSwapStreamHdl;
delete mpSimpleCache; delete mpSimpleCache;
} }
void GraphicObject::ImplConstruct() void GraphicObject::ImplConstruct()
{ {
mpMgr = NULL; mpMgr = NULL;
mpSwapStreamHdl = NULL; maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
mpSwapOutTimer = NULL; mpSwapOutTimer = NULL;
mpSimpleCache = NULL; mpSimpleCache = NULL;
mnAnimationLoopCount = 0; mnAnimationLoopCount = 0;
...@@ -350,7 +349,7 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj ) ...@@ -350,7 +349,7 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
{ {
mpMgr->ImplUnregisterObj( *this ); mpMgr->ImplUnregisterObj( *this );
delete mpSwapStreamHdl, mpSwapStreamHdl = NULL; maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
delete mpSimpleCache, mpSimpleCache = NULL; delete mpSimpleCache, mpSimpleCache = NULL;
maGraphic = rGraphicObj.GetGraphic(); maGraphic = rGraphicObj.GetGraphic();
...@@ -391,7 +390,7 @@ OString GraphicObject::GetUniqueID() const ...@@ -391,7 +390,7 @@ OString GraphicObject::GetUniqueID() const
SvStream* GraphicObject::GetSwapStream() const SvStream* GraphicObject::GetSwapStream() const
{ {
if( HasSwapStreamHdl() ) if( HasSwapStreamHdl() )
return reinterpret_cast<SvStream*>( mpSwapStreamHdl->Call( const_cast<void*>(static_cast<const void*>(this)) ) ); return maSwapStreamHdl.Call( this );
else else
return GRFMGR_AUTOSWAPSTREAM_NONE; return GRFMGR_AUTOSWAPSTREAM_NONE;
} }
...@@ -428,11 +427,11 @@ void GraphicObject::SetUserData( const OUString& rUserData ) ...@@ -428,11 +427,11 @@ void GraphicObject::SetUserData( const OUString& rUserData )
void GraphicObject::SetSwapStreamHdl() void GraphicObject::SetSwapStreamHdl()
{ {
if( mpSwapStreamHdl ) if( mpSwapOutTimer )
{ {
delete mpSwapOutTimer, mpSwapOutTimer = NULL; delete mpSwapOutTimer, mpSwapOutTimer = NULL;
delete mpSwapStreamHdl, mpSwapStreamHdl = NULL;
} }
maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
} }
static sal_uInt32 GetCacheTimeInMs() static sal_uInt32 GetCacheTimeInMs()
...@@ -444,9 +443,9 @@ static sal_uInt32 GetCacheTimeInMs() ...@@ -444,9 +443,9 @@ static sal_uInt32 GetCacheTimeInMs()
return nSeconds * 1000; return nSeconds * 1000;
} }
void GraphicObject::SetSwapStreamHdl(const Link<>& rHdl) void GraphicObject::SetSwapStreamHdl(const Link<const GraphicObject*, SvStream*>& rHdl)
{ {
delete mpSwapStreamHdl, mpSwapStreamHdl = new Link<>( rHdl ); maSwapStreamHdl = rHdl;
sal_uInt32 const nSwapOutTimeout(GetCacheTimeInMs()); sal_uInt32 const nSwapOutTimeout(GetCacheTimeInMs());
if( nSwapOutTimeout ) if( nSwapOutTimeout )
......
...@@ -1268,7 +1268,7 @@ void SdrGrafObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly ) ...@@ -1268,7 +1268,7 @@ void SdrGrafObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly )
} }
} }
IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO ) IMPL_LINK_TYPED( SdrGrafObj, ImpSwapHdl, const GraphicObject*, pO, SvStream* )
{ {
SvStream* pRet = GRFMGR_AUTOSWAPSTREAM_NONE; SvStream* pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
...@@ -1380,7 +1380,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO ) ...@@ -1380,7 +1380,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
pRet = GRFMGR_AUTOSWAPSTREAM_TEMP; pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
} }
return reinterpret_cast<sal_IntPtr>(pRet); return pRet;
} }
void SdrGrafObj::SetGrafAnimationAllowed(bool bNew) void SdrGrafObj::SetGrafAnimationAllowed(bool bNew)
......
...@@ -72,7 +72,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTextNode ...@@ -72,7 +72,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTextNode
void InsertLink( const OUString& rGrfName, const OUString& rFltName ); void InsertLink( const OUString& rGrfName, const OUString& rFltName );
bool ImportGraphic( SvStream& rStrm ); bool ImportGraphic( SvStream& rStrm );
DECL_LINK( SwapGraphic, GraphicObject* ); DECL_LINK_TYPED( SwapGraphic, const GraphicObject*, SvStream* );
/** helper method to determine stream for the embedded graphic. /** helper method to determine stream for the embedded graphic.
......
...@@ -953,7 +953,7 @@ SwContentNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const ...@@ -953,7 +953,7 @@ SwContentNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
return pGrfNd; return pGrfNd;
} }
IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj ) IMPL_LINK_TYPED( SwGrfNode, SwapGraphic, const GraphicObject*, pGrfObj, SvStream* )
{ {
SvStream* pRet; SvStream* pRet;
...@@ -985,7 +985,7 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj ) ...@@ -985,7 +985,7 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
pRet = GRFMGR_AUTOSWAPSTREAM_TEMP; pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
} }
return reinterpret_cast<sal_IntPtr>(pRet); return pRet;
} }
/// returns the Graphic-Attr-Structure filled with our graphic attributes /// returns the Graphic-Attr-Structure filled with our graphic attributes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment