summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2017-12-19 02:11:36 +0900
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-12-19 07:54:18 +0100
commit67bd9382aa17594cb7a6d1fad304ed9f275941b1 (patch)
tree5862c6303bc9ad03b23aec9d98c8c95eea4a3ae4 /svtools
parent150af593ce1dee2a04dd56d9de67b3e0c4581811 (diff)
svtools: Use std::unique_ptr for GraphicCacheEntry
... and GraphicDisplayCacheEntry. Change-Id: Ic4c4f6078837d96ce56e245caa926c7730034a08 Reviewed-on: https://gerrit.libreoffice.org/46732 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/graphic/grfcache.cxx64
1 files changed, 16 insertions, 48 deletions
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index da41b631fc93..cd42a0aa289a 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -147,9 +147,9 @@ private:
GraphicID maID;
GfxLink maGfxLink;
- BitmapEx* mpBmpEx;
- GDIMetaFile* mpMtf;
- Animation* mpAnimation;
+ std::unique_ptr<BitmapEx> mpBmpEx;
+ std::unique_ptr<GDIMetaFile> mpMtf;
+ std::unique_ptr<Animation> mpAnimation;
bool mbSwappedAll;
// VectorGraphicData support
@@ -178,9 +178,6 @@ public:
GraphicCacheEntry::GraphicCacheEntry( const GraphicObject& rObj ) :
maID ( rObj ),
- mpBmpEx ( nullptr ),
- mpMtf ( nullptr ),
- mpAnimation ( nullptr ),
mbSwappedAll ( true )
{
mbSwappedAll = !ImplInit( rObj );
@@ -193,10 +190,6 @@ GraphicCacheEntry::~GraphicCacheEntry()
maGraphicObjectList.empty(),
"GraphicCacheEntry::~GraphicCacheEntry(): Not all GraphicObjects are removed from this entry"
);
-
- delete mpBmpEx;
- delete mpMtf;
- delete mpAnimation;
}
bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
@@ -207,23 +200,9 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
{
const Graphic& rGraphic = rObj.GetGraphic();
- if( mpBmpEx )
- {
- delete mpBmpEx;
- mpBmpEx = nullptr;
- }
-
- if( mpMtf )
- {
- delete mpMtf;
- mpMtf = nullptr;
- }
-
- if( mpAnimation )
- {
- delete mpAnimation;
- mpAnimation = nullptr;
- }
+ mpBmpEx.reset();
+ mpMtf.reset();
+ mpAnimation.reset();
switch( rGraphic.GetType() )
{
@@ -235,11 +214,11 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
}
else if( rGraphic.IsAnimated() )
{
- mpAnimation = new Animation( rGraphic.GetAnimation() );
+ mpAnimation.reset(new Animation( rGraphic.GetAnimation() ));
}
else
{
- mpBmpEx = new BitmapEx( rGraphic.GetBitmapEx() );
+ mpBmpEx.reset(new BitmapEx( rGraphic.GetBitmapEx() ));
if (rGraphic.getPdfData().hasElements())
maPdfData = rGraphic.getPdfData();
}
@@ -248,7 +227,7 @@ bool GraphicCacheEntry::ImplInit( const GraphicObject& rObj )
case GraphicType::GdiMetafile:
{
- mpMtf = new GDIMetaFile( rGraphic.GetGDIMetaFile() );
+ mpMtf.reset(new GDIMetaFile( rGraphic.GetGDIMetaFile() ));
}
break;
@@ -375,12 +354,9 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut()
if( !mbSwappedAll )
return;
- delete mpBmpEx;
- mpBmpEx = nullptr;
- delete mpMtf;
- mpMtf = nullptr;
- delete mpAnimation;
- mpAnimation = nullptr;
+ mpBmpEx.reset();
+ mpMtf.reset();
+ mpAnimation.reset();
// #119176# also reset VectorGraphicData
maVectorGraphicData.reset();
@@ -399,8 +375,8 @@ private:
::salhelper::TTimeValue maReleaseTime;
const GraphicCacheEntry* mpRefCacheEntry;
- GDIMetaFile* mpMtf;
- BitmapEx* mpBmpEx;
+ std::unique_ptr<GDIMetaFile> mpMtf;
+ std::unique_ptr<BitmapEx> mpBmpEx;
GraphicAttr maAttr;
Size maOutSizePix;
sal_uLong mnCacheSize;
@@ -425,7 +401,7 @@ public:
const GraphicObject& rObj, const GraphicAttr& rAttr,
const BitmapEx& rBmpEx ) :
mpRefCacheEntry( pRefCacheEntry ),
- mpMtf( nullptr ), mpBmpEx( new BitmapEx( rBmpEx ) ),
+ mpBmpEx( new BitmapEx( rBmpEx ) ),
maAttr( rAttr ), maOutSizePix( pOut->LogicToPixel( rSz ) ),
mnCacheSize( GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) ),
mnOutDevDrawMode( pOut->GetDrawMode() ),
@@ -438,7 +414,7 @@ public:
const GraphicObject& rObj, const GraphicAttr& rAttr,
const GDIMetaFile& rMtf ) :
mpRefCacheEntry( pRefCacheEntry ),
- mpMtf( new GDIMetaFile( rMtf ) ), mpBmpEx( nullptr ),
+ mpMtf( new GDIMetaFile( rMtf ) ),
maAttr( rAttr ), maOutSizePix( pOut->LogicToPixel( rSz ) ),
mnCacheSize( GetNeededSize( pOut, rPt, rSz, rObj, rAttr ) ),
mnOutDevDrawMode( pOut->GetDrawMode() ),
@@ -447,8 +423,6 @@ public:
}
- ~GraphicDisplayCacheEntry();
-
sal_uLong GetCacheSize() const { return mnCacheSize; }
const GraphicCacheEntry* GetReferencedCacheEntry() const { return mpRefCacheEntry; }
@@ -797,12 +771,6 @@ sal_uLong GraphicDisplayCacheEntry::GetNeededSize( OutputDevice const * pOut, co
return rGraphic.GetSizeBytes();
}
-GraphicDisplayCacheEntry::~GraphicDisplayCacheEntry()
-{
- delete mpMtf;
- delete mpBmpEx;
-}
-
void GraphicDisplayCacheEntry::Draw( OutputDevice* pOut, const Point& rPt, const Size& rSz ) const
{
if( mpMtf )