[Libreoffice-commits] core.git: Branch 'feature/useuniqueptr-2' - 10 commits - include/vcl vcl/inc vcl/qa vcl/source vcl/unx

Noel Grandin noel.grandin at collabora.co.uk
Tue Jan 16 09:51:54 UTC 2018


 include/vcl/graphicfilter.hxx                 |    3 +-
 include/vcl/pdfextoutdevdata.hxx              |    5 ++-
 include/vcl/vectorgraphicdata.hxx             |    3 +-
 vcl/inc/fontinstance.hxx                      |    3 +-
 vcl/inc/octree.hxx                            |    2 -
 vcl/inc/unx/glyphcache.hxx                    |    2 -
 vcl/inc/window.h                              |   16 ++++++----
 vcl/qa/cppunit/graphicfilter/filters-test.cxx |   12 ++++----
 vcl/source/app/settings.cxx                   |   38 ++++++++++++--------------
 vcl/source/filter/graphicfilter.cxx           |    4 +-
 vcl/source/font/fontinstance.cxx              |    5 +--
 vcl/source/gdi/octree.cxx                     |    4 +-
 vcl/source/gdi/pdfextoutdevdata.cxx           |    9 ++----
 vcl/source/gdi/pdfwriter_impl.cxx             |    9 ++----
 vcl/source/gdi/pdfwriter_impl.hxx             |   15 ++--------
 vcl/source/gdi/vectorgraphicdata.cxx          |    6 ----
 vcl/source/window/accessibility.cxx           |   12 ++++----
 vcl/source/window/clipping.cxx                |   10 ++----
 vcl/source/window/window.cxx                  |   24 +++++++---------
 vcl/source/window/window2.cxx                 |    4 +-
 vcl/unx/generic/glyphs/glyphcache.cxx         |    6 +---
 21 files changed, 88 insertions(+), 104 deletions(-)

New commits:
commit a2d3f3295c81e47e209112555c8fdc4b78b4403f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 14:35:43 2018 +0200

    loplugin:useuniqueptr in GlyphCache
    
    Change-Id: I4d6cca83f321f74faae7d2c6d0481a864f5f0b95

diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index 42b2f4244450..ba56ecf48b75 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -93,7 +93,7 @@ private:
     mutable int             mnGlyphCount;
     FreetypeFont*           mpCurrentGCFont;
 
-    FreetypeManager*        mpFtManager;
+    std::unique_ptr<FreetypeManager>  mpFtManager;
 };
 
 class GlyphData
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx
index aaff8d36535f..fa5bfb6a5de1 100644
--- a/vcl/unx/generic/glyphs/glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/glyphcache.cxx
@@ -36,17 +36,15 @@ GlyphCache::GlyphCache()
     mnBytesUsed(sizeof(GlyphCache)),
     mnLruIndex(0),
     mnGlyphCount(0),
-    mpCurrentGCFont(nullptr),
-    mpFtManager(nullptr)
+    mpCurrentGCFont(nullptr)
 {
     pInstance = this;
-    mpFtManager = new FreetypeManager;
+    mpFtManager.reset( new FreetypeManager );
 }
 
 GlyphCache::~GlyphCache()
 {
     InvalidateAllGlyphs();
-    delete mpFtManager;
 }
 
 void GlyphCache::InvalidateAllGlyphs()
commit 4c6897e1d36c083d0b4a0f33fbe555aed043e480
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 14:34:05 2018 +0200

    loplugin:useuniqueptr in GraphicFilter
    
    Change-Id: Ib359da131c84c291504a9df210a3b222fd77bd0c

diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index e10afd1997d2..bc218851f412 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -30,6 +30,7 @@
 
 #include <com/sun/star/uno/Sequence.h>
 #include <com/sun/star/beans/PropertyValue.hpp>
+#include <memory>
 
 class FilterConfigCache;
 class SvStream;
@@ -310,7 +311,7 @@ private:
 
                     DECL_LINK( FilterCallback, ConvertData&, bool );
 
-    FilterErrorEx*      pErrorEx;
+    std::unique_ptr<FilterErrorEx> pErrorEx;
     bool                bUseConfig;
 };
 
