summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMark Page <aptitude@btconnect.com>2016-07-04 09:48:50 +0100
committerNoel Grandin <noelgrandin@gmail.com>2016-07-04 12:59:02 +0000
commite9c3eccdb1ebf77d09dd7ad47b0708e1cb44417d (patch)
tree38f179cd921a9b45f6d6df6f47a3b9b9e4941e71 /vcl
parentf81316af4f3c69d1f405040f4eddc523ce792add (diff)
Modify the ImpGraphic class, mpGfxLink to use an unique pointer
Change-Id: I74eb2347970ef19f7a215b86bfeae9945c07dbea Reviewed-on: https://gerrit.libreoffice.org/26889 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/impgraph.hxx26
-rw-r--r--vcl/source/gdi/impgraph.cxx33
2 files changed, 21 insertions, 38 deletions
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index e5ba1e94e4ae..bb67c66522fd 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -37,20 +37,20 @@ class ImpGraphic
private:
- GDIMetaFile maMetaFile;
- BitmapEx maEx;
- ImpSwapInfo maSwapInfo;
- std::unique_ptr<Animation> mpAnimation;
- GraphicReader* mpContext;
+ GDIMetaFile maMetaFile;
+ BitmapEx maEx;
+ ImpSwapInfo maSwapInfo;
+ std::unique_ptr<Animation> mpAnimation;
+ GraphicReader* mpContext;
std::shared_ptr<ImpSwapFile> mpSwapFile;
- GfxLink* mpGfxLink;
- GraphicType meType;
- mutable sal_uLong mnSizeBytes;
- sal_uLong mnRefCount;
- bool mbSwapOut;
- bool mbSwapUnderway;
- bool mbDummyContext;
- SvgDataPtr maSvgData;
+ std::unique_ptr<GfxLink> mpGfxLink;
+ GraphicType meType;
+ mutable sal_uLong mnSizeBytes;
+ sal_uLong mnRefCount;
+ bool mbSwapOut;
+ bool mbSwapUnderway;
+ bool mbDummyContext;
+ SvgDataPtr maSvgData;
css::uno::Sequence<sal_Int8> maPdfData;
private:
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 0f7eb2160e82..5478305f6397 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -96,7 +96,6 @@ Size GraphicReader::GetPreviewSize() const
ImpGraphic::ImpGraphic() :
mpContext ( nullptr ),
- mpGfxLink ( nullptr ),
meType ( GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mnRefCount ( 1UL ),
@@ -119,9 +118,7 @@ ImpGraphic::ImpGraphic( const ImpGraphic& rImpGraphic ) :
mbDummyContext ( rImpGraphic.mbDummyContext )
{
if( rImpGraphic.mpGfxLink )
- mpGfxLink = new GfxLink( *rImpGraphic.mpGfxLink );
- else
- mpGfxLink = nullptr;
+ mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink );
if( rImpGraphic.mpAnimation )
{
@@ -136,7 +133,6 @@ ImpGraphic::ImpGraphic( const ImpGraphic& rImpGraphic ) :
ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
maEx ( rBitmap ),
mpContext ( nullptr ),
- mpGfxLink ( nullptr ),
meType ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mnRefCount ( 1UL ),
@@ -149,7 +145,6 @@ ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
maEx ( rBitmapEx ),
mpContext ( nullptr ),
- mpGfxLink ( nullptr ),
meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mnRefCount ( 1UL ),
@@ -160,9 +155,7 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
}
ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr)
-: mpAnimation( nullptr ),
- mpContext( nullptr ),
- mpGfxLink( nullptr ),
+: mpContext( nullptr ),
meType( rSvgDataPtr.get() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes( 0UL ),
mnRefCount( 1UL ),
@@ -177,7 +170,6 @@ ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
maEx ( rAnimation.GetBitmapEx() ),
mpAnimation ( o3tl::make_unique<Animation>( rAnimation ) ),
mpContext ( nullptr ),
- mpGfxLink ( nullptr ),
meType ( GraphicType::Bitmap ),
mnSizeBytes ( 0UL ),
mnRefCount ( 1UL ),
@@ -190,7 +182,6 @@ ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
maMetaFile ( rMtf ),
mpContext ( nullptr ),
- mpGfxLink ( nullptr ),
meType ( GraphicType::GdiMetafile ),
mnSizeBytes ( 0UL ),
mnRefCount ( 1UL ),
@@ -235,12 +226,10 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
mpSwapFile = rImpGraphic.mpSwapFile;
}
- delete mpGfxLink;
+ mpGfxLink.reset();
if( rImpGraphic.mpGfxLink )
- mpGfxLink = new GfxLink( *rImpGraphic.mpGfxLink );
- else
- mpGfxLink = nullptr;
+ mpGfxLink = o3tl::make_unique<GfxLink>( *rImpGraphic.mpGfxLink );
maSvgData = rImpGraphic.maSvgData;
maPdfData = rImpGraphic.maPdfData;
@@ -333,12 +322,7 @@ void ImpGraphic::ImplClearGraphics( bool bCreateSwapInfo )
mpAnimation.reset();
}
- if( mpGfxLink )
- {
- delete mpGfxLink;
- mpGfxLink = nullptr;
- }
-
+ mpGfxLink.reset();
maSvgData.reset();
maPdfData = uno::Sequence<sal_Int8>();
}
@@ -1299,8 +1283,7 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm )
void ImpGraphic::ImplSetLink( const GfxLink& rGfxLink )
{
- delete mpGfxLink;
- mpGfxLink = new GfxLink( rGfxLink );
+ mpGfxLink = o3tl::make_unique<GfxLink>( rGfxLink );
if( mpGfxLink->IsNative() )
mpGfxLink->SwapOut();
@@ -1313,7 +1296,7 @@ GfxLink ImpGraphic::ImplGetLink()
bool ImpGraphic::ImplIsLink() const
{
- return ( mpGfxLink != nullptr );
+ return ( bool(mpGfxLink) );
}
BitmapChecksum ImpGraphic::ImplGetChecksum() const
@@ -1420,7 +1403,7 @@ SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) )
{
// set link only, if no other link was set
- const bool bSetLink = ( rImpGraphic.mpGfxLink == nullptr );
+ const bool bSetLink = ( !rImpGraphic.mpGfxLink );
// assign graphic
rImpGraphic = *aGraphic.ImplGetImpGraphic();