[Libreoffice-commits] core.git: filter/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 19 06:13:32 UTC 2018


 filter/source/graphicfilter/icgm/cgm.cxx    |   15 ++++-----------
 filter/source/graphicfilter/icgm/cgm.hxx    |   12 ++++++------
 filter/source/graphicfilter/icgm/class0.cxx |    6 ++----
 filter/source/graphicfilter/icgm/class1.cxx |    6 +++---
 filter/source/graphicfilter/icgm/class4.cxx |    5 ++---
 filter/source/graphicfilter/icgm/class7.cxx |    2 +-
 6 files changed, 18 insertions(+), 28 deletions(-)

New commits:
commit ef8ed797598062273ecb43fac8dbae4dbe3bf3cb
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Feb 6 15:24:01 2018 +0200

    loplugin:useuniqueptr in CGM
    
    Change-Id: Iecd9251f68cd894a14fb6824151768d4cb663e0f
    Reviewed-on: https://gerrit.libreoffice.org/49944
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/source/graphicfilter/icgm/cgm.cxx b/filter/source/graphicfilter/icgm/cgm.cxx
index 5e066bc65127..3da966412c77 100644
--- a/filter/source/graphicfilter/icgm/cgm.cxx
+++ b/filter/source/graphicfilter/icgm/cgm.cxx
@@ -64,26 +64,19 @@ CGM::CGM(uno::Reference< frame::XModel > const & rModel)
     , mnElementID(0)
     , mnElementSize(0)
 {
-    pElement = new CGMElements;
-    pCopyOfE = new CGMElements;
+    pElement.reset( new CGMElements );
+    pCopyOfE.reset( new CGMElements );
 }
 
 CGM::~CGM()
 {
-    for(sal_uInt8* i : maDefRepList)
-        delete [] i;
     maDefRepList.clear();
     maDefRepSizeList.clear();
-    delete mpBitmapInUse;
-    delete mpChart;
-    delete mpOutAct;
-    delete pCopyOfE;
-    delete pElement;
 };
 
 sal_uInt32 CGM::GetBackGroundColor()
 {
-    return ( pElement ) ? pElement->aColorTable[ 0 ] : 0;
+    return pElement ? pElement->aColorTable[ 0 ] : 0;
 }
 
 sal_uInt32 CGM::ImplGetUI16()
@@ -615,7 +608,7 @@ void CGM::ImplDefaultReplacement()
 
         for ( size_t i = 0, n = maDefRepList.size(); i < n; ++i )
         {
-            sal_uInt8*  pBuf = maDefRepList[ i ];
+            sal_uInt8*  pBuf = maDefRepList[ i ].get();
             sal_uInt32  nElementSize = maDefRepSizeList[ i ];
             mpEndValidSource = pBuf + nElementSize;
             sal_uInt32  nCount = 0;
diff --git a/filter/source/graphicfilter/icgm/cgm.hxx b/filter/source/graphicfilter/icgm/cgm.hxx
index 06ce45ed27be..8ecbec12998c 100644
--- a/filter/source/graphicfilter/icgm/cgm.hxx
+++ b/filter/source/graphicfilter/icgm/cgm.hxx
@@ -65,14 +65,14 @@ class CGM
         bool                mbFirstOutPut;
         bool                mbInDefaultReplacement;
         sal_uInt32          mnAct4PostReset;
-        CGMBitmap*          mpBitmapInUse;
-        CGMChart*           mpChart;                // if sal_True->"SHWSLIDEREC"
+        std::unique_ptr<CGMBitmap> mpBitmapInUse;
+        std::unique_ptr<CGMChart> mpChart;          // if sal_True->"SHWSLIDEREC"
                                                     //  otherwise "BEGINPIC" commands
                                                     // controls page inserting
-        CGMElements*        pElement;
-        CGMElements*        pCopyOfE;
-        CGMImpressOutAct*   mpOutAct;
-        ::std::vector< sal_uInt8 * > maDefRepList;
+        std::unique_ptr<CGMElements> pElement;
+        std::unique_ptr<CGMElements> pCopyOfE;
+        std::unique_ptr<CGMImpressOutAct> mpOutAct;
+        ::std::vector< std::unique_ptr<sal_uInt8[]> > maDefRepList;
         ::std::vector< sal_uInt32  > maDefRepSizeList;
 
         sal_uInt8*              mpSource;         // start of source buffer that is not increased
diff --git a/filter/source/graphicfilter/icgm/class0.cxx b/filter/source/graphicfilter/icgm/class0.cxx
index c6f1e4d4a6b9..baeef1249dd7 100644
--- a/filter/source/graphicfilter/icgm/class0.cxx
+++ b/filter/source/graphicfilter/icgm/class0.cxx
@@ -38,8 +38,7 @@ void CGM::ImplDoClass0()
                 CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
                 // do anything with the bitmap
                 mpOutAct->DrawBitmap( pBmpDesc );
-                delete mpBitmapInUse;
-                mpBitmapInUse = nullptr;
+                mpBitmapInUse.reset();
             }
             mbIsFinished = true;
             mbPictureBody = false;