diff --git a/vcl/qa/cppunit/graphicfilter/filters-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
index bdfa85a403b0..a423a17081e8 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-test.cxx
@@ -25,11 +25,11 @@ class VclFiltersTest :
     public test::FiltersTest,
     public test::BootstrapFixture
 {
-    GraphicFilter mGraphicFilter;
+    std::unique_ptr<GraphicFilter> mpGraphicFilter;
 public:
     VclFiltersTest() :
         BootstrapFixture(true, false),
-        mGraphicFilter(GraphicFilter(false))
+        mpGraphicFilter(new GraphicFilter(false))
     {}
 
     virtual bool load(const OUString &,
@@ -59,7 +59,7 @@ bool VclFiltersTest::load(const OUString &,
 {
     SvFileStream aFileStream(rURL, StreamMode::READ);
     Graphic aGraphic;
-    bool bRetval(ERRCODE_NONE == mGraphicFilter.ImportGraphic(aGraphic, rURL, aFileStream));
+    bool bRetval(ERRCODE_NONE == mpGraphicFilter->ImportGraphic(aGraphic, rURL, aFileStream));
 
     if (!bRetval)
     {
@@ -116,15 +116,15 @@ void VclFiltersTest::checkExportImport(const OUString& aFilterShortName)
     aFilterData[ 2 ].Name = "Quality";
     aFilterData[ 2 ].Value <<= sal_Int32(90);
 
-    sal_uInt16 aFilterType = mGraphicFilter.GetExportFormatNumberForShortName(aFilterShortName);
-    mGraphicFilter.ExportGraphic( aBitmap, OUString(), aStream, aFilterType, &aFilterData );
+    sal_uInt16 aFilterType = mpGraphicFilter->GetExportFormatNumberForShortName(aFilterShortName);
+    mpGraphicFilter->ExportGraphic( aBitmap, OUString(), aStream, aFilterType, &aFilterData );
 
     CPPUNIT_ASSERT(aStream.Tell() > 0);
 
     aStream.Seek( STREAM_SEEK_TO_BEGIN );
 
     Graphic aLoadedGraphic;
-    mGraphicFilter.ImportGraphic( aLoadedGraphic, OUString(), aStream );
+    mpGraphicFilter->ImportGraphic( aLoadedGraphic, OUString(), aStream );
 
     BitmapEx aLoadedBitmapEx = aLoadedGraphic.GetBitmapEx();
     Size aSize = aLoadedBitmapEx.GetSizePixel();
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 56b5ab6d0ef5..4c0166716ddd 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1100,7 +1100,7 @@ GraphicFilter::~GraphicFilter()
         }
     }
 
-    delete pErrorEx;
+    pErrorEx.reset();
 }
 
 void GraphicFilter::ImplInit()
@@ -1126,7 +1126,7 @@ void GraphicFilter::ImplInit()
         osl::FileBase::getSystemPathFromFileURL(url, aFilterPath);
     }
 
-    pErrorEx = new FilterErrorEx;
+    pErrorEx.reset( new FilterErrorEx );
 }
 
 ErrCode GraphicFilter::ImplSetError( ErrCode nError, const SvStream* pStm )
commit 6a5b7fe72d59ac3ce1adc9897ceb536d95d097e4
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 14:26:54 2018 +0200

    loplugin:useuniqueptr in ImplAllSettingsData
    
    Change-Id: If1894bd1a77fa1aab72896574357bd9852f66708

diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index c1a02dc27a91..97723e7a21b5 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -243,10 +243,10 @@ struct ImplAllSettingsData
     LanguageTag                             maLocale;
     AllSettingsFlags                        mnWindowUpdate;
     LanguageTag                             maUILocale;
-    LocaleDataWrapper*                      mpLocaleDataWrapper;
-    LocaleDataWrapper*                      mpUILocaleDataWrapper;
-    vcl::I18nHelper*                        mpI18nHelper;
-    vcl::I18nHelper*                        mpUII18nHelper;
+    std::unique_ptr<LocaleDataWrapper>      mpLocaleDataWrapper;
+    std::unique_ptr<LocaleDataWrapper>      mpUILocaleDataWrapper;
+    std::unique_ptr<vcl::I18nHelper>        mpI18nHelper;
+    std::unique_ptr<vcl::I18nHelper>        mpUII18nHelper;
     SvtSysLocale                            maSysLocale;
 };
 
@@ -2680,10 +2680,10 @@ ImplAllSettingsData::ImplAllSettingsData( const ImplAllSettingsData& rData ) :
 
 ImplAllSettingsData::~ImplAllSettingsData()
 {
-    delete mpLocaleDataWrapper;
-    delete mpUILocaleDataWrapper;
-    delete mpI18nHelper;
-    delete mpUII18nHelper;
+    mpLocaleDataWrapper.reset();
+    mpUILocaleDataWrapper.reset();
+    mpI18nHelper.reset();
+    mpUII18nHelper.reset();
 }
 
 AllSettings::AllSettings()
