Kaydet (Commit) 5288887d authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in ScDrawTransferObj

Change-Id: I7a895a88576eabf010caa13353ad5698b4daf4d6
Reviewed-on: https://gerrit.libreoffice.org/59756
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst b59feb12
...@@ -72,9 +72,9 @@ constexpr sal_uInt32 SCDRAWTRANS_TYPE_EMBOBJ = 1; ...@@ -72,9 +72,9 @@ constexpr sal_uInt32 SCDRAWTRANS_TYPE_EMBOBJ = 1;
constexpr sal_uInt32 SCDRAWTRANS_TYPE_DRAWMODEL = 2; constexpr sal_uInt32 SCDRAWTRANS_TYPE_DRAWMODEL = 2;
constexpr sal_uInt32 SCDRAWTRANS_TYPE_DOCUMENT = 3; constexpr sal_uInt32 SCDRAWTRANS_TYPE_DOCUMENT = 3;
ScDrawTransferObj::ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell, ScDrawTransferObj::ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDocShell* pContainerShell,
const TransferableObjectDescriptor& rDesc ) : const TransferableObjectDescriptor& rDesc ) :
m_pModel( pClipModel ), m_pModel( std::move(pClipModel) ),
m_aObjDesc( rDesc ), m_aObjDesc( rDesc ),
m_pBookmark( nullptr ), m_pBookmark( nullptr ),
m_bGraphic( false ), m_bGraphic( false ),
......
...@@ -327,7 +327,7 @@ void ScSelectionTransferObj::CreateDrawData() ...@@ -327,7 +327,7 @@ void ScSelectionTransferObj::CreateDrawData()
} }
ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() ); ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() );
SdrModel* pModel = pDrawView->GetMarkedObjModel(); std::unique_ptr<SdrModel> pModel(pDrawView->GetMarkedObjModel());
ScDrawLayer::SetGlobalDrawPersist(nullptr); ScDrawLayer::SetGlobalDrawPersist(nullptr);
ScViewData& rViewData = pView->GetViewData(); ScViewData& rViewData = pView->GetViewData();
...@@ -338,7 +338,7 @@ void ScSelectionTransferObj::CreateDrawData() ...@@ -338,7 +338,7 @@ void ScSelectionTransferObj::CreateDrawData()
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScDrawTransferObj ctor // maSize is set in ScDrawTransferObj ctor
rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc ); rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), pDocSh, aObjDesc );
SfxObjectShellRef aPersistRef( aDragShellRef.get() ); SfxObjectShellRef aPersistRef( aDragShellRef.get() );
pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive
......
...@@ -69,7 +69,7 @@ private: ...@@ -69,7 +69,7 @@ private:
void CreateOLEData(); void CreateOLEData();
public: public:
ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell, ScDrawTransferObj( std::unique_ptr<SdrModel> pClipModel, ScDocShell* pContainerShell,
const TransferableObjectDescriptor& rDesc ); const TransferableObjectDescriptor& rDesc );
virtual ~ScDrawTransferObj() override; virtual ~ScDrawTransferObj() override;
......
...@@ -1253,14 +1253,14 @@ static void lcl_DoDragObject( ScDocShell* pSrcShell, const OUString& rName, ScCo ...@@ -1253,14 +1253,14 @@ static void lcl_DoDragObject( ScDocShell* pSrcShell, const OUString& rName, ScCo
SdrPageView* pPV = aEditView.GetSdrPageView(); SdrPageView* pPV = aEditView.GetSdrPageView();
aEditView.MarkObj(pObject, pPV); aEditView.MarkObj(pObject, pPV);
SdrModel* pDragModel = aEditView.GetMarkedObjModel(); std::unique_ptr<SdrModel> pDragModel(aEditView.GetMarkedObjModel());
TransferableObjectDescriptor aObjDesc; TransferableObjectDescriptor aObjDesc;
pSrcShell->FillTransferableObjectDescriptor( aObjDesc ); pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass(); aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScDrawTransferObj ctor // maSize is set in ScDrawTransferObj ctor
rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( pDragModel, pSrcShell, aObjDesc ); rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pDragModel), pSrcShell, aObjDesc );
pTransferObj->SetDragSourceObj( *pObject, nTab ); pTransferObj->SetDragSourceObj( *pObject, nTab );
pTransferObj->SetDragSourceFlags(ScDragSrc::Navigator); pTransferObj->SetDragSourceFlags(ScDragSrc::Navigator);
......
...@@ -80,7 +80,7 @@ void ScDrawView::BeginDrag( vcl::Window* pWindow, const Point& rStartPos ) ...@@ -80,7 +80,7 @@ void ScDrawView::BeginDrag( vcl::Window* pWindow, const Point& rStartPos )
aDragShellRef->DoInitNew(); aDragShellRef->DoInitNew();
} }
ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() ); ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() );
SdrModel* pModel = GetMarkedObjModel(); std::unique_ptr<SdrModel> pModel(GetMarkedObjModel());
ScDrawLayer::SetGlobalDrawPersist(nullptr); ScDrawLayer::SetGlobalDrawPersist(nullptr);
// Charts now always copy their data in addition to the source reference, so // Charts now always copy their data in addition to the source reference, so
...@@ -95,7 +95,7 @@ void ScDrawView::BeginDrag( vcl::Window* pWindow, const Point& rStartPos ) ...@@ -95,7 +95,7 @@ void ScDrawView::BeginDrag( vcl::Window* pWindow, const Point& rStartPos )
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScDrawTransferObj ctor // maSize is set in ScDrawTransferObj ctor
rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc ); rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), pDocSh, aObjDesc );
pTransferObj->SetDrawPersist( aDragShellRef.get() ); // keep persist for ole objects alive pTransferObj->SetDrawPersist( aDragShellRef.get() ); // keep persist for ole objects alive
pTransferObj->SetDragSource( this ); // copies selection pTransferObj->SetDragSource( this ); // copies selection
...@@ -358,7 +358,7 @@ void ScDrawView::DoCopy() ...@@ -358,7 +358,7 @@ void ScDrawView::DoCopy()
ScDocument& rClipDoc = xDocSh->GetDocument(); ScDocument& rClipDoc = xDocSh->GetDocument();
copyChartRefDataToClipDoc(pDoc, &rClipDoc, aRanges); copyChartRefDataToClipDoc(pDoc, &rClipDoc, aRanges);
} }
SdrModel* pModel = GetMarkedObjModel(); std::unique_ptr<SdrModel> pModel(GetMarkedObjModel());
ScDrawLayer::SetGlobalDrawPersist(nullptr); ScDrawLayer::SetGlobalDrawPersist(nullptr);
// Charts now always copy their data in addition to the source reference, so // Charts now always copy their data in addition to the source reference, so
...@@ -373,7 +373,7 @@ void ScDrawView::DoCopy() ...@@ -373,7 +373,7 @@ void ScDrawView::DoCopy()
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScDrawTransferObj ctor // maSize is set in ScDrawTransferObj ctor
ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc ); ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( std::move(pModel), pDocSh, aObjDesc );
uno::Reference<css::datatransfer::XTransferable2> xTransferObj = pTransferObj; uno::Reference<css::datatransfer::XTransferable2> xTransferObj = pTransferObj;
if ( ScGlobal::xDrawClipDocShellRef.is() ) if ( ScGlobal::xDrawClipDocShellRef.is() )
...@@ -392,7 +392,7 @@ uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable() ...@@ -392,7 +392,7 @@ uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable()
// update ScGlobal::xDrawClipDocShellRef // update ScGlobal::xDrawClipDocShellRef
ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) ); ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
SdrModel* pModel = GetMarkedObjModel(); std::unique_ptr<SdrModel> pModel( GetMarkedObjModel() );
ScDrawLayer::SetGlobalDrawPersist(nullptr); ScDrawLayer::SetGlobalDrawPersist(nullptr);
// Charts now always copy their data in addition to the source reference, so // Charts now always copy their data in addition to the source reference, so
...@@ -408,7 +408,7 @@ uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable() ...@@ -408,7 +408,7 @@ uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable()
aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass(); aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
// maSize is set in ScDrawTransferObj ctor // maSize is set in ScDrawTransferObj ctor
ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc ); ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( std::move(pModel), pDocSh, aObjDesc );
uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj ); uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
if ( ScGlobal::xDrawClipDocShellRef.is() ) if ( ScGlobal::xDrawClipDocShellRef.is() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment