diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-20 12:54:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-22 09:53:45 +0100 |
commit | b7654432bfeca619b7657abc8d27193e44cf4dfc (patch) | |
tree | 0935306e00e967c1dca4efc8af57f4d67c30a508 /sc/source/ui/undo | |
parent | f82888653c853f236ab0035bb578a7129ec72fa5 (diff) |
loplugin:useuniqueptr in ScDocument
and fix bug where we were deleting a pointer to an object
we did not own via pFormatExchangeList
Change-Id: I488c679734c48bd21bc6be04837e037e97550647
Reviewed-on: https://gerrit.libreoffice.org/51668
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui/undo')
-rw-r--r-- | sc/source/ui/undo/refundo.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 14 |
3 files changed, 14 insertions, 15 deletions
diff --git a/sc/source/ui/undo/refundo.cxx b/sc/source/ui/undo/refundo.cxx index 7488465e63af..857120cc69da 100644 --- a/sc/source/ui/undo/refundo.cxx +++ b/sc/source/ui/undo/refundo.cxx @@ -80,7 +80,6 @@ ScRefUndoData::~ScRefUndoData() delete pDetOpList; delete pChartListenerCollection; delete pAreaLinks; - delete pUnoRefs; } void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) @@ -140,7 +139,7 @@ void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) pUnoRefs = const_cast<ScDocument*>(pDoc)->EndUnoRefUndo(); if ( pUnoRefs && pUnoRefs->IsEmpty() ) { - DELETEZ( pUnoRefs ); + pUnoRefs.reset(); } } } @@ -148,9 +147,9 @@ void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) void ScRefUndoData::DoUndo( ScDocument* pDoc, bool bUndoRefFirst ) { if (pDBCollection) - pDoc->SetDBCollection( new ScDBCollection(*pDBCollection) ); + pDoc->SetDBCollection( std::unique_ptr<ScDBCollection>(new ScDBCollection(*pDBCollection)) ); if (pRangeName) - pDoc->SetRangeName( new ScRangeName(*pRangeName) ); + pDoc->SetRangeName( std::unique_ptr<ScRangeName>(new ScRangeName(*pRangeName)) ); if (pPrintRanges) pDoc->RestorePrintRanges(*pPrintRanges); @@ -163,7 +162,7 @@ void ScRefUndoData::DoUndo( ScDocument* pDoc, bool bUndoRefFirst ) } if (pDetOpList) - pDoc->SetDetOpList( new ScDetOpList(*pDetOpList) ); + pDoc->SetDetOpList( std::unique_ptr<ScDetOpList>(new ScDetOpList(*pDetOpList)) ); // bUndoRefFirst is bSetChartRangeLists if ( pChartListenerCollection ) diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 522914ec9cdc..9e8e09a1bb6f 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -912,7 +912,7 @@ void ScUndoDetective::Undo() if (bIsDelete) { if ( pOldList ) - rDoc.SetDetOpList( new ScDetOpList(*pOldList) ); + rDoc.SetDetOpList( std::unique_ptr<ScDetOpList>(new ScDetOpList(*pOldList)) ); } else { @@ -999,14 +999,14 @@ void ScUndoRangeNames::DoChange( bool bUndo ) if (mnTab >= 0) rDoc.SetRangeName( mnTab, new ScRangeName( *pOldRanges ) ); else - rDoc.SetRangeName( new ScRangeName( *pOldRanges ) ); + rDoc.SetRangeName( std::unique_ptr<ScRangeName>(new ScRangeName( *pOldRanges )) ); } else { if (mnTab >= 0) rDoc.SetRangeName( mnTab, new ScRangeName( *pNewRanges ) ); else - rDoc.SetRangeName( new ScRangeName( *pNewRanges ) ); + rDoc.SetRangeName( std::unique_ptr<ScRangeName>(new ScRangeName( *pNewRanges )) ); } rDoc.CompileHybridFormula(); diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index d3cef474a5d0..afaed1811b1e 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -656,9 +656,9 @@ void ScUndoSubTotals::Undo() aParam.nCol2,aParam.nRow2,nTab ); if (xUndoRange) - rDoc.SetRangeName(new ScRangeName(*xUndoRange)); + rDoc.SetRangeName(std::unique_ptr<ScRangeName>(new ScRangeName(*xUndoRange))); if (xUndoDB) - rDoc.SetDBCollection(new ScDBCollection(*xUndoDB), true); + rDoc.SetDBCollection(std::unique_ptr<ScDBCollection>(new ScDBCollection(*xUndoDB)), true); SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); if ( nVisTab != nTab ) @@ -796,7 +796,7 @@ void ScUndoQuery::Undo() InsertDeleteFlags::NONE, false, rDoc); if (xUndoDB) - rDoc.SetDBCollection(new ScDBCollection(*xUndoDB ), true); + rDoc.SetDBCollection(std::unique_ptr<ScDBCollection>(new ScDBCollection(*xUndoDB )), true); if (!bCopy) { @@ -980,7 +980,7 @@ void ScUndoDBData::Undo() bool bOldAutoCalc = rDoc.GetAutoCalc(); rDoc.SetAutoCalc( false ); // Avoid unnecessary calculations rDoc.PreprocessDBDataUpdate(); - rDoc.SetDBCollection( new ScDBCollection(*pUndoColl), true ); + rDoc.SetDBCollection( std::unique_ptr<ScDBCollection>(new ScDBCollection(*pUndoColl)), true ); rDoc.CompileHybridFormula(); rDoc.SetAutoCalc( bOldAutoCalc ); @@ -998,7 +998,7 @@ void ScUndoDBData::Redo() bool bOldAutoCalc = rDoc.GetAutoCalc(); rDoc.SetAutoCalc( false ); // Avoid unnecessary calculations rDoc.PreprocessDBDataUpdate(); - rDoc.SetDBCollection( new ScDBCollection(*pRedoColl), true ); + rDoc.SetDBCollection( std::unique_ptr<ScDBCollection>(new ScDBCollection(*pRedoColl)), true ); rDoc.CompileHybridFormula(); rDoc.SetAutoCalc( bOldAutoCalc ); @@ -1333,9 +1333,9 @@ void ScUndoRepeatDB::Undo() aBlockEnd.Col(),aBlockEnd.Row(),nTab ); if (xUndoRange) - rDoc.SetRangeName(new ScRangeName(*xUndoRange)); + rDoc.SetRangeName(std::unique_ptr<ScRangeName>(new ScRangeName(*xUndoRange))); if (xUndoDB) - rDoc.SetDBCollection(new ScDBCollection(*xUndoDB), true); + rDoc.SetDBCollection(std::unique_ptr<ScDBCollection>(new ScDBCollection(*xUndoDB)), true); SCTAB nVisTab = pViewShell->GetViewData().GetTabNo(); if ( nVisTab != nTab ) |