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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jul 19 09:56:50 UTC 2018


 sw/source/core/inc/UndoTable.hxx |    5 ++---
 sw/source/core/undo/untbl.cxx    |   29 +++++++++++++----------------
 2 files changed, 15 insertions(+), 19 deletions(-)

New commits:
commit dcfef09233972619533caa39f2706629025124cb
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 18 15:06:12 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jul 19 11:56:22 2018 +0200

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

diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index e4f27cfbfdb4..95fe3cad5675 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -278,12 +278,11 @@ public:
 };
 
 struct UndoTableCpyTable_Entry;
-using SwUndoTableCpyTable_Entries = std::vector<std::unique_ptr<UndoTableCpyTable_Entry>>;
 
 class SwUndoTableCpyTable : public SwUndo
 {
-    SwUndoTableCpyTable_Entries* m_pArr;
-    SwUndoTableNdsChg* pInsRowUndo;
+    std::vector<std::unique_ptr<UndoTableCpyTable_Entry>> m_vArr;
+    std::unique_ptr<SwUndoTableNdsChg> pInsRowUndo;
 
     //b6341295: When redlining is active, PrepareRedline has to create the
     //redlining attributes for the new and the old table cell content
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 87a5460c5f1e..de4d29ffb07b 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -2396,15 +2396,13 @@ UndoTableCpyTable_Entry::UndoTableCpyTable_Entry( const SwTableBox& rBox )
 
 SwUndoTableCpyTable::SwUndoTableCpyTable(const SwDoc* pDoc)
     : SwUndo( SwUndoId::TBLCPYTBL, pDoc )
-    , m_pArr(new SwUndoTableCpyTable_Entries)
-    , pInsRowUndo(nullptr)
 {
 }
 
 SwUndoTableCpyTable::~SwUndoTableCpyTable()
 {
-    delete m_pArr;
-    delete pInsRowUndo;
+    m_vArr.clear();
+    pInsRowUndo.reset();
 }
 
 void SwUndoTableCpyTable::UndoImpl(::sw::UndoRedoContext & rContext)
@@ -2413,9 +2411,9 @@ void SwUndoTableCpyTable::UndoImpl(::sw::UndoRedoContext & rContext)
     DEBUG_REDLINE( &rDoc )
 
     SwTableNode* pTableNd = nullptr;
-    for (size_t n = m_pArr->size(); n; )
+    for (size_t n = m_vArr.size(); n; )
     {
-        UndoTableCpyTable_Entry *const pEntry = (*m_pArr)[ --n ].get();
+        UndoTableCpyTable_Entry *const pEntry = m_vArr[ --n ].get();
         sal_uLong nSttPos = pEntry->nBoxIdx + pEntry->nOffset;
         SwStartNode* pSNd = rDoc.GetNodes()[ nSttPos ]->StartOfSectionNode();
         if( !pTableNd )
@@ -2567,9 +2565,9 @@ void SwUndoTableCpyTable::RedoImpl(::sw::UndoRedoContext & rContext)
     }
 
     SwTableNode* pTableNd = nullptr;
-    for (size_t n = 0; n < m_pArr->size(); ++n)
+    for (size_t n = 0; n < m_vArr.size(); ++n)
     {
-        UndoTableCpyTable_Entry *const pEntry = (*m_pArr)[ n ].get();
+        UndoTableCpyTable_Entry *const pEntry = m_vArr[ n ].get();
         sal_uLong nSttPos = pEntry->nBoxIdx + pEntry->nOffset;
         SwStartNode* pSNd = rDoc.GetNodes()[ nSttPos ]->StartOfSectionNode();
         if( !pTableNd )
@@ -2648,11 +2646,11 @@ void SwUndoTableCpyTable::RedoImpl(::sw::UndoRedoContext & rContext)
 
 void SwUndoTableCpyTable::AddBoxBefore( const SwTableBox& rBox, bool bDelContent )
 {
-    if (!m_pArr->empty() && !bDelContent)
+    if (!m_vArr.empty() && !bDelContent)
         return;
 
     UndoTableCpyTable_Entry* pEntry = new UndoTableCpyTable_Entry( rBox );
-    m_pArr->push_back(std::unique_ptr<UndoTableCpyTable_Entry>(pEntry));
+    m_vArr.push_back(std::unique_ptr<UndoTableCpyTable_Entry>(pEntry));
 
     SwDoc* pDoc = rBox.GetFrameFormat()->GetDoc();
     DEBUG_REDLINE( pDoc )
@@ -2681,7 +2679,7 @@ void SwUndoTableCpyTable::AddBoxBefore( const SwTableBox& rBox, bool bDelContent
 
 void SwUndoTableCpyTable::AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx, bool bDelContent )
 {
-    UndoTableCpyTable_Entry *const pEntry = (*m_pArr).back().get();
+    UndoTableCpyTable_Entry *const pEntry = m_vArr.back().get();
 
     // If the content was deleted than remove also the temporarily created node
     if( bDelContent )
@@ -2785,8 +2783,8 @@ bool SwUndoTableCpyTable::InsertRow( SwTable& rTable, const SwSelBoxes& rBoxes,
     SwTableNode* pTableNd = const_cast<SwTableNode*>(rTable.GetTabSortBoxes()[0]->
                                 GetSttNd()->FindTableNode());
 
-    pInsRowUndo = new SwUndoTableNdsChg( SwUndoId::TABLE_INSROW, rBoxes, *pTableNd,
-                                       0, 0, nCnt, true, false );
+    pInsRowUndo.reset( new SwUndoTableNdsChg( SwUndoId::TABLE_INSROW, rBoxes, *pTableNd,
+                                       0, 0, nCnt, true, false ) );
     SwTableSortBoxes aTmpLst( rTable.GetTabSortBoxes() );
 
     bool bRet = rTable.InsertRow( rTable.GetFrameFormat()->GetDoc(), rBoxes, nCnt, /*bBehind*/true );
@@ -2794,15 +2792,14 @@ bool SwUndoTableCpyTable::InsertRow( SwTable& rTable, const SwSelBoxes& rBoxes,
         pInsRowUndo->SaveNewBoxes( *pTableNd, aTmpLst );
     else
     {
-        delete pInsRowUndo;
-        pInsRowUndo = nullptr;
+        pInsRowUndo.reset();
     }
     return bRet;
 }
 
 bool SwUndoTableCpyTable::IsEmpty() const
 {
-    return !pInsRowUndo && m_pArr->empty();
+    return !pInsRowUndo && m_vArr.empty();
 }
 
 SwUndoCpyTable::SwUndoCpyTable(const SwDoc* pDoc)


More information about the Libreoffice-commits mailing list