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

loplugin:useuniqueptr in SdTransferable

Change-Id: I7ace5ab37ce6df240d3b7fbe8c0fd12618fa3031
Reviewed-on: https://gerrit.libreoffice.org/51669Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst c0a76a94
...@@ -121,7 +121,7 @@ SdTransferable::~SdTransferable() ...@@ -121,7 +121,7 @@ SdTransferable::~SdTransferable()
if( mbOwnView ) if( mbOwnView )
delete mpSdViewIntern; delete mpSdViewIntern;
delete mpOLEDataHelper; mpOLEDataHelper.reset();
if( maDocShellRef.is() ) if( maDocShellRef.is() )
{ {
...@@ -135,12 +135,12 @@ SdTransferable::~SdTransferable() ...@@ -135,12 +135,12 @@ SdTransferable::~SdTransferable()
if( mbOwnDocument ) if( mbOwnDocument )
delete mpSdDrawDocumentIntern; delete mpSdDrawDocumentIntern;
delete mpGraphic; mpGraphic.reset();
delete mpBookmark; mpBookmark.reset();
delete mpImageMap; mpImageMap.reset();
mpVDev.disposeAndClear(); mpVDev.disposeAndClear();
delete mpObjDesc; mpObjDesc.reset();
//call explicitly at end of dtor to be covered by above SolarMutex //call explicitly at end of dtor to be covered by above SolarMutex
maUserData.clear(); maUserData.clear();
...@@ -150,14 +150,10 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj ) ...@@ -150,14 +150,10 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
{ {
if( pObj ) if( pObj )
{ {
delete mpOLEDataHelper; mpOLEDataHelper.reset();
mpOLEDataHelper = nullptr; mpGraphic.reset();
delete mpGraphic; mpBookmark.reset();
mpGraphic = nullptr; mpImageMap.reset();
delete mpBookmark;
mpBookmark = nullptr;
delete mpImageMap;
mpImageMap = nullptr;
if( nullptr!= dynamic_cast< const SdrOle2Obj* >( pObj ) ) if( nullptr!= dynamic_cast< const SdrOle2Obj* >( pObj ) )
{ {
...@@ -167,13 +163,13 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj ) ...@@ -167,13 +163,13 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY ); uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
if( xObj.is() && xPersist.is() && xPersist->hasEntry() ) if( xObj.is() && xPersist.is() && xPersist->hasEntry() )
{ {
mpOLEDataHelper = new TransferableDataHelper( new SvEmbedTransferHelper( xObj, static_cast< SdrOle2Obj* >( pObj )->GetGraphic(), static_cast< SdrOle2Obj* >( pObj )->GetAspect() ) ); mpOLEDataHelper.reset( new TransferableDataHelper( new SvEmbedTransferHelper( xObj, static_cast< SdrOle2Obj* >( pObj )->GetGraphic(), static_cast< SdrOle2Obj* >( pObj )->GetAspect() ) ) );
// TODO/LATER: the standalone handling of the graphic should not be used any more in future // TODO/LATER: the standalone handling of the graphic should not be used any more in future
// The EmbedDataHelper should bring the graphic in future // The EmbedDataHelper should bring the graphic in future
const Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic(); const Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic();
if ( pObjGr ) if ( pObjGr )
mpGraphic = new Graphic( *pObjGr ); mpGraphic.reset( new Graphic( *pObjGr ) );
} }
} }
catch( uno::Exception& ) catch( uno::Exception& )
...@@ -181,7 +177,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj ) ...@@ -181,7 +177,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
} }
else if( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr && (mpSourceDoc && !SdDrawDocument::GetAnimationInfo( pObj )) ) else if( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr && (mpSourceDoc && !SdDrawDocument::GetAnimationInfo( pObj )) )
{ {
mpGraphic = new Graphic( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() ); mpGraphic.reset( new Graphic( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() ) );
} }
else if( pObj->IsUnoObj() && SdrInventor::FmForm == pObj->GetObjInventor() && ( pObj->GetObjIdentifier() == sal_uInt16(OBJ_FM_BUTTON) ) ) else if( pObj->IsUnoObj() && SdrInventor::FmForm == pObj->GetObjInventor() && ( pObj->GetObjIdentifier() == sal_uInt16(OBJ_FM_BUTTON) ) )
{ {
...@@ -209,7 +205,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj ) ...@@ -209,7 +205,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
xPropSet->getPropertyValue( "Label" ) >>= aLabel; xPropSet->getPropertyValue( "Label" ) >>= aLabel;
xPropSet->getPropertyValue( "TargetURL" ) >>= aURL; xPropSet->getPropertyValue( "TargetURL" ) >>= aURL;
mpBookmark = new INetBookmark( aURL, aLabel ); mpBookmark.reset( new INetBookmark( aURL, aLabel ) );
} }
} }
} }
...@@ -237,7 +233,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj ) ...@@ -237,7 +233,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
// when both are unused // when both are unused
if(!pObj->HasFillStyle() && !pObj->HasLineStyle()) if(!pObj->HasFillStyle() && !pObj->HasLineStyle())
{ {
mpBookmark = new INetBookmark( pURL->GetURL(), pURL->GetRepresentation() ); mpBookmark.reset( new INetBookmark( pURL->GetURL(), pURL->GetRepresentation() ) );
} }
} }
} }
...@@ -247,7 +243,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj ) ...@@ -247,7 +243,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
SdIMapInfo* pInfo = SdDrawDocument::GetIMapInfo( pObj ); SdIMapInfo* pInfo = SdDrawDocument::GetIMapInfo( pObj );
if( pInfo ) if( pInfo )
mpImageMap = new ImageMap( pInfo->GetImageMap() ); mpImageMap.reset( new ImageMap( pInfo->GetImageMap() ) );
} }
} }
...@@ -687,11 +683,10 @@ void SdTransferable::ObjectReleased() ...@@ -687,11 +683,10 @@ void SdTransferable::ObjectReleased()
SD_MOD()->pTransferSelection = nullptr; SD_MOD()->pTransferSelection = nullptr;
} }
void SdTransferable::SetObjectDescriptor( const TransferableObjectDescriptor& rObjDesc ) void SdTransferable::SetObjectDescriptor( std::unique_ptr<TransferableObjectDescriptor> pObjDesc )
{ {
delete mpObjDesc; mpObjDesc = std::move(pObjDesc);
mpObjDesc = new TransferableObjectDescriptor( rObjDesc ); PrepareOLE( *mpObjDesc );
PrepareOLE( rObjDesc );
} }
void SdTransferable::SetPageBookmarks( const std::vector<OUString> &rPageBookmarks, bool bPersistent ) void SdTransferable::SetPageBookmarks( const std::vector<OUString> &rPageBookmarks, bool bPersistent )
......
...@@ -1351,7 +1351,7 @@ void SdPageObjsTLB::AddShapeToTransferable ( ...@@ -1351,7 +1351,7 @@ void SdPageObjsTLB::AddShapeToTransferable (
SdTransferable& rTransferable, SdTransferable& rTransferable,
SdrObject& rObject) const SdrObject& rObject) const
{ {
TransferableObjectDescriptor aObjectDescriptor; std::unique_ptr<TransferableObjectDescriptor> pObjectDescriptor(new TransferableObjectDescriptor);
bool bIsDescriptorFillingPending (true); bool bIsDescriptorFillingPending (true);
const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject); const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject);
...@@ -1364,7 +1364,7 @@ void SdPageObjsTLB::AddShapeToTransferable ( ...@@ -1364,7 +1364,7 @@ void SdPageObjsTLB::AddShapeToTransferable (
if (xPersObj.is() && xPersObj->hasEntry()) if (xPersObj.is() && xPersObj->hasEntry())
{ {
SvEmbedTransferHelper::FillTransferableObjectDescriptor( SvEmbedTransferHelper::FillTransferableObjectDescriptor(
aObjectDescriptor, *pObjectDescriptor,
pOleObject->GetObjRef(), pOleObject->GetObjRef(),
pOleObject->GetGraphic(), pOleObject->GetGraphic(),
pOleObject->GetAspect()); pOleObject->GetAspect());
...@@ -1379,20 +1379,20 @@ void SdPageObjsTLB::AddShapeToTransferable ( ...@@ -1379,20 +1379,20 @@ void SdPageObjsTLB::AddShapeToTransferable (
::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh(); ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
if (bIsDescriptorFillingPending && pDocShell!=nullptr) if (bIsDescriptorFillingPending && pDocShell!=nullptr)
{ {
pDocShell->FillTransferableObjectDescriptor(aObjectDescriptor); pDocShell->FillTransferableObjectDescriptor(*pObjectDescriptor);
} }
Point aDragPos (rObject.GetCurrentBoundRect().Center()); Point aDragPos (rObject.GetCurrentBoundRect().Center());
//Point aDragPos (0,0); //Point aDragPos (0,0);
aObjectDescriptor.maDragStartPos = aDragPos; pObjectDescriptor->maDragStartPos = aDragPos;
// aObjectDescriptor.maSize = GetAllMarkedRect().GetSize(); // aObjectDescriptor.maSize = GetAllMarkedRect().GetSize();
if (pDocShell != nullptr) if (pDocShell != nullptr)
aObjectDescriptor.maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass(); pObjectDescriptor->maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
else else
aObjectDescriptor.maDisplayName.clear(); pObjectDescriptor->maDisplayName.clear();
rTransferable.SetStartPos(aDragPos); rTransferable.SetStartPos(aDragPos);
rTransferable.SetObjectDescriptor( aObjectDescriptor ); rTransferable.SetObjectDescriptor( std::move(pObjectDescriptor) );
} }
::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell) ::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell)
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
void SetView(const ::sd::View* pView); void SetView(const ::sd::View* pView);
const ::sd::View* GetView() const { return mpSdView; } const ::sd::View* GetView() const { return mpSdView; }
void SetObjectDescriptor( const TransferableObjectDescriptor& rObjDesc ); void SetObjectDescriptor( std::unique_ptr<TransferableObjectDescriptor> pObjDesc );
void SetStartPos( const Point& rStartPos ) { maStartPos = rStartPos; } void SetStartPos( const Point& rStartPos ) { maStartPos = rStartPos; }
const Point& GetStartPos() const { return maStartPos; } const Point& GetStartPos() const { return maStartPos; }
...@@ -116,17 +116,17 @@ private: ...@@ -116,17 +116,17 @@ private:
SfxObjectShellRef maDocShellRef; SfxObjectShellRef maDocShellRef;
::sd::DrawDocShell* mpPageDocShell; ::sd::DrawDocShell* mpPageDocShell;
std::vector<OUString> maPageBookmarks; std::vector<OUString> maPageBookmarks;
TransferableDataHelper* mpOLEDataHelper; std::unique_ptr<TransferableDataHelper> mpOLEDataHelper;
TransferableObjectDescriptor* mpObjDesc; std::unique_ptr<TransferableObjectDescriptor> mpObjDesc;
const ::sd::View* mpSdView; const ::sd::View* mpSdView;
::sd::View* mpSdViewIntern; ::sd::View* mpSdViewIntern;
SdDrawDocument* mpSdDrawDocument; SdDrawDocument* mpSdDrawDocument;
SdDrawDocument* mpSdDrawDocumentIntern; SdDrawDocument* mpSdDrawDocumentIntern;
SdDrawDocument* mpSourceDoc; SdDrawDocument* mpSourceDoc;
VclPtr<VirtualDevice> mpVDev; VclPtr<VirtualDevice> mpVDev;
INetBookmark* mpBookmark; std::unique_ptr<INetBookmark> mpBookmark;
Graphic* mpGraphic; std::unique_ptr<Graphic> mpGraphic;
ImageMap* mpImageMap; std::unique_ptr<ImageMap> mpImageMap;
::tools::Rectangle maVisArea; ::tools::Rectangle maVisArea;
Point maStartPos; Point maStartPos;
bool mbInternalMove : 1; bool mbInternalMove : 1;
......
...@@ -445,12 +445,12 @@ void Clipboard::CreateSlideTransferable ( ...@@ -445,12 +445,12 @@ void Clipboard::CreateSlideTransferable (
pDocument->CreatingDataObj (pTransferable); pDocument->CreatingDataObj (pTransferable);
pTransferable->SetWorkDocument(pDocument->AllocSdDrawDocument()); pTransferable->SetWorkDocument(pDocument->AllocSdDrawDocument());
TransferableObjectDescriptor aObjDesc; std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
pTransferable->GetWorkDocument()->GetDocSh() pTransferable->GetWorkDocument()->GetDocSh()
->FillTransferableObjectDescriptor (aObjDesc); ->FillTransferableObjectDescriptor (*pObjDesc);
if (pDataDocSh != nullptr) if (pDataDocSh != nullptr)
aObjDesc.maDisplayName = pDataDocSh->GetMedium()->GetURLObject().GetURLNoPass(); pObjDesc->maDisplayName = pDataDocSh->GetMedium()->GetURLObject().GetURLNoPass();
vcl::Window* pActionWindow = pWindow; vcl::Window* pActionWindow = pWindow;
if (pActionWindow == nullptr) if (pActionWindow == nullptr)
...@@ -462,7 +462,7 @@ void Clipboard::CreateSlideTransferable ( ...@@ -462,7 +462,7 @@ void Clipboard::CreateSlideTransferable (
pTransferable->SetStartPos (pActionWindow->PixelToLogic( pTransferable->SetStartPos (pActionWindow->PixelToLogic(
pActionWindow->GetPointerPosPixel())); pActionWindow->GetPointerPosPixel()));
pTransferable->SetObjectDescriptor (aObjDesc); pTransferable->SetObjectDescriptor (std::move(pObjDesc));
{ {
TemporarySlideTrackingDeactivator aDeactivator (mrController); TemporarySlideTrackingDeactivator aDeactivator (mrController);
......
...@@ -99,7 +99,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat ...@@ -99,7 +99,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat
// #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect to get // #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect to get
// fat lines correctly // fat lines correctly
const ::tools::Rectangle aMarkRect( GetAllMarkedBoundRect() ); const ::tools::Rectangle aMarkRect( GetAllMarkedBoundRect() );
TransferableObjectDescriptor aObjDesc; std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
SdrOle2Obj* pSdrOleObj = nullptr; SdrOle2Obj* pSdrOleObj = nullptr;
SdrPageView* pPgView = GetSdrPageView(); SdrPageView* pPgView = GetSdrPageView();
SdPage* pOldPage = pPgView ? static_cast<SdPage*>( pPgView->GetPage() ) : nullptr; SdPage* pOldPage = pPgView ? static_cast<SdPage*>( pPgView->GetPage() ) : nullptr;
...@@ -130,17 +130,17 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat ...@@ -130,17 +130,17 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat
} }
if( pSdrOleObj ) if( pSdrOleObj )
SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() ); SvEmbedTransferHelper::FillTransferableObjectDescriptor( *pObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
else else
pTransferable->GetWorkDocument()->GetDocSh()->FillTransferableObjectDescriptor( aObjDesc ); pTransferable->GetWorkDocument()->GetDocSh()->FillTransferableObjectDescriptor( *pObjDesc );
if( mpDocSh ) if( mpDocSh )
aObjDesc.maDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass(); pObjDesc->maDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
aObjDesc.maSize = aMarkRect.GetSize(); pObjDesc->maSize = aMarkRect.GetSize();
pTransferable->SetStartPos( aMarkRect.TopLeft() ); pTransferable->SetStartPos( aMarkRect.TopLeft() );
pTransferable->SetObjectDescriptor( aObjDesc ); pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
pTransferable->CopyToClipboard( mpViewSh->GetActiveWindow() ); pTransferable->CopyToClipboard( mpViewSh->GetActiveWindow() );
return xRet; return xRet;
...@@ -153,7 +153,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje ...@@ -153,7 +153,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje
SD_MOD()->pTransferDrag = pTransferable; SD_MOD()->pTransferDrag = pTransferable;
TransferableObjectDescriptor aObjDesc; std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
OUString aDisplayName; OUString aDisplayName;
SdrOle2Obj* pSdrOleObj = nullptr; SdrOle2Obj* pSdrOleObj = nullptr;
...@@ -179,16 +179,16 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje ...@@ -179,16 +179,16 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje
aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass(); aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
if( pSdrOleObj ) if( pSdrOleObj )
SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() ); SvEmbedTransferHelper::FillTransferableObjectDescriptor( *pObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
else if (mpDocSh) else if (mpDocSh)
mpDocSh->FillTransferableObjectDescriptor( aObjDesc ); mpDocSh->FillTransferableObjectDescriptor( *pObjDesc );
aObjDesc.maSize = GetAllMarkedRect().GetSize(); pObjDesc->maSize = GetAllMarkedRect().GetSize();
aObjDesc.maDragStartPos = rDragPos; pObjDesc->maDragStartPos = rDragPos;
aObjDesc.maDisplayName = aDisplayName; pObjDesc->maDisplayName = aDisplayName;
pTransferable->SetStartPos( rDragPos ); pTransferable->SetStartPos( rDragPos );
pTransferable->SetObjectDescriptor( aObjDesc ); pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
pTransferable->StartDrag( &rWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK ); pTransferable->StartDrag( &rWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
return xRet; return xRet;
...@@ -198,7 +198,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDat ...@@ -198,7 +198,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDat
{ {
SdTransferable* pTransferable = new SdTransferable( &mrDoc, pWorkView, true ); SdTransferable* pTransferable = new SdTransferable( &mrDoc, pWorkView, true );
css::uno::Reference< css::datatransfer::XTransferable > xRet( pTransferable ); css::uno::Reference< css::datatransfer::XTransferable > xRet( pTransferable );
TransferableObjectDescriptor aObjDesc; std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
const ::tools::Rectangle aMarkRect( GetAllMarkedRect() ); const ::tools::Rectangle aMarkRect( GetAllMarkedRect() );
OUString aDisplayName; OUString aDisplayName;
...@@ -207,13 +207,13 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDat ...@@ -207,13 +207,13 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDat
if( mpDocSh ) if( mpDocSh )
{ {
aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass(); aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
mpDocSh->FillTransferableObjectDescriptor( aObjDesc ); mpDocSh->FillTransferableObjectDescriptor( *pObjDesc );
} }
aObjDesc.maSize = aMarkRect.GetSize(); pObjDesc->maSize = aMarkRect.GetSize();
pTransferable->SetStartPos( aMarkRect.TopLeft() ); pTransferable->SetStartPos( aMarkRect.TopLeft() );
pTransferable->SetObjectDescriptor( aObjDesc ); pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
pTransferable->CopyToSelection( &rWindow ); pTransferable->CopyToSelection( &rWindow );
return xRet; return xRet;
......
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