diff options
author | Mark Page <aptitude@btconnect.com> | 2016-11-30 14:10:30 +0000 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-11-30 22:08:03 +0000 |
commit | 64e6e7c6e7b881bf240de82ef020b290036e7e0e (patch) | |
tree | 9f4b4a2c1ac819f2583c1c0f9738984143507f18 /vcl/source | |
parent | 0de5101df0a8db41ad067b2575d16fd9b5a9a751 (diff) |
Use smart pointers for gdi pdf functions
Change-Id: Ia78adfbd0d07449e12a7e0d02acf8a1a1108437c
Reviewed-on: https://gerrit.libreoffice.org/31421
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 13 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/pngread.cxx | 26 |
3 files changed, 18 insertions, 25 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 919a514c62ae..db27d507d7ef 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -39,6 +39,7 @@ #include <cppuhelper/implbase.hxx> #include <i18nlangtag/languagetag.hxx> #include <o3tl/numeric.hxx> +#include <o3tl/make_unique.hxx> #include <osl/file.hxx> #include <osl/thread.h> #include <rtl/crc.h> @@ -1722,8 +1723,6 @@ void PDFWriterImpl::PDFPage::appendWaveLine( sal_Int32 nWidth, sal_Int32 nY, sal m_aContext(rContext), m_aFile(m_aContext.URL), m_bOpen(false), - m_pCodec( nullptr ), - m_pMemStream(nullptr), m_aDocDigest( rtl_digest_createMD5() ), m_aCipher( nullptr ), m_aDigest( nullptr ), @@ -2139,8 +2138,8 @@ void PDFWriterImpl::beginCompression() { if (!g_bDebugDisableCompression) { - m_pCodec = new ZCodec( 0x4000, 0x4000 ); - m_pMemStream = new SvMemoryStream(); + m_pCodec = o3tl::make_unique<ZCodec>( 0x4000, 0x4000 ); + m_pMemStream = o3tl::make_unique<SvMemoryStream>(); m_pCodec->BeginCompression(); } } @@ -2150,13 +2149,11 @@ void PDFWriterImpl::endCompression() if (!g_bDebugDisableCompression && m_pCodec) { m_pCodec->EndCompression(); - delete m_pCodec; - m_pCodec = nullptr; + m_pCodec.reset(); sal_uInt64 nLen = m_pMemStream->Tell(); m_pMemStream->Seek( 0 ); writeBuffer( m_pMemStream->GetData(), nLen ); - delete m_pMemStream; - m_pMemStream = nullptr; + m_pMemStream.reset(); } } diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 9abe5b5bf24e..5a30cf23afd8 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -713,8 +713,8 @@ private: std::list< GraphicsState > m_aGraphicsStack; GraphicsState m_aCurrentPDFState; - ZCodec* m_pCodec; - SvMemoryStream* m_pMemStream; + std::unique_ptr<ZCodec> m_pCodec; + std::unique_ptr<SvMemoryStream> m_pMemStream; std::vector< PDFAddStream > m_aAdditionalStreams; std::set< PDFWriter::ErrorCode > m_aErrors; diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx index c26a84129de4..f7ea29e23e19 100644 --- a/vcl/source/gdi/pngread.cxx +++ b/vcl/source/gdi/pngread.cxx @@ -28,6 +28,7 @@ #include <vcl/svapp.hxx> #include <vcl/alpha.hxx> #include <osl/endian.h> +#include <o3tl/make_unique.hxx> namespace vcl { @@ -74,11 +75,12 @@ private: std::vector<vcl::PNGReader::ChunkData>::iterator maChunkIter; std::vector<sal_uInt8>::iterator maDataIter; - Bitmap* mpBmp; - BitmapWriteAccess* mpAcc; - Bitmap* mpMaskBmp; - AlphaMask* mpAlphaMask; - BitmapWriteAccess* mpMaskAcc; + std::unique_ptr<Bitmap> mpBmp; + BitmapWriteAccess* mpAcc; + std::unique_ptr<Bitmap> mpMaskBmp; + std::unique_ptr<AlphaMask> mpAlphaMask; + BitmapWriteAccess* mpMaskAcc; + ZCodec mpZCodec; sal_uInt8* mpInflateInBuf; // as big as the size of a scanline + alphachannel + 1 sal_uInt8* mpScanPrior; // pointer to the latest scanline @@ -165,10 +167,7 @@ public: PNGReaderImpl::PNGReaderImpl( SvStream& rPNGStream ) : mrPNGStream( rPNGStream ), - mpBmp ( nullptr ), mpAcc ( nullptr ), - mpMaskBmp ( nullptr ), - mpAlphaMask ( nullptr ), mpMaskAcc ( nullptr ), mpInflateInBuf ( nullptr ), mpScanPrior ( nullptr ), @@ -246,9 +245,6 @@ PNGReaderImpl::~PNGReaderImpl() if( mpColorTable != mpDefaultColorTable ) delete[] mpColorTable; - delete mpBmp; - delete mpAlphaMask; - delete mpMaskBmp; delete[] mpTransTab; delete[] mpInflateInBuf; delete[] mpScanPrior; @@ -665,14 +661,14 @@ bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint ) if ( !mpInflateInBuf || !mpScanPrior ) return false; - mpBmp = new Bitmap( maTargetSize, mnTargetDepth ); + mpBmp = o3tl::make_unique<Bitmap>( maTargetSize, mnTargetDepth ); mpAcc = mpBmp->AcquireWriteAccess(); if( !mpAcc ) return false; if ( mbAlphaChannel ) { - mpAlphaMask = new AlphaMask( maTargetSize ); + mpAlphaMask = o3tl::make_unique<AlphaMask>( maTargetSize ); mpAlphaMask->Erase( 128 ); mpMaskAcc = mpAlphaMask->AcquireWriteAccess(); if( !mpMaskAcc ) @@ -789,12 +785,12 @@ bool PNGReaderImpl::ImplReadTransparent() { if( bNeedAlpha) { - mpAlphaMask = new AlphaMask( maTargetSize ); + mpAlphaMask = o3tl::make_unique<AlphaMask>( maTargetSize ); mpMaskAcc = mpAlphaMask->AcquireWriteAccess(); } else { - mpMaskBmp = new Bitmap( maTargetSize, 1 ); + mpMaskBmp = o3tl::make_unique<Bitmap>( maTargetSize, 1 ); mpMaskAcc = mpMaskBmp->AcquireWriteAccess(); } mbTransparent = (mpMaskAcc != nullptr); |