@@ -75,8 +74,7 @@ void CGM::ImplDoClass0()
                     CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
                     // do anything with the bitmap
                     mpOutAct->DrawBitmap( pBmpDesc );
-                    delete mpBitmapInUse;
-                    mpBitmapInUse = nullptr;
+                    mpBitmapInUse.reset();
                 }
                 mpOutAct->EndFigure();                          // close potential figures
                 mpOutAct->EndGrouping();                        // finish potential groups
diff --git a/filter/source/graphicfilter/icgm/class1.cxx b/filter/source/graphicfilter/icgm/class1.cxx
index 3bd903796aab..b8eabf83f04d 100644
--- a/filter/source/graphicfilter/icgm/class1.cxx
+++ b/filter/source/graphicfilter/icgm/class1.cxx
@@ -164,9 +164,9 @@ void CGM::ImplDoClass1()
         {
             if ( mnElementSize > 1 )
             {
-                sal_uInt8* pBuf = new sal_uInt8[ mnElementSize ];
-                memcpy( pBuf, mpSource, mnElementSize );
-                maDefRepList.push_back( pBuf );
+                std::unique_ptr<sal_uInt8[]> pBuf(new sal_uInt8[ mnElementSize ]);
+                memcpy( pBuf.get(), mpSource, mnElementSize );
+                maDefRepList.push_back( std::move(pBuf) );
                 maDefRepSizeList.push_back( mnElementSize );
             }
             mnParaSize = mnElementSize;
diff --git a/filter/source/graphicfilter/icgm/class4.cxx b/filter/source/graphicfilter/icgm/class4.cxx
index ba95ba63392b..c2c0e95910f1 100644
--- a/filter/source/graphicfilter/icgm/class4.cxx
+++ b/filter/source/graphicfilter/icgm/class4.cxx
@@ -112,8 +112,7 @@ void CGM::ImplDoClass4()
         CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
         // do anything with the bitmap
         mpOutAct->DrawBitmap( pBmpDesc );
-        delete mpBitmapInUse;
-        mpBitmapInUse = nullptr;
+        mpBitmapInUse.reset();
     }
 
     if ( ( mpChart == nullptr ) || mpChart->IsAnnotation() )
@@ -316,7 +315,7 @@ void CGM::ImplDoClass4()
                 }
                 else
                 {
-                    mpBitmapInUse = new CGMBitmap( *this );
+                    mpBitmapInUse.reset( new CGMBitmap( *this ) );
                 }
             }
             break;
diff --git a/filter/source/graphicfilter/icgm/class7.cxx b/filter/source/graphicfilter/icgm/class7.cxx
index 1e56cf544f86..54cebd4bdf2b 100644
--- a/filter/source/graphicfilter/icgm/class7.cxx
+++ b/filter/source/graphicfilter/icgm/class7.cxx
@@ -48,7 +48,7 @@ void CGM::ImplDoClass7()
                             throw css::uno::Exception("attempt to read past end of input", nullptr);
 
                         if ( mpChart == nullptr )
-                            mpChart = new CGMChart;
+                            mpChart.reset( new CGMChart );
                         mpChart->mnCurrentFileType = pAppData[ 3 ];
                     }
                     break;


More information about the Libreoffice-commits mailing list