[Libreoffice-commits] core.git: vcl/source
Mark Page
aptitude at btconnect.com
Wed Nov 30 22:08:27 UTC 2016
vcl/source/gdi/pdfwriter_impl.cxx | 13 +++++--------
vcl/source/gdi/pdfwriter_impl.hxx | 4 ++--
vcl/source/gdi/pngread.cxx | 26 +++++++++++---------------
3 files changed, 18 insertions(+), 25 deletions(-)
New commits:
commit 64e6e7c6e7b881bf240de82ef020b290036e7e0e
Author: Mark Page <aptitude at btconnect.com>
Date: Wed Nov 30 14:10:30 2016 +0000
Use smart pointers for gdi pdf functions
Change-Id: Ia78adfbd0d07449e12a7e0d02acf8a1a1108437c
Reviewed-on: https://gerrit.libreoffice.org/31421
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 919a514..db27d50 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 9abe5b5..5a30cf2 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 c26a841..f7ea29e 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);
More information about the Libreoffice-commits
mailing list