diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2017-03-31 21:10:48 -0400 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2017-04-01 01:53:21 +0000 |
commit | c0ba76030ab03f9a424d36113a2def38eca3fb7c (patch) | |
tree | 758e9a9317dc240426949d3db3256ffd239a37c6 | |
parent | cdb75e0172d09d235f91c417fca0712add6b6e49 (diff) |
This is a prime candidate for unique_ptr.
Change-Id: I8ca8ec76d3b0f81e2dea47501cf86b63459479f2
Reviewed-on: https://gerrit.libreoffice.org/35990
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
-rw-r--r-- | sc/source/ui/docshell/docfunc.cxx | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index e822dcd4dfe5..18f12cfe728f 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -28,6 +28,7 @@ #include <vcl/virdev.hxx> #include <vcl/waitobj.hxx> #include <svl/PasswordHelper.hxx> +#include <o3tl/make_unique.hxx> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/script/ModuleType.hpp> @@ -2670,7 +2671,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, SCTAB nDestEndTab = nDestTab+nSrcTabCount-1; SCTAB nTab; - ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP ); + std::unique_ptr<ScDocument> pClipDoc = o3tl::make_unique<ScDocument>(SCDOCMODE_CLIP); ScMarkData aSourceMark; for (nTab=nStartTab; nTab<=nEndTab; nTab++) @@ -2686,7 +2687,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() ); ScClipParam aClipParam(ScRange(nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nStartTab), bCut); - rDoc.CopyToClip(aClipParam, pClipDoc, &aSourceMark, bScenariosAdded, true); + rDoc.CopyToClip(aClipParam, pClipDoc.get(), &aSourceMark, bScenariosAdded, true); ScDrawLayer::SetGlobalDrawPersist(nullptr); @@ -2726,7 +2727,6 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, { if (!bApi) rDocShell.ErrorMessage(STR_PASTE_FULL); - delete pClipDoc; return false; } @@ -2743,7 +2743,6 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, { if (!bApi) rDocShell.ErrorMessage(aTester.GetMessageId()); - delete pClipDoc; return false; } @@ -2755,7 +2754,6 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, { // "Merge of already merged cells not possible" if (!bApi) rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0); - delete pClipDoc; return false; } @@ -2811,7 +2809,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, nUndoEndCol,nUndoEndRow,nDestEndTab, HasAttrFlags::Merged | HasAttrFlags::Overlapped )) { - rDoc.CopyFromClip( rSource, aSourceMark, InsertDeleteFlags::ALL, nullptr, pClipDoc ); + rDoc.CopyFromClip( rSource, aSourceMark, InsertDeleteFlags::ALL, nullptr, pClipDoc.get() ); for (nTab=nStartTab; nTab<=nEndTab; nTab++) { SCCOL nTmpEndCol = nEndCol; @@ -2824,7 +2822,6 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0); delete pUndoDoc; - delete pClipDoc; return false; } @@ -2843,7 +2840,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, ScDrawLayer::MoveCells() which may move away inserted objects to wrong positions (e.g. if source and destination range overlaps).*/ rDoc.CopyFromClip( aPasteDest, aDestMark, InsertDeleteFlags::ALL & ~(InsertDeleteFlags::OBJECTS), - nullptr, pClipDoc, true, false, bIncludeFiltered ); + nullptr, pClipDoc.get(), true, false, bIncludeFiltered ); // skipped rows and merged cells don't mix if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() ) @@ -2858,7 +2855,7 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, clipdoc does not contain a drawing layer.*/ if ( pClipDoc->GetDrawLayer() ) rDoc.CopyFromClip( aPasteDest, aDestMark, InsertDeleteFlags::OBJECTS, - nullptr, pClipDoc, true, false, bIncludeFiltered ); + nullptr, pClipDoc.get(), true, false, bIncludeFiltered ); if (bRecord) { @@ -2954,7 +2951,6 @@ bool ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos, SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) ); - delete pClipDoc; return true; } |