[Libreoffice-commits] core.git: sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sat Aug 25 08:59:58 UTC 2018
sc/source/ui/docshell/docfunc.cxx | 38 ++++++++++++++++++--------------------
sc/source/ui/inc/undobase.hxx | 4 ++--
sc/source/ui/inc/undoblk.hxx | 8 ++++----
sc/source/ui/inc/undotab.hxx | 2 +-
sc/source/ui/undo/undobase.cxx | 4 ++--
sc/source/ui/undo/undoblk.cxx | 16 ++++++++--------
sc/source/ui/undo/undotab.cxx | 4 ++--
sc/source/ui/view/viewfun2.cxx | 7 +++----
sc/source/ui/view/viewfunc.cxx | 6 +++---
9 files changed, 43 insertions(+), 46 deletions(-)
New commits:
commit 6ae4c85fe6c1bdd009b494382ac2ca2584307801
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 24 14:27:12 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Aug 25 10:59:37 2018 +0200
loplugin:useuniqueptr in ScMoveUndo
Change-Id: I622a0f37866c5ea1f4ec5f4475d784682a0179c2
Reviewed-on: https://gerrit.libreoffice.org/59560
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index d215f87ea15b..94ec954867f8 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1798,11 +1798,11 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
WaitObject aWait( ScDocShell::GetActiveDialogParent() ); // important due to TrackFormulas at UpdateReference
- ScDocument* pRefUndoDoc = nullptr;
+ ScDocumentUniquePtr pRefUndoDoc;
ScRefUndoData* pUndoData = nullptr;
if ( bRecord )
{
- pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRefUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pRefUndoDoc->InitUndo( &rDoc, 0, nTabCount-1 );
// pRefUndoDoc is filled in InsertCol / InsertRow
@@ -1968,24 +1968,24 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
switch (eCmd)
{
case INS_CELLSDOWN:
- bSuccess = rDoc.InsertRow( nStartCol, 0, nEndCol, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &aFullMark );
+ bSuccess = rDoc.InsertRow( nStartCol, 0, nEndCol, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc.get(), &aFullMark );
nPaintEndRow = MAXROW;
break;
case INS_INSROWS_BEFORE:
case INS_INSROWS_AFTER:
- bSuccess = rDoc.InsertRow( 0, 0, MAXCOL, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &aFullMark );
+ bSuccess = rDoc.InsertRow( 0, 0, MAXCOL, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc.get(), &aFullMark );
nPaintStartCol = 0;
nPaintEndCol = MAXCOL;
nPaintEndRow = MAXROW;
nPaintFlags |= PaintPartFlags::Left;
break;
case INS_CELLSRIGHT:
- bSuccess = rDoc.InsertCol( nStartRow, 0, nEndRow, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &aFullMark );
+ bSuccess = rDoc.InsertCol( nStartRow, 0, nEndRow, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc.get(), &aFullMark );
nPaintEndCol = MAXCOL;
break;
case INS_INSCOLS_BEFORE:
case INS_INSCOLS_AFTER:
- bSuccess = rDoc.InsertCol( 0, 0, MAXROW, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &aFullMark );
+ bSuccess = rDoc.InsertCol( 0, 0, MAXROW, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc.get(), &aFullMark );
nPaintStartRow = 0;
nPaintEndRow = MAXROW;
nPaintEndCol = MAXCOL;
@@ -2025,7 +2025,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, pRefUndoDoc, pUndoData, bPartOfPaste ) );
+ nUndoPos, pTabs, pScenarios, eCmd, std::move(pRefUndoDoc), pUndoData, bPartOfPaste ) );
}
// #i8302 : we remerge growing ranges, with the new part inserted
@@ -2121,7 +2121,7 @@ bool ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark,
rDocShell.GetUndoManager()->LeaveListAction();
rDocShell.GetUndoManager()->RemoveLastUndoAction();
- delete pRefUndoDoc;
+ pRefUndoDoc.reset();
delete pUndoData;
if (!bApi)
rDocShell.ErrorMessage(STR_INSERT_FULL); // column/row full
@@ -2451,7 +2451,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
WaitObject aWait( ScDocShell::GetActiveDialogParent() ); // important because of TrackFormulas in UpdateReference
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
ScDocument* pRefUndoDoc = nullptr;
ScRefUndoData* pUndoData = nullptr;
if ( bRecord )
@@ -2459,7 +2459,7 @@ bool ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
// With the fix for #101329#, UpdateRef always puts cells into pRefUndoDoc at their old position,
// so it's no longer necessary to copy more than the deleted range into pUndoDoc.
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, 0, nTabCount-1, (eCmd==DelCellCmd::Cols), (eCmd==DelCellCmd::Rows) );
itr = aMark.begin();
for (; itr != itrEnd && *itr < nTabCount; ++itr)
@@ -2558,7 +2558,7 @@ 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,
- eCmd, pUndoDoc, pUndoData ) );
+ eCmd, std::move(pUndoDoc), pUndoData ) );
}
// #i8302 want to be able to insert into the middle of merged cells
@@ -2834,7 +2834,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
// do it
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if (bRecord)
{
@@ -2842,7 +2842,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
bool bWholeRows = ( nStartCol == 0 && nEndCol == MAXCOL );
InsertDeleteFlags nUndoFlags = (InsertDeleteFlags::ALL & ~InsertDeleteFlags::OBJECTS) | InsertDeleteFlags::NOCAPTIONS;
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nStartTab, nEndTab, bWholeCols, bWholeRows );
if (bCut)
@@ -2889,7 +2889,6 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
if (!bApi) // "Merge of already merged cells not possible"
rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0);
- delete pUndoDoc;
return false;
}
@@ -2910,7 +2909,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
rDoc.CopyFromClip(
aPasteDest, aDestMark, InsertDeleteFlags::ALL & ~InsertDeleteFlags::OBJECTS,
- pUndoDoc, pClipDoc.get(), true, false, bIncludeFiltered);
+ pUndoDoc.get(), pClipDoc.get(), true, false, bIncludeFiltered);
// skipped rows and merged cells don't mix
if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() )
@@ -2934,7 +2933,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
rDocShell.GetUndoManager()->AddUndoAction(
new ScUndoDragDrop(
- &rDocShell, aUndoRange, aDestPos, bCut, pUndoDoc, bScenariosAdded));
+ &rDocShell, aUndoRange, aDestPos, bCut, std::move(pUndoDoc), bScenariosAdded));
}
SCCOL nDestPaintEndCol = nDestEndCol;
@@ -3181,11 +3180,11 @@ bool ScDocFunc::DeleteTable( SCTAB nTab, bool bRecord )
if ( bVbaEnabled )
bRecord = false;
bool bWasLinked = rDoc.IsLinked(nTab);
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
ScRefUndoData* pUndoData = nullptr;
if (bRecord)
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
SCTAB nCount = rDoc.GetTableCount();
pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true ); // only nTab with Flags
@@ -3230,7 +3229,7 @@ bool ScDocFunc::DeleteTable( SCTAB nTab, bool bRecord )
vector<SCTAB> theTabs;
theTabs.push_back(nTab);
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData ));
+ new ScUndoDeleteTab( &rDocShell, theTabs, std::move(pUndoDoc), pUndoData ));
}
// Update views:
if( bVbaEnabled )
@@ -3263,7 +3262,6 @@ bool ScDocFunc::DeleteTable( SCTAB nTab, bool bRecord )
}
else
{
- delete pUndoDoc;
delete pUndoData;
}
return bSuccess;
diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx
index a531caf1cac2..86da282b3f8b 100644
--- a/sc/source/ui/inc/undobase.hxx
+++ b/sc/source/ui/inc/undobase.hxx
@@ -142,13 +142,13 @@ class ScMoveUndo: public ScSimpleUndo // with references
{
public:
ScMoveUndo( ScDocShell* pDocSh,
- ScDocument* pRefDoc, ScRefUndoData* pRefData,
+ ScDocumentUniquePtr pRefDoc, ScRefUndoData* pRefData,
ScMoveUndoMode eRefMode );
virtual ~ScMoveUndo() override;
protected:
std::unique_ptr<SdrUndoAction> pDrawUndo;
- std::unique_ptr<ScDocument> pRefUndoDoc;
+ ScDocumentUniquePtr pRefUndoDoc;
std::unique_ptr<ScRefUndoData> pRefUndoData;
ScMoveUndoMode eMode;
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index 4db6b1b58b1c..ed47fb2913ee 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -44,7 +44,7 @@ class ScUndoInsertCells: public ScMoveUndo
public:
ScUndoInsertCells( ScDocShell* pNewDocShell,
const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios,
- InsCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData,
+ InsCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, ScRefUndoData* pRefData,
bool bNewPartOfPaste );
virtual ~ScUndoInsertCells() override;
@@ -79,7 +79,7 @@ class ScUndoDeleteCells: public ScMoveUndo
public:
ScUndoDeleteCells( ScDocShell* pNewDocShell,
const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios,
- DelCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData );
+ DelCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, ScRefUndoData* pRefData );
virtual ~ScUndoDeleteCells() override;
virtual void Undo() override;
@@ -111,7 +111,7 @@ public:
ScUndoDeleteMulti( ScDocShell* pNewDocShell,
bool bNewRows, bool bNeedsRefresh, SCTAB nNewTab,
const std::vector<sc::ColRowSpan>& rSpans,
- ScDocument* pUndoDocument, ScRefUndoData* pRefData );
+ ScDocumentUniquePtr pUndoDocument, ScRefUndoData* pRefData );
virtual ~ScUndoDeleteMulti() override;
@@ -220,7 +220,7 @@ class ScUndoDragDrop: public ScMoveUndo
public:
ScUndoDragDrop( ScDocShell* pNewDocShell,
const ScRange& rRange, const ScAddress& aNewDestPos, bool bNewCut,
- ScDocument* pUndoDocument,
+ ScDocumentUniquePtr pUndoDocument,
bool bScenario );
virtual ~ScUndoDragDrop() override;
diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
index 621b94063d40..8471814c03bd 100644
--- a/sc/source/ui/inc/undotab.hxx
+++ b/sc/source/ui/inc/undotab.hxx
@@ -97,7 +97,7 @@ public:
ScUndoDeleteTab(
ScDocShell* pNewDocShell,
const std::vector<SCTAB> &theTabs, //SCTAB nNewTab,
- ScDocument* pUndoDocument,
+ ScDocumentUniquePtr pUndoDocument,
ScRefUndoData* pRefData );
virtual ~ScUndoDeleteTab() override;
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index e2c74dfd864a..7285d48af446 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -406,10 +406,10 @@ void ScMultiBlockUndo::ShowBlock()
}
}
-ScMoveUndo::ScMoveUndo( ScDocShell* pDocSh, ScDocument* pRefDoc, ScRefUndoData* pRefData,
+ScMoveUndo::ScMoveUndo( ScDocShell* pDocSh, ScDocumentUniquePtr pRefDoc, ScRefUndoData* pRefData,
ScMoveUndoMode eRefMode ) :
ScSimpleUndo( pDocSh ),
- pRefUndoDoc( pRefDoc ),
+ pRefUndoDoc( std::move(pRefDoc) ),
pRefUndoData( pRefData ),
eMode( eRefMode )
{
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index f50ad069579a..df97db382da3 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -69,9 +69,9 @@
ScUndoInsertCells::ScUndoInsertCells( ScDocShell* pNewDocShell,
const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios,
- InsCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData,
+ InsCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, ScRefUndoData* pRefData,
bool bNewPartOfPaste ) :
- ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ),
+ ScMoveUndo( pNewDocShell, std::move(pUndoDocument), pRefData, SC_UNDO_REFLAST ),
aEffRange( rRange ),
nCount( nNewCount ),
pTabs( pNewTabs ),
@@ -338,8 +338,8 @@ bool ScUndoInsertCells::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoDeleteCells::ScUndoDeleteCells( ScDocShell* pNewDocShell,
const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios,
- DelCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
- ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ),
+ DelCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, ScRefUndoData* pRefData ) :
+ ScMoveUndo( pNewDocShell, std::move(pUndoDocument), pRefData, SC_UNDO_REFLAST ),
aEffRange( rRange ),
nCount( nNewCount ),
pTabs( pNewTabs ),
@@ -623,8 +623,8 @@ ScUndoDeleteMulti::ScUndoDeleteMulti(
ScDocShell* pNewDocShell,
bool bNewRows, bool bNeedsRefresh, SCTAB nNewTab,
const std::vector<sc::ColRowSpan>& rSpans,
- ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
- ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ),
+ ScDocumentUniquePtr pUndoDocument, ScRefUndoData* pRefData ) :
+ ScMoveUndo( pNewDocShell, std::move(pUndoDocument), pRefData, SC_UNDO_REFLAST ),
mbRows(bNewRows),
mbRefresh(bNeedsRefresh),
nTab( nNewTab ),
@@ -1171,8 +1171,8 @@ bool ScUndoPaste::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoDragDrop::ScUndoDragDrop( ScDocShell* pNewDocShell,
const ScRange& rRange, const ScAddress& aNewDestPos, bool bNewCut,
- ScDocument* pUndoDocument, bool bScenario ) :
- ScMoveUndo( pNewDocShell, pUndoDocument, nullptr, SC_UNDO_REFLAST ),
+ ScDocumentUniquePtr pUndoDocument, bool bScenario ) :
+ ScMoveUndo( pNewDocShell, std::move(pUndoDocument), nullptr, SC_UNDO_REFLAST ),
mnPaintExtFlags( 0 ),
aSrcRange( rRange ),
bCut( bNewCut ),
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index d9de877c2f36..689eb309ceb1 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -247,8 +247,8 @@ bool ScUndoInsertTables::CanRepeat(SfxRepeatTarget& rTarget) const
}
ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell* pNewDocShell, const vector<SCTAB> &aTab,
- ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
- ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST )
+ ScDocumentUniquePtr pUndoDocument, ScRefUndoData* pRefData ) :
+ ScMoveUndo( pNewDocShell, std::move(pUndoDocument), pRefData, SC_UNDO_REFLAST )
{
theTabs.insert(theTabs.end(), aTab.begin(), aTab.end() );
SetChangeTrack();
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 1fd9ca6ab7f3..3f343b6d69e3 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2330,11 +2330,11 @@ bool ScViewFunc::DeleteTables(const vector<SCTAB> &TheTabs, bool bRecord )
--nNewTab;
bool bWasLinked = false;
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
ScRefUndoData* pUndoData = nullptr;
if (bRecord)
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
SCTAB nCount = rDoc.GetTableCount();
OUString aOldName;
@@ -2411,7 +2411,7 @@ bool ScViewFunc::DeleteTables(const vector<SCTAB> &TheTabs, bool bRecord )
{
pDocSh->GetUndoManager()->AddUndoAction(
new ScUndoDeleteTab( GetViewData().GetDocShell(), TheTabs,
- pUndoDoc, pUndoData ));
+ std::move(pUndoDoc), pUndoData ));
}
if (bDelDone)
@@ -2437,7 +2437,6 @@ bool ScViewFunc::DeleteTables(const vector<SCTAB> &TheTabs, bool bRecord )
}
else
{
- delete pUndoDoc;
delete pUndoData;
}
return bDelDone;
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 818ef89ab361..e433d96fd2ab 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1820,11 +1820,11 @@ void ScViewFunc::DeleteMulti( bool bRows )
WaitObject aWait( GetFrameWin() ); // important for TrackFormulas in UpdateReference
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
ScRefUndoData* pUndoData = nullptr;
if (bRecord)
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nTab, nTab, !bRows, bRows ); // row height
for (sc::ColRowSpan & rSpan : aSpans)
@@ -1877,7 +1877,7 @@ void ScViewFunc::DeleteMulti( bool bRows )
{
pDocSh->GetUndoManager()->AddUndoAction(
new ScUndoDeleteMulti(
- pDocSh, bRows, bNeedRefresh, nTab, aSpans, pUndoDoc, pUndoData));
+ pDocSh, bRows, bNeedRefresh, nTab, aSpans, std::move(pUndoDoc), pUndoData));
}
if (!AdjustRowHeight(0, MAXROW))
More information about the Libreoffice-commits
mailing list