[Libreoffice-commits] core.git: 2 commits - include/svx svx/source

Noel Grandin noel.grandin at collabora.co.uk
Thu May 3 06:22:46 UTC 2018


 include/svx/svdpntv.hxx        |    5 +++--
 svx/source/svdraw/svdpntv.cxx  |   13 +++++--------
 svx/source/table/svdotable.cxx |   24 ++++++------------------
 3 files changed, 14 insertions(+), 28 deletions(-)

New commits:
commit c35f95b3ec48e6057d4ddafe688daff1cede59c0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 2 10:33:15 2018 +0200

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

diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 889dbccff77a..e90b0e8fbab0 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -191,7 +191,7 @@ public:
     CellRef mxActiveCell;
     TableModelRef mxTable;
     SdrTableObj* mpTableObj;
-    TableLayouter* mpLayouter;
+    std::unique_ptr<TableLayouter> mpLayouter;
     CellPos maEditPos;
     TableStyleSettings maTableStyle;
     Reference< XIndexAccess > mxTableStyle;
@@ -277,7 +277,7 @@ void SdrTableObjImpl::init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 n
     mxTable->init( nColumns, nRows );
     Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
     mxTable->addModifyListener( xListener );
-    mpLayouter = new TableLayouter( mxTable );
+    mpLayouter.reset(new TableLayouter( mxTable ));
     LayoutTable( mpTableObj->maRect, true, true );
     mpTableObj->maLogicRect = mpTableObj->maRect;
 }
@@ -289,11 +289,7 @@ SdrTableObjImpl& SdrTableObjImpl::operator=( const SdrTableObjImpl& rSource )
     {
         disconnectTableStyle();
 
-        if( mpLayouter )
-        {
-            delete mpLayouter;
-            mpLayouter = nullptr;
-        }
+        mpLayouter.reset();
 
         if( mxTable.is() )
         {
@@ -306,7 +302,7 @@ SdrTableObjImpl& SdrTableObjImpl::operator=( const SdrTableObjImpl& rSource )
         maTableStyle = rSource.maTableStyle;
 
         mxTable = new TableModel( mpTableObj, rSource.mxTable );
-        mpLayouter = new TableLayouter( mxTable );
+        mpLayouter.reset(new TableLayouter( mxTable ));
         Reference< XModifyListener > xListener( static_cast< css::util::XModifyListener* >(this) );
         mxTable->addModifyListener( xListener );
         mxTableStyle = rSource.mxTableStyle;
@@ -456,11 +452,7 @@ void SdrTableObjImpl::dispose()
     disconnectTableStyle();
     mxTableStyle.clear();
 
-    if( mpLayouter )
-    {
-        delete mpLayouter;
-        mpLayouter = nullptr;
-    }
+    mpLayouter.reset();
 
     if( mxTable.is() )
     {
@@ -638,11 +630,7 @@ void SAL_CALL SdrTableObjImpl::disposing( const css::lang::EventObject& /*Source
 {
     mxActiveCell.clear();
     mxTable.clear();
-    if( mpLayouter )
-    {
-        delete mpLayouter;
-        mpLayouter = nullptr;
-    }
+    mpLayouter.reset();
     mpTableObj = nullptr;
 }
 
commit fef6c6cf67eab1b02a7761cedf6355e33804f6e2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 2 10:29:25 2018 +0200

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

diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx
index 2405ad9ca4b5..dc20ac774300 100644
--- a/include/svx/svdpntv.hxx
+++ b/include/svx/svdpntv.hxx
@@ -34,6 +34,7 @@
 #include <svtools/optionsdrawinglayer.hxx>
 #include <unotools/options.hxx>
 #include <vcl/idle.hxx>
+#include <memory>
 
 
 // Pre defines
@@ -133,7 +134,7 @@ private:
     // the SdrModel this view was created with, unchanged during lifetime
     SdrModel&                   mrSdrModelFromSdrView;
 
-    SdrPageView*                mpPageView;
+    std::unique_ptr<SdrPageView> mpPageView;
 protected:
     SdrModel*                   mpModel;
 #ifdef DBG_UTIL
@@ -313,7 +314,7 @@ public:
     virtual void HideSdrPage();
 
     // Iterate over all registered PageViews
-    SdrPageView* GetSdrPageView() const { return mpPageView; }
+    SdrPageView* GetSdrPageView() const { return mpPageView.get(); }
 
     // A SdrView can be displayed on multiple Windows at the same time
     virtual void AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pWindow);
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index ba0e252da346..f83f7fc9052b 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -185,7 +185,6 @@ SdrPaintView::SdrPaintView(
     SdrModel& rSdrModel,
     OutputDevice* pOut)
 :   mrSdrModelFromSdrView(rSdrModel),
-    mpPageView(nullptr),
     maDefaultAttr(rSdrModel.GetItemPool()),
     mbBufferedOutputAllowed(false),
     mbBufferedOverlayAllowed(false),
@@ -394,8 +393,7 @@ void SdrPaintView::ClearPageView()
     if(mpPageView)
     {
         InvalidateAllWin();
-        delete mpPageView;
-        mpPageView = nullptr;
+        mpPageView.reset();
     }
 }
 
@@ -406,14 +404,14 @@ SdrPageView* SdrPaintView::ShowSdrPage(SdrPage* pPage)
         if(mpPageView)
         {
             InvalidateAllWin();
-            delete mpPageView;
+            mpPageView.reset();
         }
 
-        mpPageView = new SdrPageView(pPage, *static_cast<SdrView*>(this));
+        mpPageView.reset(new SdrPageView(pPage, *static_cast<SdrView*>(this)));
         mpPageView->Show();
     }
 
-    return mpPageView;
+    return mpPageView.get();
 }
 
 void SdrPaintView::HideSdrPage()
@@ -421,8 +419,7 @@ void SdrPaintView::HideSdrPage()
     if(mpPageView)
     {
         mpPageView->Hide();
-        delete mpPageView;
-        mpPageView = nullptr;
+        mpPageView.reset();
     }
 }
 


More information about the Libreoffice-commits mailing list