Kaydet (Commit) 0d46a29b authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in forms

Change-Id: I656ef57a322a4d04d0a39ae8f9e1df6fff054a58
Reviewed-on: https://gerrit.libreoffice.org/41511Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a05e5adc
...@@ -161,16 +161,11 @@ ImageProducer::ImageProducer() ...@@ -161,16 +161,11 @@ ImageProducer::ImageProducer()
, mnTransIndex(0) , mnTransIndex(0)
, mbConsInit(false) , mbConsInit(false)
{ {
mpGraphic = new Graphic; mpGraphic.reset( new Graphic );
} }
ImageProducer::~ImageProducer() ImageProducer::~ImageProducer()
{ {
delete mpGraphic;
mpGraphic = nullptr;
delete mpStm;
mpStm = nullptr;
} }
...@@ -206,19 +201,18 @@ void ImageProducer::SetImage( const OUString& rPath ) ...@@ -206,19 +201,18 @@ void ImageProducer::SetImage( const OUString& rPath )
maURL = rPath; maURL = rPath;
mpGraphic->Clear(); mpGraphic->Clear();
mbConsInit = false; mbConsInit = false;
delete mpStm; mpStm.reset();
if ( ::svt::GraphicAccess::isSupportedURL( maURL ) ) if ( ::svt::GraphicAccess::isSupportedURL( maURL ) )
{ {
mpStm = ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL ); mpStm.reset( ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL ) );
} }
else if( !maURL.isEmpty() ) else if( !maURL.isEmpty() )
{ {
SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, StreamMode::STD_READ ); SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, StreamMode::STD_READ );
mpStm = pIStm ? new SvStream( new ImgProdLockBytes( pIStm, true ) ) : nullptr; if (pIStm)
mpStm.reset( new SvStream( new ImgProdLockBytes( pIStm, true ) ) );
} }
else
mpStm = nullptr;
} }
...@@ -228,8 +222,7 @@ void ImageProducer::SetImage( SvStream& rStm ) ...@@ -228,8 +222,7 @@ void ImageProducer::SetImage( SvStream& rStm )
mpGraphic->Clear(); mpGraphic->Clear();
mbConsInit = false; mbConsInit = false;
delete mpStm; mpStm.reset( new SvStream( new ImgProdLockBytes( &rStm, false ) ) );
mpStm = new SvStream( new ImgProdLockBytes( &rStm, false ) );
} }
...@@ -238,12 +231,10 @@ void ImageProducer::setImage( css::uno::Reference< css::io::XInputStream > const ...@@ -238,12 +231,10 @@ void ImageProducer::setImage( css::uno::Reference< css::io::XInputStream > const
maURL.clear(); maURL.clear();
mpGraphic->Clear(); mpGraphic->Clear();
mbConsInit = false; mbConsInit = false;
delete mpStm; mpStm.reset();
if( rInputStmRef.is() ) if( rInputStmRef.is() )
mpStm = new SvStream( new ImgProdLockBytes( rInputStmRef ) ); mpStm.reset( new SvStream( new ImgProdLockBytes( rInputStmRef ) ) );
else
mpStm = nullptr;
} }
...@@ -268,7 +259,7 @@ void ImageProducer::startProduction() ...@@ -268,7 +259,7 @@ void ImageProducer::startProduction()
if( ( mpGraphic->GetType() == GraphicType::NONE ) || mpGraphic->GetContext() ) if( ( mpGraphic->GetType() == GraphicType::NONE ) || mpGraphic->GetContext() )
{ {
if ( ImplImportGraphic( *mpGraphic ) ) if ( ImplImportGraphic( *mpGraphic ) )
maDoneHdl.Call( mpGraphic ); maDoneHdl.Call( mpGraphic.get() );
} }
if( mpGraphic->GetType() != GraphicType::NONE ) if( mpGraphic->GetType() != GraphicType::NONE )
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <com/sun/star/awt/XImageProducer.hpp> #include <com/sun/star/awt/XImageProducer.hpp>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <memory>
#include <vector> #include <vector>
...@@ -47,8 +48,10 @@ private: ...@@ -47,8 +48,10 @@ private:
OUString maURL; OUString maURL;
ConsumerList_t maConsList; ConsumerList_t maConsList;
Graphic* mpGraphic; std::unique_ptr<Graphic>
SvStream* mpStm; mpGraphic;
std::unique_ptr<SvStream>
mpStm;
sal_uInt32 mnTransIndex; sal_uInt32 mnTransIndex;
bool mbConsInit; bool mbConsInit;
Link<Graphic*,void> maDoneHdl; Link<Graphic*,void> maDoneHdl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment