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

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 26 09:15:40 UTC 2018


 filter/source/msfilter/msdffimp.cxx  |   10 +++-------
 filter/source/msfilter/svdfppt.cxx   |    6 +++---
 include/filter/msfilter/msdffimp.hxx |    9 ++++++++-
 sc/source/filter/excel/xiescher.cxx  |    6 +-----
 4 files changed, 15 insertions(+), 16 deletions(-)

New commits:
commit 91db89b73c4059bc2af86d91752b89d2497034c7
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Feb 7 10:50:16 2018 +0200

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

diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 3ffae20be7dc..fa05c6a71e58 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -399,10 +399,6 @@ SvxMSDffSolverContainer::SvxMSDffSolverContainer()
 
 SvxMSDffSolverContainer::~SvxMSDffSolverContainer()
 {
-    for(SvxMSDffConnectorRule* i : aCList) {
-        delete i;
-    }
-    aCList.clear();
 }
 
 SvStream& ReadSvxMSDffSolverContainer( SvStream& rIn, SvxMSDffSolverContainer& rContainer )
@@ -419,9 +415,9 @@ SvStream& ReadSvxMSDffSolverContainer( SvStream& rIn, SvxMSDffSolverContainer& r
                 break;
             if ( aCRule.nRecType == DFF_msofbtConnectorRule )
             {
-                SvxMSDffConnectorRule* pRule = new SvxMSDffConnectorRule;
+                std::unique_ptr<SvxMSDffConnectorRule> pRule(new SvxMSDffConnectorRule);
                 rIn >> *pRule;
-                rContainer.aCList.push_back( pRule );
+                rContainer.aCList.push_back( std::move(pRule) );
             }
             if (!aCRule.SeekToEndOfRecord(rIn))
                 break;
@@ -435,7 +431,7 @@ void SvxMSDffManager::SolveSolver( const SvxMSDffSolverContainer& rSolver )
     size_t i, nCnt;
     for ( i = 0, nCnt = rSolver.aCList.size(); i < nCnt; i++ )
     {
-        SvxMSDffConnectorRule* pPtr = rSolver.aCList[ i ];
+        SvxMSDffConnectorRule* pPtr = rSolver.aCList[ i ].get();
         if ( pPtr->pCObj )
         {
             for ( int nN = 0; nN < 2; nN++ )
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 28401d7cc4e6..7d018dff716b 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -1237,7 +1237,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
         }
         if (rPersistEntry.xSolverContainer)
         {
-            for (SvxMSDffConnectorRule* pPtr : rPersistEntry.xSolverContainer->aCList)
+            for (auto & pPtr : rPersistEntry.xSolverContainer->aCList)
             {
                 if ( rObjData.nShapeId == pPtr->nShapeC )
                     pPtr->pCObj = pRet;
@@ -2921,7 +2921,7 @@ void SdrPowerPointImport::ImportPage( SdrPage* pRet, const PptSlidePersistEntry*
                             pRet->getSdrPageProperties().PutItemSet(rSlidePersist.pBObj->GetMergedItemSet());
                             if (rSlidePersist.xSolverContainer)
                             {
-                                for (SvxMSDffConnectorRule* pPtr : rSlidePersist.xSolverContainer->aCList)
+                                for (auto & pPtr : rSlidePersist.xSolverContainer->aCList)
                                 {
                                     // check connections to the group object
                                     if (pPtr->pAObj == rSlidePersist.pBObj)
@@ -7659,7 +7659,7 @@ SdrObject* SdrPowerPointImport::CreateTable( SdrObject* pGroup, const sal_uInt32
         // possibly connections to the group object have to be removed.
         if ( pSolverContainer )
         {
-            for (SvxMSDffConnectorRule* pPtr : pSolverContainer->aCList)
+            for (auto & pPtr : pSolverContainer->aCList)
             {
                 // check connections to the group object
                 if ( pPtr->pAObj == pGroup )
diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx
index 447ea7226400..e79991a052d7 100644
--- a/include/filter/msfilter/msdffimp.hxx
+++ b/include/filter/msfilter/msdffimp.hxx
@@ -91,6 +91,10 @@ public:
 
     explicit DffPropertyReader( const SvxMSDffManager& rManager );
     ~DffPropertyReader();
+
+    DffPropertyReader& operator=( DffPropertyReader const & ) = delete; // MSVC2015 workaround
+    DffPropertyReader( DffPropertyReader const & ) = delete; // MSVC2015 workaround
+
     static sal_Int32 Fix16ToAngle( sal_Int32 nAngle );
 
 #ifdef DBG_CUSTOMSHAPE
@@ -174,11 +178,14 @@ struct SvxMSDffConnectorRule
 
 struct MSFILTER_DLLPUBLIC SvxMSDffSolverContainer
 {
-    ::std::vector< SvxMSDffConnectorRule* > aCList;
+    ::std::vector< std::unique_ptr<SvxMSDffConnectorRule> > aCList;
 
     SvxMSDffSolverContainer();
     ~SvxMSDffSolverContainer();
 
+    SvxMSDffSolverContainer& operator=( SvxMSDffSolverContainer const & ) = delete; // MSVC2015 workaround
+    SvxMSDffSolverContainer( SvxMSDffSolverContainer const & ) = delete; // MSVC2015 workaround
+
     MSFILTER_DLLPUBLIC friend SvStream& ReadSvxMSDffSolverContainer( SvStream& rIn, SvxMSDffSolverContainer& rAtom );
 };
 
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 8a84cfcf4c20..5e5b1d12f490 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -3176,7 +3176,7 @@ void XclImpSolverContainer::RemoveSdrObjectInfo( SdrObject& rSdrObj )
 
 void XclImpSolverContainer::UpdateConnectorRules()
 {
-    for (SvxMSDffConnectorRule* pRule : aCList)
+    for (auto const & pRule : aCList)
     {
         UpdateConnection( pRule->nShapeA, pRule->pAObj, &pRule->nSpFlagsA );
         UpdateConnection( pRule->nShapeB, pRule->pBObj, &pRule->nSpFlagsB );
@@ -3186,10 +3186,6 @@ void XclImpSolverContainer::UpdateConnectorRules()
 
 void XclImpSolverContainer::RemoveConnectorRules()
 {
-    // base class from SVX uses plain untyped tools/List
-    for (SvxMSDffConnectorRule* p : aCList) {
-        delete p;
-    }
     aCList.clear();
     maSdrInfoMap.clear();
     maSdrObjMap.clear();


More information about the Libreoffice-commits mailing list