summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-03-20 13:49:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-22 07:36:30 +0100
commitbf1daa9f4b0bd2ac706133def18c4af4cad9f216 (patch)
tree9e314013735ada1f2fe2429d25cad9cfa26e348e /sd
parentc0a76a9460a4a7db1575bc87744985150462a334 (diff)
loplugin:useuniqueptr in SdTransferable
Change-Id: I7ace5ab37ce6df240d3b7fbe8c0fd12618fa3031 Reviewed-on: https://gerrit.libreoffice.org/51669 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/app/sdxfer.cxx41
-rw-r--r--sd/source/ui/dlg/sdtreelb.cxx14
-rw-r--r--sd/source/ui/inc/sdxfer.hxx12
-rw-r--r--sd/source/ui/slidesorter/controller/SlsClipboard.cxx8
-rw-r--r--sd/source/ui/view/sdview2.cxx34
5 files changed, 52 insertions, 57 deletions
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 7b3783d79b9b..8183825d2ec2 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -121,7 +121,7 @@ SdTransferable::~SdTransferable()
if( mbOwnView )
delete mpSdViewIntern;
- delete mpOLEDataHelper;
+ mpOLEDataHelper.reset();
if( maDocShellRef.is() )
{
@@ -135,12 +135,12 @@ SdTransferable::~SdTransferable()
if( mbOwnDocument )
delete mpSdDrawDocumentIntern;
- delete mpGraphic;
- delete mpBookmark;
- delete mpImageMap;
+ mpGraphic.reset();
+ mpBookmark.reset();
+ mpImageMap.reset();
mpVDev.disposeAndClear();
- delete mpObjDesc;
+ mpObjDesc.reset();
//call explicitly at end of dtor to be covered by above SolarMutex
maUserData.clear();
@@ -150,14 +150,10 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
{
if( pObj )
{
- delete mpOLEDataHelper;
- mpOLEDataHelper = nullptr;
- delete mpGraphic;
- mpGraphic = nullptr;
- delete mpBookmark;
- mpBookmark = nullptr;
- delete mpImageMap;
- mpImageMap = nullptr;
+ mpOLEDataHelper.reset();
+ mpGraphic.reset();
+ mpBookmark.reset();
+ mpImageMap.reset();
if( nullptr!= dynamic_cast< const SdrOle2Obj* >( pObj ) )
{
@@ -167,13 +163,13 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
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
// The EmbedDataHelper should bring the graphic in future
const Graphic* pObjGr = static_cast< SdrOle2Obj* >( pObj )->GetGraphic();
if ( pObjGr )
- mpGraphic = new Graphic( *pObjGr );
+ mpGraphic.reset( new Graphic( *pObjGr ) );
}
}
catch( uno::Exception& )
@@ -181,7 +177,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* 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) ) )
{
@@ -209,7 +205,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
xPropSet->getPropertyValue( "Label" ) >>= aLabel;
xPropSet->getPropertyValue( "TargetURL" ) >>= aURL;
- mpBookmark = new INetBookmark( aURL, aLabel );
+ mpBookmark.reset( new INetBookmark( aURL, aLabel ) );
}
}
}
@@ -237,7 +233,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
// when both are unused
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 )
SdIMapInfo* pInfo = SdDrawDocument::GetIMapInfo( pObj );
if( pInfo )
- mpImageMap = new ImageMap( pInfo->GetImageMap() );
+ mpImageMap.reset( new ImageMap( pInfo->GetImageMap() ) );
}
}
@@ -687,11 +683,10 @@ void SdTransferable::ObjectReleased()
SD_MOD()->pTransferSelection = nullptr;
}
-void SdTransferable::SetObjectDescriptor( const TransferableObjectDescriptor& rObjDesc )
+void SdTransferable::SetObjectDescriptor( std::unique_ptr<TransferableObjectDescriptor> pObjDesc )
{
- delete mpObjDesc;
- mpObjDesc = new TransferableObjectDescriptor( rObjDesc );
- PrepareOLE( rObjDesc );
+ mpObjDesc = std::move(pObjDesc);
+ PrepareOLE( *mpObjDesc );
}
void SdTransferable::SetPageBookmarks( const std::vector<OUString> &rPageBookmarks, bool bPersistent )
diff --git a/sd/source/ui/dlg/sdtreelb.cxx b/sd/source/ui/dlg/sdtreelb.cxx
index 42e34374fc02..c39da4833f0c 100644
--- a/sd/source/ui/dlg/sdtreelb.cxx
+++ b/sd/source/ui/dlg/sdtreelb.cxx
@@ -1351,7 +1351,7 @@ void SdPageObjsTLB::AddShapeToTransferable (
SdTransferable& rTransferable,
SdrObject& rObject) const
{
- TransferableObjectDescriptor aObjectDescriptor;
+ std::unique_ptr<TransferableObjectDescriptor> pObjectDescriptor(new TransferableObjectDescriptor);
bool bIsDescriptorFillingPending (true);
const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject);
@@ -1364,7 +1364,7 @@ void SdPageObjsTLB::AddShapeToTransferable (
if (xPersObj.is() && xPersObj->hasEntry())
{
SvEmbedTransferHelper::FillTransferableObjectDescriptor(
- aObjectDescriptor,
+ *pObjectDescriptor,
pOleObject->GetObjRef(),
pOleObject->GetGraphic(),
pOleObject->GetAspect());
@@ -1379,20 +1379,20 @@ void SdPageObjsTLB::AddShapeToTransferable (
::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh();
if (bIsDescriptorFillingPending && pDocShell!=nullptr)
{
- pDocShell->FillTransferableObjectDescriptor(aObjectDescriptor);
+ pDocShell->FillTransferableObjectDescriptor(*pObjectDescriptor);
}
Point aDragPos (rObject.GetCurrentBoundRect().Center());
//Point aDragPos (0,0);
- aObjectDescriptor.maDragStartPos = aDragPos;
+ pObjectDescriptor->maDragStartPos = aDragPos;
// aObjectDescriptor.maSize = GetAllMarkedRect().GetSize();
if (pDocShell != nullptr)
- aObjectDescriptor.maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
+ pObjectDescriptor->maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass();
else
- aObjectDescriptor.maDisplayName.clear();
+ pObjectDescriptor->maDisplayName.clear();
rTransferable.SetStartPos(aDragPos);
- rTransferable.SetObjectDescriptor( aObjectDescriptor );
+ rTransferable.SetObjectDescriptor( std::move(pObjectDescriptor) );
}
::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell)
diff --git a/sd/source/ui/inc/sdxfer.hxx b/sd/source/ui/inc/sdxfer.hxx
index 54661ba96992..e50d4248d377 100644
--- a/sd/source/ui/inc/sdxfer.hxx
+++ b/sd/source/ui/inc/sdxfer.hxx
@@ -53,7 +53,7 @@ public:
void SetView(const ::sd::View* pView);
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; }
const Point& GetStartPos() const { return maStartPos; }
@@ -116,17 +116,17 @@ private:
SfxObjectShellRef maDocShellRef;
::sd::DrawDocShell* mpPageDocShell;
std::vector<OUString> maPageBookmarks;
- TransferableDataHelper* mpOLEDataHelper;
- TransferableObjectDescriptor* mpObjDesc;
+ std::unique_ptr<TransferableDataHelper> mpOLEDataHelper;
+ std::unique_ptr<TransferableObjectDescriptor> mpObjDesc;
const ::sd::View* mpSdView;
::sd::View* mpSdViewIntern;
SdDrawDocument* mpSdDrawDocument;
SdDrawDocument* mpSdDrawDocumentIntern;
SdDrawDocument* mpSourceDoc;
VclPtr<VirtualDevice> mpVDev;
- INetBookmark* mpBookmark;
- Graphic* mpGraphic;
- ImageMap* mpImageMap;
+ std::unique_ptr<INetBookmark> mpBookmark;
+ std::unique_ptr<Graphic> mpGraphic;
+ std::unique_ptr<ImageMap> mpImageMap;
::tools::Rectangle maVisArea;
Point maStartPos;
bool mbInternalMove : 1;
diff --git a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
index 07bf85ee8d85..fae32538b324 100644
--- a/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -445,12 +445,12 @@ void Clipboard::CreateSlideTransferable (
pDocument->CreatingDataObj (pTransferable);
pTransferable->SetWorkDocument(pDocument->AllocSdDrawDocument());
- TransferableObjectDescriptor aObjDesc;
+ std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
pTransferable->GetWorkDocument()->GetDocSh()
- ->FillTransferableObjectDescriptor (aObjDesc);
+ ->FillTransferableObjectDescriptor (*pObjDesc);
if (pDataDocSh != nullptr)
- aObjDesc.maDisplayName = pDataDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ pObjDesc->maDisplayName = pDataDocSh->GetMedium()->GetURLObject().GetURLNoPass();
vcl::Window* pActionWindow = pWindow;
if (pActionWindow == nullptr)
@@ -462,7 +462,7 @@ void Clipboard::CreateSlideTransferable (
pTransferable->SetStartPos (pActionWindow->PixelToLogic(
pActionWindow->GetPointerPosPixel()));
- pTransferable->SetObjectDescriptor (aObjDesc);
+ pTransferable->SetObjectDescriptor (std::move(pObjDesc));
{
TemporarySlideTrackingDeactivator aDeactivator (mrController);
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
index 8f8775b015f7..c18f8bdbed0c 100644
--- a/sd/source/ui/view/sdview2.cxx
+++ b/sd/source/ui/view/sdview2.cxx
@@ -99,7 +99,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat
// #112978# need to use GetAllMarkedBoundRect instead of GetAllMarkedRect to get
// fat lines correctly
const ::tools::Rectangle aMarkRect( GetAllMarkedBoundRect() );
- TransferableObjectDescriptor aObjDesc;
+ std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
SdrOle2Obj* pSdrOleObj = nullptr;
SdrPageView* pPgView = GetSdrPageView();
SdPage* pOldPage = pPgView ? static_cast<SdPage*>( pPgView->GetPage() ) : nullptr;
@@ -130,17 +130,17 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateClipboardDat
}
if( pSdrOleObj )
- SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
+ SvEmbedTransferHelper::FillTransferableObjectDescriptor( *pObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
else
- pTransferable->GetWorkDocument()->GetDocSh()->FillTransferableObjectDescriptor( aObjDesc );
+ pTransferable->GetWorkDocument()->GetDocSh()->FillTransferableObjectDescriptor( *pObjDesc );
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->SetObjectDescriptor( aObjDesc );
+ pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
pTransferable->CopyToClipboard( mpViewSh->GetActiveWindow() );
return xRet;
@@ -153,7 +153,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje
SD_MOD()->pTransferDrag = pTransferable;
- TransferableObjectDescriptor aObjDesc;
+ std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
OUString aDisplayName;
SdrOle2Obj* pSdrOleObj = nullptr;
@@ -179,16 +179,16 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateDragDataObje
aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
if( pSdrOleObj )
- SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
+ SvEmbedTransferHelper::FillTransferableObjectDescriptor( *pObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
else if (mpDocSh)
- mpDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ mpDocSh->FillTransferableObjectDescriptor( *pObjDesc );
- aObjDesc.maSize = GetAllMarkedRect().GetSize();
- aObjDesc.maDragStartPos = rDragPos;
- aObjDesc.maDisplayName = aDisplayName;
+ pObjDesc->maSize = GetAllMarkedRect().GetSize();
+ pObjDesc->maDragStartPos = rDragPos;
+ pObjDesc->maDisplayName = aDisplayName;
pTransferable->SetStartPos( rDragPos );
- pTransferable->SetObjectDescriptor( aObjDesc );
+ pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
pTransferable->StartDrag( &rWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
return xRet;
@@ -198,7 +198,7 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDat
{
SdTransferable* pTransferable = new SdTransferable( &mrDoc, pWorkView, true );
css::uno::Reference< css::datatransfer::XTransferable > xRet( pTransferable );
- TransferableObjectDescriptor aObjDesc;
+ std::unique_ptr<TransferableObjectDescriptor> pObjDesc(new TransferableObjectDescriptor);
const ::tools::Rectangle aMarkRect( GetAllMarkedRect() );
OUString aDisplayName;
@@ -207,13 +207,13 @@ css::uno::Reference< css::datatransfer::XTransferable > View::CreateSelectionDat
if( mpDocSh )
{
aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
- mpDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ mpDocSh->FillTransferableObjectDescriptor( *pObjDesc );
}
- aObjDesc.maSize = aMarkRect.GetSize();
+ pObjDesc->maSize = aMarkRect.GetSize();
pTransferable->SetStartPos( aMarkRect.TopLeft() );
- pTransferable->SetObjectDescriptor( aObjDesc );
+ pTransferable->SetObjectDescriptor( std::move(pObjDesc) );
pTransferable->CopyToSelection( &rWindow );
return xRet;