@@ -2801,13 +2801,11 @@ void AllSettings::SetLanguageTag( const LanguageTag& rLanguageTag )
 
         if ( mxData->mpLocaleDataWrapper )
         {
-            delete mxData->mpLocaleDataWrapper;
-            mxData->mpLocaleDataWrapper = nullptr;
+            mxData->mpLocaleDataWrapper.reset();
         }
         if ( mxData->mpI18nHelper )
         {
-            delete mxData->mpI18nHelper;
-            mxData->mpI18nHelper = nullptr;
+            mxData->mpI18nHelper.reset();
         }
     }
 }
@@ -2911,24 +2909,24 @@ const LanguageTag& AllSettings::GetUILanguageTag() const
 const LocaleDataWrapper& AllSettings::GetLocaleDataWrapper() const
 {
     if ( !mxData->mpLocaleDataWrapper )
-        const_cast<AllSettings*>(this)->mxData->mpLocaleDataWrapper = new LocaleDataWrapper(
-            comphelper::getProcessComponentContext(), GetLanguageTag() );
+        const_cast<AllSettings*>(this)->mxData->mpLocaleDataWrapper.reset( new LocaleDataWrapper(
+            comphelper::getProcessComponentContext(), GetLanguageTag() ) );
     return *mxData->mpLocaleDataWrapper;
 }
 
 const LocaleDataWrapper& AllSettings::GetUILocaleDataWrapper() const
 {
     if ( !mxData->mpUILocaleDataWrapper )
-        const_cast<AllSettings*>(this)->mxData->mpUILocaleDataWrapper = new LocaleDataWrapper(
-            comphelper::getProcessComponentContext(), GetUILanguageTag() );
+        const_cast<AllSettings*>(this)->mxData->mpUILocaleDataWrapper.reset( new LocaleDataWrapper(
+            comphelper::getProcessComponentContext(), GetUILanguageTag() ) );
     return *mxData->mpUILocaleDataWrapper;
 }
 
 const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const
 {
     if ( !mxData->mpI18nHelper ) {
-        const_cast<AllSettings*>(this)->mxData->mpI18nHelper = new vcl::I18nHelper(
-            comphelper::getProcessComponentContext(), GetLanguageTag() );
+        const_cast<AllSettings*>(this)->mxData->mpI18nHelper.reset( new vcl::I18nHelper(
+            comphelper::getProcessComponentContext(), GetLanguageTag() ) );
     }
     return *mxData->mpI18nHelper;
 }
@@ -2936,8 +2934,8 @@ const vcl::I18nHelper& AllSettings::GetLocaleI18nHelper() const
 const vcl::I18nHelper& AllSettings::GetUILocaleI18nHelper() const
 {
     if ( !mxData->mpUII18nHelper ) {
-        const_cast<AllSettings*>(this)->mxData->mpUII18nHelper = new vcl::I18nHelper(
-            comphelper::getProcessComponentContext(), GetUILanguageTag() );
+        const_cast<AllSettings*>(this)->mxData->mpUII18nHelper.reset( new vcl::I18nHelper(
+            comphelper::getProcessComponentContext(), GetUILanguageTag() ) );
     }
     return *mxData->mpUII18nHelper;
 }
commit d6789142c59e1371198c1f9035cf90db0ebc83f3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 14:26:33 2018 +0200

    loplugin:useuniqueptr in LogicalFontInstance
    
    Change-Id: Id0ba44d9080294576dbafc47e68dff41a8257d29

diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index be6df2c0fbad..cdafb1573a98 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -25,6 +25,7 @@
 #include "PhysicalFontFace.hxx"
 
 #include <unordered_map>
+#include <memory>
 
 class ConvertChar;
 class ImplFontCache;
@@ -65,7 +66,7 @@ private:
     // TODO: a fallback map can be shared with many other ImplFontEntries
     // TODO: at least the ones which just differ in orientation, stretching or height
     typedef ::std::unordered_map< ::std::pair<sal_UCS4,FontWeight>, OUString > UnicodeFallbackList;
-    UnicodeFallbackList* mpUnicodeFallbackList;
+    std::unique_ptr<UnicodeFallbackList> mpUnicodeFallbackList;
     ImplFontCache * mpFontCache;
     sal_uInt32      mnRefCount;
 };
diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx
index 05263e863aef..85383399abff 100644
--- a/vcl/source/font/fontinstance.cxx
+++ b/vcl/source/font/fontinstance.cxx
@@ -45,7 +45,6 @@ LogicalFontInstance::LogicalFontInstance( const FontSelectPattern& rFontSelData
     , mnOwnOrientation( 0 )
     , mnOrientation( 0 )
     , mbInit( false )
-    , mpUnicodeFallbackList( nullptr )
     , mpFontCache( nullptr )
     , mnRefCount( 1 )
 {
@@ -54,7 +53,7 @@ LogicalFontInstance::LogicalFontInstance( const FontSelectPattern& rFontSelData
 
 LogicalFontInstance::~LogicalFontInstance()
 {
-    delete mpUnicodeFallbackList;
+    mpUnicodeFallbackList.reset();
     mpFontCache = nullptr;
     mxFontMetric = nullptr;
 }
@@ -83,7 +82,7 @@ void LogicalFontInstance::Release()
 void LogicalFontInstance::AddFallbackForUnicode( sal_UCS4 cChar, FontWeight eWeight, const OUString& rFontName )
 {
     if( !mpUnicodeFallbackList )
-        mpUnicodeFallbackList = new UnicodeFallbackList;
+        mpUnicodeFallbackList.reset(new UnicodeFallbackList);
     (*mpUnicodeFallbackList)[ std::pair< sal_UCS4, FontWeight >(cChar,eWeight) ] = rFontName;
 }
 
commit 4e32805ccb3f3337dd33e851385a3feb98a4c96c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 11:49:59 2018 +0200

    loplugin:useuniqueptr in PDFExtOutDevData
    
    Change-Id: I1607fa0f1d6385ccff657be2f892b876575b9674

diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx
index 6dc5165d99a5..e577454c14bd 100644
--- a/include/vcl/pdfextoutdevdata.hxx
+++ b/include/vcl/pdfextoutdevdata.hxx
@@ -27,6 +27,7 @@
 #include <vcl/gdimtf.hxx>
 #include <vcl/mapmod.hxx>
 #include <vector>
+#include <memory>
 
 class Graphic;
 
@@ -87,8 +88,8 @@ class VCL_DLLPUBLIC PDFExtOutDevData : public ExtOutDevData
     sal_Int32                   mnCompressionQuality;
     css::lang::Locale           maDocLocale;
 
-    PageSyncData*               mpPageSyncData;
-    GlobalSyncData*             mpGlobalSyncData;
+    std::unique_ptr<PageSyncData> mpPageSyncData;
+    std::unique_ptr<GlobalSyncData> mpGlobalSyncData;
 
     std::vector< PDFExtOutDevBookmarkEntry > maBookmarks;
 
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index 4966aec601f2..db5b731393c9 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -511,16 +511,15 @@ PDFExtOutDevData::PDFExtOutDevData( const OutputDevice& rOutDev ) :
     mbExportNDests          ( false ),
     mnPage                  ( -1 ),
     mnCompressionQuality    ( 90 ),
-    mpPageSyncData          ( nullptr ),
     mpGlobalSyncData        ( new GlobalSyncData() )
 {
-    mpPageSyncData = new PageSyncData( mpGlobalSyncData );
+    mpPageSyncData.reset( new PageSyncData( mpGlobalSyncData.get() ) );
 }
 
 PDFExtOutDevData::~PDFExtOutDevData()
 {
-    delete mpPageSyncData;
-    delete mpGlobalSyncData;
+    mpPageSyncData.reset();
+    mpGlobalSyncData.reset();
 }
 
 const Graphic& PDFExtOutDevData::GetCurrentGraphic() const
@@ -582,7 +581,7 @@ void PDFExtOutDevData::SetIsExportNamedDestinations( const bool bExportNDests )
 }
 void PDFExtOutDevData::ResetSyncData()
 {
-    *mpPageSyncData = PageSyncData( mpGlobalSyncData );
+    *mpPageSyncData = PageSyncData( mpGlobalSyncData.get() );
 }
 bool PDFExtOutDevData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rIdx )
 {
commit 3ab177cc74c71e798dfaf9cc40f3a50bdc6f45c6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 11:41:28 2018 +0200

    loplugin:useuniqueptr in VectorGraphicData
    
    Change-Id: I73badcdf544b1c3508c9eb9e489b049a9fa12928

diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx
index 66541616b41c..c258182bc120 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -26,6 +26,7 @@
 #include <vcl/wmfexternal.hxx>
 #include <rtl/ustring.hxx>
 #include <deque>
+#include <memory>
 
 
 typedef css::uno::Sequence<sal_Int8> VectorGraphicDataArray;
@@ -65,7 +66,7 @@ private:
     VectorGraphicDataType       meVectorGraphicDataType;
 
     // extra:
-    WmfExternal*         mpExternalHeader;
+    std::unique_ptr<WmfExternal> mpExternalHeader;
 
     // on demand creators
     void ensureReplacement();
diff --git a/vcl/source/gdi/vectorgraphicdata.cxx b/vcl/source/gdi/vectorgraphicdata.cxx
index e59d87495e5d..24aea9c34ffc 100644
--- a/vcl/source/gdi/vectorgraphicdata.cxx
+++ b/vcl/source/gdi/vectorgraphicdata.cxx
@@ -129,7 +129,7 @@ void VectorGraphicData::setWmfExternalHeader(const WmfExternal& aExtHeader)
 {
     if (!mpExternalHeader)
     {
-        mpExternalHeader = new WmfExternal;
+        mpExternalHeader.reset( new WmfExternal );
     }
 
     *mpExternalHeader = aExtHeader;
@@ -269,10 +269,6 @@ VectorGraphicData::VectorGraphicData(
 
 VectorGraphicData::~VectorGraphicData()
 {
-    if (mpExternalHeader)
-    {
-        delete mpExternalHeader;
-    };
 }
 
 const basegfx::B2DRange& VectorGraphicData::getRange() const
commit 242a9d81b31423be78ad042934055a8ab84a995c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 11:37:46 2018 +0200

    loplugin:useuniqueptr in Octree
    
    Change-Id: I26824107dbcf5d313409e301059a37a59b59a05b

diff --git a/vcl/inc/octree.hxx b/vcl/inc/octree.hxx
index 7665d9321619..729a61255552 100644
--- a/vcl/inc/octree.hxx
+++ b/vcl/inc/octree.hxx
@@ -60,7 +60,7 @@ private:
     NODE*                       pTree;
     NODE*                       pReduce[ OCTREE_BITS + 1 ];
     BitmapColor const *         pColor;
-    ImpNodeCache*               pNodeCache;
+    std::unique_ptr<ImpNodeCache> pNodeCache;
     const BitmapReadAccess*     pAcc;
     sal_uInt16                  nPalIndex;
 
diff --git a/vcl/source/gdi/octree.cxx b/vcl/source/gdi/octree.cxx
index d4eb44eb33c0..a6450a2b0882 100644
--- a/vcl/source/gdi/octree.cxx
+++ b/vcl/source/gdi/octree.cxx
@@ -61,7 +61,7 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors)
     , pAcc(&rReadAcc)
     , nPalIndex(0)
 {
-    pNodeCache = new ImpNodeCache( nColors );
+    pNodeCache.reset( new ImpNodeCache( nColors ) );
     memset( pReduce, 0, ( OCTREE_BITS + 1 ) * sizeof( NODE* ) );
 
     if( !!*pAcc )
@@ -109,7 +109,7 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong nColors)
 Octree::~Octree()
 {
     ImplDeleteOctree( &pTree );
-    delete pNodeCache;
+    pNodeCache.reset();
 }
 
 void Octree::ImplDeleteOctree( NODE** ppNode )
commit de3a64e0f679792138bdb13f09d8320fa673af1b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 11:14:53 2018 +0200

    loplugin:useuniqueptr in TransparencyEmit
    
    Change-Id: I7cc2d329cb6238c7933f087fd94d1409756512ff

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 75e11feb27ba..9a874f0e84a9 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2300,8 +2300,7 @@ void PDFWriterImpl::endPage()
         if( item.m_pContentStream )
         {
             writeTransparentObject(item);
-            delete item.m_pContentStream;
-            item.m_pContentStream = nullptr;
+            item.m_pContentStream.reset();
         }
     }
 
@@ -7781,7 +7780,7 @@ void PDFWriterImpl::drawTransparent( const tools::PolyPolygon& rPolyPoly, sal_uI
     m_aTransparentObjects.back().m_nObject          = createObject();
     m_aTransparentObjects.back().m_nExtGStateObject = createObject();
     m_aTransparentObjects.back().m_fAlpha           = static_cast<double>(100-nTransparentPercent) / 100.0;
-    m_aTransparentObjects.back().m_pContentStream   = new SvMemoryStream( 256, 256 );
+    m_aTransparentObjects.back().m_pContentStream.reset(new SvMemoryStream( 256, 256 ));
     // create XObject's content stream
     OStringBuffer aContent( 256 );
     m_aPages.back().appendPolyPolygon( rPolyPoly, aContent );
@@ -7925,7 +7924,7 @@ void PDFWriterImpl::endTransparencyGroup( const tools::Rectangle& rBoundingBox,
     m_aTransparentObjects.back().m_nObject      = createObject();
     m_aTransparentObjects.back().m_fAlpha       = static_cast<double>(100-nTransparentPercent) / 100.0;
     // get XObject's content stream
-    m_aTransparentObjects.back().m_pContentStream = static_cast<SvMemoryStream*>(endRedirect());
+    m_aTransparentObjects.back().m_pContentStream.reset( static_cast<SvMemoryStream*>(endRedirect()) );
     m_aTransparentObjects.back().m_nExtGStateObject = createObject();
 
     OStringBuffer aObjName( 16 );
@@ -8507,7 +8506,7 @@ void PDFWriterImpl::writeTransparentObject( TransparencyEmit& rObject )
 {
     CHECK_RETURN2( updateObject( rObject.m_nObject ) );
 
-    bool bFlateFilter = compressStream( rObject.m_pContentStream );
+    bool bFlateFilter = compressStream( rObject.m_pContentStream.get() );
     rObject.m_pContentStream->Seek( STREAM_SEEK_TO_END );
     sal_uLong nSize = rObject.m_pContentStream->Tell();
     rObject.m_pContentStream->Seek( STREAM_SEEK_TO_BEGIN );
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index b2890823fad3..835c7c8792f5 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -297,22 +297,15 @@ public:
         sal_Int32           m_nObject;
         sal_Int32           m_nExtGStateObject;
         double              m_fAlpha;
-        tools::Rectangle           m_aBoundRect;
-        SvMemoryStream*     m_pContentStream;
-        SvMemoryStream*     m_pSoftMaskStream;
+        tools::Rectangle    m_aBoundRect;
+        std::unique_ptr<SvMemoryStream>  m_pContentStream;
+        std::unique_ptr<SvMemoryStream>  m_pSoftMaskStream;
 
         TransparencyEmit()
                 : m_nObject( 0 ),
                   m_nExtGStateObject( -1 ),
-                  m_fAlpha( 0.0 ),
-                  m_pContentStream( nullptr ),
-                  m_pSoftMaskStream( nullptr )
+                  m_fAlpha( 0.0 )
         {}
-        ~TransparencyEmit()
-        {
-            delete m_pContentStream;
-            delete m_pSoftMaskStream;
-        }
     };
 
     // font subsets
commit 1347b52e02fca2d2a4f1a8b77f95f5cd660ca52c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 11:05:14 2018 +0200

    loplugin:useuniqueptr in WindowImpl
    
    Change-Id: I6a24f9fdf574276281d4a67caec426df14b2dd8c

diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 94d0013908db..5c942db6c1e0 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -270,12 +270,12 @@ public:
     css::uno::Reference< css::accessibility::XAccessible > mxAccessible;
     std::shared_ptr< VclSizeGroup > m_xSizeGroup;
     std::vector< VclPtr<FixedText> > m_aMnemonicLabels;
-    ImplAccessibleInfos* mpAccessibleInfos;
+    std::unique_ptr<ImplAccessibleInfos> mpAccessibleInfos;
     VCLXWindow*         mpVCLXWindow;
     vcl::Region              maWinRegion;            //< region to 'shape' the VCL window (frame coordinates)
     vcl::Region              maWinClipRegion;        //< the (clipping) region that finally corresponds to the VCL window (frame coordinates)
     vcl::Region              maInvalidateRegion;     //< region that has to be redrawn (frame coordinates)
-    vcl::Region*             mpChildClipRegion;      //< child clip region if CLIPCHILDREN is set (frame coordinates)
+    std::unique_ptr<vcl::Region> mpChildClipRegion;  //< child clip region if CLIPCHILDREN is set (frame coordinates)
     vcl::Region*             mpPaintRegion;          //< only set during Paint() method call (window coordinates)
     WinBits             mnStyle;
     WinBits             mnPrevStyle;
diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx
index 4ee4b07ea89d..098044899898 100644
--- a/vcl/source/window/accessibility.cxx
+++ b/vcl/source/window/accessibility.cxx
@@ -281,7 +281,7 @@ vcl::Window* Window::GetAccessibleChildWindow( sal_uInt16 n )
 void Window::SetAccessibleRole( sal_uInt16 nRole )
 {
     if ( !mpWindowImpl->mpAccessibleInfos )
-        mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
+        mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos );
 
     SAL_WARN_IF( mpWindowImpl->mpAccessibleInfos->nAccessibleRole != 0xFFFF, "vcl", "AccessibleRole already set!" );
     mpWindowImpl->mpAccessibleInfos->nAccessibleRole = nRole;
@@ -418,7 +418,7 @@ sal_uInt16 Window::GetAccessibleRole() const
 void Window::SetAccessibleName( const OUString& rName )
 {
    if ( !mpWindowImpl->mpAccessibleInfos )
-        mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
+        mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos );
 
     OUString oldName = GetAccessibleName();
 
@@ -500,7 +500,7 @@ OUString Window::getDefaultAccessibleName() const
 void Window::SetAccessibleDescription( const OUString& rDescription )
 {
    if ( ! mpWindowImpl->mpAccessibleInfos )
-        mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
+        mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos );
 
     SAL_WARN_IF( mpWindowImpl->mpAccessibleInfos->pAccessibleDescription, "vcl", "AccessibleDescription already set!" );
     mpWindowImpl->mpAccessibleInfos->pAccessibleDescription.reset( new OUString( rDescription ) );
@@ -530,21 +530,21 @@ OUString Window::GetAccessibleDescription() const
 void Window::SetAccessibleRelationLabeledBy( vcl::Window* pLabeledBy )
 {
     if ( !mpWindowImpl->mpAccessibleInfos )
-        mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
+        mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos );
     mpWindowImpl->mpAccessibleInfos->pLabeledByWindow = pLabeledBy;
 }
 
 void Window::SetAccessibleRelationLabelFor( vcl::Window* pLabelFor )
 {
     if ( !mpWindowImpl->mpAccessibleInfos )
-        mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
+        mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos );
     mpWindowImpl->mpAccessibleInfos->pLabelForWindow = pLabelFor;
 }
 
 void Window::SetAccessibleRelationMemberOf( vcl::Window* pMemberOfWin )
 {
     if ( !mpWindowImpl->mpAccessibleInfos )
-        mpWindowImpl->mpAccessibleInfos = new ImplAccessibleInfos;
+        mpWindowImpl->mpAccessibleInfos.reset( new ImplAccessibleInfos );
     mpWindowImpl->mpAccessibleInfos->pMemberOfWindow = pMemberOfWin;
 }
 
diff --git a/vcl/source/window/clipping.cxx b/vcl/source/window/clipping.cxx
index 922ff7104e30..9a45d03c1f08 100644
--- a/vcl/source/window/clipping.cxx
+++ b/vcl/source/window/clipping.cxx
@@ -265,16 +265,12 @@ void Window::ImplInitWinChildClipRegion()
 {
     if ( !mpWindowImpl->mpFirstChild )
     {
-        if ( mpWindowImpl->mpChildClipRegion )
-        {
-            delete mpWindowImpl->mpChildClipRegion;
-            mpWindowImpl->mpChildClipRegion = nullptr;
-        }
+        mpWindowImpl->mpChildClipRegion.reset();
     }
     else
     {
         if ( !mpWindowImpl->mpChildClipRegion )
-            mpWindowImpl->mpChildClipRegion = new vcl::Region( mpWindowImpl->maWinClipRegion );
+            mpWindowImpl->mpChildClipRegion.reset( new vcl::Region( mpWindowImpl->maWinClipRegion ) );
         else
             *mpWindowImpl->mpChildClipRegion = mpWindowImpl->maWinClipRegion;
 
@@ -291,7 +287,7 @@ Region* Window::ImplGetWinChildClipRegion()
     if ( mpWindowImpl->mbInitChildRegion )
         ImplInitWinChildClipRegion();
     if ( mpWindowImpl->mpChildClipRegion )
-        return mpWindowImpl->mpChildClipRegion;
+        return mpWindowImpl->mpChildClipRegion.get();
     else
         return &mpWindowImpl->maWinClipRegion;
 }
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 036034a37e77..f1ee1d744baa 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -744,8 +744,8 @@ WindowImpl::WindowImpl( WindowType nType )
 
 WindowImpl::~WindowImpl()
 {
-    delete mpChildClipRegion;
-    delete mpAccessibleInfos;
+    mpChildClipRegion.reset();
+    mpAccessibleInfos.reset();
 }
 
 ImplWinData::ImplWinData() :
commit 854b93d9a2250455d90016172d4ddb2fc17dd8fe
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 15 09:46:31 2018 +0200

    loplugin:useuniqueptr in ImplWinData
    
    Change-Id: Iea0e657bed5a8008f82534494cb0965a9749f1b2

diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index dec452861bb1..94d0013908db 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -94,13 +94,17 @@ struct ImplWinData
                         mpExtOldText;
     std::unique_ptr<ExtTextInputAttr[]>
                         mpExtOldAttrAry;
-    tools::Rectangle*   mpCursorRect;
+    std::unique_ptr<tools::Rectangle>
+                        mpCursorRect;
     long                mnCursorExtWidth;
     bool                mbVertical;
-    tools::Rectangle*   mpCompositionCharRects;
+    std::unique_ptr<tools::Rectangle[]>
+                        mpCompositionCharRects;
     long                mnCompositionCharRects;
-    tools::Rectangle*   mpFocusRect;
-    tools::Rectangle*   mpTrackRect;
+    std::unique_ptr<tools::Rectangle>
+                        mpFocusRect;
+    std::unique_ptr<tools::Rectangle>
+                        mpTrackRect;
     ShowTrackFlags      mnTrackFlags;
     sal_uInt16          mnIsTopWindow;
     bool                mbMouseOver;            //< tracks mouse over for native widget paint effect
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 36dad81c68cb..036034a37e77 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -767,10 +767,10 @@ ImplWinData::ImplWinData() :
 
 ImplWinData::~ImplWinData()
 {
-    delete mpCursorRect;
-    delete[] mpCompositionCharRects;
-    delete mpFocusRect;
-    delete mpTrackRect;
+    mpCursorRect.reset();
+    mpCompositionCharRects.reset();
+    mpFocusRect.reset();
+    mpTrackRect.reset();
 }
 
 ImplFrameData::ImplFrameData( vcl::Window *pWindow )
@@ -2086,14 +2086,13 @@ void Window::SetCursorRect( const tools::Rectangle* pRect, long nExtTextInputWid
             *pWinData->mpCursorRect = *pRect;
         else
         {
-            delete pWinData->mpCursorRect;
-            pWinData->mpCursorRect = nullptr;
+            pWinData->mpCursorRect.reset();
         }
     }
     else
     {
         if ( pRect )
-            pWinData->mpCursorRect = new tools::Rectangle( *pRect );
+            pWinData->mpCursorRect.reset( new tools::Rectangle( *pRect ) );
     }
 
     pWinData->mnCursorExtWidth = nExtTextInputWidth;
@@ -2104,7 +2103,7 @@ const tools::Rectangle* Window::GetCursorRect() const
 {
 
     ImplWinData* pWinData = ImplGetWinData();
-    return pWinData->mpCursorRect;
+    return pWinData->mpCursorRect.get();
 }
 
 long Window::GetCursorExtTextInputWidth() const
@@ -2117,13 +2116,12 @@ long Window::GetCursorExtTextInputWidth() const
 void Window::SetCompositionCharRect( const tools::Rectangle* pRect, long nCompositionLength, bool bVertical ) {
 
     ImplWinData* pWinData = ImplGetWinData();
-    delete[] pWinData->mpCompositionCharRects;
+    pWinData->mpCompositionCharRects.reset();
     pWinData->mbVertical = bVertical;
-    pWinData->mpCompositionCharRects = nullptr;
     pWinData->mnCompositionCharRects = nCompositionLength;
     if ( pRect && (nCompositionLength > 0) )
     {
-        pWinData->mpCompositionCharRects = new tools::Rectangle[nCompositionLength];
+        pWinData->mpCompositionCharRects.reset( new tools::Rectangle[nCompositionLength] );
         for (long i = 0; i < nCompositionLength; ++i)
             pWinData->mpCompositionCharRects[i] = pRect[i];
     }
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 5c8e043da580..097464d27f6e 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -76,7 +76,7 @@ void Window::ShowFocus( const tools::Rectangle& rRect )
             ImplInvertFocus( rRect );
         }
         if ( !pWinData->mpFocusRect )
-            pWinData->mpFocusRect = new tools::Rectangle( rRect );
+            pWinData->mpFocusRect.reset( new tools::Rectangle( rRect ) );
         else
             *(pWinData->mpFocusRect) = rRect;
         mpWindowImpl->mbFocusVisible = true;
@@ -145,7 +145,7 @@ void Window::ShowTracking( const tools::Rectangle& rRect, ShowTrackFlags nFlags
     }
 
     if ( !pWinData->mpTrackRect )
-        pWinData->mpTrackRect = new tools::Rectangle( rRect );
+        pWinData->mpTrackRect.reset(new tools::Rectangle( rRect ));
     else
         *(pWinData->mpTrackRect) = rRect;
     pWinData->mnTrackFlags      = nFlags;


More information about the Libreoffice-commits mailing list