[Libreoffice-commits] core.git: basctl/source include/svx svx/source sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 5 17:00:49 UTC 2019


 basctl/source/dlged/dlgedobj.cxx |    6 +--
 basctl/source/inc/dlgedobj.hxx   |    2 -
 include/svx/svddrgmt.hxx         |    6 +--
 include/svx/svdobj.hxx           |   11 ++++--
 include/svx/svdoedge.hxx         |    2 -
 include/svx/svdograf.hxx         |    2 -
 include/svx/svdoole2.hxx         |    4 +-
 include/svx/svdotext.hxx         |    2 -
 include/svx/svdovirt.hxx         |    2 -
 svx/source/svdraw/svddrgmt.cxx   |   62 +++++++++++++--------------------------
 svx/source/svdraw/svdobj.cxx     |    4 +-
 svx/source/svdraw/svdoedge.cxx   |    4 +-
 svx/source/svdraw/svdograf.cxx   |    6 +--
 svx/source/svdraw/svdoole2.cxx   |   12 +++----
 svx/source/svdraw/svdotext.cxx   |    8 ++---
 svx/source/svdraw/svdovirt.cxx   |    6 +--
 sw/source/core/draw/dflyobj.cxx  |    4 +-
 sw/source/core/inc/dflyobj.hxx   |    2 -
 18 files changed, 64 insertions(+), 81 deletions(-)

New commits:
commit 8b7434bc04de343b47d3107995cd9c3c96de40b0
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Sep 5 16:46:13 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 5 18:59:52 2019 +0200

    use unique_ptr in SdrObject::getFullDragClone
    
    Change-Id: I904f1f13bb4958e3457476e6e682ec7d7b97c670
    Reviewed-on: https://gerrit.libreoffice.org/78660
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index 0d491bd303e0..80bf91698928 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -914,13 +914,13 @@ DlgEdObj* DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const
     return pDlgEdObj;
 }
 
-SdrObject* DlgEdObj::getFullDragClone() const
+SdrObjectUniquePtr DlgEdObj::getFullDragClone() const
 {
     // no need to really add the clone for dragging, it's a temporary
     // object
-    SdrObject* pObj = new SdrUnoObj(
+    SdrObjectUniquePtr pObj( new SdrUnoObj(
         getSdrModelFromSdrObject(),
-        OUString());
+        OUString()) );
     *pObj = *static_cast<const SdrUnoObj*>(this);
 
     return pObj;
diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx
index 5a1f6c25ce43..8442747bce78 100644
--- a/basctl/source/inc/dlgedobj.hxx
+++ b/basctl/source/inc/dlgedobj.hxx
@@ -107,7 +107,7 @@ public:
     void clonedFrom(const DlgEdObj* _pSource);                          // not working yet
 
     // FullDrag support
-    virtual SdrObject* getFullDragClone() const override;
+    virtual SdrObjectUniquePtr getFullDragClone() const override;
 
     bool supportsService( OUString const & serviceName ) const;
     OUString GetDefaultName() const;
diff --git a/include/svx/svddrgmt.hxx b/include/svx/svddrgmt.hxx
index f5759d6b9083..94d185547941 100644
--- a/include/svx/svddrgmt.hxx
+++ b/include/svx/svddrgmt.hxx
@@ -65,7 +65,7 @@ class SdrDragEntrySdrObject : public SdrDragEntry
 {
 private:
     const SdrObject&                                maOriginal;
-    SdrObject*                                      mpClone;
+    SdrObjectUniquePtr                              mxClone;
     bool const                                      mbModify;
 
 public:
@@ -78,7 +78,7 @@ public:
     // added accessors to original and clone
     void prepareCurrentState(SdrDragMethod& rDragMethod);
     const SdrObject& getOriginal() const { return maOriginal; }
-    SdrObject* getClone() { return mpClone; }
+    SdrObject* getClone() { return mxClone.get(); }
 
     virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod) override;
 };
@@ -284,7 +284,7 @@ private:
     // mechanism to modify wireframe visualisations, but uses the
     // SdrObject::applySpecialDrag() method to change a clone of the
     // SdrObject
-    SdrObject*                  mpClone;
+    SdrObjectUniquePtr               mxClone;
 
 protected:
     virtual void createSdrDragEntries() override;
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 61faabb2e4ea..86c1f06180f1 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -104,6 +104,12 @@ namespace svx
 }
 
 class SvxShape;
+class SdrObject;
+struct SVX_DLLPUBLIC SdrObjectFreeOp;
+
+// helper for constructing std::unique_ptr for SdrObjects where a
+// deleter is needed - here, SdrObject::Free needs to be used.
+typedef std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr;
 
 enum SdrObjKind {
     OBJ_NONE       = 0,  /// abstract object (SdrObject)
@@ -543,7 +549,7 @@ public:
     // part of the model, thus not changing anything since it's only a temporary
     // helper object for interaction
     virtual bool supportsFullDrag() const;
-    virtual SdrObject* getFullDragClone() const;
+    virtual SdrObjectUniquePtr getFullDragClone() const;
 
     /// Every object must be able to create itself interactively.
     /// On MouseDown first an object is created, and its BegCreate() method
@@ -1025,8 +1031,6 @@ private:
     SdrObject( const SdrObject& ) = delete;
 };
 
-// helper for constructing std::unique_ptr for SdrObjects where a
-// deleter is needed - here, SdrObject::Free needs to be used.
 struct SVX_DLLPUBLIC SdrObjectFreeOp
 {
     void operator()(SdrObject* obj)
@@ -1034,7 +1038,6 @@ struct SVX_DLLPUBLIC SdrObjectFreeOp
         SdrObject::Free(obj);
     }
 };
