diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-12 10:59:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-12 13:54:16 +0200 |
commit | bd8e6d77e297a473e3ce7179a866422a432ae084 (patch) | |
tree | 35c3ba6c91cbc195152a6ecb0af9d60e3df1c82f | |
parent | 5a0485566052af04c2a2493341d25fd43df2a8b3 (diff) |
loplugin:useuniqueptr in ScRefUndoData
Change-Id: I35e0bf44cf63be5ea94863f47f08d376a9c0b1ef
Reviewed-on: https://gerrit.libreoffice.org/52762
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/source/ui/inc/areasave.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/refundo.hxx | 14 | ||||
-rw-r--r-- | sc/source/ui/undo/areasave.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/undo/refundo.cxx | 38 |
4 files changed, 30 insertions, 30 deletions
diff --git a/sc/source/ui/inc/areasave.hxx b/sc/source/ui/inc/areasave.hxx index 6efee92d5722..a21a5b4f0073 100644 --- a/sc/source/ui/inc/areasave.hxx +++ b/sc/source/ui/inc/areasave.hxx @@ -59,7 +59,7 @@ public: void Restore( ScDocument* pDoc ); // returns NULL if empty - static ScAreaLinkSaveCollection* CreateFromDoc( const ScDocument* pDoc ); + static std::unique_ptr<ScAreaLinkSaveCollection> CreateFromDoc( const ScDocument* pDoc ); ScAreaLinkSaver& operator[](size_t nIndex); const ScAreaLinkSaver& operator[](size_t nIndex) const; diff --git a/sc/source/ui/inc/refundo.hxx b/sc/source/ui/inc/refundo.hxx index c3e4466f8733..7ee764eca39a 100644 --- a/sc/source/ui/inc/refundo.hxx +++ b/sc/source/ui/inc/refundo.hxx @@ -35,13 +35,13 @@ class ScUnoRefList; class ScRefUndoData { private: - ScDBCollection* pDBCollection; - ScRangeName* pRangeName; - ScPrintRangeSaver* pPrintRanges; - ScDPCollection* pDPCollection; - ScDetOpList* pDetOpList; - ScChartListenerCollection* pChartListenerCollection; - ScAreaLinkSaveCollection* pAreaLinks; + std::unique_ptr<ScDBCollection> pDBCollection; + std::unique_ptr<ScRangeName> pRangeName; + std::unique_ptr<ScPrintRangeSaver> pPrintRanges; + std::unique_ptr<ScDPCollection> pDPCollection; + std::unique_ptr<ScDetOpList> pDetOpList; + std::unique_ptr<ScChartListenerCollection> pChartListenerCollection; + std::unique_ptr<ScAreaLinkSaveCollection> pAreaLinks; std::unique_ptr<ScUnoRefList> pUnoRefs; public: diff --git a/sc/source/ui/undo/areasave.cxx b/sc/source/ui/undo/areasave.cxx index 0112164d2365..998032371892 100644 --- a/sc/source/ui/undo/areasave.cxx +++ b/sc/source/ui/undo/areasave.cxx @@ -146,9 +146,9 @@ void ScAreaLinkSaveCollection::Restore( ScDocument* pDoc ) } } -ScAreaLinkSaveCollection* ScAreaLinkSaveCollection::CreateFromDoc( const ScDocument* pDoc ) +std::unique_ptr<ScAreaLinkSaveCollection> ScAreaLinkSaveCollection::CreateFromDoc( const ScDocument* pDoc ) { - ScAreaLinkSaveCollection* pColl = nullptr; + std::unique_ptr<ScAreaLinkSaveCollection> pColl; sfx2::LinkManager* pLinkManager = const_cast<ScDocument*>(pDoc)->GetLinkManager(); if (pLinkManager) @@ -161,7 +161,7 @@ ScAreaLinkSaveCollection* ScAreaLinkSaveCollection::CreateFromDoc( const ScDocum if (dynamic_cast<const ScAreaLink*>( pBase) != nullptr) { if (!pColl) - pColl = new ScAreaLinkSaveCollection; + pColl.reset(new ScAreaLinkSaveCollection); pColl->push_back( ScAreaLinkSaver( *static_cast<ScAreaLink*>(pBase ) ) ); } diff --git a/sc/source/ui/undo/refundo.cxx b/sc/source/ui/undo/refundo.cxx index 857120cc69da..4aeb94dc36b1 100644 --- a/sc/source/ui/undo/refundo.cxx +++ b/sc/source/ui/undo/refundo.cxx @@ -46,25 +46,25 @@ ScRefUndoData::ScRefUndoData( const ScDocument* pDoc ) : { const ScDBCollection* pOldDBColl = pDoc->GetDBCollection(); if (pOldDBColl && !pOldDBColl->empty()) - pDBCollection = new ScDBCollection(*pOldDBColl); + pDBCollection.reset(new ScDBCollection(*pOldDBColl)); const ScRangeName* pOldRanges = pDoc->GetRangeName(); if (pOldRanges && !pOldRanges->empty()) - pRangeName = new ScRangeName(*pOldRanges); + pRangeName.reset(new ScRangeName(*pOldRanges)); // when handling Pivot solely keep the range? const ScDPCollection* pOldDP = pDoc->GetDPCollection(); if (pOldDP && pOldDP->GetCount()) - pDPCollection = new ScDPCollection(*pOldDP); + pDPCollection.reset(new ScDPCollection(*pOldDP)); const ScDetOpList* pOldDetOp = pDoc->GetDetOpList(); if (pOldDetOp && pOldDetOp->Count()) - pDetOpList = new ScDetOpList(*pOldDetOp); + pDetOpList.reset(new ScDetOpList(*pOldDetOp)); const ScChartListenerCollection* pOldChartLisColl = pDoc->GetChartListenerCollection(); if (pOldChartLisColl) - pChartListenerCollection = new ScChartListenerCollection(*pOldChartLisColl); + pChartListenerCollection.reset(new ScChartListenerCollection(*pOldChartLisColl)); pAreaLinks = ScAreaLinkSaveCollection::CreateFromDoc(pDoc); // returns NULL if empty @@ -73,13 +73,13 @@ ScRefUndoData::ScRefUndoData( const ScDocument* pDoc ) : ScRefUndoData::~ScRefUndoData() { - delete pDBCollection; - delete pRangeName; - delete pPrintRanges; - delete pDPCollection; - delete pDetOpList; - delete pChartListenerCollection; - delete pAreaLinks; + pDBCollection.reset(); + pRangeName.reset(); + pPrintRanges.reset(); + pDPCollection.reset(); + pDetOpList.reset(); + pChartListenerCollection.reset(); + pAreaLinks.reset(); } void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) @@ -88,20 +88,20 @@ void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) { ScDBCollection* pNewDBColl = pDoc->GetDBCollection(); if ( pNewDBColl && *pDBCollection == *pNewDBColl ) - DELETEZ(pDBCollection); + pDBCollection.reset(); } if (pRangeName) { ScRangeName* pNewRanges = pDoc->GetRangeName(); if ( pNewRanges && *pRangeName == *pNewRanges ) - DELETEZ(pRangeName); + pRangeName.reset(); } if (pPrintRanges) { ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver(); if ( pNewRanges && *pPrintRanges == *pNewRanges ) - DELETEZ(pPrintRanges); + pPrintRanges.reset(); delete pNewRanges; } @@ -109,14 +109,14 @@ void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) { ScDPCollection* pNewDP = const_cast<ScDocument*>(pDoc)->GetDPCollection(); //! const if ( pNewDP && pDPCollection->RefsEqual(*pNewDP) ) - DELETEZ(pDPCollection); + pDPCollection.reset(); } if (pDetOpList) { ScDetOpList* pNewDetOp = pDoc->GetDetOpList(); if ( pNewDetOp && *pDetOpList == *pNewDetOp ) - DELETEZ(pDetOpList); + pDetOpList.reset(); } if ( pChartListenerCollection ) @@ -125,13 +125,13 @@ void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) pDoc->GetChartListenerCollection(); if ( pNewChartListenerCollection && *pChartListenerCollection == *pNewChartListenerCollection ) - DELETEZ( pChartListenerCollection ); + pChartListenerCollection.reset(); } if (pAreaLinks) { if ( pAreaLinks->IsEqual( pDoc ) ) - DELETEZ(pAreaLinks); + pAreaLinks.reset(); } if ( pDoc->HasUnoRefUndo() ) |