sw/inc/swtable.hxx                  |    2 +-
 sw/source/core/table/swnewtable.cxx |   13 ++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)

New commits:
commit 97fe7d5f0eed7d3ef4940f4e7a70a7dd64d2390f
Author: Mike Kaganski <mike.kagan...@collabora.com>
Date:   Sat Apr 21 11:47:43 2018 +0100

    Use unique_ptr
    
    Change-Id: I8fea12c523e07b895c47ee410120549398fc8f37
    Reviewed-on: https://gerrit.libreoffice.org/53249
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 619d37dd432e..edeb04509d18 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -164,7 +164,7 @@ private:
     bool NewMerge( SwDoc*, const SwSelBoxes&, const SwSelBoxes& rMerged,
                    SwUndoTableMerge* );
     bool NewSplitRow( SwDoc*, const SwSelBoxes&, sal_uInt16, bool );
-    SwBoxSelection* CollectBoxSelection( const SwPaM& rPam ) const;
+    std::unique_ptr<SwBoxSelection> CollectBoxSelection( const SwPaM& rPam ) 
const;
     void InsertSpannedRow( SwDoc* pDoc, sal_uInt16 nIdx, sal_uInt16 nCnt );
     bool InsertRow_( SwDoc*, const SwSelBoxes&, sal_uInt16 nCnt, bool bBehind 
);
     bool NewInsertCol( SwDoc*, const SwSelBoxes& rBoxes, sal_uInt16 nCnt, bool 
);
diff --git a/sw/source/core/table/swnewtable.cxx 
b/sw/source/core/table/swnewtable.cxx
index e6a9a590187c..96702150011b 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -41,6 +41,7 @@
 #include <editeng/protitem.hxx>
 #include <swtblfmt.hxx>
 #include <calbck.hxx>
+#include <o3tl/make_unique.hxx>
 
 #ifdef DBG_UTIL
 #define CHECK_TABLE(t) (t).CheckConsistency();
@@ -322,7 +323,7 @@ static void lcl_ChangeRowSpan( const SwTable& rTable, const 
long nDiff,
     and prepares the selected cells for merging
 */
 
-SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
+std::unique_ptr<SwBoxSelection> SwTable::CollectBoxSelection( const SwPaM& 
rPam ) const
 {
     OSL_ENSURE( m_bNewModel, "Don't call me for old tables" );
     if( m_aLines.empty() )
@@ -370,7 +371,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& 
rPam ) const
     bool bOkay = true;
     long nMid = ( nMin + nMax ) / 2;
 
-    SwBoxSelection* pRet = new SwBoxSelection();
+    auto pRet(o3tl::make_unique<SwBoxSelection>());
     std::vector< std::pair< SwTableBox*, long > > aNewWidthVector;
     size_t nCheckBottom = nBottom;
     long nLeftSpan = 0;
@@ -560,11 +561,11 @@ SwBoxSelection* SwTable::CollectBoxSelection( const 
SwPaM& rPam ) const
             --nRightSpanCnt;
         pRet->push_back(aBoxes);
     }
-    pRet->mnMergeWidth = nMax - nMin;
     if( nCheckBottom > nBottom )
         bOkay = false;
     if( bOkay )
     {
+        pRet->mnMergeWidth = nMax - nMin;
         for (auto const& newWidth : aNewWidthVector)
         {
             SwFrameFormat* pFormat = newWidth.first->ClaimFrameFormat();
@@ -573,10 +574,8 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& 
rPam ) const
         }
     }
     else
-    {
-        delete pRet;
-        pRet = nullptr;
-    }
+        pRet.reset();
+
     return pRet;
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to