summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-08-26 13:48:25 +0200
committerNoel Grandin <noel@peralex.com>2015-08-26 13:52:28 +0200
commit93157d284ea37cca200759804268c0a872852549 (patch)
tree7116d9eb94ecfc115db83f2155ba686037f618d8
parentcadac8400a018c8c566379f7767ea5edff78523d (diff)
convert Link to Typed
and make it statically allocated, no point in dynamically allocating such a small object Change-Id: If476bf5dc1e0d535383d16bc49c8d567776f16cd
-rw-r--r--include/svtools/grfmgr.hxx6
-rw-r--r--include/svx/svdograf.hxx2
-rw-r--r--svtools/qa/unit/GraphicObjectTest.cxx6
-rw-r--r--svtools/source/graphic/grfmgr.cxx15
-rw-r--r--svx/source/svdraw/svdograf.cxx4
-rw-r--r--sw/inc/ndgrf.hxx2
-rw-r--r--sw/source/core/graphic/ndgrf.cxx4
7 files changed, 19 insertions, 20 deletions
diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 70f635f6126a..3ea3097d37d4 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -184,7 +184,7 @@ private:
GraphicType meType;
GraphicManager* mpMgr;
OUString maLink;
- Link<>* mpSwapStreamHdl;
+ Link<const GraphicObject*, SvStream*> maSwapStreamHdl;
OUString maUserData;
Timer* mpSwapOutTimer;
GrfSimpleCacheObj* mpSimpleCache;
@@ -339,9 +339,9 @@ public:
bool operator==( const GraphicObject& rCacheObj ) const;
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(const Link<>& rHdl);
+ void SetSwapStreamHdl(const Link<const GraphicObject*, SvStream*>& rHdl);
void FireSwapInRequest();
void FireSwapOutRequest();
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 31a9965ac921..97a6aa40cf30 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -112,7 +112,7 @@ private:
void ImpLinkAbmeldung();
bool ImpUpdateGraphicLink( bool bAsynchron = true ) const;
void ImpSetLinkedGraphic( const Graphic& rGraphic );
- DECL_LINK( ImpSwapHdl, GraphicObject* );
+ DECL_LINK_TYPED( ImpSwapHdl, const GraphicObject*, SvStream* );
void onGraphicChanged();
public:
diff --git a/svtools/qa/unit/GraphicObjectTest.cxx b/svtools/qa/unit/GraphicObjectTest.cxx
index 463a1ce2935c..2801cc210f96 100644
--- a/svtools/qa/unit/GraphicObjectTest.cxx
+++ b/svtools/qa/unit/GraphicObjectTest.cxx
@@ -52,7 +52,7 @@ public:
}
private:
- DECL_LINK(getLinkStream, GraphicObject*);
+ DECL_LINK_TYPED(getLinkStream, const GraphicObject*, SvStream*);
private:
CPPUNIT_TEST_SUITE(GraphicObjectTest);
@@ -72,9 +72,9 @@ const Graphic lcl_loadGraphic(const rtl::OUString &rUrl)
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()
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index 64c4ee7f247d..bac2be74e966 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -130,14 +130,13 @@ GraphicObject::~GraphicObject()
}
delete mpSwapOutTimer;
- delete mpSwapStreamHdl;
delete mpSimpleCache;
}
void GraphicObject::ImplConstruct()
{
mpMgr = NULL;
- mpSwapStreamHdl = NULL;
+ maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
mpSwapOutTimer = NULL;
mpSimpleCache = NULL;
mnAnimationLoopCount = 0;
@@ -350,7 +349,7 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
{
mpMgr->ImplUnregisterObj( *this );
- delete mpSwapStreamHdl, mpSwapStreamHdl = NULL;
+ maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
delete mpSimpleCache, mpSimpleCache = NULL;
maGraphic = rGraphicObj.GetGraphic();
@@ -391,7 +390,7 @@ OString GraphicObject::GetUniqueID() const
SvStream* GraphicObject::GetSwapStream() const
{
if( HasSwapStreamHdl() )
- return reinterpret_cast<SvStream*>( mpSwapStreamHdl->Call( const_cast<void*>(static_cast<const void*>(this)) ) );
+ return maSwapStreamHdl.Call( this );
else
return GRFMGR_AUTOSWAPSTREAM_NONE;
}
@@ -428,11 +427,11 @@ void GraphicObject::SetUserData( const OUString& rUserData )
void GraphicObject::SetSwapStreamHdl()
{
- if( mpSwapStreamHdl )
+ if( mpSwapOutTimer )
{
delete mpSwapOutTimer, mpSwapOutTimer = NULL;
- delete mpSwapStreamHdl, mpSwapStreamHdl = NULL;
}
+ maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
}
static sal_uInt32 GetCacheTimeInMs()
@@ -444,9 +443,9 @@ static sal_uInt32 GetCacheTimeInMs()
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());
if( nSwapOutTimeout )
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 75e54323fbf9..17bc54438c6b 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -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;
@@ -1380,7 +1380,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
}
- return reinterpret_cast<sal_IntPtr>(pRet);
+ return pRet;
}
void SdrGrafObj::SetGrafAnimationAllowed(bool bNew)
diff --git a/sw/inc/ndgrf.hxx b/sw/inc/ndgrf.hxx
index 59bd4457f1e3..65da31e73a87 100644
--- a/sw/inc/ndgrf.hxx
+++ b/sw/inc/ndgrf.hxx
@@ -72,7 +72,7 @@ class SW_DLLPUBLIC SwGrfNode: public SwNoTextNode
void InsertLink( const OUString& rGrfName, const OUString& rFltName );
bool ImportGraphic( SvStream& rStrm );
- DECL_LINK( SwapGraphic, GraphicObject* );
+ DECL_LINK_TYPED( SwapGraphic, const GraphicObject*, SvStream* );
/** helper method to determine stream for the embedded graphic.
diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx
index e3411c2846b7..fb64e79d76aa 100644
--- a/sw/source/core/graphic/ndgrf.cxx
+++ b/sw/source/core/graphic/ndgrf.cxx
@@ -953,7 +953,7 @@ SwContentNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const
return pGrfNd;
}
-IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
+IMPL_LINK_TYPED( SwGrfNode, SwapGraphic, const GraphicObject*, pGrfObj, SvStream* )
{
SvStream* pRet;
@@ -985,7 +985,7 @@ IMPL_LINK( SwGrfNode, SwapGraphic, GraphicObject*, pGrfObj )
pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
}
- return reinterpret_cast<sal_IntPtr>(pRet);
+ return pRet;
}
/// returns the Graphic-Attr-Structure filled with our graphic attributes