diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-30 12:25:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-31 13:27:11 +0200 |
commit | b0d94ba8efe46c3ff7e90fa98f9a8708f48c5e66 (patch) | |
tree | 5a2dbd8cbbbca92f0c2120e5e85e861e5fab801a /sc/source | |
parent | 64cb57c82d9e7f7069821b2e2ef92574ec73ebe2 (diff) |
use std::unique_ptr in various sc undo code
Change-Id: I7906f4e78336d3b738ea3409838ce3404e7f5c30
Reviewed-on: https://gerrit.libreoffice.org/59796
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/docshell/dbdocfun.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 41 | ||||
-rw-r--r-- | sc/source/ui/inc/undoblk.hxx | 16 | ||||
-rw-r--r-- | sc/source/ui/inc/undocell.hxx | 5 | ||||
-rw-r--r-- | sc/source/ui/inc/undodat.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/undo/undoblk.cxx | 34 | ||||
-rw-r--r-- | sc/source/ui/undo/undocell.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc3.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/view/viewfun2.cxx | 4 |
11 files changed, 72 insertions, 66 deletions
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index f6c3a95b4c2e..a0f85a2712bd 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -342,7 +342,7 @@ bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bApi, bool bIsUnnamed, //! Undo needed data only ? ScDocumentUniquePtr pUndoDoc; - ScOutlineTable* pUndoTab = nullptr; + std::unique_ptr<ScOutlineTable> pUndoTab; std::unique_ptr<ScRangeName> pUndoRange; std::unique_ptr<ScDBCollection> pUndoDB; @@ -353,7 +353,7 @@ bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bApi, bool bIsUnnamed, ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab ); if (pTable) { - pUndoTab = new ScOutlineTable( *pTable ); + pUndoTab.reset(new ScOutlineTable( *pTable )); // column/row state SCCOLROW nOutStartCol, nOutEndCol; @@ -448,7 +448,7 @@ bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bApi, bool bIsUnnamed, nNewEndRow, //nCurX, nCurY, nStartCol, nStartRow, - std::move(pUndoDoc), pUndoTab, + std::move(pUndoDoc), std::move(pUndoTab), std::move(pUndoRange), std::move(pUndoDB), pOld, pNew ) ); } diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index a49e78d89f65..fcd7af66e640 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -416,16 +416,16 @@ bool ScDocFunc::DetectiveDelAll(SCTAB nTab) if (bDone) { ScDetOpList* pOldList = rDoc.GetDetOpList(); - ScDetOpList* pUndoList = nullptr; - if (bUndo) - pUndoList = pOldList ? new ScDetOpList(*pOldList) : nullptr; + std::unique_ptr<ScDetOpList> pUndoList; + if (bUndo && pOldList) + pUndoList.reset(new ScDetOpList(*pOldList)); rDoc.ClearDetectiveOperations(); if (bUndo) { rDocShell.GetUndoManager()->AddUndoAction( - new ScUndoDetective( &rDocShell, pUndo.release(), nullptr, pUndoList ) ); + new ScUndoDetective( &rDocShell, pUndo.release(), nullptr, std::move(pUndoList) ) ); } aModificator.SetDocumentModified(); SfxBindings* pBindings = rDocShell.GetViewBindings(); @@ -1933,9 +1933,9 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, { if (bRecord && !pUndoRemoveMerge) { - ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO )); pUndoDoc->InitUndo( &rDoc, *aMark.begin(), *aMark.rbegin()); - pUndoRemoveMerge.reset( new ScUndoRemoveMerge( &rDocShell, rRange, pUndoDoc )); + pUndoRemoveMerge.reset( new ScUndoRemoveMerge( &rDocShell, rRange, std::move(pUndoDoc) )); } for( ::std::vector<ScRange>::const_iterator iIter( qIncreaseRange.begin()); iIter != qIncreaseRange.end(); ++iIter ) @@ -2001,8 +2001,8 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, if ( bRecord ) { - SCTAB* pTabs = new SCTAB[nSelCount]; - SCTAB* pScenarios = new SCTAB[nSelCount]; + std::unique_ptr<SCTAB[]> pTabs(new SCTAB[nSelCount]); + std::unique_ptr<SCTAB[]> pScenarios(new SCTAB[nSelCount]); nUndoPos = 0; itr = aMark.begin(); for (; itr != itrEnd && *itr < nTabCount; ++itr) @@ -2023,7 +2023,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, rDocShell.GetUndoManager()->AddUndoAction( new ScUndoInsertCells( &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ), - nUndoPos, pTabs, pScenarios, eCmd, std::move(pRefUndoDoc), std::move(pUndoData), bPartOfPaste ) ); + nUndoPos, std::move(pTabs), std::move(pScenarios), eCmd, std::move(pRefUndoDoc), std::move(pUndoData), bPartOfPaste ) ); } // #i8302 : we remerge growing ranges, with the new part inserted @@ -2414,9 +2414,9 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, { if (bRecord && !pUndoRemoveMerge) { - ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO )); pUndoDoc->InitUndo( &rDoc, *aMark.begin(), *aMark.rbegin()); - pUndoRemoveMerge.reset( new ScUndoRemoveMerge( &rDocShell, rRange, pUndoDoc )); + pUndoRemoveMerge.reset( new ScUndoRemoveMerge( &rDocShell, rRange, std::move(pUndoDoc) )); } for( ::std::vector<ScRange>::const_iterator iIter( qDecreaseRange.begin()); iIter != qDecreaseRange.end(); ++iIter ) @@ -2531,8 +2531,8 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, pRefUndoDoc->CopyToDocument(0,0,0,MAXCOL,MAXROW,MAXTAB,InsertDeleteFlags::FORMULA,false,*pUndoDoc,nullptr,false); delete pRefUndoDoc; - SCTAB* pTabs = new SCTAB[nSelCount]; - SCTAB* pScenarios = new SCTAB[nSelCount]; + std::unique_ptr<SCTAB[]> pTabs( new SCTAB[nSelCount]); + std::unique_ptr<SCTAB[]> pScenarios( new SCTAB[nSelCount]); SCTAB nUndoPos = 0; itr = aMark.begin(); @@ -2554,7 +2554,8 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, } rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDeleteCells( - &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ),nUndoPos, pTabs, pScenarios, + &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ), + nUndoPos, std::move(pTabs), std::move(pScenarios), eCmd, std::move(pUndoDoc), std::move(pUndoData) ) ); } @@ -3981,12 +3982,12 @@ void ScDocFunc::ClearItems( const ScMarkData& rMark, const sal_uInt16* pWhich, b SCTAB nStartTab = aMarkRange.aStart.Tab(); SCTAB nEndTab = aMarkRange.aEnd.Tab(); - ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO )); pUndoDoc->InitUndo( &rDoc, nStartTab, nEndTab ); rDoc.CopyToDocument( aMarkRange, InsertDeleteFlags::ATTRIB, true, *pUndoDoc, &aMultiMark ); rDocShell.GetUndoManager()->AddUndoAction( - new ScUndoClearItems( &rDocShell, aMultiMark, pUndoDoc, pWhich ) ); + new ScUndoClearItems( &rDocShell, aMultiMark, std::move(pUndoDoc), pWhich ) ); } rDoc.ClearSelectionItems( pWhich, aMultiMark ); @@ -4968,7 +4969,7 @@ bool ScDocFunc::UnmergeCells( const ScCellMergeOption& rOption, bool bRecord, Sc else { rDocShell.GetUndoManager()->AddUndoAction( - new ScUndoRemoveMerge( &rDocShell, rOption, pUndoDoc ) ); + new ScUndoRemoveMerge( &rDocShell, rOption, ScDocumentUniquePtr(pUndoDoc) ) ); } } aModificator.SetDocumentModified(); @@ -5000,10 +5001,10 @@ void ScDocFunc::SetNewRangeNames( std::unique_ptr<ScRangeName> pNewRanges, bool { pOld = rDoc.GetRangeName(); } - ScRangeName* pUndoRanges = new ScRangeName(*pOld); - ScRangeName* pRedoRanges = new ScRangeName(*pNewRanges); + std::unique_ptr<ScRangeName> pUndoRanges(new ScRangeName(*pOld)); + std::unique_ptr<ScRangeName> pRedoRanges(new ScRangeName(*pNewRanges)); rDocShell.GetUndoManager()->AddUndoAction( - new ScUndoRangeNames( &rDocShell, pUndoRanges, pRedoRanges, nTab ) ); + new ScUndoRangeNames( &rDocShell, std::move(pUndoRanges), std::move(pRedoRanges), nTab ) ); } // #i55926# While loading XML, formula cells only have a single string token, diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx index 399c7efde0e0..ac67b1eeffc9 100644 --- a/sc/source/ui/inc/undoblk.hxx +++ b/sc/source/ui/inc/undoblk.hxx @@ -43,7 +43,8 @@ class ScUndoInsertCells: public ScMoveUndo { public: ScUndoInsertCells( ScDocShell* pNewDocShell, - const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios, + const ScRange& rRange, + SCTAB nNewCount, std::unique_ptr<SCTAB[]> pNewTabs, std::unique_ptr<SCTAB[]> pNewScenarios, InsCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData, bool bNewPartOfPaste ); virtual ~ScUndoInsertCells() override; @@ -78,7 +79,8 @@ class ScUndoDeleteCells: public ScMoveUndo { public: ScUndoDeleteCells( ScDocShell* pNewDocShell, - const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios, + const ScRange& rRange, + SCTAB nNewCount, std::unique_ptr<SCTAB[]> pNewTabs, std::unique_ptr<SCTAB[]> pNewScenarios, DelCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData ); virtual ~ScUndoDeleteCells() override; @@ -893,7 +895,7 @@ class ScUndoClearItems: public ScBlockUndo { public: ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& rMark, - ScDocument* pNewUndoDoc, const sal_uInt16* pW ); + ScDocumentUniquePtr pNewUndoDoc, const sal_uInt16* pW ); virtual ~ScUndoClearItems() override; virtual void Undo() override; @@ -915,7 +917,7 @@ class ScUndoRemoveBreaks: public ScSimpleUndo { public: ScUndoRemoveBreaks( ScDocShell* pNewDocShell, - SCTAB nNewTab, ScDocument* pNewUndoDoc ); + SCTAB nNewTab, ScDocumentUniquePtr pNewUndoDoc ); virtual ~ScUndoRemoveBreaks() override; virtual void Undo() override; @@ -936,10 +938,10 @@ class ScUndoRemoveMerge: public ScBlockUndo public: ScUndoRemoveMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption, - ScDocument* pNewUndoDoc ); + ScDocumentUniquePtr pNewUndoDoc ); ScUndoRemoveMerge( ScDocShell* pNewDocShell, const ScRange& rRange, - ScDocument* pNewUndoDoc ); + ScDocumentUniquePtr pNewUndoDoc ); virtual ~ScUndoRemoveMerge() override; virtual void Undo() override; @@ -964,7 +966,7 @@ class ScUndoBorder: public ScBlockUndo public: ScUndoBorder(ScDocShell* pNewDocShell, const ScRangeList& rRangeList, - ScDocument* pNewUndoDoc, + ScDocumentUniquePtr pNewUndoDoc, const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner); diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx index 51caaead3557..00b9913808c0 100644 --- a/sc/source/ui/inc/undocell.hxx +++ b/sc/source/ui/inc/undocell.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SC_SOURCE_UI_INC_UNDOCELL_HXX #include "undobase.hxx" +#include <detdata.hxx> #include <postit.hxx> #include <cellvalue.hxx> #include <cellvalues.hxx> @@ -352,7 +353,7 @@ class ScUndoDetective: public ScSimpleUndo public: ScUndoDetective( ScDocShell* pNewDocShell, SdrUndoAction* pDraw, const ScDetOpData* pOperation, - ScDetOpList* pUndoList = nullptr ); + std::unique_ptr<ScDetOpList> pUndoList = nullptr ); virtual ~ScUndoDetective() override; virtual void Undo() override; @@ -375,7 +376,7 @@ class ScUndoRangeNames: public ScSimpleUndo public: //use nTab = -1 for global range names ScUndoRangeNames( ScDocShell* pNewDocShell, - ScRangeName* pOld, ScRangeName* pNew , SCTAB nTab); + std::unique_ptr<ScRangeName> pOld, std::unique_ptr<ScRangeName> pNew , SCTAB nTab); virtual ~ScUndoRangeNames() override; virtual void Undo() override; diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx index 0d9991ad3700..18b2ba6fd0dd 100644 --- a/sc/source/ui/inc/undodat.hxx +++ b/sc/source/ui/inc/undodat.hxx @@ -317,7 +317,7 @@ public: ScUndoRepeatDB(ScDocShell* pNewDocShell, SCTAB nNewTab, SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY, - ScDocumentUniquePtr pNewUndoDoc, ScOutlineTable* pNewUndoTab, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab, std::unique_ptr<ScRangeName> pNewUndoRange, std::unique_ptr<ScDBCollection> pNewUndoDB, const ScRange* pOldQ, const ScRange* pNewQ); diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx index 1826896cf3fa..07ff4ff622b8 100644 --- a/sc/source/ui/undo/undoblk.cxx +++ b/sc/source/ui/undo/undoblk.cxx @@ -68,14 +68,15 @@ //? // check later ScUndoInsertCells::ScUndoInsertCells( ScDocShell* pNewDocShell, - const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios, + const ScRange& rRange, + SCTAB nNewCount, std::unique_ptr<SCTAB[]> pNewTabs, std::unique_ptr<SCTAB[]> pNewScenarios, InsCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData, bool bNewPartOfPaste ) : ScMoveUndo( pNewDocShell, std::move(pUndoDocument), std::move(pRefData), SC_UNDO_REFLAST ), aEffRange( rRange ), nCount( nNewCount ), - pTabs( pNewTabs ), - pScenarios( pNewScenarios ), + pTabs( std::move(pNewTabs) ), + pScenarios( std::move(pNewScenarios) ), eCmd( eNewCmd ), bPartOfPaste( bNewPartOfPaste ), pPasteUndo( nullptr ) @@ -337,13 +338,14 @@ bool ScUndoInsertCells::CanRepeat(SfxRepeatTarget& rTarget) const } ScUndoDeleteCells::ScUndoDeleteCells( ScDocShell* pNewDocShell, - const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios, + const ScRange& rRange, + SCTAB nNewCount, std::unique_ptr<SCTAB[]> pNewTabs, std::unique_ptr<SCTAB[]> pNewScenarios, DelCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData ) : ScMoveUndo( pNewDocShell, std::move(pUndoDocument), std::move(pRefData), SC_UNDO_REFLAST ), aEffRange( rRange ), nCount( nNewCount ), - pTabs( pNewTabs ), - pScenarios( pNewScenarios ), + pTabs( std::move(pNewTabs) ), + pScenarios( std::move(pNewScenarios) ), eCmd( eNewCmd ) { if (eCmd == DelCellCmd::Rows) // whole row? @@ -2094,10 +2096,10 @@ bool ScUndoTransliterate::CanRepeat(SfxRepeatTarget& rTarget) const } ScUndoClearItems::ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& rMark, - ScDocument* pNewUndoDoc, const sal_uInt16* pW ) : + ScDocumentUniquePtr pNewUndoDoc, const sal_uInt16* pW ) : ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ), aMarkData( rMark ), - pUndoDoc( pNewUndoDoc ), + pUndoDoc( std::move(pNewUndoDoc) ), pWhich( nullptr ) { OSL_ENSURE( pW, "ScUndoClearItems: Which-Pointer is Null" ); @@ -2157,10 +2159,10 @@ bool ScUndoClearItems::CanRepeat(SfxRepeatTarget& rTarget) const // remove all line breaks of a table ScUndoRemoveBreaks::ScUndoRemoveBreaks( ScDocShell* pNewDocShell, - SCTAB nNewTab, ScDocument* pNewUndoDoc ) : + SCTAB nNewTab, ScDocumentUniquePtr pNewUndoDoc ) : ScSimpleUndo( pNewDocShell ), nTab( nNewTab ), - pUndoDoc( pNewUndoDoc ) + pUndoDoc( std::move(pNewUndoDoc) ) { } @@ -2219,17 +2221,17 @@ bool ScUndoRemoveBreaks::CanRepeat(SfxRepeatTarget& rTarget) const } ScUndoRemoveMerge::ScUndoRemoveMerge( ScDocShell* pNewDocShell, - const ScCellMergeOption& rOption, ScDocument* pNewUndoDoc ) : + const ScCellMergeOption& rOption, ScDocumentUniquePtr pNewUndoDoc ) : ScBlockUndo( pNewDocShell, rOption.getFirstSingleRange(), SC_UNDO_SIMPLE ), - pUndoDoc( pNewUndoDoc ) + pUndoDoc( std::move(pNewUndoDoc) ) { maOptions.push_back( rOption); } ScUndoRemoveMerge::ScUndoRemoveMerge( ScDocShell* pNewDocShell, - const ScRange& rRange, ScDocument* pNewUndoDoc ) : + const ScRange& rRange, ScDocumentUniquePtr pNewUndoDoc ) : ScBlockUndo( pNewDocShell, rRange, SC_UNDO_SIMPLE ), - pUndoDoc( pNewUndoDoc ) + pUndoDoc( std::move(pNewUndoDoc) ) { } @@ -2377,10 +2379,10 @@ static ScRange lcl_TotalRange( const ScRangeList& rRanges ) } ScUndoBorder::ScUndoBorder(ScDocShell* pNewDocShell, - const ScRangeList& rRangeList, ScDocument* pNewUndoDoc, + const ScRangeList& rRangeList, ScDocumentUniquePtr pNewUndoDoc, const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner) : ScBlockUndo(pNewDocShell, lcl_TotalRange(rRangeList), SC_UNDO_SIMPLE) - , xUndoDoc(pNewUndoDoc) + , xUndoDoc(std::move(pNewUndoDoc)) { xRanges.reset(new ScRangeList(rRangeList)); xOuter.reset(new SvxBoxItem(rNewOuter)); diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx index 9cfd7a0ccca1..6deea5b1fb50 100644 --- a/sc/source/ui/undo/undocell.cxx +++ b/sc/source/ui/undo/undocell.cxx @@ -1032,9 +1032,9 @@ OUString ScUndoShowHideNote::GetComment() const ScUndoDetective::ScUndoDetective( ScDocShell* pNewDocShell, SdrUndoAction* pDraw, const ScDetOpData* pOperation, - ScDetOpList* pUndoList ) : + std::unique_ptr<ScDetOpList> pUndoList ) : ScSimpleUndo( pNewDocShell ), - pOldList ( pUndoList ), + pOldList ( std::move(pUndoList) ), nAction ( 0 ), pDrawUndo ( pDraw ) { @@ -1136,10 +1136,10 @@ bool ScUndoDetective::CanRepeat(SfxRepeatTarget& /* rTarget */) const } ScUndoRangeNames::ScUndoRangeNames( ScDocShell* pNewDocShell, - ScRangeName* pOld, ScRangeName* pNew, SCTAB nTab ) : + std::unique_ptr<ScRangeName> pOld, std::unique_ptr<ScRangeName> pNew, SCTAB nTab ) : ScSimpleUndo( pNewDocShell ), - pOldRanges ( pOld ), - pNewRanges ( pNew ), + pOldRanges ( std::move(pOld) ), + pNewRanges ( std::move(pNew) ), mnTab ( nTab ) { } diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index d5af929e94ae..f43ba974a21f 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -1223,7 +1223,7 @@ bool ScUndoImportData::CanRepeat(SfxRepeatTarget& rTarget) const ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab, SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY, - ScDocumentUniquePtr pNewUndoDoc, ScOutlineTable* pNewUndoTab, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab, std::unique_ptr<ScRangeName> pNewUndoRange, std::unique_ptr<ScDBCollection> pNewUndoDB, const ScRange* pOldQ, const ScRange* pNewQ ) : ScSimpleUndo( pNewDocShell ), @@ -1232,7 +1232,7 @@ ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab, nNewEndRow( nResultEndRow ), aCursorPos( nCurX,nCurY,nNewTab ), xUndoDoc(std::move(pNewUndoDoc)), - xUndoTable(pNewUndoTab), + xUndoTable(std::move(pNewUndoTab)), xUndoRange(std::move(pNewUndoRange)), xUndoDB(std::move(pNewUndoDB)), bQuerySize( false ) diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 40386f297348..6b6985cdd5b4 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1057,9 +1057,9 @@ void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& r { ScDocument& rDoc = pDocShell->GetDocument(); bool bUndo(rDoc.IsUndoEnabled()); - ScDocument* pUndoDoc = nullptr; + ScDocumentUniquePtr pUndoDoc; if (bUndo) - pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); size_t nCount = rRanges.size(); for (size_t i = 0; i < nCount; ++i) { @@ -1086,7 +1086,7 @@ void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& r if (bUndo) { pDocShell->GetUndoManager()->AddUndoAction( - new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) ); + new ScUndoBorder( pDocShell, rRanges, std::move(pUndoDoc), rOuter, rInner ) ); } for (size_t i = 0; i < nCount; ++i ) @@ -7023,11 +7023,11 @@ void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() if (bUndo) { - ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO )); pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); rDoc.CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, InsertDeleteFlags::NONE, false, *pUndoDoc); pDocSh->GetUndoManager()->AddUndoAction( - new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) ); + new ScUndoRemoveBreaks( pDocSh, nTab, std::move(pUndoDoc) ) ); } rDoc.RemoveManualBreaks(nTab); diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index de201bb0c9d5..72f36dbeabb3 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -2131,7 +2131,7 @@ void ScDBFunc::RepeatDB( bool bRecord ) //! undo only needed data ? ScDocumentUniquePtr pUndoDoc; - ScOutlineTable* pUndoTab = nullptr; + std::unique_ptr<ScOutlineTable> pUndoTab; std::unique_ptr<ScRangeName> pUndoRange; std::unique_ptr<ScDBCollection> pUndoDB; @@ -2142,7 +2142,7 @@ void ScDBFunc::RepeatDB( bool bRecord ) ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); if (pTable) { - pUndoTab = new ScOutlineTable( *pTable ); + pUndoTab.reset(new ScOutlineTable( *pTable )); SCCOLROW nOutStartCol; // row/column status SCCOLROW nOutStartRow; @@ -2235,7 +2235,7 @@ void ScDBFunc::RepeatDB( bool bRecord ) nStartCol, nStartRow, nEndCol, nEndRow, nNewEndRow, nCurX, nCurY, - std::move(pUndoDoc), pUndoTab, + std::move(pUndoDoc), std::move(pUndoTab), std::move(pUndoRange), std::move(pUndoDB), pOld, pNew ) ); } diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index 94b01f2f420b..d4ffd0644c23 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -908,11 +908,11 @@ void ScViewFunc::RemoveManualBreaks() if (bUndo) { - ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO ); + ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO )); pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); rDoc.CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, InsertDeleteFlags::NONE, false, *pUndoDoc ); pDocSh->GetUndoManager()->AddUndoAction( - new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) ); + new ScUndoRemoveBreaks( pDocSh, nTab, std::move(pUndoDoc) ) ); } rDoc.RemoveManualBreaks(nTab); |