From 6dee1b1a8c12770d1e8139819aa532056deb3ed5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 15 Sep 2016 12:02:44 +0100 Subject: use std::unique_ptr Change-Id: Ibdbb7c32435684c7166ff3437a9fe812b3760356 --- filter/source/svg/svgexport.cxx | 22 +++++----------------- filter/source/svg/svgfilter.hxx | 18 ++++++++---------- 2 files changed, 13 insertions(+), 27 deletions(-) (limited to 'filter') diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index 9c9ac5fadc13..77964a862640 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -373,48 +373,36 @@ SVGExport::SVGExport( XML_NAMESPACE_ANIMATION); } - SVGExport::~SVGExport() { GetDocHandler()->endDocument(); } - -ObjectRepresentation::ObjectRepresentation() : - mpMtf( nullptr ) +ObjectRepresentation::ObjectRepresentation() { } - ObjectRepresentation::ObjectRepresentation( const Reference< XInterface >& rxObject, const GDIMetaFile& rMtf ) : mxObject( rxObject ), - mpMtf( new GDIMetaFile( rMtf ) ) + mxMtf( new GDIMetaFile( rMtf ) ) { } - ObjectRepresentation::ObjectRepresentation( const ObjectRepresentation& rPresentation ) : mxObject( rPresentation.mxObject ), - mpMtf( rPresentation.mpMtf ? new GDIMetaFile( *rPresentation.mpMtf ) : nullptr ) -{ -} - - -ObjectRepresentation::~ObjectRepresentation() + mxMtf( rPresentation.mxMtf ? new GDIMetaFile( *rPresentation.mxMtf ) : nullptr ) { - delete mpMtf; } - ObjectRepresentation& ObjectRepresentation::operator=( const ObjectRepresentation& rPresentation ) { // Check for self-assignment if (this == &rPresentation) return *this; + mxObject = rPresentation.mxObject; - delete mpMtf; - mpMtf = rPresentation.mpMtf ? new GDIMetaFile( *rPresentation.mpMtf ) : nullptr; + mxMtf.reset(rPresentation.mxMtf ? new GDIMetaFile(*rPresentation.mxMtf) : nullptr); return *this; } diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx index 447bf77921bc..2d4763857dde 100644 --- a/filter/source/svg/svgfilter.hxx +++ b/filter/source/svg/svgfilter.hxx @@ -123,21 +123,19 @@ class ObjectRepresentation private: Reference< XInterface > mxObject; - GDIMetaFile* mpMtf; + std::unique_ptr mxMtf; public: + ObjectRepresentation(); + ObjectRepresentation(const Reference< XInterface >& rxIf, + const GDIMetaFile& rMtf); + ObjectRepresentation(const ObjectRepresentation& rPresentation); - ObjectRepresentation(); - ObjectRepresentation( const Reference< XInterface >& rxIf, - const GDIMetaFile& rMtf ); - ObjectRepresentation( const ObjectRepresentation& rPresentation ); - ~ObjectRepresentation(); - - ObjectRepresentation& operator=( const ObjectRepresentation& rPresentation ); + ObjectRepresentation& operator=(const ObjectRepresentation& rPresentation); const Reference< XInterface >& GetObject() const { return mxObject; } - bool HasRepresentation() const { return mpMtf != nullptr; } - const GDIMetaFile& GetRepresentation() const { return *mpMtf; } + bool HasRepresentation() const { return static_cast(mxMtf); } + const GDIMetaFile& GetRepresentation() const { return *mxMtf; } }; struct PagePropertySet -- cgit