diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-09-09 20:30:53 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-10 12:19:13 +0200 |
commit | 16987d2aae9e0ed052de8a8f7155070c4b05cf4a (patch) | |
tree | 19a8216f86c3b263165a8152d24a75b0bd946678 /forms | |
parent | 9e67902277421aa3fae3bf10eb7bb8b70259c78e (diff) |
unique_ptr->optional for Graphic
Graphic is just a wrapper around shared_ptr, so no need to
allocate this separately
Change-Id: Ie657dea1c021e66a6876e814090a44cb6f995b91
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139739
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/component/imgprod.cxx | 22 | ||||
-rw-r--r-- | forms/source/component/imgprod.hxx | 7 |
2 files changed, 15 insertions, 14 deletions
diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx index ce88a85c0c24..950a0848a84a 100644 --- a/forms/source/component/imgprod.cxx +++ b/forms/source/component/imgprod.cxx @@ -163,7 +163,7 @@ ImageProducer::ImageProducer() : mnTransIndex(0) , mbConsInit(false) { - mpGraphic.reset( new Graphic ); + moGraphic.emplace(); } ImageProducer::~ImageProducer() @@ -201,7 +201,7 @@ void ImageProducer::removeConsumer( const css::uno::Reference< css::awt::XImageC void ImageProducer::SetImage( const OUString& rPath ) { maURL = rPath; - mpGraphic->Clear(); + moGraphic->Clear(); mbConsInit = false; mpStm.reset(); @@ -221,7 +221,7 @@ void ImageProducer::SetImage( const OUString& rPath ) void ImageProducer::SetImage( SvStream& rStm ) { maURL.clear(); - mpGraphic->Clear(); + moGraphic->Clear(); mbConsInit = false; mpStm.reset( new SvStream( new ImgProdLockBytes( &rStm, false ) ) ); @@ -231,7 +231,7 @@ void ImageProducer::SetImage( SvStream& rStm ) void ImageProducer::setImage( css::uno::Reference< css::io::XInputStream > const & rInputStmRef ) { maURL.clear(); - mpGraphic->Clear(); + moGraphic->Clear(); mbConsInit = false; mpStm.reset(); @@ -242,7 +242,7 @@ void ImageProducer::setImage( css::uno::Reference< css::io::XInputStream > const void ImageProducer::NewDataAvailable() { - if( ( GraphicType::NONE == mpGraphic->GetType() ) || mpGraphic->GetReaderContext() ) + if( ( GraphicType::NONE == moGraphic->GetType() ) || moGraphic->GetReaderContext() ) startProduction(); } @@ -255,18 +255,18 @@ void ImageProducer::startProduction() bool bNotifyEmptyGraphics = false; // valid stream or filled graphic? => update consumers - if( mpStm || ( mpGraphic->GetType() != GraphicType::NONE ) ) + if( mpStm || ( moGraphic->GetType() != GraphicType::NONE ) ) { // if we already have a graphic, we don't have to import again; // graphic is cleared if a new Stream is set - if( ( mpGraphic->GetType() == GraphicType::NONE ) || mpGraphic->GetReaderContext() ) + if( ( moGraphic->GetType() == GraphicType::NONE ) || moGraphic->GetReaderContext() ) { - if ( ImplImportGraphic( *mpGraphic ) ) - maDoneHdl.Call( mpGraphic.get() ); + if ( ImplImportGraphic( *moGraphic ) ) + maDoneHdl.Call( &*moGraphic ); } - if( mpGraphic->GetType() != GraphicType::NONE ) - ImplUpdateData( *mpGraphic ); + if( moGraphic->GetType() != GraphicType::NONE ) + ImplUpdateData( *moGraphic ); else bNotifyEmptyGraphics = true; } diff --git a/forms/source/component/imgprod.hxx b/forms/source/component/imgprod.hxx index 0e746eb6bd5d..4b68a9fcfeb0 100644 --- a/forms/source/component/imgprod.hxx +++ b/forms/source/component/imgprod.hxx @@ -24,12 +24,13 @@ #include <com/sun/star/awt/XImageProducer.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <cppuhelper/weak.hxx> +#include <vcl/graph.hxx> #include <memory> +#include <optional> #include <vector> class SvStream; -class Graphic; namespace com::sun::star::io { class XInputStream; } @@ -43,8 +44,8 @@ private: OUString maURL; ConsumerList_t maConsList; - std::unique_ptr<Graphic> - mpGraphic; + std::optional<Graphic> + moGraphic; std::unique_ptr<SvStream> mpStm; sal_uInt32 mnTransIndex; |