diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-30 11:26:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-31 08:23:20 +0200 |
commit | df26410a52419707590fdf62dc043d13b79ada81 (patch) | |
tree | 16311130812a2997f3e9328e356c8222e5e2def2 /sc | |
parent | 418e6419219a7ffa61b7400abbbcec6a6a93b91f (diff) |
pass ScDBData by std::unique_ptr
Change-Id: Ia16bde5b428be6a39ff7e3f6052258652ea0f07a
Reviewed-on: https://gerrit.libreoffice.org/59789
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/docshell/dbdocfun.cxx | 26 | ||||
-rw-r--r-- | sc/source/ui/docshell/dbdocimp.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh5.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/inc/undodat.hxx | 12 | ||||
-rw-r--r-- | sc/source/ui/undo/undodat.cxx | 30 | ||||
-rw-r--r-- | sc/source/ui/view/dbfunc3.cxx | 20 |
6 files changed, 53 insertions, 52 deletions
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx index 5c324bab714a..f6c3a95b4c2e 100644 --- a/sc/source/ui/docshell/dbdocfun.cxx +++ b/sc/source/ui/docshell/dbdocfun.cxx @@ -343,8 +343,8 @@ bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bApi, bool bIsUnnamed, ScDocumentUniquePtr pUndoDoc; ScOutlineTable* pUndoTab = nullptr; - ScRangeName* pUndoRange = nullptr; - ScDBCollection* pUndoDB = nullptr; + std::unique_ptr<ScRangeName> pUndoRange; + std::unique_ptr<ScDBCollection> pUndoDB; if (bRecord) { @@ -381,10 +381,10 @@ bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bApi, bool bIsUnnamed, // ranges of DB and other ScRangeName* pDocRange = rDoc.GetRangeName(); if (!pDocRange->empty()) - pUndoRange = new ScRangeName( *pDocRange ); + pUndoRange.reset(new ScRangeName( *pDocRange )); ScDBCollection* pDocDB = rDoc.GetDBCollection(); if (!pDocDB->empty()) - pUndoDB = new ScDBCollection( *pDocDB ); + pUndoDB.reset(new ScDBCollection( *pDocDB )); } if (bSort && bSubTotal) @@ -449,7 +449,7 @@ bool ScDBDocFunc::RepeatDB( const OUString& rDBName, bool bApi, bool bIsUnnamed, //nCurX, nCurY, nStartCol, nStartRow, std::move(pUndoDoc), pUndoTab, - pUndoRange, pUndoDB, + std::move(pUndoRange), std::move(pUndoDB), pOld, pNew ) ); } @@ -737,7 +737,7 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam, } ScDocumentUniquePtr pUndoDoc; - ScDBCollection* pUndoDB = nullptr; + std::unique_ptr<ScDBCollection> pUndoDB; const ScRange* pOld = nullptr; if ( bRecord ) @@ -766,7 +766,7 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam, ScDBCollection* pDocDB = rDoc.GetDBCollection(); if (!pDocDB->empty()) - pUndoDB = new ScDBCollection( *pDocDB ); + pUndoDB.reset(new ScDBCollection( *pDocDB )); rDoc.BeginDrawUndo(); } @@ -930,7 +930,7 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam, { // create undo action after executing, because of drawing layer undo rDocShell.GetUndoManager()->AddUndoAction( - new ScUndoQuery( &rDocShell, nTab, rQueryParam, std::move(pUndoDoc), pUndoDB, + new ScUndoQuery( &rDocShell, nTab, rQueryParam, std::move(pUndoDoc), std::move(pUndoDB), pOld, bDoSize, pAdvSource ) ); } @@ -1029,8 +1029,8 @@ void ScDBDocFunc::DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam, ScSubTotalParam aNewParam( rParam ); // end of range is being changed ScDocumentUniquePtr pUndoDoc; std::unique_ptr<ScOutlineTable> pUndoTab; - ScRangeName* pUndoRange = nullptr; - ScDBCollection* pUndoDB = nullptr; + std::unique_ptr<ScRangeName> pUndoRange; + std::unique_ptr<ScDBCollection> pUndoDB; if (bRecord) // secure old data { @@ -1067,10 +1067,10 @@ void ScDBDocFunc::DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam, // ranges of DB and other ScRangeName* pDocRange = rDoc.GetRangeName(); if (!pDocRange->empty()) - pUndoRange = new ScRangeName( *pDocRange ); + pUndoRange.reset(new ScRangeName( *pDocRange )); ScDBCollection* pDocDB = rDoc.GetDBCollection(); if (!pDocDB->empty()) - pUndoDB = new ScDBCollection( *pDocDB ); + pUndoDB.reset(new ScDBCollection( *pDocDB )); } // rDoc.SetOutlineTable( nTab, NULL ); @@ -1111,7 +1111,7 @@ void ScDBDocFunc::DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam, new ScUndoSubTotals( &rDocShell, nTab, rParam, aNewParam.nRow2, std::move(pUndoDoc), std::move(pUndoTab), // pUndoDBData, - pUndoRange, pUndoDB ) ); + std::move(pUndoRange), std::move(pUndoDB) ) ); } if (!bSuccess) diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx index b7362c0966b0..df9b96129c2f 100644 --- a/sc/source/ui/docshell/dbdocimp.cxx +++ b/sc/source/ui/docshell/dbdocimp.cxx @@ -467,13 +467,13 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, SCROW nUndoEndRow = std::max( nEndRow, rParam.nRow2 ); ScDocumentUniquePtr pUndoDoc; - ScDBData* pUndoDBData = nullptr; + std::unique_ptr<ScDBData> pUndoDBData; if ( bRecord ) { pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO )); pUndoDoc->InitUndo( &rDoc, nTab, nTab ); - pUndoDBData = new ScDBData( *pDBData ); + pUndoDBData.reset(new ScDBData( *pDBData )); } ScMarkData aNewMark; @@ -581,13 +581,14 @@ bool ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam, nEndCol+nFormulaCols, nEndRow, nTab, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, *pRedoDoc); - ScDBData* pRedoDBData = pDBData ? new ScDBData( *pDBData ) : nullptr; + std::unique_ptr<ScDBData> pRedoDBData(pDBData ? new ScDBData( *pDBData ) : nullptr); rDocShell.GetUndoManager()->AddUndoAction( new ScUndoImportData( &rDocShell, nTab, rParam, nUndoEndCol, nUndoEndRow, nFormulaCols, - std::move(pUndoDoc), std::move(pRedoDoc), pUndoDBData, pRedoDBData ) ); + std::move(pUndoDoc), std::move(pRedoDoc), + std::move(pUndoDBData), std::move(pRedoDBData) ) ); } sc::SetFormulaDirtyContext aCxt; diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx index 95106e21676f..58a9ead66043 100644 --- a/sc/source/ui/docshell/docsh5.cxx +++ b/sc/source/ui/docshell/docsh5.cxx @@ -560,7 +560,7 @@ void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, bool bRecord ) aData.GetSize( nColSize, nRowSize ); if (bRecord && nColSize > 0 && nRowSize > 0) { - ScDBData* pUndoData = pDestData ? new ScDBData(*pDestData) : nullptr; + std::unique_ptr<ScDBData> pUndoData(pDestData ? new ScDBData(*pDestData) : nullptr); SCTAB nDestTab = rParam.nTab; ScArea aDestArea( rParam.nTab, rParam.nCol, rParam.nRow, @@ -575,7 +575,7 @@ void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, bool bRecord ) // old outlines ScOutlineTable* pTable = m_aDocument.GetOutlineTable( nDestTab ); - ScOutlineTable* pUndoTab = pTable ? new ScOutlineTable( *pTable ) : nullptr; + std::unique_ptr<ScOutlineTable> pUndoTab(pTable ? new ScOutlineTable( *pTable ) : nullptr); ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO )); pUndoDoc->InitUndo( &m_aDocument, 0, nTabCount-1, false, true ); @@ -599,7 +599,7 @@ void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, bool bRecord ) GetUndoManager()->AddUndoAction( new ScUndoConsolidate( this, aDestArea, rParam, std::move(pUndoDoc), - true, nInsertCount, pUndoTab, pUndoData ) ); + true, nInsertCount, std::move(pUndoTab), std::move(pUndoData) ) ); } else { @@ -616,7 +616,7 @@ void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, bool bRecord ) GetUndoManager()->AddUndoAction( new ScUndoConsolidate( this, aDestArea, rParam, std::move(pUndoDoc), - false, 0, nullptr, pUndoData ) ); + false, 0, nullptr, std::move(pUndoData) ) ); } } diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx index 2464f098b8e3..0d9991ad3700 100644 --- a/sc/source/ui/inc/undodat.hxx +++ b/sc/source/ui/inc/undodat.hxx @@ -193,7 +193,7 @@ public: ScUndoSubTotals(ScDocShell* pNewDocShell, SCTAB nNewTab, const ScSubTotalParam& rNewParam, SCROW nNewEndY, ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab, - ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB); + std::unique_ptr<ScRangeName> pNewUndoRange, std::unique_ptr<ScDBCollection> pNewUndoDB); virtual void Undo() override; virtual void Redo() override; @@ -217,7 +217,7 @@ class ScUndoQuery: public ScDBFuncUndo public: ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQueryParam& rParam, ScDocumentUniquePtr pNewUndoDoc, - ScDBCollection* pNewUndoDB, const ScRange* pOld, + std::unique_ptr<ScDBCollection> pNewUndoDB, const ScRange* pOld, bool bSize, const ScRange* pAdvSrc ); virtual ~ScUndoQuery() override; @@ -289,7 +289,7 @@ public: const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY, SCCOL nNewFormula, ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, - ScDBData* pNewUndoData, ScDBData* pNewRedoData); + std::unique_ptr<ScDBData> pNewUndoData, std::unique_ptr<ScDBData> pNewRedoData); virtual void Undo() override; virtual void Redo() override; @@ -318,7 +318,7 @@ public: SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY, ScDocumentUniquePtr pNewUndoDoc, ScOutlineTable* pNewUndoTab, - ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB, + std::unique_ptr<ScRangeName> pNewUndoRange, std::unique_ptr<ScDBCollection> pNewUndoDB, const ScRange* pOldQ, const ScRange* pNewQ); virtual void Undo() override; @@ -371,8 +371,8 @@ public: ScUndoConsolidate(ScDocShell* pNewDocShell, const ScArea& rArea, const ScConsolidateParam& rPar, ScDocumentUniquePtr pNewUndoDoc, bool bReference, - SCROW nInsCount, ScOutlineTable* pTab, - ScDBData* pData); + SCROW nInsCount, std::unique_ptr<ScOutlineTable> pTab, + std::unique_ptr<ScDBData> pData); virtual void Undo() override; virtual void Redo() override; diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx index f258c8ecfdf1..d5af929e94ae 100644 --- a/sc/source/ui/undo/undodat.cxx +++ b/sc/source/ui/undo/undodat.cxx @@ -586,7 +586,7 @@ bool ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const ScUndoSubTotals::ScUndoSubTotals(ScDocShell* pNewDocShell, SCTAB nNewTab, const ScSubTotalParam& rNewParam, SCROW nNewEndY, ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScOutlineTable> pNewUndoTab, - ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB) + std::unique_ptr<ScRangeName> pNewUndoRange, std::unique_ptr<ScDBCollection> pNewUndoDB) : ScDBFuncUndo(pNewDocShell, ScRange(rNewParam.nCol1, rNewParam.nRow1, nNewTab, rNewParam.nCol2, rNewParam.nRow2, nNewTab)) , nTab(nNewTab) @@ -594,8 +594,8 @@ ScUndoSubTotals::ScUndoSubTotals(ScDocShell* pNewDocShell, SCTAB nNewTab, , nNewEndRow(nNewEndY) , xUndoDoc(std::move(pNewUndoDoc)) , xUndoTable(std::move(pNewUndoTab)) - , xUndoRange(pNewUndoRange) - , xUndoDB(pNewUndoDB) + , xUndoRange(std::move(pNewUndoRange)) + , xUndoDB(std::move(pNewUndoDB)) { } @@ -698,7 +698,7 @@ bool ScUndoSubTotals::CanRepeat(SfxRepeatTarget& /* rTarget */) const } ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQueryParam& rParam, - ScDocumentUniquePtr pNewUndoDoc, ScDBCollection* pNewUndoDB, + ScDocumentUniquePtr pNewUndoDoc, std::unique_ptr<ScDBCollection> pNewUndoDB, const ScRange* pOld, bool bSize, const ScRange* pAdvSrc ) : ScDBFuncUndo( pNewDocShell, ScRange( rParam.nCol1, rParam.nRow1, nNewTab, rParam.nCol2, rParam.nRow2, nNewTab ) ), @@ -706,7 +706,7 @@ ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQuery nTab( nNewTab ), aQueryParam( rParam ), xUndoDoc( std::move(pNewUndoDoc) ), - xUndoDB( pNewUndoDB ), + xUndoDB( std::move(pNewUndoDB) ), bIsAdvanced( false ), bDestArea( false ), bDoSize( bSize ) @@ -1020,7 +1020,7 @@ ScUndoImportData::ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY, SCCOL nNewFormula, ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, - ScDBData* pNewUndoData, ScDBData* pNewRedoData ) : + std::unique_ptr<ScDBData> pNewUndoData, std::unique_ptr<ScDBData> pNewRedoData ) : ScSimpleUndo( pNewDocShell ), nTab( nNewTab ), aImportParam( rParam ), @@ -1028,8 +1028,8 @@ ScUndoImportData::ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab, nEndRow( nNewEndY ), xUndoDoc(std::move(pNewUndoDoc)), xRedoDoc(std::move(pNewRedoDoc)), - xUndoDBData(pNewUndoData), - xRedoDBData(pNewRedoData), + xUndoDBData(std::move(pNewUndoData)), + xRedoDBData(std::move(pNewRedoData)), nFormulaCols( nNewFormula ), bRedoFilled( false ) { @@ -1224,7 +1224,7 @@ ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab, SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY, SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY, ScDocumentUniquePtr pNewUndoDoc, ScOutlineTable* pNewUndoTab, - ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB, + std::unique_ptr<ScRangeName> pNewUndoRange, std::unique_ptr<ScDBCollection> pNewUndoDB, const ScRange* pOldQ, const ScRange* pNewQ ) : ScSimpleUndo( pNewDocShell ), aBlockStart( nStartX,nStartY,nNewTab ), @@ -1233,8 +1233,8 @@ ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab, aCursorPos( nCurX,nCurY,nNewTab ), xUndoDoc(std::move(pNewUndoDoc)), xUndoTable(pNewUndoTab), - xUndoRange(pNewUndoRange), - xUndoDB(pNewUndoDB), + xUndoRange(std::move(pNewUndoRange)), + xUndoDB(std::move(pNewUndoDB)), bQuerySize( false ) { if ( pOldQ && pNewQ ) @@ -1524,16 +1524,16 @@ bool ScUndoDataPilot::CanRepeat(SfxRepeatTarget& /* rTarget */) const ScUndoConsolidate::ScUndoConsolidate( ScDocShell* pNewDocShell, const ScArea& rArea, const ScConsolidateParam& rPar, ScDocumentUniquePtr pNewUndoDoc, - bool bReference, SCROW nInsCount, ScOutlineTable* pTab, - ScDBData* pData ) + bool bReference, SCROW nInsCount, std::unique_ptr<ScOutlineTable> pTab, + std::unique_ptr<ScDBData> pData ) : ScSimpleUndo(pNewDocShell) , aDestArea(rArea) , xUndoDoc(std::move(pNewUndoDoc)) , aParam(rPar) , bInsRef(bReference) , nInsertCount(nInsCount) - , xUndoTab(pTab) - , xUndoData(pData) + , xUndoTab(std::move(pTab)) + , xUndoData(std::move(pData)) { } diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 57608b8bb091..de201bb0c9d5 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -439,8 +439,8 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, bool bRecord, ScSubTotalParam aNewParam( rParam ); // change end of range ScDocumentUniquePtr pUndoDoc; std::unique_ptr<ScOutlineTable> pUndoTab; - ScRangeName* pUndoRange = nullptr; - ScDBCollection* pUndoDB = nullptr; + std::unique_ptr<ScRangeName> pUndoRange; + std::unique_ptr<ScDBCollection> pUndoDB; if (bRecord) // record old data { @@ -477,10 +477,10 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, bool bRecord, // database and other ranges ScRangeName* pDocRange = rDoc.GetRangeName(); if (!pDocRange->empty()) - pUndoRange = new ScRangeName( *pDocRange ); + pUndoRange.reset(new ScRangeName( *pDocRange )); ScDBCollection* pDocDB = rDoc.GetDBCollection(); if (!pDocDB->empty()) - pUndoDB = new ScDBCollection( *pDocDB ); + pUndoDB.reset(new ScDBCollection( *pDocDB )); } ScOutlineTable* pOut = rDoc.GetOutlineTable( nTab ); @@ -527,7 +527,7 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, bool bRecord, new ScUndoSubTotals( pDocSh, nTab, rParam, aNewParam.nRow2, std::move(pUndoDoc), std::move(pUndoTab), // pUndoDBData, - pUndoRange, pUndoDB ) ); + std::move(pUndoRange), std::move(pUndoDB) ) ); } if (!bSuccess) @@ -2132,8 +2132,8 @@ void ScDBFunc::RepeatDB( bool bRecord ) ScDocumentUniquePtr pUndoDoc; ScOutlineTable* pUndoTab = nullptr; - ScRangeName* pUndoRange = nullptr; - ScDBCollection* pUndoDB = nullptr; + std::unique_ptr<ScRangeName> pUndoRange; + std::unique_ptr<ScDBCollection> pUndoDB; if (bRecord) { @@ -2167,10 +2167,10 @@ void ScDBFunc::RepeatDB( bool bRecord ) // data base and other ranges ScRangeName* pDocRange = pDoc->GetRangeName(); if (!pDocRange->empty()) - pUndoRange = new ScRangeName( *pDocRange ); + pUndoRange.reset(new ScRangeName( *pDocRange )); ScDBCollection* pDocDB = pDoc->GetDBCollection(); if (!pDocDB->empty()) - pUndoDB = new ScDBCollection( *pDocDB ); + pUndoDB.reset(new ScDBCollection( *pDocDB )); } if (bSort && bSubTotal) @@ -2236,7 +2236,7 @@ void ScDBFunc::RepeatDB( bool bRecord ) nNewEndRow, nCurX, nCurY, std::move(pUndoDoc), pUndoTab, - pUndoRange, pUndoDB, + std::move(pUndoRange), std::move(pUndoDB), pOld, pNew ) ); } |