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

Jochen Nitschke j.nitschke+logerrit at ok.de
Thu Feb 9 08:46:35 UTC 2017


 sc/source/filter/excel/excdoc.cxx            |    4 ++--
 sc/source/filter/inc/XclExpChangeTrack.hxx   |    9 ++++-----
 sc/source/filter/inc/xcl97rec.hxx            |    2 +-
 sc/source/filter/xcl97/XclExpChangeTrack.cxx |    8 +++-----
 sc/source/filter/xcl97/xcl97rec.cxx          |   15 +++++----------
 5 files changed, 15 insertions(+), 23 deletions(-)

New commits:
commit 5b19a738ed7aa943cc05a313dbed7b45ec081d95
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Wed Feb 8 16:19:25 2017 +0100

    replace pointers with objects in std::vectors
    
    Change-Id: Id5577ae0b3bdf31b6d5e409cd2c0033d9f2591a2
    Reviewed-on: https://gerrit.libreoffice.org/34046
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index c70603d..67e2ae4 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -560,9 +560,9 @@ void ExcTable::FillAsTableBinary( SCTAB nCodeNameIdx )
     if( rR.pUserBViewList )
     {
         XclExpUserBViewList::const_iterator iter;
-        for ( iter = rR.pUserBViewList->begin(); iter != rR.pUserBViewList->end(); ++iter)
+        for ( iter = rR.pUserBViewList->cbegin(); iter != rR.pUserBViewList->cend(); ++iter)
         {
-            Add( new XclExpUsersViewBegin( (*iter)->GetGUID(), nExcTab ) );
+            Add( new XclExpUsersViewBegin( (*iter).GetGUID(), nExcTab ) );
             Add( new XclExpUsersViewEnd );
         }
     }
diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx
index 9ea74ed..6f633dc 100644
--- a/sc/source/filter/inc/XclExpChangeTrack.hxx
+++ b/sc/source/filter/inc/XclExpChangeTrack.hxx
@@ -61,18 +61,17 @@ public:
 class XclExpUserBViewList : public ExcEmptyRec
 {
 private:
-    std::vector<XclExpUserBView*> aViews;
+    std::vector<XclExpUserBView> aViews;
 
 public:
 
-    typedef std::vector<XclExpUserBView*>::iterator iterator;
-    typedef std::vector<XclExpUserBView*>::const_iterator const_iterator;
+    typedef std::vector<XclExpUserBView>::const_iterator const_iterator;
 
                                 XclExpUserBViewList( const ScChangeTrack& rChangeTrack );
     virtual                     ~XclExpUserBViewList() override;
 
-    inline iterator begin () { return aViews.begin(); }
-    inline iterator end () { return aViews.end(); }
+    inline const_iterator cbegin () { return aViews.cbegin(); }
+    inline const_iterator cend () { return aViews.cend(); }
 
     virtual void                Save( XclExpStream& rStrm ) override;
 };
diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx
index 955fd01..62698c2 100644
--- a/sc/source/filter/inc/xcl97rec.hxx
+++ b/sc/source/filter/inc/xcl97rec.hxx
@@ -397,7 +397,7 @@ class ExcEScenarioManager : public ExcRecord
 {
 private:
     sal_uInt16                      nActive;
-    std::vector<ExcEScenario*> aScenes;
+    std::vector<ExcEScenario>   aScenes;
 
     virtual void                SaveCont( XclExpStream& rStrm ) override;
 
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index a3254ed..a9cce7f 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -137,20 +137,18 @@ XclExpUserBViewList::XclExpUserBViewList( const ScChangeTrack& rChangeTrack )
     for (; it != itEnd; ++it)
     {
         lcl_GenerateGUID( aGUID, bValidGUID );
-        aViews.push_back( new XclExpUserBView(*it, aGUID) );
+        aViews.emplace_back( *it, aGUID );
     }
 }
 
 XclExpUserBViewList::~XclExpUserBViewList()
 {
-    for( iterator iter = aViews.begin(); iter != aViews.end(); ++iter )
-        delete *iter;
 }
 
 void XclExpUserBViewList::Save( XclExpStream& rStrm )
 {
-   for( iterator iter = aViews.begin(); iter != aViews.end(); ++iter )
-        (*iter)->Save( rStrm );
+   for( XclExpUserBView& rView : aViews )
+       rView.Save( rStrm );
 }
 
 XclExpUsersViewBegin::XclExpUsersViewBegin( const sal_uInt8* pGUID, sal_uInt32 nTab ) :
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index f35be315..1a7f1f9 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -1462,7 +1462,7 @@ ExcEScenarioManager::ExcEScenarioManager( const XclExpRoot& rRoot, SCTAB nTab )
 
     while( rDoc.IsScenario( nNewTab ) )
     {
-        aScenes.push_back( new ExcEScenario( rRoot, nNewTab ) );
+        aScenes.emplace_back( rRoot, nNewTab  );
 
         if( rDoc.IsActiveScenario( nNewTab ) )
             nActive = static_cast<sal_uInt16>(nNewTab - nFirstTab);
@@ -1472,9 +1472,6 @@ ExcEScenarioManager::ExcEScenarioManager( const XclExpRoot& rRoot, SCTAB nTab )
 
 ExcEScenarioManager::~ExcEScenarioManager()
 {
-    std::vector<ExcEScenario*>::iterator pIter;
-    for( pIter = aScenes.begin(); pIter != aScenes.end(); ++pIter )
-        delete *pIter;
 }
 
 void ExcEScenarioManager::SaveCont( XclExpStream& rStrm )
@@ -1490,9 +1487,8 @@ void ExcEScenarioManager::Save( XclExpStream& rStrm )
     if( !aScenes.empty() )
         ExcRecord::Save( rStrm );
 
-    std::vector<ExcEScenario*>::iterator pIter;
-    for( pIter = aScenes.begin(); pIter != aScenes.end(); ++pIter )
-        (*pIter)->Save( rStrm );
+    for( ExcEScenario& rScenario : aScenes )
+        rScenario.Save( rStrm );
 }
 
 void ExcEScenarioManager::SaveXml( XclExpXmlStream& rStrm )
@@ -1507,9 +1503,8 @@ void ExcEScenarioManager::SaveXml( XclExpXmlStream& rStrm )
             // OOXTODO: XML_sqref,
             FSEND );
 
-    std::vector<ExcEScenario*>::iterator pIter;
-    for( pIter = aScenes.begin(); pIter != aScenes.end(); ++pIter )
-        (*pIter)->SaveXml( rStrm );
+    for( ExcEScenario& rScenario : aScenes )
+        rScenario.SaveXml( rStrm );
 
     rWorkbook->endElement( XML_scenarios );
 }


More information about the Libreoffice-commits mailing list