sc/source/ui/app/drwtrans.cxx | 20 +++++++++----------- sc/source/ui/inc/drwtrans.hxx | 10 +++++----- 2 files changed, 14 insertions(+), 16 deletions(-)
New commits: commit 63229c51ba33ccb478ac9df1737281555ebea0bd Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Mon Apr 9 12:08:55 2018 +0200 loplugin:useuniqueptr in ScDrawTransferObj Change-Id: I0de14f370f81b6b1e37cb7c9e517d4e9b857ab83 Reviewed-on: https://gerrit.libreoffice.org/52644 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx index 3fa00a949b55..13d5c91e142d 100644 --- a/sc/source/ui/app/drwtrans.cxx +++ b/sc/source/ui/app/drwtrans.cxx @@ -174,7 +174,7 @@ ScDrawTransferObj::ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContain aLabel = sTmp; } } - pBookmark = new INetBookmark( aAbs, aLabel ); + pBookmark.reset( new INetBookmark( aAbs, aLabel ) ); } } } @@ -229,11 +229,11 @@ ScDrawTransferObj::~ScDrawTransferObj() aOleData = TransferableDataHelper(); // clear before releasing the mutex aDocShellRef.clear(); - delete pModel; + pModel.reset(); aDrawPersistRef.clear(); // after the model - delete pBookmark; - delete pDragSourceView; + pBookmark.reset(); + pDragSourceView.reset(); } ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard( vcl::Window* pWin ) @@ -339,7 +339,7 @@ void ScDrawTransferObj::AddSupportedFormats() AddFormat( SotClipboardFormatId::DRAWING ); // leave out bitmap and metafile if there are only controls - if ( !lcl_HasOnlyControls( pModel ) ) + if ( !lcl_HasOnlyControls( pModel.get() ) ) { AddFormat( SotClipboardFormatId::PNG ); AddFormat( SotClipboardFormatId::BITMAP ); @@ -387,7 +387,7 @@ bool ScDrawTransferObj::GetData( const css::datatransfer::DataFlavor& rFlavor, c } else if ( nFormat == SotClipboardFormatId::DRAWING ) { - bOK = SetObject( pModel, SCDRAWTRANS_TYPE_DRAWMODEL, rFlavor ); + bOK = SetObject( pModel.get(), SCDRAWTRANS_TYPE_DRAWMODEL, rFlavor ); } else if ( nFormat == SotClipboardFormatId::BITMAP || nFormat == SotClipboardFormatId::PNG @@ -602,7 +602,7 @@ void ScDrawTransferObj::DragFinished( sal_Int8 nDropAction ) if ( pScMod->GetDragData().pDrawTransfer == this ) pScMod->ResetDragObject(); - DELETEZ( pDragSourceView ); + pDragSourceView.reset(); TransferableHelper::DragFinished( nDropAction ); } @@ -631,8 +631,7 @@ static void lcl_InitMarks( SdrMarkView& rDest, const SdrMarkView& rSource, SCTAB void ScDrawTransferObj::SetDragSource( const ScDrawView* pView ) { - DELETEZ( pDragSourceView ); - pDragSourceView = new SdrView(pView->getSdrModelFromSdrView()); // TTTT pView should be reference + pDragSourceView.reset(new SdrView(pView->getSdrModelFromSdrView())); // TTTT pView should be reference lcl_InitMarks( *pDragSourceView, *pView, pView->GetTab() ); //! add as listener with document, delete pDragSourceView if document gone @@ -640,8 +639,7 @@ void ScDrawTransferObj::SetDragSource( const ScDrawView* pView ) void ScDrawTransferObj::SetDragSourceObj( SdrObject& rObj, SCTAB nTab ) { - DELETEZ( pDragSourceView ); - pDragSourceView = new SdrView(rObj.getSdrModelFromSdrObject()); + pDragSourceView.reset(new SdrView(rObj.getSdrModelFromSdrObject())); pDragSourceView->ShowSdrPage(pDragSourceView->GetModel()->GetPage(nTab)); SdrPageView* pPV = pDragSourceView->GetSdrPageView(); pDragSourceView->MarkObj(&rObj, pPV); // TTTT MarkObj should take SdrObject& diff --git a/sc/source/ui/inc/drwtrans.hxx b/sc/source/ui/inc/drwtrans.hxx index cf2fdaeaeb40..30ee2f793f53 100644 --- a/sc/source/ui/inc/drwtrans.hxx +++ b/sc/source/ui/inc/drwtrans.hxx @@ -41,7 +41,7 @@ enum class ScDragSrc; class ScDrawTransferObj : public TransferableHelper { private: - SdrModel* pModel; + std::unique_ptr<SdrModel> pModel; TransferableDataHelper aOleData; TransferableObjectDescriptor aObjDesc; SfxObjectShellRef aDocShellRef; @@ -49,13 +49,13 @@ private: // extracted from model in ctor: Size aSrcSize; - INetBookmark* pBookmark; + std::unique_ptr<INetBookmark> pBookmark; bool bGraphic; bool bGrIsBit; bool bOleObj; // source information for drag&drop: // (view is needed to handle drawing obejcts) - SdrView* pDragSourceView; + std::unique_ptr<SdrView> pDragSourceView; ScDragSrc nDragSourceFlags; bool bDragWasInternal; @@ -79,7 +79,7 @@ public: const css::datatransfer::DataFlavor& rFlavor ) override; virtual void DragFinished( sal_Int8 nDropAction ) override; - SdrModel* GetModel() { return pModel; } + SdrModel* GetModel() { return pModel.get(); } void SetDrawPersist( const SfxObjectShellRef& rRef ); void SetDragSource( const ScDrawView* pView ); @@ -89,7 +89,7 @@ public: const OUString& GetShellID() const; - SdrView* GetDragSourceView() { return pDragSourceView; } + SdrView* GetDragSourceView() { return pDragSourceView.get(); } ScDragSrc GetDragSourceFlags() const { return nDragSourceFlags; } static ScDrawTransferObj* GetOwnClipboard( vcl::Window* ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits