[Libreoffice-commits] core.git: sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Aug 24 13:58:02 UTC 2018
sc/source/ui/docshell/arealink.cxx | 8 ++---
sc/source/ui/docshell/docfunc.cxx | 38 +++++++++++++--------------
sc/source/ui/docshell/tablink.cxx | 6 ++--
sc/source/ui/inc/undoblk.hxx | 36 ++++++++++++-------------
sc/source/ui/undo/undoblk3.cxx | 52 ++++++++++++++++++-------------------
sc/source/ui/unoobj/cellsuno.cxx | 13 ++-------
sc/source/ui/view/spelldialog.cxx | 4 +-
sc/source/ui/view/viewfun2.cxx | 8 ++---
sc/source/ui/view/viewfun4.cxx | 28 +++++++++----------
sc/source/ui/view/viewfunc.cxx | 14 ++++-----
10 files changed, 101 insertions(+), 106 deletions(-)
New commits:
commit 1cf7fcda337ad7e9e63234b750b7ab227f5ee6f3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Aug 24 14:16:09 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Aug 24 15:57:30 2018 +0200
loplugin:useuniqueptr pass ScDocument by unique_ptr in the undo code
Change-Id: I85188a4b3da4bc7f1a8a83870c8888be18bc1053
Reviewed-on: https://gerrit.libreoffice.org/59559
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index 5c3f22ec4c17..c23c9308429a 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -333,10 +333,10 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter,
// initialise Undo
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if ( bAddUndo && bUndo )
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
if ( bDoInsert )
{
if ( nNewEndX != nOldEndX || nNewEndY != nOldEndY ) // range changed?
@@ -411,7 +411,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter,
if ( bAddUndo && bUndo)
{
- ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScDocumentUniquePtr pRedoDoc(new ScDocument( SCDOCMODE_UNDO ));
pRedoDoc->InitUndo( &rDoc, nDestTab, nDestTab );
rDoc.CopyToDocument(aNewRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, *pRedoDoc);
@@ -421,7 +421,7 @@ bool ScAreaLink::Refresh( const OUString& rNewFile, const OUString& rNewFilter,
aSourceArea, aOldRange, GetRefreshDelay(),
aNewUrl, rNewFilter, aNewOpt,
rNewArea, aNewRange, nNewRefresh,
- pUndoDoc, pRedoDoc, bDoInsert ) );
+ std::move(pUndoDoc), std::move(pRedoDoc), bDoInsert ) );
}
// remember new settings
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index db989b28a661..d215f87ea15b 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -1339,7 +1339,7 @@ bool ScDocFunc::ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& r
if ( bRecord )
{
- ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScDocumentUniquePtr pUndoDoc( new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, aMultiRange.aStart.Tab(), aMultiRange.aEnd.Tab() );
rDoc.CopyToDocument(aMultiRange, InsertDeleteFlags::ATTRIB, bMulti, *pUndoDoc, &rMark);
@@ -1348,7 +1348,7 @@ bool ScDocFunc::ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& r
&rDocShell, rMark,
aMultiRange.aStart.Col(), aMultiRange.aStart.Row(), aMultiRange.aStart.Tab(),
aMultiRange.aEnd.Col(), aMultiRange.aEnd.Row(), aMultiRange.aEnd.Tab(),
- pUndoDoc, bMulti, &rPattern ) );
+ std::move(pUndoDoc), bMulti, &rPattern ) );
}
// While loading XML it is not necessary to ask HasAttrib. It needs too much time.
@@ -4106,10 +4106,10 @@ bool ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
bool bSize = pAutoFormat->findByIndex(nFormatNo)->GetIncludeWidthHeight();
SCTAB nTabCount = rDoc.GetTableCount();
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if ( bRecord )
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nStartTab, nStartTab, bSize, bSize );
ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
for (; itr != itrEnd && *itr < nTabCount; ++itr)
@@ -4165,7 +4165,7 @@ bool ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
if ( bRecord ) // only now is Draw-Undo available
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoAutoFormat( &rDocShell, rRange, pUndoDoc, aMark, bSize, nFormatNo ) );
+ new ScUndoAutoFormat( &rDocShell, rRange, std::move(pUndoDoc), aMark, bSize, nFormatNo ) );
}
aModificator.SetDocumentModified();
@@ -4299,14 +4299,14 @@ bool ScDocFunc::TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
if ( bRecord )
{
//! take selected sheets into account also when undoing
- ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nStartTab, nEndTab );
rDoc.CopyToDocument( rRange, InsertDeleteFlags::ALL & ~InsertDeleteFlags::NOTE, false, *pUndoDoc );
rDocShell.GetUndoManager()->AddUndoAction(
new ScUndoTabOp( &rDocShell,
nStartCol, nStartRow, nStartTab,
- nEndCol, nEndRow, nEndTab, pUndoDoc,
+ nEndCol, nEndRow, nEndTab, std::move(pUndoDoc),
rParam.aRefFormulaCell,
rParam.aRefFormulaEnd,
rParam.aRefRowCell,
@@ -4464,13 +4464,13 @@ bool ScDocFunc::FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
break;
}
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if ( bRecord )
{
SCTAB nTabCount = rDoc.GetTableCount();
SCTAB nDestStartTab = aDestArea.aStart.Tab();
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nDestStartTab, nDestStartTab );
ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
for (; itr != itrEnd && *itr < nTabCount; ++itr)
@@ -4500,7 +4500,7 @@ bool ScDocFunc::FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
if ( bRecord ) // only now is Draw-Undo available
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
+ new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, std::move(pUndoDoc), aMark,
eDir, FILL_SIMPLE, FILL_DAY, MAXDOUBLE, 1.0, 1e307) );
}
@@ -4580,13 +4580,13 @@ bool ScDocFunc::FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
break;
}
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if ( bRecord )
{
SCTAB nTabCount = rDoc.GetTableCount();
SCTAB nDestStartTab = aDestArea.aStart.Tab();
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nDestStartTab, nDestStartTab );
ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
for (; itr != itrEnd && *itr < nTabCount; ++itr)
@@ -4631,7 +4631,7 @@ bool ScDocFunc::FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
if ( bRecord ) // only now is Draw-Undo available
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
+ new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, std::move(pUndoDoc), aMark,
eDir, eCmd, eDateCmd, fStart, fStep, fMax) );
}
@@ -4732,13 +4732,13 @@ bool ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir e
WaitObject aWait( ScDocShell::GetActiveDialogParent() );
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if ( bRecord )
{
SCTAB nTabCount = rDoc.GetTableCount();
SCTAB nDestStartTab = aDestArea.aStart.Tab();
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nDestStartTab, nDestStartTab );
ScMarkData::iterator itr = aMark.begin(), itrEnd = aMark.end();
for (; itr != itrEnd && nTabCount; ++itr)
@@ -4770,7 +4770,7 @@ bool ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir e
if ( bRecord ) // only now is Draw-Undo available
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
+ new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, std::move(pUndoDoc), aMark,
eDir, eCmd, eDateCmd, MAXDOUBLE, fStep, fMax) );
}
@@ -4824,7 +4824,7 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
}
}
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
bool bNeedContentsUndo = false;
for (set<SCTAB>::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
{
@@ -4846,7 +4846,7 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
if (!pUndoDoc)
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo(&rDoc, nTab1, nTab2);
}
// note captions are collected by drawing undo
@@ -4884,7 +4884,7 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
{
std::unique_ptr<SdrUndoGroup> pDrawUndo = rDoc.GetDrawLayer() ? rDoc.GetDrawLayer()->GetCalcUndo() : nullptr;
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoMerge(&rDocShell, rOption, bNeedContentsUndo, pUndoDoc, pDrawUndo.release()) );
+ new ScUndoMerge(&rDocShell, rOption, bNeedContentsUndo, std::move(pUndoDoc), pDrawUndo.release()) );
}
aModificator.SetDocumentModified();
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index 816a69bbf8a1..4b1ebb5928ed 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -208,10 +208,10 @@ bool ScTableLink::Refresh(const OUString& rNewFile, const OUString& rNewFilter,
// Undo...
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
bool bFirst = true;
if (bAddUndo && bUndo)
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
// copy tables
@@ -384,7 +384,7 @@ bool ScTableLink::Refresh(const OUString& rNewFile, const OUString& rNewFilter,
if (bAddUndo && bUndo)
pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
- new ScUndoRefreshLink( pImpl->m_pDocSh, pUndoDoc ) );
+ new ScUndoRefreshLink( pImpl->m_pDocSh, std::move(pUndoDoc) ) );
// Paint (may be several tables)
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index f36842ce1cdc..4db6b1b58b1c 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -290,7 +290,7 @@ public:
const ScMarkData& rMark,
SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, bool bNewMulti, SCTAB nSrc,
+ ScDocumentUniquePtr pNewUndoDoc, bool bNewMulti, SCTAB nSrc,
InsertDeleteFlags nFlg, ScPasteFunc nFunc, bool bSkip, bool bLink );
virtual ~ScUndoFillTable() override;
@@ -326,7 +326,7 @@ public:
const ScMarkData& rMark,
SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, bool bNewMulti,
+ ScDocumentUniquePtr pNewUndoDoc, bool bNewMulti,
const ScPatternAttr* pNewApply,
const SvxBoxItem* pNewOuter = nullptr,
const SvxBoxInfoItem* pNewInner = nullptr,
@@ -346,7 +346,7 @@ private:
ScRange aRange;
ScRange aRangeCover;
std::unique_ptr<ScEditDataArray> mpDataArray;
- std::unique_ptr<ScDocument> pUndoDoc;
+ ScDocumentUniquePtr pUndoDoc;
bool bMulti;
ScPatternAttr* pApplyPattern;
SvxBoxItem* pLineOuter;
@@ -397,7 +397,7 @@ class ScUndoAutoFill: public ScBlockUndo
public:
ScUndoAutoFill( ScDocShell* pNewDocShell,
const ScRange& rRange, const ScRange& rSourceArea,
- ScDocument* pNewUndoDoc, const ScMarkData& rMark,
+ ScDocumentUniquePtr pNewUndoDoc, const ScMarkData& rMark,
FillDir eNewFillDir,
FillCmd eNewFillCmd, FillDateCmd eNewFillDateCmd,
double fNewStartValue, double fNewStepValue, double fNewMaxValue );
@@ -431,7 +431,7 @@ class ScUndoMerge: public ScSimpleUndo
{
public:
ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
- bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo);
+ bool bMergeContents, ScDocumentUniquePtr pUndoDoc, SdrUndoAction* pDrawUndo);
virtual ~ScUndoMerge() override;
virtual void Undo() override;
@@ -454,7 +454,7 @@ class ScUndoAutoFormat: public ScBlockUndo
{
public:
ScUndoAutoFormat( ScDocShell* pNewDocShell,
- const ScRange& rRange, ScDocument* pNewUndoDoc,
+ const ScRange& rRange, ScDocumentUniquePtr pNewUndoDoc,
const ScMarkData& rMark,
bool bNewSize, sal_uInt16 nNewFormatNo );
virtual ~ScUndoAutoFormat() override;
@@ -480,7 +480,7 @@ public:
ScUndoReplace( ScDocShell* pNewDocShell,
const ScMarkData& rMark,
SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
- const OUString& rNewUndoStr, ScDocument* pNewUndoDoc,
+ const OUString& rNewUndoStr, ScDocumentUniquePtr pNewUndoDoc,
const SvxSearchItem* pItem );
virtual ~ScUndoReplace() override;
@@ -495,7 +495,7 @@ private:
ScAddress aCursorPos;
ScMarkData aMarkData;
OUString aUndoStr; // Data at single selection
- std::unique_ptr<ScDocument> pUndoDoc; // Block mark and deleted data
+ ScDocumentUniquePtr pUndoDoc; // Block mark and deleted data
std::unique_ptr<SvxSearchItem> pSearchItem;
sal_uLong nStartChangeAction;
sal_uLong nEndChangeAction;
@@ -509,7 +509,7 @@ public:
ScUndoTabOp( ScDocShell* pNewDocShell,
SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc,
+ ScDocumentUniquePtr pNewUndoDoc,
const ScRefAddress& rFormulaCell,
const ScRefAddress& rFormulaEnd,
const ScRefAddress& rRowCell,
@@ -540,8 +540,8 @@ class ScUndoConversion : public ScSimpleUndo
public:
ScUndoConversion( ScDocShell* pNewDocShell, const ScMarkData& rMark,
- SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocument* pNewUndoDoc,
- SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocument* pNewRedoDoc,
+ SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocumentUniquePtr pNewUndoDoc,
+ SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocumentUniquePtr pNewRedoDoc,
const ScConversionParam& rConvParam );
virtual ~ScUndoConversion() override;
@@ -555,9 +555,9 @@ public:
private:
ScMarkData aMarkData;
ScAddress aCursorPos;
- std::unique_ptr<ScDocument> pUndoDoc; // Block mark and deleted data
+ ScDocumentUniquePtr pUndoDoc; // Block mark and deleted data
ScAddress aNewCursorPos;
- std::unique_ptr<ScDocument> pRedoDoc; // Block mark and new data
+ ScDocumentUniquePtr pRedoDoc; // Block mark and new data
sal_uLong nStartChangeAction;
sal_uLong nEndChangeAction;
ScConversionParam maConvParam; /// Conversion type and parameters.
@@ -571,7 +571,7 @@ class ScUndoRefConversion: public ScSimpleUndo
public:
ScUndoRefConversion( ScDocShell* pNewDocShell,
const ScRange& aMarkRange, const ScMarkData& rMark,
- ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, bool bNewMulti);
+ ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, bool bNewMulti);
virtual ~ScUndoRefConversion() override;
virtual void Undo() override;
@@ -583,8 +583,8 @@ public:
private:
ScMarkData aMarkData;
- std::unique_ptr<ScDocument> pUndoDoc;
- std::unique_ptr<ScDocument> pRedoDoc;
+ ScDocumentUniquePtr pUndoDoc;
+ ScDocumentUniquePtr pRedoDoc;
ScRange aRange;
bool bMulti;
sal_uLong nStartChangeAction;
@@ -712,7 +712,7 @@ class ScUndoRefreshLink: public ScSimpleUndo
{
public:
ScUndoRefreshLink(ScDocShell* pNewDocShell,
- ScDocument* pNewUndoDoc);
+ ScDocumentUniquePtr pNewUndoDoc);
virtual void Undo() override;
virtual void Redo() override;
@@ -816,7 +816,7 @@ public:
const OUString& rNewF, const OUString& rNewO,
const OUString& rNewA, const ScRange& rNewR,
sal_uLong nNewRD,
- ScDocument* pUndo, ScDocument* pRedo,
+ ScDocumentUniquePtr pUndo, ScDocumentUniquePtr pRedo,
bool bDoInsert);
virtual void Undo() override;
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 2d7ac8fe424e..d90b65195a90 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -213,12 +213,12 @@ ScUndoFillTable::ScUndoFillTable( ScDocShell* pNewDocShell,
const ScMarkData& rMark,
SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, bool bNewMulti, SCTAB nSrc,
+ ScDocumentUniquePtr pNewUndoDoc, bool bNewMulti, SCTAB nSrc,
InsertDeleteFlags nFlg, ScPasteFunc nFunc, bool bSkip, bool bLink )
: ScSimpleUndo( pNewDocShell ),
aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
aMarkData ( rMark ),
- pUndoDoc ( pNewUndoDoc ),
+ pUndoDoc ( std::move(pNewUndoDoc) ),
nFlags ( nFlg ),
nFunction ( nFunc ),
nSrcTab ( nSrc ),
@@ -345,7 +345,7 @@ ScUndoSelectionAttr::ScUndoSelectionAttr( ScDocShell* pNewDocShell,
const ScMarkData& rMark,
SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
- ScDocument* pNewUndoDoc, bool bNewMulti,
+ ScDocumentUniquePtr pNewUndoDoc, bool bNewMulti,
const ScPatternAttr* pNewApply,
const SvxBoxItem* pNewOuter, const SvxBoxInfoItem* pNewInner,
const ScRange* pRangeCover )
@@ -353,7 +353,7 @@ ScUndoSelectionAttr::ScUndoSelectionAttr( ScDocShell* pNewDocShell,
aMarkData ( rMark ),
aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
mpDataArray(new ScEditDataArray),
- pUndoDoc ( pNewUndoDoc ),
+ pUndoDoc ( std::move(pNewUndoDoc) ),
bMulti ( bNewMulti )
{
ScDocumentPool* pPool = pDocShell->GetDocument().GetPool();
@@ -485,13 +485,13 @@ bool ScUndoSelectionAttr::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoAutoFill::ScUndoAutoFill( ScDocShell* pNewDocShell,
const ScRange& rRange, const ScRange& rSourceArea,
- ScDocument* pNewUndoDoc, const ScMarkData& rMark,
+ ScDocumentUniquePtr pNewUndoDoc, const ScMarkData& rMark,
FillDir eNewFillDir, FillCmd eNewFillCmd, FillDateCmd eNewFillDateCmd,
double fNewStartValue, double fNewStepValue, double fNewMaxValue )
: ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ),
aSource ( rSourceArea ),
aMarkData ( rMark ),
- pUndoDoc ( pNewUndoDoc ),
+ pUndoDoc ( std::move(pNewUndoDoc) ),
eFillDir ( eNewFillDir ),
eFillCmd ( eNewFillCmd ),
eFillDateCmd ( eNewFillDateCmd ),
@@ -637,11 +637,11 @@ bool ScUndoAutoFill::CanRepeat(SfxRepeatTarget& rTarget) const
}
ScUndoMerge::ScUndoMerge(ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
- bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo)
+ bool bMergeContents, ScDocumentUniquePtr pUndoDoc, SdrUndoAction* pDrawUndo)
: ScSimpleUndo(pNewDocShell)
, maOption(rOption)
, mbMergeContents(bMergeContents)
- , mxUndoDoc(pUndoDoc)
+ , mxUndoDoc(std::move(pUndoDoc))
, mpDrawUndo(pDrawUndo)
{
}
@@ -769,10 +769,10 @@ bool ScUndoMerge::CanRepeat(SfxRepeatTarget& rTarget) const
}
ScUndoAutoFormat::ScUndoAutoFormat( ScDocShell* pNewDocShell,
- const ScRange& rRange, ScDocument* pNewUndoDoc,
+ const ScRange& rRange, ScDocumentUniquePtr pNewUndoDoc,
const ScMarkData& rMark, bool bNewSize, sal_uInt16 nNewFormatNo )
: ScBlockUndo( pNewDocShell, rRange, bNewSize ? SC_UNDO_MANUALHEIGHT : SC_UNDO_AUTOHEIGHT ),
- pUndoDoc ( pNewUndoDoc ),
+ pUndoDoc ( std::move(pNewUndoDoc) ),
aMarkData ( rMark ),
bSize ( bNewSize ),
nFormatNo ( nNewFormatNo )
@@ -920,13 +920,13 @@ bool ScUndoAutoFormat::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoReplace::ScUndoReplace( ScDocShell* pNewDocShell, const ScMarkData& rMark,
SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
- const OUString& rNewUndoStr, ScDocument* pNewUndoDoc,
+ const OUString& rNewUndoStr, ScDocumentUniquePtr pNewUndoDoc,
const SvxSearchItem* pItem )
: ScSimpleUndo( pNewDocShell ),
aCursorPos ( nCurX, nCurY, nCurZ ),
aMarkData ( rMark ),
aUndoStr ( rNewUndoStr ),
- pUndoDoc ( pNewUndoDoc )
+ pUndoDoc ( std::move(pNewUndoDoc) )
{
pSearchItem.reset( new SvxSearchItem( *pItem ) );
SetChangeTrack();
@@ -1100,7 +1100,7 @@ bool ScUndoReplace::CanRepeat(SfxRepeatTarget& rTarget) const
// multi-operation (only simple blocks)
ScUndoTabOp::ScUndoTabOp( ScDocShell* pNewDocShell,
SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
- SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, ScDocument* pNewUndoDoc,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, ScDocumentUniquePtr pNewUndoDoc,
const ScRefAddress& rFormulaCell,
const ScRefAddress& rFormulaEnd,
const ScRefAddress& rRowCell,
@@ -1108,7 +1108,7 @@ ScUndoTabOp::ScUndoTabOp( ScDocShell* pNewDocShell,
ScTabOpParam::Mode eMode )
: ScSimpleUndo( pNewDocShell ),
aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
- pUndoDoc ( pNewUndoDoc ),
+ pUndoDoc ( std::move(pNewUndoDoc) ),
theFormulaCell ( rFormulaCell ),
theFormulaEnd ( rFormulaEnd ),
theRowCell ( rRowCell ),
@@ -1173,15 +1173,15 @@ bool ScUndoTabOp::CanRepeat(SfxRepeatTarget& /* rTarget */) const
ScUndoConversion::ScUndoConversion(
ScDocShell* pNewDocShell, const ScMarkData& rMark,
- SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocument* pNewUndoDoc,
- SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocument* pNewRedoDoc,
+ SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocumentUniquePtr pNewUndoDoc,
+ SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocumentUniquePtr pNewRedoDoc,
const ScConversionParam& rConvParam ) :
ScSimpleUndo( pNewDocShell ),
aMarkData( rMark ),
aCursorPos( nCurX, nCurY, nCurZ ),
- pUndoDoc( pNewUndoDoc ),
+ pUndoDoc( std::move(pNewUndoDoc) ),
aNewCursorPos( nNewX, nNewY, nNewZ ),
- pRedoDoc( pNewRedoDoc ),
+ pRedoDoc( std::move(pNewRedoDoc) ),
maConvParam( rConvParam )
{
SetChangeTrack();
@@ -1280,11 +1280,11 @@ bool ScUndoConversion::CanRepeat(SfxRepeatTarget& rTarget) const
ScUndoRefConversion::ScUndoRefConversion( ScDocShell* pNewDocShell,
const ScRange& aMarkRange, const ScMarkData& rMark,
- ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, bool bNewMulti) :
+ ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, bool bNewMulti) :
ScSimpleUndo( pNewDocShell ),
aMarkData ( rMark ),
-pUndoDoc ( pNewUndoDoc ),
-pRedoDoc ( pNewRedoDoc ),
+pUndoDoc ( std::move(pNewUndoDoc) ),
+pRedoDoc ( std::move(pNewRedoDoc) ),
aRange ( aMarkRange ),
bMulti ( bNewMulti )
{
@@ -1364,9 +1364,9 @@ bool ScUndoRefConversion::CanRepeat(SfxRepeatTarget& rTarget) const
}
ScUndoRefreshLink::ScUndoRefreshLink(ScDocShell* pNewDocShell,
- ScDocument* pNewUndoDoc)
+ ScDocumentUniquePtr pNewUndoDoc)
: ScSimpleUndo(pNewDocShell)
- , xUndoDoc(pNewUndoDoc)
+ , xUndoDoc(std::move(pNewUndoDoc))
{
}
@@ -1612,7 +1612,7 @@ ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell,
const OUString& rOldA, const ScRange& rOldR, sal_uLong nOldRD,
const OUString& rNewD, const OUString& rNewF, const OUString& rNewO,
const OUString& rNewA, const ScRange& rNewR, sal_uLong nNewRD,
- ScDocument* pUndo, ScDocument* pRedo, bool bDoInsert )
+ ScDocumentUniquePtr pUndo, ScDocumentUniquePtr pRedo, bool bDoInsert )
: ScSimpleUndo( pShell ),
aOldDoc ( rOldD ),
aOldFlt ( rOldF ),
@@ -1624,8 +1624,8 @@ ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell,
aNewOpt ( rNewO ),
aNewArea ( rNewA ),
aNewRange ( rNewR ),
- xUndoDoc ( pUndo ),
- xRedoDoc ( pRedo ),
+ xUndoDoc ( std::move(pUndo) ),
+ xRedoDoc ( std::move(pRedo) ),
nOldRefresh ( nOldRD ),
nNewRefresh ( nNewRD ),
bWithInsert ( bDoInsert )
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 8346be3d8c88..645c6bc4aefd 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -4032,10 +4032,10 @@ sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSea
SCROW nRow = 0;
OUString aUndoStr;
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if (bUndo)
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nTab, nTab );
}
itr = aMark.begin();
@@ -4051,7 +4051,7 @@ sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSea
{
ScRangeList aMatchedRanges;
bFound = rDoc.SearchAndReplace(
- *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc );
+ *pSearchItem, nCol, nRow, nTab, aMark, aMatchedRanges, aUndoStr, pUndoDoc.get() );
}
if (bFound)
{
@@ -4059,16 +4059,11 @@ sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSea
pDocShell->GetUndoManager()->AddUndoAction(
new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
- aUndoStr, pUndoDoc, pSearchItem ) );
+ aUndoStr, std::move(pUndoDoc), pSearchItem ) );
pDocShell->PostPaintGridAll();
pDocShell->SetDocumentModified();
}
- else
- {
- delete pUndoDoc;
- // nReplaced stays zero
- }
}
}
}
diff --git a/sc/source/ui/view/spelldialog.cxx b/sc/source/ui/view/spelldialog.cxx
index 9b498b6b820c..0678f8aea6b1 100644
--- a/sc/source/ui/view/spelldialog.cxx
+++ b/sc/source/ui/view/spelldialog.cxx
@@ -126,8 +126,8 @@ void ScSpellDialogChildWindow::Reset()
SCROW nNewRow = mpViewData->GetCurY();
mpDocShell->GetUndoManager()->AddUndoAction( new ScUndoConversion(
mpDocShell, mpViewData->GetMarkData(),
- nOldCol, nOldRow, nTab, mxUndoDoc.release(),
- nNewCol, nNewRow, nTab, mxRedoDoc.release(),
+ nOldCol, nOldRow, nTab, std::move(mxUndoDoc),
+ nNewCol, nNewRow, nTab, std::move(mxRedoDoc),
ScConversionParam( SC_CONVERSION_SPELLCHECK ) ) );
sc::SetFormulaDirtyContext aCxt;
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index dfa2728d2486..1fd9ca6ab7f3 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -1558,11 +1558,11 @@ void ScViewFunc::FillTab( InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool
else
aMarkRange = ScRange( GetViewData().GetCurX(), GetViewData().GetCurY(), nTab );
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if (bUndo)
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nTab, nTab );
ScMarkData::iterator itr = rMark.begin(), itrEnd = rMark.end();
@@ -1592,7 +1592,7 @@ void ScViewFunc::FillTab( InsertDeleteFlags nFlags, ScPasteFunc nFunction, bool
new ScUndoFillTable( pDocSh, rMark,
aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nTab,
aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), nTab,
- pUndoDoc, bMulti, nTab, nFlags, nFunction, bSkipEmpty, bAsLink ) );
+ std::move(pUndoDoc), bMulti, nTab, nFlags, nFunction, bSkipEmpty, bAsLink ) );
}
pDocSh->PostPaintGridAll();
@@ -1841,7 +1841,7 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
GetViewData().GetDocShell()->GetUndoManager()->AddUndoAction(
new ScUndoReplace( GetViewData().GetDocShell(), *pUndoMark,
nCol, nRow, nTab,
- aUndoStr, pUndoDoc.release(), pSearchItem ) );
+ aUndoStr, std::move(pUndoDoc), pSearchItem ) );
}
if (nCommand == SvxSearchCmd::FIND_ALL || nCommand == SvxSearchCmd::REPLACE_ALL)
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 5bc8f11db602..dbcf8352622e 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -209,10 +209,10 @@ void ScViewFunc::DoRefConversion()
ScDocShell* pDocSh = GetViewData().GetDocShell();
bool bOk = false;
- ScDocument* pUndoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
if (bRecord)
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset( new ScDocument( SCDOCMODE_UNDO ) );
SCTAB nTab = aMarkRange.aStart.Tab();
pUndoDoc->InitUndo( pDoc, nTab, nTab );
@@ -282,7 +282,7 @@ void ScViewFunc::DoRefConversion()
}
if (bRecord)
{
- ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScDocumentUniquePtr pRedoDoc(new ScDocument( SCDOCMODE_UNDO ));
SCTAB nTab = aMarkRange.aStart.Tab();
pRedoDoc->InitUndo( pDoc, nTab, nTab );
@@ -300,7 +300,7 @@ void ScViewFunc::DoRefConversion()
pDocSh->GetUndoManager()->AddUndoAction(
new ScUndoRefConversion( pDocSh,
- aMarkRange, rMark, pUndoDoc, pRedoDoc, bMulti) );
+ aMarkRange, rMark, std::move(pUndoDoc), std::move(pRedoDoc), bMulti) );
}
pDocSh->PostPaint( aMarkRange, PaintPartFlags::Grid );
@@ -485,13 +485,13 @@ void ScViewFunc::DoSheetConversion( const ScConversionParam& rConvParam )
}
}
- ScDocument* pUndoDoc = nullptr;
- ScDocument* pRedoDoc = nullptr;
+ ScDocumentUniquePtr pUndoDoc;
+ ScDocumentUniquePtr pRedoDoc;
if (bRecord)
{
- pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc.reset( new ScDocument( SCDOCMODE_UNDO ) );
pUndoDoc->InitUndo( &rDoc, nTab, nTab );
- pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc.reset( new ScDocument( SCDOCMODE_UNDO ) );
pRedoDoc->InitUndo( &rDoc, nTab, nTab );
if ( rMark.GetSelectCount() > 1 )
@@ -518,12 +518,12 @@ void ScViewFunc::DoSheetConversion( const ScConversionParam& rConvParam )
{
case SC_CONVERSION_SPELLCHECK:
pEngine.reset(new ScSpellingEngine(
- rDoc.GetEnginePool(), rViewData, pUndoDoc, pRedoDoc, LinguMgr::GetSpellChecker() ));
+ rDoc.GetEnginePool(), rViewData, pUndoDoc.get(), pRedoDoc.get(), LinguMgr::GetSpellChecker() ));
break;
case SC_CONVERSION_HANGULHANJA:
case SC_CONVERSION_CHINESE_TRANSL:
pEngine.reset(new ScTextConversionEngine(
- rDoc.GetEnginePool(), rViewData, rConvParam, pUndoDoc, pRedoDoc ));
+ rDoc.GetEnginePool(), rViewData, rConvParam, pUndoDoc.get(), pRedoDoc.get() ));
break;
default:
OSL_FAIL( "ScViewFunc::DoSheetConversion - unknown conversion type" );
@@ -557,8 +557,8 @@ void ScViewFunc::DoSheetConversion( const ScConversionParam& rConvParam )
rViewData.GetDocShell()->GetUndoManager()->AddUndoAction(
new ScUndoConversion(
pDocSh, rMark,
- nCol, nRow, nTab, pUndoDoc,
- nNewCol, nNewRow, nTab, pRedoDoc, rConvParam ) );
+ nCol, nRow, nTab, std::move(pUndoDoc),
+ nNewCol, nNewRow, nTab, std::move(pRedoDoc), rConvParam ) );
}
sc::SetFormulaDirtyContext aCxt;
@@ -568,8 +568,8 @@ void ScViewFunc::DoSheetConversion( const ScConversionParam& rConvParam )
}
else
{
- delete pUndoDoc;
- delete pRedoDoc;
+ pUndoDoc.reset();
+ pRedoDoc.reset();
}
// *** final cleanup *** --------------------------------------------------
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index a1baca741e0e..818ef89ab361 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -1063,7 +1063,7 @@ void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem
if (bRecord)
{
- ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO ));
SCTAB nStartTab = aMarkRange.aStart.Tab();
SCTAB nTabCount = pDoc->GetTableCount();
bool bCopyOnlyMarked = false;
@@ -1082,10 +1082,10 @@ void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem
pDocSh->GetUndoManager()->AddUndoAction(
new ScUndoSelectionAttr(
- pDocSh, aFuncMark,
- aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), aMarkRange.aStart.Tab(),
- aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), aMarkRange.aEnd.Tab(),
- pUndoDoc, bCopyOnlyMarked, &rAttr, &rNewOuter, pNewInner, &aMarkRangeWithEnvelope ) );
+ pDocSh, aFuncMark,
+ aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), aMarkRange.aStart.Tab(),
+ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), aMarkRange.aEnd.Tab(),
+ std::move(pUndoDoc), bCopyOnlyMarked, &rAttr, &rNewOuter, pNewInner, &aMarkRangeWithEnvelope ) );
}
sal_uInt16 nExt = SC_PF_TESTMERGE;
@@ -1180,7 +1180,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor
aCopyRange.aStart.SetTab(0);
aCopyRange.aEnd.SetTab(nTabCount-1);
- ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScDocumentUniquePtr pUndoDoc(new ScDocument( SCDOCMODE_UNDO ));
pUndoDoc->InitUndo( &rDoc, nStartTab, nStartTab );
itr = aFuncMark.begin();
for (; itr != itrEnd; ++itr)
@@ -1192,7 +1192,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor
pUndoAttr = new ScUndoSelectionAttr(
pDocSh, aFuncMark, nStartCol, nStartRow, nStartTab,
- nEndCol, nEndRow, nEndTab, pUndoDoc, bMulti, &rAttr );
+ nEndCol, nEndRow, nEndTab, std::move(pUndoDoc), bMulti, &rAttr );
pDocSh->GetUndoManager()->AddUndoAction(pUndoAttr);
pEditDataArray = pUndoAttr->GetDataArray();
}
More information about the Libreoffice-commits
mailing list