[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source
Noel Grandin
noel.grandin at collabora.co.uk
Tue Mar 27 06:22:47 UTC 2018
sc/inc/drwlayer.hxx | 4 +-
sc/inc/prnsave.hxx | 8 ++---
sc/source/core/data/drwlayer.cxx | 12 +++-----
sc/source/core/tool/prnsave.cxx | 16 ++++-------
sc/source/ui/docshell/docfunc.cxx | 52 +++++++++++++-------------------------
sc/source/ui/drawfunc/futext3.cxx | 8 ++---
sc/source/ui/inc/undoolk.hxx | 2 -
sc/source/ui/undo/undobase.cxx | 6 ++--
sc/source/ui/undo/undoblk2.cxx | 2 -
sc/source/ui/undo/undoblk3.cxx | 2 -
sc/source/ui/undo/undodat.cxx | 2 -
sc/source/ui/undo/undoolk.cxx | 2 -
sc/source/ui/undo/undotab.cxx | 10 +++----
sc/source/ui/view/drawview.cxx | 2 -
14 files changed, 54 insertions(+), 74 deletions(-)
New commits:
commit 50af4bf5c67eaac39d02cfe20584906eec058235
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Mar 23 14:23:42 2018 +0200
loplugin:useuniqueptr in ScDrawLayer
Change-Id: I684e391b738be23ba7769b7c5b0a354f43a9226e
Reviewed-on: https://gerrit.libreoffice.org/51903
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/drwlayer.hxx b/sc/inc/drwlayer.hxx
index 5f695160cc42..3d9e2b72b685 100644
--- a/sc/inc/drwlayer.hxx
+++ b/sc/inc/drwlayer.hxx
@@ -96,7 +96,7 @@ class SC_DLLPUBLIC ScDrawLayer : public FmFormModel
private:
OUString aName;
ScDocument* pDoc;
- SdrUndoGroup* pUndoGroup;
+ std::unique_ptr<SdrUndoGroup> pUndoGroup;
bool bRecording;
bool bAdjustEnabled;
bool bHyphenatorSet;
@@ -135,7 +135,7 @@ public:
void EnableAdjust( bool bSet ) { bAdjustEnabled = bSet; }
void BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager);
- SdrUndoGroup* GetCalcUndo();
+ std::unique_ptr<SdrUndoGroup> GetCalcUndo();
bool IsRecording() const { return bRecording; }
void AddCalcUndo( SdrUndoAction* pUndo );
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 6a476c4d535e..3a765e8965bd 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -248,7 +248,6 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const OUString& rName ) :
true ), // bUseExtColorTable (is set below)
aName( rName ),
pDoc( pDocument ),
- pUndoGroup( nullptr ),
bRecording( false ),
bAdjustEnabled( true ),
bHyphenatorSet( false )
@@ -341,7 +340,7 @@ ScDrawLayer::~ScDrawLayer()
ClearModel(true);
- delete pUndoGroup;
+ pUndoGroup.reset();
if( !--nInst )
{
delete pF3d;
@@ -1205,7 +1204,7 @@ void ScDrawLayer::AddCalcUndo( SdrUndoAction* pUndo )
if (bRecording)
{
if (!pUndoGroup)
- pUndoGroup = new SdrUndoGroup(*this);
+ pUndoGroup.reset(new SdrUndoGroup(*this));
pUndoGroup->AddAction( pUndo );
}
@@ -1216,14 +1215,13 @@ void ScDrawLayer::AddCalcUndo( SdrUndoAction* pUndo )
void ScDrawLayer::BeginCalcUndo(bool bDisableTextEditUsesCommonUndoManager)
{
SetDisableTextEditUsesCommonUndoManager(bDisableTextEditUsesCommonUndoManager);
- DELETEZ(pUndoGroup);
+ pUndoGroup.reset();
bRecording = true;
}
-SdrUndoGroup* ScDrawLayer::GetCalcUndo()
+std::unique_ptr<SdrUndoGroup> ScDrawLayer::GetCalcUndo()
{
- SdrUndoGroup* pRet = pUndoGroup;
- pUndoGroup = nullptr;
+ std::unique_ptr<SdrUndoGroup> pRet = std::move(pUndoGroup);
bRecording = false;
SetDisableTextEditUsesCommonUndoManager(false);
return pRet;
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 80c99cef7f40..55913db5f4c9 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -179,7 +179,7 @@ bool ScDocFunc::DetectiveAddPred(const ScAddress& rPos)
if (bUndo)
pModel->BeginCalcUndo(false);
bool bDone = ScDetectiveFunc( &rDoc,nTab ).ShowPred( nCol, nRow );
- SdrUndoGroup* pUndo = nullptr;
+ std::unique_ptr<SdrUndoGroup> pUndo;
if (bUndo)
pUndo = pModel->GetCalcUndo();
if (bDone)
@@ -189,15 +189,13 @@ bool ScDocFunc::DetectiveAddPred(const ScAddress& rPos)
if (bUndo)
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
}
aModificator.SetDocumentModified();
SfxBindings* pBindings = rDocShell.GetViewBindings();
if (pBindings)
pBindings->Invalidate( SID_DETECTIVE_REFRESH );
}
- else
- delete pUndo;
return bDone;
}
@@ -220,7 +218,7 @@ bool ScDocFunc::DetectiveDelPred(const ScAddress& rPos)
if (bUndo)
pModel->BeginCalcUndo(false);
bool bDone = ScDetectiveFunc( &rDoc,nTab ).DeletePred( nCol, nRow );
- SdrUndoGroup* pUndo = nullptr;
+ std::unique_ptr<SdrUndoGroup> pUndo;
if (bUndo)
pUndo = pModel->GetCalcUndo();
if (bDone)
@@ -230,15 +228,13 @@ bool ScDocFunc::DetectiveDelPred(const ScAddress& rPos)
if (bUndo)
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
}
aModificator.SetDocumentModified();
SfxBindings* pBindings = rDocShell.GetViewBindings();
if (pBindings)
pBindings->Invalidate( SID_DETECTIVE_REFRESH );
}
- else
- delete pUndo;
return bDone;
}
@@ -259,7 +255,7 @@ bool ScDocFunc::DetectiveAddSucc(const ScAddress& rPos)
if (bUndo)
pModel->BeginCalcUndo(false);
bool bDone = ScDetectiveFunc( &rDoc,nTab ).ShowSucc( nCol, nRow );
- SdrUndoGroup* pUndo = nullptr;
+ std::unique_ptr<SdrUndoGroup> pUndo;
if (bUndo)
pUndo = pModel->GetCalcUndo();
if (bDone)
@@ -269,15 +265,13 @@ bool ScDocFunc::DetectiveAddSucc(const ScAddress& rPos)
if (bUndo)
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
}
aModificator.SetDocumentModified();
SfxBindings* pBindings = rDocShell.GetViewBindings();
if (pBindings)
pBindings->Invalidate( SID_DETECTIVE_REFRESH );
}
- else
- delete pUndo;
return bDone;
}
@@ -300,7 +294,7 @@ bool ScDocFunc::DetectiveDelSucc(const ScAddress& rPos)
if (bUndo)
pModel->BeginCalcUndo(false);
bool bDone = ScDetectiveFunc( &rDoc,nTab ).DeleteSucc( nCol, nRow );
- SdrUndoGroup* pUndo = nullptr;
+ std::unique_ptr<SdrUndoGroup> pUndo;
if (bUndo)
pUndo = pModel->GetCalcUndo();
if (bDone)
@@ -310,15 +304,13 @@ bool ScDocFunc::DetectiveDelSucc(const ScAddress& rPos)
if (bUndo)
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
}
aModificator.SetDocumentModified();
SfxBindings* pBindings = rDocShell.GetViewBindings();
if (pBindings)
pBindings->Invalidate( SID_DETECTIVE_REFRESH );
}
- else
- delete pUndo;
return bDone;
}
@@ -339,7 +331,7 @@ bool ScDocFunc::DetectiveAddError(const ScAddress& rPos)
if (bUndo)
pModel->BeginCalcUndo(false);
bool bDone = ScDetectiveFunc( &rDoc,nTab ).ShowError( nCol, nRow );
- SdrUndoGroup* pUndo = nullptr;
+ std::unique_ptr<SdrUndoGroup> pUndo;
if (bUndo)
pUndo = pModel->GetCalcUndo();
if (bDone)
@@ -349,15 +341,13 @@ bool ScDocFunc::DetectiveAddError(const ScAddress& rPos)
if (bUndo)
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ new ScUndoDetective( &rDocShell, pUndo.release(), &aOperation ) );
}
aModificator.SetDocumentModified();
SfxBindings* pBindings = rDocShell.GetViewBindings();
if (pBindings)
pBindings->Invalidate( SID_DETECTIVE_REFRESH );
}
- else
- delete pUndo;
return bDone;
}
@@ -379,7 +369,7 @@ bool ScDocFunc::DetectiveMarkInvalid(SCTAB nTab)
pModel->BeginCalcUndo(false);
bool bOverflow;
bool bDone = ScDetectiveFunc( &rDoc,nTab ).MarkInvalid( bOverflow );
- SdrUndoGroup* pUndo = nullptr;
+ std::unique_ptr<SdrUndoGroup> pUndo;
if (bUndo)
pUndo = pModel->GetCalcUndo();
if (pWaitWin)
@@ -389,7 +379,7 @@ bool ScDocFunc::DetectiveMarkInvalid(SCTAB nTab)
if (pUndo && bUndo)
{
pUndo->SetComment( ScGlobal::GetRscString( STR_UNDO_DETINVALID ) );
- rDocShell.GetUndoManager()->AddUndoAction( pUndo );
+ rDocShell.GetUndoManager()->AddUndoAction( pUndo.release() );
}
aModificator.SetDocumentModified();
if ( bOverflow )
@@ -400,8 +390,6 @@ bool ScDocFunc::DetectiveMarkInvalid(SCTAB nTab)
xInfoBox->run();
}
}
- else
- delete pUndo;
return bDone;
}
@@ -420,7 +408,7 @@ bool ScDocFunc::DetectiveDelAll(SCTAB nTab)
if (bUndo)
pModel->BeginCalcUndo(false);
bool bDone = ScDetectiveFunc( &rDoc,nTab ).DeleteAll( ScDetectiveDelete::Detective );
- SdrUndoGroup* pUndo = nullptr;
+ std::unique_ptr<SdrUndoGroup> pUndo;
if (bUndo)
pUndo = pModel->GetCalcUndo();
if (bDone)
@@ -435,15 +423,13 @@ bool ScDocFunc::DetectiveDelAll(SCTAB nTab)
if (bUndo)
{
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDetective( &rDocShell, pUndo, nullptr, pUndoList ) );
+ new ScUndoDetective( &rDocShell, pUndo.release(), nullptr, pUndoList ) );
}
aModificator.SetDocumentModified();
SfxBindings* pBindings = rDocShell.GetViewBindings();
if (pBindings)
pBindings->Invalidate( SID_DETECTIVE_REFRESH );
}
- else
- delete pUndo;
return bDone;
}
@@ -502,13 +488,13 @@ bool ScDocFunc::DetectiveRefresh( bool bAutomatic )
if (bUndo)
{
- SdrUndoGroup* pUndo = pModel->GetCalcUndo();
+ std::unique_ptr<SdrUndoGroup> pUndo = pModel->GetCalcUndo();
if (pUndo)
{
pUndo->SetComment( ScGlobal::GetRscString( STR_UNDO_DETREFRESH ) );
// associate with the last action
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoDraw( pUndo, &rDocShell ),
+ new ScUndoDraw( pUndo.release(), &rDocShell ),
bAutomatic );
}
}
@@ -1297,7 +1283,7 @@ void ScDocFunc::ReplaceNote( const ScAddress& rPos, const OUString& rNoteText, c
// create the undo action
if( pUndoMgr && (aOldData.mxCaption || aNewData.mxCaption) )
- pUndoMgr->AddUndoAction( new ScUndoReplaceNote( rDocShell, rPos, aOldData, aNewData, pDrawLayer->GetCalcUndo() ) );
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( rDocShell, rPos, aOldData, aNewData, pDrawLayer->GetCalcUndo().release() ) );
// repaint cell (to make note marker visible)
rDocShell.PostPaintCell( rPos );
@@ -4894,9 +4880,9 @@ bool ScDocFunc::MergeCells( const ScCellMergeOption& rOption, bool bContents, bo
if (pUndoDoc)
{
- SdrUndoGroup* pDrawUndo = rDoc.GetDrawLayer() ? rDoc.GetDrawLayer()->GetCalcUndo() : nullptr;
+ std::unique_ptr<SdrUndoGroup> pDrawUndo = rDoc.GetDrawLayer() ? rDoc.GetDrawLayer()->GetCalcUndo() : nullptr;
rDocShell.GetUndoManager()->AddUndoAction(
- new ScUndoMerge(&rDocShell, rOption, bNeedContentsUndo, pUndoDoc, pDrawUndo) );
+ new ScUndoMerge(&rDocShell, rOption, bNeedContentsUndo, pUndoDoc, pDrawUndo.release()) );
}
aModificator.SetDocumentModified();
diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx
index 3e0dff9d1cc7..f6608432422d 100644
--- a/sc/source/ui/drawfunc/futext3.cxx
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -77,7 +77,7 @@ void FuText::StopEditMode()
{
/* Put all undo actions already collected (e.g. create caption object)
and all following undo actions (text changed) together into a ListAction. */
- SdrUndoGroup* pCalcUndo = pDrawLayer->GetCalcUndo();
+ std::unique_ptr<SdrUndoGroup> pCalcUndo = pDrawLayer->GetCalcUndo();
if(pCalcUndo)
{
@@ -91,9 +91,9 @@ void FuText::StopEditMode()
// create a "insert note" undo action if needed
if( bNewNote )
- pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, pNote->GetNoteData(), true, pCalcUndo ) );
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, pNote->GetNoteData(), true, pCalcUndo.release() ) );
else
- pUndoMgr->AddUndoAction( pCalcUndo );
+ pUndoMgr->AddUndoAction( pCalcUndo.release() );
}
}
@@ -142,7 +142,7 @@ void FuText::StopEditMode()
// delete note from document (removes caption, but does not delete it)
rDoc.ReleaseNote(aNotePos);
// create undo action for removed note
- pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo().release() ) );
}
else
{
diff --git a/sc/source/ui/inc/undoolk.hxx b/sc/source/ui/inc/undoolk.hxx
index 4474cf3f4a64..c9c80b23fa7e 100644
--- a/sc/source/ui/inc/undoolk.hxx
+++ b/sc/source/ui/inc/undoolk.hxx
@@ -23,7 +23,7 @@
class SdrUndoAction;
class ScDocument;
-SdrUndoAction* GetSdrUndoAction ( ScDocument* pDoc );
+std::unique_ptr<SdrUndoAction> GetSdrUndoAction( ScDocument* pDoc );
void DoSdrUndoAction ( SdrUndoAction* pUndoAction, ScDocument* pDoc );
void RedoSdrUndoAction ( SdrUndoAction* pUndoAction );
void DeleteSdrUndoAction ( SdrUndoAction* pUndoAction );
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index d88d29d71b53..abaaa8a88ae7 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -245,7 +245,7 @@ ScBlockUndo::ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
aBlockRange( rRange ),
eMode( eBlockMode )
{
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
}
ScBlockUndo::~ScBlockUndo()
@@ -346,7 +346,7 @@ ScMultiBlockUndo::ScMultiBlockUndo(
ScSimpleUndo(pDocSh),
maBlockRanges(rRanges)
{
- mpDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ mpDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
}
ScMultiBlockUndo::~ScMultiBlockUndo()
@@ -416,7 +416,7 @@ ScMoveUndo::ScMoveUndo( ScDocShell* pDocSh, ScDocument* pRefDoc, ScRefUndoData*
ScDocument& rDoc = pDocShell->GetDocument();
if (pRefUndoData)
pRefUndoData->DeleteUnchanged(&rDoc);
- pDrawUndo = GetSdrUndoAction( &rDoc );
+ pDrawUndo = GetSdrUndoAction( &rDoc ).release();
}
ScMoveUndo::~ScMoveUndo()
diff --git a/sc/source/ui/undo/undoblk2.cxx b/sc/source/ui/undo/undoblk2.cxx
index d8baab68c6af..3b1c99a7d66e 100644
--- a/sc/source/ui/undo/undoblk2.cxx
+++ b/sc/source/ui/undo/undoblk2.cxx
@@ -54,7 +54,7 @@ ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
eMode( eNewMode ),
pDrawUndo( nullptr )
{
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
}
ScUndoWidthOrHeight::~ScUndoWidthOrHeight()
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index 8e6dd0f50358..99973bd4d7e7 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -75,7 +75,7 @@ ScUndoDeleteContents::ScUndoDeleteContents(
bMulti ( bNewMulti ) // unnecessary
{
if (bObjects)
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
if ( !(aMarkData.IsMarked() || aMarkData.IsMultiMarked()) ) // if no cell is selected:
aMarkData.SetMarkArea( aRange ); // select cell under cursor
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index afaed1811b1e..f7ee7e4779b7 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -721,7 +721,7 @@ ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQuery
aAdvSource = *pAdvSrc;
}
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
}
ScUndoQuery::~ScUndoQuery()
diff --git a/sc/source/ui/undo/undoolk.cxx b/sc/source/ui/undo/undoolk.cxx
index 060aac26c00b..6a8632fad499 100644
--- a/sc/source/ui/undo/undoolk.cxx
+++ b/sc/source/ui/undo/undoolk.cxx
@@ -23,7 +23,7 @@
#include <drwlayer.hxx>
#include <undoolk.hxx>
-SdrUndoAction* GetSdrUndoAction( ScDocument* pDoc )
+std::unique_ptr<SdrUndoAction> GetSdrUndoAction( ScDocument* pDoc )
{
ScDrawLayer* pLayer = pDoc->GetDrawLayer();
if (pLayer)
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
index 290457ce4f87..d99555e6a277 100644
--- a/sc/source/ui/undo/undotab.cxx
+++ b/sc/source/ui/undo/undotab.cxx
@@ -67,7 +67,7 @@ ScUndoInsertTab::ScUndoInsertTab( ScDocShell* pNewDocShell,
nTab( nTabNum ),
bAppend( bApp )
{
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
SetChangeTrack();
}
@@ -159,7 +159,7 @@ ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell,
aNameList( newNameList ),
nTab( nTabNum )
{
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
SetChangeTrack();
}
@@ -573,7 +573,7 @@ ScUndoCopyTab::ScUndoCopyTab(
mpNewNames(pNewNames),
pDrawUndo( nullptr )
{
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
if (mpNewNames && mpNewTabs->size() != mpNewNames->size())
// The sizes differ. Something is wrong.
@@ -784,7 +784,7 @@ ScUndoMakeScenario::ScUndoMakeScenario( ScDocShell* pNewDocShell,
nFlags( nF ),
pDrawUndo( nullptr )
{
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
}
ScUndoMakeScenario::~ScUndoMakeScenario()
@@ -863,7 +863,7 @@ ScUndoImportTab::ScUndoImportTab(ScDocShell* pShell,
, nCount(nNewCount)
, pDrawUndo(nullptr)
{
- pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() );
+ pDrawUndo = GetSdrUndoAction( &pDocShell->GetDocument() ).release();
}
ScUndoImportTab::~ScUndoImportTab()
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
index 47e262ec83f3..0a3916ced717 100644
--- a/sc/source/ui/view/drawview.cxx
+++ b/sc/source/ui/view/drawview.cxx
@@ -874,7 +874,7 @@ void ScDrawView::DeleteMarked()
delete pNote;
// add the undo action for the note
if( bUndo )
- pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo().release() ) );
// repaint the cell to get rid of the note marker
if( pDocShell )
pDocShell->PostPaintCell( pCaptData->maStart );
commit 26ebaae4f1e43d43646cf132379058b4b78065af
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Mar 23 12:47:02 2018 +0200
loplugin:useuniqueptr in ScPrintSaverTab
Change-Id: I51ef59e97e9b46cf9496dbefaabcc15471e9cdae
Reviewed-on: https://gerrit.libreoffice.org/51902
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/inc/prnsave.hxx b/sc/inc/prnsave.hxx
index 463a424451ad..f5137aefebd9 100644
--- a/sc/inc/prnsave.hxx
+++ b/sc/inc/prnsave.hxx
@@ -31,8 +31,8 @@ class ScPrintSaverTab
typedef ::std::vector< ScRange > ScRangeVec;
ScRangeVec maPrintRanges; ///< Array
- ScRange* mpRepeatCol; ///< single
- ScRange* mpRepeatRow; ///< single
+ std::unique_ptr<ScRange> mpRepeatCol; ///< single
+ std::unique_ptr<ScRange> mpRepeatRow; ///< single
bool mbEntireSheet;
public:
@@ -44,8 +44,8 @@ public:
const ScRangeVec& GetPrintRanges() const { return maPrintRanges; }
bool IsEntireSheet() const { return mbEntireSheet; }
- const ScRange* GetRepeatCol() const { return mpRepeatCol; }
- const ScRange* GetRepeatRow() const { return mpRepeatRow; }
+ const ScRange* GetRepeatCol() const { return mpRepeatCol.get(); }
+ const ScRange* GetRepeatRow() const { return mpRepeatRow.get(); }
bool operator==( const ScPrintSaverTab& rCmp ) const;
};
diff --git a/sc/source/core/tool/prnsave.cxx b/sc/source/core/tool/prnsave.cxx
index 223647db7cee..97b3ebe09101 100644
--- a/sc/source/core/tool/prnsave.cxx
+++ b/sc/source/core/tool/prnsave.cxx
@@ -26,16 +26,14 @@
// Data per table
ScPrintSaverTab::ScPrintSaverTab() :
- mpRepeatCol(nullptr),
- mpRepeatRow(nullptr),
mbEntireSheet(false)
{
}
ScPrintSaverTab::~ScPrintSaverTab()
{
- delete mpRepeatCol;
- delete mpRepeatRow;
+ mpRepeatCol.reset();
+ mpRepeatRow.reset();
}
void ScPrintSaverTab::SetAreas( const ScRangeVec& rRanges, bool bEntireSheet )
@@ -46,10 +44,8 @@ void ScPrintSaverTab::SetAreas( const ScRangeVec& rRanges, bool bEntireSheet )
void ScPrintSaverTab::SetRepeat( const ScRange* pCol, const ScRange* pRow )
{
- delete mpRepeatCol;
- mpRepeatCol = pCol ? new ScRange(*pCol) : nullptr;
- delete mpRepeatRow;
- mpRepeatRow = pRow ? new ScRange(*pRow) : nullptr;
+ mpRepeatCol.reset(pCol ? new ScRange(*pCol) : nullptr);
+ mpRepeatRow.reset(pRow ? new ScRange(*pRow) : nullptr);
}
inline bool PtrEqual( const ScRange* p1, const ScRange* p2 )
@@ -60,8 +56,8 @@ inline bool PtrEqual( const ScRange* p1, const ScRange* p2 )
bool ScPrintSaverTab::operator==( const ScPrintSaverTab& rCmp ) const
{
return
- PtrEqual( mpRepeatCol, rCmp.mpRepeatCol ) &&
- PtrEqual( mpRepeatRow, rCmp.mpRepeatRow ) &&
+ PtrEqual( mpRepeatCol.get(), rCmp.mpRepeatCol.get() ) &&
+ PtrEqual( mpRepeatRow.get(), rCmp.mpRepeatRow.get() ) &&
(mbEntireSheet == rCmp.mbEntireSheet) &&
(maPrintRanges == rCmp.maPrintRanges);
}
More information about the Libreoffice-commits
mailing list