post ctor, pre dtor there is always a mpMgr and its mpGlobalMgr
move the ImplEnsureGraphicManager calls to be the first thing in the ctor to ensure that its also always available during the ctoring, this is hopefully a good change Change-Id: Iccddee7cac152df66dec0039df207a7575e1fa54
This commit is contained in:
@@ -181,7 +181,6 @@ private:
|
|||||||
MapMode maPrefMapMode;
|
MapMode maPrefMapMode;
|
||||||
sal_uLong mnSizeBytes;
|
sal_uLong mnSizeBytes;
|
||||||
GraphicType meType;
|
GraphicType meType;
|
||||||
GraphicManager* mpMgr;
|
|
||||||
OUString maLink;
|
OUString maLink;
|
||||||
Link<const GraphicObject*, SvStream*> maSwapStreamHdl;
|
Link<const GraphicObject*, SvStream*> maSwapStreamHdl;
|
||||||
OUString maUserData;
|
OUString maUserData;
|
||||||
@@ -202,7 +201,7 @@ private:
|
|||||||
|
|
||||||
void SVT_DLLPRIVATE ImplConstruct();
|
void SVT_DLLPRIVATE ImplConstruct();
|
||||||
void SVT_DLLPRIVATE ImplAssignGraphicData();
|
void SVT_DLLPRIVATE ImplAssignGraphicData();
|
||||||
void SVT_DLLPRIVATE ImplEnsureGraphicManager();
|
static void SVT_DLLPRIVATE ImplEnsureGraphicManager();
|
||||||
void SVT_DLLPRIVATE ImplAutoSwapIn();
|
void SVT_DLLPRIVATE ImplAutoSwapIn();
|
||||||
bool SVT_DLLPRIVATE ImplGetCropParams(
|
bool SVT_DLLPRIVATE ImplGetCropParams(
|
||||||
OutputDevice* pOut,
|
OutputDevice* pOut,
|
||||||
@@ -332,7 +331,12 @@ public:
|
|||||||
void FireSwapInRequest();
|
void FireSwapInRequest();
|
||||||
void FireSwapOutRequest();
|
void FireSwapOutRequest();
|
||||||
|
|
||||||
GraphicManager& GetGraphicManager() const { return *mpMgr; }
|
GraphicManager& GetGraphicManager() const
|
||||||
|
{
|
||||||
|
(void)this; // avoid loplugin:staticmethods because first GraphicManager ctor creates
|
||||||
|
// mpGlobalMgr and the last GraphicManager dtor destroys it
|
||||||
|
return *mpGlobalMgr;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsCached(
|
bool IsCached(
|
||||||
OutputDevice* pOut,
|
OutputDevice* pOut,
|
||||||
|
@@ -67,18 +67,17 @@ void GraphicObject::ImplAfterDataChange()
|
|||||||
mnDataChangeTimeStamp = aIncrementingTimeOfLastDataChange++;
|
mnDataChangeTimeStamp = aIncrementingTimeOfLastDataChange++;
|
||||||
|
|
||||||
// check memory footprint of all GraphicObjects managed and evtl. take action
|
// check memory footprint of all GraphicObjects managed and evtl. take action
|
||||||
if (mpMgr)
|
mpGlobalMgr->ImplCheckSizeOfSwappedInGraphics(this);
|
||||||
mpMgr->ImplCheckSizeOfSwappedInGraphics(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicObject::GraphicObject() :
|
GraphicObject::GraphicObject() :
|
||||||
maLink (),
|
maLink (),
|
||||||
maUserData ()
|
maUserData ()
|
||||||
{
|
{
|
||||||
|
ImplEnsureGraphicManager();
|
||||||
ImplConstruct();
|
ImplConstruct();
|
||||||
ImplAssignGraphicData();
|
ImplAssignGraphicData();
|
||||||
ImplEnsureGraphicManager();
|
mpGlobalMgr->ImplRegisterObj(*this, maGraphic, nullptr, nullptr);
|
||||||
mpMgr->ImplRegisterObj(*this, maGraphic, nullptr, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicObject::GraphicObject( const Graphic& rGraphic ) :
|
GraphicObject::GraphicObject( const Graphic& rGraphic ) :
|
||||||
@@ -86,10 +85,10 @@ GraphicObject::GraphicObject( const Graphic& rGraphic ) :
|
|||||||
maLink (),
|
maLink (),
|
||||||
maUserData ()
|
maUserData ()
|
||||||
{
|
{
|
||||||
|
ImplEnsureGraphicManager();
|
||||||
ImplConstruct();
|
ImplConstruct();
|
||||||
ImplAssignGraphicData();
|
ImplAssignGraphicData();
|
||||||
ImplEnsureGraphicManager();
|
mpGlobalMgr->ImplRegisterObj(*this, maGraphic, nullptr, nullptr);
|
||||||
mpMgr->ImplRegisterObj(*this, maGraphic, nullptr, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicObject::GraphicObject( const GraphicObject& rGraphicObj ) :
|
GraphicObject::GraphicObject( const GraphicObject& rGraphicObj ) :
|
||||||
@@ -98,10 +97,10 @@ GraphicObject::GraphicObject( const GraphicObject& rGraphicObj ) :
|
|||||||
maLink ( rGraphicObj.maLink ),
|
maLink ( rGraphicObj.maLink ),
|
||||||
maUserData ( rGraphicObj.maUserData )
|
maUserData ( rGraphicObj.maUserData )
|
||||||
{
|
{
|
||||||
|
ImplEnsureGraphicManager();
|
||||||
ImplConstruct();
|
ImplConstruct();
|
||||||
ImplAssignGraphicData();
|
ImplAssignGraphicData();
|
||||||
ImplEnsureGraphicManager();
|
mpGlobalMgr->ImplRegisterObj(*this, maGraphic, nullptr, &rGraphicObj);
|
||||||
mpMgr->ImplRegisterObj(*this, maGraphic, nullptr, &rGraphicObj);
|
|
||||||
if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() )
|
if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() )
|
||||||
SetSwapState();
|
SetSwapState();
|
||||||
}
|
}
|
||||||
@@ -110,13 +109,14 @@ GraphicObject::GraphicObject( const OString& rUniqueID ) :
|
|||||||
maLink (),
|
maLink (),
|
||||||
maUserData ()
|
maUserData ()
|
||||||
{
|
{
|
||||||
|
ImplEnsureGraphicManager();
|
||||||
|
|
||||||
ImplConstruct();
|
ImplConstruct();
|
||||||
|
|
||||||
// assign default properties
|
// assign default properties
|
||||||
ImplAssignGraphicData();
|
ImplAssignGraphicData();
|
||||||
|
|
||||||
ImplEnsureGraphicManager();
|
mpGlobalMgr->ImplRegisterObj(*this, maGraphic, &rUniqueID, nullptr);
|
||||||
mpMgr->ImplRegisterObj(*this, maGraphic, &rUniqueID, nullptr);
|
|
||||||
|
|
||||||
// update properties
|
// update properties
|
||||||
ImplAssignGraphicData();
|
ImplAssignGraphicData();
|
||||||
@@ -124,7 +124,7 @@ GraphicObject::GraphicObject( const OString& rUniqueID ) :
|
|||||||
|
|
||||||
GraphicObject::~GraphicObject()
|
GraphicObject::~GraphicObject()
|
||||||
{
|
{
|
||||||
mpMgr->ImplUnregisterObj( *this );
|
mpGlobalMgr->ImplUnregisterObj( *this );
|
||||||
|
|
||||||
if (!mpGlobalMgr->ImplHasObjects())
|
if (!mpGlobalMgr->ImplHasObjects())
|
||||||
{
|
{
|
||||||
@@ -135,7 +135,6 @@ GraphicObject::~GraphicObject()
|
|||||||
|
|
||||||
void GraphicObject::ImplConstruct()
|
void GraphicObject::ImplConstruct()
|
||||||
{
|
{
|
||||||
mpMgr = nullptr;
|
|
||||||
maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
|
maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
|
||||||
mnAnimationLoopCount = 0;
|
mnAnimationLoopCount = 0;
|
||||||
mbAutoSwapped = false;
|
mbAutoSwapped = false;
|
||||||
@@ -186,8 +185,6 @@ void GraphicObject::ImplEnsureGraphicManager()
|
|||||||
20000);
|
20000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mpMgr = mpGlobalMgr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicObject::ImplAutoSwapIn()
|
void GraphicObject::ImplAutoSwapIn()
|
||||||
@@ -242,8 +239,8 @@ void GraphicObject::ImplAutoSwapIn()
|
|||||||
|
|
||||||
mbIsInSwapIn = false;
|
mbIsInSwapIn = false;
|
||||||
|
|
||||||
if( !mbAutoSwapped && mpMgr )
|
if (!mbAutoSwapped)
|
||||||
mpMgr->ImplGraphicObjectWasSwappedIn( *this );
|
mpGlobalMgr->ImplGraphicObjectWasSwappedIn( *this );
|
||||||
}
|
}
|
||||||
ImplAssignGraphicData();
|
ImplAssignGraphicData();
|
||||||
}
|
}
|
||||||
@@ -322,7 +319,7 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
|
|||||||
{
|
{
|
||||||
if( &rGraphicObj != this )
|
if( &rGraphicObj != this )
|
||||||
{
|
{
|
||||||
mpMgr->ImplUnregisterObj( *this );
|
mpGlobalMgr->ImplUnregisterObj( *this );
|
||||||
|
|
||||||
maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
|
maSwapStreamHdl = Link<const GraphicObject*, SvStream*>();
|
||||||
mxSimpleCache.reset();
|
mxSimpleCache.reset();
|
||||||
@@ -333,8 +330,7 @@ GraphicObject& GraphicObject::operator=( const GraphicObject& rGraphicObj )
|
|||||||
maUserData = rGraphicObj.maUserData;
|
maUserData = rGraphicObj.maUserData;
|
||||||
ImplAssignGraphicData();
|
ImplAssignGraphicData();
|
||||||
mbAutoSwapped = false;
|
mbAutoSwapped = false;
|
||||||
mpMgr = rGraphicObj.mpMgr;
|
mpGlobalMgr->ImplRegisterObj( *this, maGraphic, nullptr, &rGraphicObj );
|
||||||
mpMgr->ImplRegisterObj( *this, maGraphic, nullptr, &rGraphicObj );
|
|
||||||
if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() )
|
if( rGraphicObj.HasUserData() && rGraphicObj.IsSwappedOut() )
|
||||||
SetSwapState();
|
SetSwapState();
|
||||||
}
|
}
|
||||||
@@ -354,12 +350,7 @@ OString GraphicObject::GetUniqueID() const
|
|||||||
if ( !IsInSwapIn() && IsEPS() )
|
if ( !IsInSwapIn() && IsEPS() )
|
||||||
const_cast<GraphicObject*>(this)->FireSwapInRequest();
|
const_cast<GraphicObject*>(this)->FireSwapInRequest();
|
||||||
|
|
||||||
OString aRet;
|
return mpGlobalMgr->ImplGetUniqueID(*this);
|
||||||
|
|
||||||
if( mpMgr )
|
|
||||||
aRet = mpMgr->ImplGetUniqueID( *this );
|
|
||||||
|
|
||||||
return aRet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SvStream* GraphicObject::GetSwapStream() const
|
SvStream* GraphicObject::GetSwapStream() const
|
||||||
@@ -459,7 +450,7 @@ bool GraphicObject::IsCached( OutputDevice* pOut, const Point& rPt, const Size&
|
|||||||
bool bRectClip;
|
bool bRectClip;
|
||||||
ImplGetCropParams( pOut, aPt, aSz, pAttr, aClipPolyPoly, bRectClip );
|
ImplGetCropParams( pOut, aPt, aSz, pAttr, aClipPolyPoly, bRectClip );
|
||||||
}
|
}
|
||||||
bRet = mpMgr->IsInCache( pOut, aPt, aSz, *this, ( pAttr ? *pAttr : GetAttr() ) );
|
bRet = mpGlobalMgr->IsInCache( pOut, aPt, aSz, *this, ( pAttr ? *pAttr : GetAttr() ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bRet = false;
|
bRet = false;
|
||||||
@@ -524,7 +515,7 @@ bool GraphicObject::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bRet = mpMgr->DrawObj( pOut, aPt, aSz, *this, aAttr, nFlags, bCached );
|
bRet = mpGlobalMgr->DrawObj( pOut, aPt, aSz, *this, aAttr, nFlags, bCached );
|
||||||
|
|
||||||
if( bCropped )
|
if( bCropped )
|
||||||
pOut->Pop();
|
pOut->Pop();
|
||||||
@@ -647,7 +638,7 @@ const Graphic& GraphicObject::GetGraphic() const
|
|||||||
|
|
||||||
void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj )
|
void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* pCopyObj )
|
||||||
{
|
{
|
||||||
mpMgr->ImplUnregisterObj( *this );
|
mpGlobalMgr->ImplUnregisterObj( *this );
|
||||||
|
|
||||||
if (mxSwapOutTimer)
|
if (mxSwapOutTimer)
|
||||||
mxSwapOutTimer->Stop();
|
mxSwapOutTimer->Stop();
|
||||||
@@ -658,7 +649,7 @@ void GraphicObject::SetGraphic( const Graphic& rGraphic, const GraphicObject* pC
|
|||||||
maLink.clear();
|
maLink.clear();
|
||||||
mxSimpleCache.reset();
|
mxSimpleCache.reset();
|
||||||
|
|
||||||
mpMgr->ImplRegisterObj( *this, maGraphic, nullptr, pCopyObj);
|
mpGlobalMgr->ImplRegisterObj( *this, maGraphic, nullptr, pCopyObj);
|
||||||
|
|
||||||
if (mxSwapOutTimer)
|
if (mxSwapOutTimer)
|
||||||
mxSwapOutTimer->Start();
|
mxSwapOutTimer->Start();
|
||||||
@@ -954,8 +945,8 @@ bool GraphicObject::SwapOut()
|
|||||||
{
|
{
|
||||||
const bool bRet = !mbAutoSwapped && maGraphic.SwapOut();
|
const bool bRet = !mbAutoSwapped && maGraphic.SwapOut();
|
||||||
|
|
||||||
if( bRet && mpMgr )
|
if (bRet)
|
||||||
mpMgr->ImplGraphicObjectWasSwappedOut( *this );
|
mpGlobalMgr->ImplGraphicObjectWasSwappedOut( *this );
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
@@ -973,8 +964,8 @@ bool GraphicObject::SwapOut( SvStream* pOStm )
|
|||||||
bRet = bRet && maGraphic.SwapOut( pOStm );
|
bRet = bRet && maGraphic.SwapOut( pOStm );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( bRet && mpMgr )
|
if (bRet)
|
||||||
mpMgr->ImplGraphicObjectWasSwappedOut( *this );
|
mpGlobalMgr->ImplGraphicObjectWasSwappedOut(*this);
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
@@ -992,8 +983,8 @@ bool GraphicObject::SwapIn()
|
|||||||
{
|
{
|
||||||
bRet = maGraphic.SwapIn();
|
bRet = maGraphic.SwapIn();
|
||||||
|
|
||||||
if( bRet && mpMgr )
|
if (bRet)
|
||||||
mpMgr->ImplGraphicObjectWasSwappedIn( *this );
|
mpGlobalMgr->ImplGraphicObjectWasSwappedIn(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( bRet )
|
if( bRet )
|
||||||
@@ -1010,8 +1001,7 @@ void GraphicObject::SetSwapState()
|
|||||||
{
|
{
|
||||||
mbAutoSwapped = true;
|
mbAutoSwapped = true;
|
||||||
|
|
||||||
if( mpMgr )
|
mpGlobalMgr->ImplGraphicObjectWasSwappedOut(*this);
|
||||||
mpMgr->ImplGraphicObjectWasSwappedOut( *this );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user