sc/inc/colcontainer.hxx              |    3 ++-
 sc/inc/table.hxx                     |    4 ++--
 sc/source/core/data/colcontainer.cxx |    6 +++---
 sc/source/core/data/document.cxx     |    2 +-
 sc/source/core/data/table2.cxx       |    2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)

New commits:
commit d19c6ab1050fb3f3ef60a3622bca85ebb07952e4
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Mon Jun 11 16:05:32 2018 +0200

    loplugin:useuniqueptr in ScColContainer
    
    Change-Id: Icb4fffb27535a767b307c1d01e5bc96372c98352
    Reviewed-on: https://gerrit.libreoffice.org/56108
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/inc/colcontainer.hxx b/sc/inc/colcontainer.hxx
index 9bd9c16e260b..2cb4ae74e487 100644
--- a/sc/inc/colcontainer.hxx
+++ b/sc/inc/colcontainer.hxx
@@ -22,13 +22,14 @@
 
 #include "types.hxx"
 
+#include <memory>
 #include <vector>
 
 class ScColumn;
 
 class ScColContainer
 {
-    typedef std::vector<ScColumn*> ScColumnVector;
+    typedef std::vector<std::unique_ptr<ScColumn>> ScColumnVector;
     ScColumnVector    aCols;
 
 public:
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index a2aa4c911b57..e7886b15c6ee 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -117,7 +117,7 @@ class ScColumnsRange final
  public:
     class Iterator final
     {
-        std::vector<ScColumn*>::const_iterator maColIter;
+        std::vector<std::unique_ptr<ScColumn>>::const_iterator maColIter;
     public:
         typedef std::input_iterator_tag iterator_category;
         typedef SCCOL value_type;
@@ -125,7 +125,7 @@ class ScColumnsRange final
         typedef const SCCOL* pointer;
         typedef SCCOL reference;
 
-        explicit Iterator(const std::vector<ScColumn*>::const_iterator& 
colIter) : maColIter(colIter) {}
+        explicit Iterator(const 
std::vector<std::unique_ptr<ScColumn>>::const_iterator& colIter) : 
maColIter(colIter) {}
 
         Iterator& operator++() { ++maColIter; return *this;}
         Iterator& operator--() { --maColIter; return *this;}
diff --git a/sc/source/core/data/colcontainer.cxx 
b/sc/source/core/data/colcontainer.cxx
index 44dcf5ff7782..79386bd805b2 100644
--- a/sc/source/core/data/colcontainer.cxx
+++ b/sc/source/core/data/colcontainer.cxx
@@ -26,7 +26,7 @@ ScColContainer::ScColContainer( const size_t nSize )
 {
     aCols.resize( nSize );
     for ( size_t nCol = 0; nCol < nSize; ++nCol )
-        aCols[nCol] = new ScColumn;
+        aCols[nCol].reset( new ScColumn );
 }
 
 ScColContainer::~ScColContainer() COVERITY_NOEXCEPT_FALSE
@@ -40,7 +40,7 @@ void ScColContainer::Clear()
     for ( SCCOL nIdx = 0; nIdx < nSize; ++nIdx )
     {
         aCols[nIdx]->PrepareBroadcastersForDestruction();
-        delete aCols[nIdx];
+        aCols[nIdx].reset();
     }
     aCols.clear();
 }
@@ -50,7 +50,7 @@ void ScColContainer::resize( const size_t aNewColSize )
     size_t aOldColSize = aCols.size();
     aCols.resize( aNewColSize );
     for ( size_t nCol = aOldColSize; nCol < aNewColSize; ++nCol )
-        aCols[nCol] = new ScColumn;
+        aCols[nCol].reset(new ScColumn);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 29b46fef75a1..b6884b9088f9 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2528,7 +2528,7 @@ ScColumnsRange ScDocument::GetColumnsRange( SCTAB nTab, 
SCCOL nColBegin, SCCOL n
 {
     if (!TableExists(nTab))
     {
-        std::vector<ScColumn*> aEmptyVector;
+        std::vector<std::unique_ptr<ScColumn>> aEmptyVector;
         return ScColumnsRange(ScColumnsRange::Iterator(aEmptyVector.begin()),
                               ScColumnsRange::Iterator(aEmptyVector.end()));
     }
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a30ca6fe5527..e542c735ed94 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1684,7 +1684,7 @@ CommentCaptionState 
ScTable::GetAllNoteCaptionsState(const ScRange& rRange, std:
 
 void ScTable::GetUnprotectedCells( ScRangeList& rRangeList ) const
 {
-    for (auto pCol : aCol)
+    for (auto const & pCol : aCol)
         pCol->GetUnprotectedCells(0, MAXROW, rRangeList);
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to