-typedef std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr;
 
 struct SdrObjCreatorParams
 {
diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx
index 16127d914ec8..5d7fac34850c 100644
--- a/include/svx/svdoedge.hxx
+++ b/include/svx/svdoedge.hxx
@@ -236,7 +236,7 @@ public:
     virtual OUString getSpecialDragComment(const SdrDragStat& rDrag) const override;
 
     // FullDrag support
-    virtual SdrObject* getFullDragClone() const override;
+    virtual SdrObjectUniquePtr getFullDragClone() const override;
 
     virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override;
     virtual void NbcMove(const Size& aSize) override;
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index 4235b69351a3..b905db092f5d 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -223,7 +223,7 @@ public:
     css::uno::Reference< css::io::XInputStream > getInputStream() const;
 
     // #i103116# FullDrag support
-    virtual SdrObject* getFullDragClone() const override;
+    virtual SdrObjectUniquePtr getFullDragClone() const override;
 
     // add handles for crop mode when selected
     virtual void addCropHandles(SdrHdlList& rTarget) const override;
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
index a897b797694d..c8fe2b14f09a 100644
--- a/include/svx/svdoole2.hxx
+++ b/include/svx/svdoole2.hxx
@@ -56,7 +56,7 @@ private:
     SVX_DLLPRIVATE void GetObjRef_Impl();
 
     // #i118485# helper added
-    SVX_DLLPRIVATE SdrObject* createSdrGrafObjReplacement(bool bAddText) const;
+    SVX_DLLPRIVATE SdrObjectUniquePtr createSdrGrafObjReplacement(bool bAddText) const;
     SVX_DLLPRIVATE void ImpSetVisAreaSize();
 
     SVX_DLLPRIVATE void Init();
@@ -131,7 +131,7 @@ public:
     void SetClosedObj( bool bIsClosed );
 
     // FullDrag support
-    virtual SdrObject* getFullDragClone() const override;
+    virtual SdrObjectUniquePtr getFullDragClone() const override;
 
     virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override;
     virtual sal_uInt16 GetObjIdentifier() const override;
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index f76ab2dc4108..9ee22622c5d7 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -207,7 +207,7 @@ protected:
     // and maintaining the OutlinerView.
     Point                       maTextEditOffset;
 
-    virtual SdrObject* getFullDragClone() const override;
+    virtual SdrObjectUniquePtr getFullDragClone() const override;
 
 
 public:
diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx
index 323cce9f18ba..187ecb307d56 100644
--- a/include/svx/svdovirt.hxx
+++ b/include/svx/svdovirt.hxx
@@ -89,7 +89,7 @@ public:
 
     // FullDrag support
     virtual bool supportsFullDrag() const override;
-    virtual SdrObject* getFullDragClone() const override;
+    virtual SdrObjectUniquePtr getFullDragClone() const override;
 
     virtual bool BegCreate(SdrDragStat& rStat) override;
     virtual bool MovCreate(SdrDragStat& rStat) override;
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index a9e7ca7a6e27..38d72142eebe 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -143,7 +143,6 @@ SdrDragEntrySdrObject::SdrDragEntrySdrObject(
     bool bModify)
 :   SdrDragEntry(),
     maOriginal(rOriginal),
-    mpClone(nullptr),
     mbModify(bModify)
 {
     // add SdrObject parts to transparent overlay stuff
@@ -152,10 +151,6 @@ SdrDragEntrySdrObject::SdrDragEntrySdrObject(
 
 SdrDragEntrySdrObject::~SdrDragEntrySdrObject()
 {
-    if(mpClone)
-    {
-        SdrObject::Free(mpClone);
-    }
 }
 
 void SdrDragEntrySdrObject::prepareCurrentState(SdrDragMethod& rDragMethod)
@@ -164,18 +159,14 @@ void SdrDragEntrySdrObject::prepareCurrentState(SdrDragMethod& rDragMethod)
     // out when clone and original have the same class, so that i can use operator=
     // in those cases
 
-    if(mpClone)
-    {
-        SdrObject::Free(mpClone);
-        mpClone = nullptr;
-    }
+    mxClone.reset();
 
     if(mbModify)
     {
-        mpClone = maOriginal.getFullDragClone();
+        mxClone = maOriginal.getFullDragClone();
 
         // apply original transformation, implemented at the DragMethods
-        rDragMethod.applyCurrentTransformationToSdrObject(*mpClone);
+        rDragMethod.applyCurrentTransformationToSdrObject(*mxClone);
     }
 }
 
@@ -183,10 +174,10 @@ drawinglayer::primitive2d::Primitive2DContainer SdrDragEntrySdrObject::createPri
 {
     const SdrObject* pSource = &maOriginal;
 
-    if(mbModify && mpClone)
+    if(mbModify && mxClone)
     {
         // choose source for geometry data
-        pSource = mpClone;
+        pSource = mxClone.get();
     }
 
     // use the view-independent primitive representation (without
@@ -1172,8 +1163,7 @@ PointerStyle SdrDragMovHdl::GetSdrDragPointer() const
 
 
 SdrDragObjOwn::SdrDragObjOwn(SdrDragView& rNewView)
-:   SdrDragMethod(rNewView),
-    mpClone(nullptr)
+:   SdrDragMethod(rNewView)
 {
     const SdrObject* pObj = GetDragObj();
 
@@ -1186,15 +1176,11 @@ SdrDragObjOwn::SdrDragObjOwn(SdrDragView& rNewView)
 
 SdrDragObjOwn::~SdrDragObjOwn()
 {
-    if(mpClone)
-    {
-        SdrObject::Free(mpClone);
-    }
 }
 
 void SdrDragObjOwn::createSdrDragEntries()
 {
-    if(mpClone)
+    if(mxClone)
     {
         basegfx::B2DPolyPolygon aDragPolyPolygon;
         bool bAddWireframe(true);
@@ -1205,7 +1191,7 @@ void SdrDragObjOwn::createSdrDragEntries()
 
             if(pPV && pPV->PageWindowCount())
             {
-                addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntrySdrObject(*mpClone, false)));
+                addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntrySdrObject(*mxClone, false)));
 
                 // potentially no wireframe needed, full drag works
                 bAddWireframe = false;
@@ -1216,7 +1202,7 @@ void SdrDragObjOwn::createSdrDragEntries()
         {
             // check for extra conditions for wireframe, e.g. no border at
             // objects
-            if(!mpClone->HasLineStyle())
+            if(!mxClone->HasLineStyle())
             {
                 bAddWireframe = true;
             }
@@ -1225,11 +1211,11 @@ void SdrDragObjOwn::createSdrDragEntries()
         if(bAddWireframe)
         {
             // use wireframe poly when full drag is off or did not work
-            aDragPolyPolygon = mpClone->TakeXorPoly();
+            aDragPolyPolygon = mxClone->TakeXorPoly();
         }
 
         // add evtl. extra DragPolyPolygon
-        const basegfx::B2DPolyPolygon aSpecialDragPolyPolygon(mpClone->getSpecialDragPoly(DragStat()));
+        const basegfx::B2DPolyPolygon aSpecialDragPolyPolygon(mxClone->getSpecialDragPoly(DragStat()));
 
         if(aSpecialDragPolyPolygon.count())
         {
@@ -1247,9 +1233,9 @@ void SdrDragObjOwn::TakeSdrDragComment(OUString& rStr) const
 {
     // #i103058# get info string from the clone preferred, the original will
     // not be changed. For security, use original as fallback
-    if(mpClone)
+    if(mxClone)
     {
-        rStr = mpClone->getSpecialDragComment(DragStat());
+        rStr = mxClone->getSpecialDragComment(DragStat());
     }
     else
     {
@@ -1264,7 +1250,7 @@ void SdrDragObjOwn::TakeSdrDragComment(OUString& rStr) const
 
 bool SdrDragObjOwn::BeginSdrDrag()
 {
-    if(!mpClone)
+    if(!mxClone)
     {
         const SdrObject* pObj = GetDragObj();
 
@@ -1273,8 +1259,8 @@ bool SdrDragObjOwn::BeginSdrDrag()
             if(pObj->beginSpecialDrag(DragStat()))
             {
                 // create initial clone to have a start visualization
-                mpClone = pObj->getFullDragClone();
-                mpClone->applySpecialDrag(DragStat());
+                mxClone = pObj->getFullDragClone();
+                mxClone->applySpecialDrag(DragStat());
 
                 return true;
             }
@@ -1329,15 +1315,11 @@ void SdrDragObjOwn::MoveSdrDrag(const Point& rNoSnapPnt)
     clearSdrDragEntries();
 
     // delete current clone (after the last reference to it is deleted above)
-    if(mpClone)
-    {
-        SdrObject::Free(mpClone);
-        mpClone = nullptr;
-    }
+    mxClone.reset();
 
     // create a new clone and modify to current drag state
-    mpClone = pObj->getFullDragClone();
-    mpClone->applySpecialDrag(DragStat());
+    mxClone = pObj->getFullDragClone();
+    mxClone->applySpecialDrag(DragStat());
 
     // AutoGrowWidth may change for SdrTextObj due to the automatism used
     // with bDisableAutoWidthOnDragging, so not only geometry changes but
@@ -1345,7 +1327,7 @@ void SdrDragObjOwn::MoveSdrDrag(const Point& rNoSnapPnt)
     // changed, it needs to be copied to the original since nothing will
     // happen when it only changes in the drag clone
     const bool bOldAutoGrowWidth(pObj->GetMergedItem(SDRATTR_TEXT_AUTOGROWWIDTH).GetValue());
-    const bool bNewAutoGrowWidth(mpClone->GetMergedItem(SDRATTR_TEXT_AUTOGROWWIDTH).GetValue());
+    const bool bNewAutoGrowWidth(mxClone->GetMergedItem(SDRATTR_TEXT_AUTOGROWWIDTH).GetValue());
 
     if (bOldAutoGrowWidth != bNewAutoGrowWidth)
     {
@@ -3600,7 +3582,7 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
     // there are currently no easy mechanisms to plug an alternative interaction
     // from there
     SdrObject* pSdrObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
-    std::unique_ptr< SdrObject, SdrObjectFreeOp > pFullDragClone;
+    SdrObjectUniquePtr pFullDragClone;
     bool bExternal(false);
     SdrObject* pExternalSdrObject(nullptr);
 
@@ -3613,7 +3595,7 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
         // real transformation. That SdrObject is owned and has to be deleted,
         // so use a std::unique_ptr with special handling for the protected
         // SDrObject destructor
-        pFullDragClone.reset(pSdrObject->getFullDragClone());
+        pFullDragClone = pSdrObject->getFullDragClone();
 
         if(dynamic_cast< SdrGrafObj* >(pFullDragClone.get()))
         {
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index c08bd1406986..6b707aeae231 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -1300,10 +1300,10 @@ bool SdrObject::supportsFullDrag() const
     return true;
 }
 
-SdrObject* SdrObject::getFullDragClone() const
+SdrObjectUniquePtr SdrObject::getFullDragClone() const
 {
     // default uses simple clone
-    return CloneSdrObject(getSdrModelFromSdrObject());
+    return SdrObjectUniquePtr(CloneSdrObject(getSdrModelFromSdrObject()));
 }
 
 bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index db21f5fc6e73..e9d40f0f298a 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -1854,7 +1854,7 @@ bool SdrEdgeObj::hasSpecialDrag() const
     return true;
 }
 
-SdrObject* SdrEdgeObj::getFullDragClone() const
+SdrObjectUniquePtr SdrEdgeObj::getFullDragClone() const
 {
     // use Clone operator
     SdrEdgeObj* pRetval(CloneSdrObject(getSdrModelFromSdrObject()));
@@ -1863,7 +1863,7 @@ SdrObject* SdrEdgeObj::getFullDragClone() const
     pRetval->ConnectToNode(true, GetConnectedNode(true));
     pRetval->ConnectToNode(false, GetConnectedNode(false));
 
-    return pRetval;
+    return SdrObjectUniquePtr(pRetval);
 }
 
 bool SdrEdgeObj::beginSpecialDrag(SdrDragStat& rDrag) const
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index cbf3c055578b..329bbaf768ea 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -702,17 +702,17 @@ OUString SdrGrafObj::TakeObjNamePlural() const
     return sName.makeStringAndClear();
 }
 
-SdrObject* SdrGrafObj::getFullDragClone() const
+SdrObjectUniquePtr SdrGrafObj::getFullDragClone() const
 {
     // call parent
-    SdrGrafObj* pRetval = static_cast< SdrGrafObj* >(SdrRectObj::getFullDragClone());
+    SdrObjectUniquePtr pRetval = SdrRectObj::getFullDragClone();
 
     // #i103116# the full drag clone leads to problems
     // with linked graphics, so reset the link in this
     // temporary interaction object and load graphic
     if(pRetval && IsLinkedGraphic())
     {
-        pRetval->ReleaseGraphicLink();
+        static_cast< SdrGrafObj* >(pRetval.get())->ReleaseGraphicLink();
     }
 
     return pRetval;
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index bf720771bd71..f0384fbc8d3e 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1166,7 +1166,7 @@ void SdrOle2Obj::Disconnect_Impl()
     mpImpl->mbConnected = false;
 }
 
-SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
+SdrObjectUniquePtr SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
 {
     const Graphic* pOLEGraphic = GetGraphic();
 
@@ -1199,7 +1199,7 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
             }
         }
 
-        return pClone;
+        return SdrObjectUniquePtr(pClone);
     }
     else
     {
@@ -1221,20 +1221,18 @@ SdrObject* SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
         pClone->SetMergedItem(XFillBmpTileItem(false));
         pClone->SetMergedItem(XFillBmpStretchItem(false));
 
-        return pClone;
+        return SdrObjectUniquePtr(pClone);
     }
 }
 
 SdrObject* SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     // #i118485# missing converter added
-    SdrObject* pRetval = createSdrGrafObjReplacement(true);
+    SdrObjectUniquePtr pRetval = createSdrGrafObjReplacement(true);
 
     if(pRetval)
     {
         SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText);
-        SdrObject::Free(pRetval);
-
         return pRetval2;
     }
 
@@ -1305,7 +1303,7 @@ void SdrOle2Obj::SetClosedObj( bool bIsClosed )
     bClosedObj = bIsClosed;
 }
 
-SdrObject* SdrOle2Obj::getFullDragClone() const
+SdrObjectUniquePtr SdrOle2Obj::getFullDragClone() const
 {
     // #i118485# use central replacement generator
     return createSdrGrafObjReplacement(false);
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 47e46b738345..93c80ff56325 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -2034,10 +2034,10 @@ bool SdrTextObj::GetPreventChainable() const
     return mbIsUnchainableClone || (GetNextLinkInChain() && GetNextLinkInChain()->IsInEditMode());
 }
 
- SdrObject* SdrTextObj::getFullDragClone() const
- {
-    SdrObject *pClone = SdrAttrObj::getFullDragClone();
-    SdrTextObj *pTextObjClone = dynamic_cast<SdrTextObj *>(pClone);
+SdrObjectUniquePtr SdrTextObj::getFullDragClone() const
+{
+    SdrObjectUniquePtr pClone = SdrAttrObj::getFullDragClone();
+    SdrTextObj *pTextObjClone = dynamic_cast<SdrTextObj *>(pClone.get());
     if (pTextObjClone != nullptr) {
         // Avoid transferring of text for chainable object during dragging
         pTextObjClone->mbIsUnchainableClone = true;
diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx
index 18d1a92125aa..202f4632c542 100644
--- a/svx/source/svdraw/svdovirt.cxx
+++ b/svx/source/svdraw/svdovirt.cxx
@@ -234,13 +234,13 @@ bool SdrVirtObj::supportsFullDrag() const
     return false;
 }
 
-SdrObject* SdrVirtObj::getFullDragClone() const
+SdrObjectUniquePtr SdrVirtObj::getFullDragClone() const
 {
     SdrObject& rReferencedObject = const_cast<SdrVirtObj*>(this)->ReferencedObj();
-    return new SdrGrafObj(
+    return SdrObjectUniquePtr(new SdrGrafObj(
         getSdrModelFromSdrObject(),
         SdrDragView::GetObjGraphic(rReferencedObject),
-        GetLogicRect());
+        GetLogicRect()));
 }
 
 bool SdrVirtObj::beginSpecialDrag(SdrDragStat& rDrag) const
diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx
index 4b4d680001e3..f7ff362b5f15 100644
--- a/sw/source/core/draw/dflyobj.cxx
+++ b/sw/source/core/draw/dflyobj.cxx
@@ -1184,10 +1184,10 @@ long SwVirtFlyDrawObj::GetRotateAngle() const
     }
 }
 
-SdrObject* SwVirtFlyDrawObj::getFullDragClone() const
+SdrObjectUniquePtr SwVirtFlyDrawObj::getFullDragClone() const
 {
     // call parent
-    SdrObject* pRetval = SdrVirtObj::getFullDragClone();
+    SdrObjectUniquePtr pRetval = SdrVirtObj::getFullDragClone();
 
     if(pRetval && GetFlyFrame() && ContainsSwGrfNode())
     {
diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx
index 5ede9007ec24..0d0a8fdfab4c 100644
--- a/sw/source/core/inc/dflyobj.hxx
+++ b/sw/source/core/inc/dflyobj.hxx
@@ -118,7 +118,7 @@ public:
     virtual       void       Rotate(const Point& rRef, long nAngle, double sn, double cs) override;
 
     // FullDrag support
-    virtual SdrObject* getFullDragClone() const override;
+    virtual SdrObjectUniquePtr getFullDragClone() const override;
 
     const SwFrameFormat *GetFormat() const;
           SwFrameFormat *GetFormat();


More information about the Libreoffice-commits mailing list