[Libreoffice-commits] core.git: cui/source filter/source include/svx sd/source svx/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Sep 6 10:52:03 UTC 2019


 cui/source/tabpages/tplneend.cxx                      |   12 ++---
 filter/source/msfilter/escherex.cxx                   |    6 +-
 include/svx/cube3d.hxx                                |    2 
 include/svx/lathe3d.hxx                               |    2 
 include/svx/polygn3d.hxx                              |    2 
 include/svx/sphere3d.hxx                              |    2 
 include/svx/svdoashp.hxx                              |    2 
 include/svx/svdobj.hxx                                |    4 -
 include/svx/svdocapt.hxx                              |    2 
 include/svx/svdocirc.hxx                              |    2 
 include/svx/svdoedge.hxx                              |    2 
 include/svx/svdograf.hxx                              |    2 
 include/svx/svdogrp.hxx                               |    2 
 include/svx/svdomeas.hxx                              |    2 
 include/svx/svdoole2.hxx                              |    2 
 include/svx/svdopath.hxx                              |    2 
 include/svx/svdorect.hxx                              |    2 
 include/svx/svdotext.hxx                              |    2 
 sd/source/ui/func/fulinend.cxx                        |    7 +--
 sd/source/ui/func/fumorph.cxx                         |    7 ---
 svx/source/customshapes/EnhancedCustomShape3d.cxx     |    5 --
 svx/source/customshapes/EnhancedCustomShapeEngine.cxx |    7 ---
 svx/source/dialog/imapwnd.cxx                         |    4 -
 svx/source/engine3d/cube3d.cxx                        |    2 
 svx/source/engine3d/lathe3d.cxx                       |    2 
 svx/source/engine3d/polygn3d.cxx                      |    2 
 svx/source/engine3d/sphere3d.cxx                      |    2 
 svx/source/engine3d/view3d.cxx                        |    2 
 svx/source/engine3d/view3d1.cxx                       |    2 
 svx/source/svdraw/svdedtv2.cxx                        |   30 +++++-------
 svx/source/svdraw/svdfmtf.cxx                         |    2 
 svx/source/svdraw/svdoashp.cxx                        |    6 +-
 svx/source/svdraw/svdobj.cxx                          |   11 ++--
 svx/source/svdraw/svdocapt.cxx                        |   42 ++++++++++--------
 svx/source/svdraw/svdocirc.cxx                        |    4 -
 svx/source/svdraw/svdoedge.cxx                        |    4 -
 svx/source/svdraw/svdograf.cxx                        |   16 +++---
 svx/source/svdraw/svdogrp.cxx                         |    8 +--
 svx/source/svdraw/svdomeas.cxx                        |    6 +-
 svx/source/svdraw/svdoole2.cxx                        |    5 --
 svx/source/svdraw/svdopath.cxx                        |    4 -
 svx/source/svdraw/svdorect.cxx                        |    4 -
 svx/source/svdraw/svdotxtr.cxx                        |    4 -
 svx/source/svdraw/svdpdf.cxx                          |    5 --
 44 files changed, 118 insertions(+), 127 deletions(-)

New commits:
commit fc161dc07cafda54ebdabd4c66dfd6528cc11813
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Sep 6 09:14:06 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 6 12:50:57 2019 +0200

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

diff --git a/cui/source/tabpages/tplneend.cxx b/cui/source/tabpages/tplneend.cxx
index eb73de028838..7901503d2d9e 100644
--- a/cui/source/tabpages/tplneend.cxx
+++ b/cui/source/tabpages/tplneend.cxx
@@ -122,12 +122,11 @@ void SvxLineEndDefTabPage::Construct()
     {
         SdrObjTransformInfoRec aInfoRec;
         pPolyObj->TakeObjInfo( aInfoRec );
-        SdrObject* pNewObj = nullptr;
+        SdrObjectUniquePtr pNewObj;
         if( aInfoRec.bCanConvToPath )
             pNewObj = pPolyObj->ConvertToPolyObj( true, false );
 
-        bCreateArrowPossible = nullptr != dynamic_cast<const SdrPathObj*>( pNewObj);
-        SdrObject::Free( pNewObj );
+        bCreateArrowPossible = nullptr != dynamic_cast<const SdrPathObj*>( pNewObj.get());
     }
 
     if( !bCreateArrowPossible )
@@ -355,7 +354,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void)
     if( pPolyObj )
     {
         const SdrObject* pNewObj;
-        SdrObject* pConvPolyObj = nullptr;
+        SdrObjectUniquePtr pConvPolyObj;
 
         if( nullptr != dynamic_cast<const SdrPathObj*>( pPolyObj) )
         {
@@ -368,7 +367,8 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void)
 
             if( aInfoRec.bCanConvToPath )
             {
-                pNewObj = pConvPolyObj = pPolyObj->ConvertToPolyObj( true, false );
+                pConvPolyObj = pPolyObj->ConvertToPolyObj( true, false );
+                pNewObj = pConvPolyObj.get();
 
                 if( !pNewObj || nullptr == dynamic_cast<const SdrPathObj*>( pNewObj) )
                     return; // cancel, additional safety, which
@@ -383,7 +383,7 @@ IMPL_LINK_NOARG(SvxLineEndDefTabPage, ClickAddHdl_Impl, weld::Button&, void)
         // normalize
         aNewPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix( -aNewRange.getMinX(), -aNewRange.getMinY()));
 
-        SdrObject::Free( pConvPolyObj );
+        pConvPolyObj.reset();
 
         OUString aNewName(SvxResId(RID_SVXSTR_LINEEND));
         OUString aDesc(CuiResId(RID_SVXSTR_DESC_LINEEND));
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index a5caf5328a40..1d0314702a1c 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -4616,8 +4616,8 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
                 else if ( nGluePointType == drawing::EnhancedCustomShapeGluePointType::SEGMENTS )
                 {
                     tools::PolyPolygon aPolyPoly;
-                    SdrObject* pTemporyryConvertResultObject(rSdrObjCustomShape.DoConvertToPolyObj(true, true));
-                    SdrPathObj* pSdrPathObj(dynamic_cast< SdrPathObj* >(pTemporyryConvertResultObject));
+                    SdrObjectUniquePtr pTemporyryConvertResultObject(rSdrObjCustomShape.DoConvertToPolyObj(true, true));
+                    SdrPathObj* pSdrPathObj(dynamic_cast< SdrPathObj* >(pTemporyryConvertResultObject.get()));
 
                     if(pSdrPathObj)
                     {
@@ -4627,7 +4627,7 @@ sal_uInt32 EscherConnectorListEntry::GetConnectorRule( bool bFirst )
                     }
 
                     // do *not* forget to delete the temporary used SdrObject - possible memory leak (!)
-                    SdrObject::Free(pTemporyryConvertResultObject);
+                    pTemporyryConvertResultObject.reset();
                     pSdrPathObj = nullptr;
 
                     if(0 != aPolyPoly.Count())
diff --git a/include/svx/cube3d.hxx b/include/svx/cube3d.hxx
index 4f8a3f23c25d..1556c0f85087 100644
--- a/include/svx/cube3d.hxx
+++ b/include/svx/cube3d.hxx
@@ -68,7 +68,7 @@ public:
     E3dCubeObj(SdrModel& rSdrModel);
 
     virtual sal_uInt16 GetObjIdentifier() const override;
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     virtual E3dCubeObj* CloneSdrObject(SdrModel& rTargetModel) const override;
 
diff --git a/include/svx/lathe3d.hxx b/include/svx/lathe3d.hxx
index 4313e74bddb6..2e92883b1977 100644
--- a/include/svx/lathe3d.hxx
+++ b/include/svx/lathe3d.hxx
@@ -105,7 +105,7 @@ public:
     // implemented mainly for the purposes of Clone()
     E3dLatheObj& operator=(const E3dLatheObj& rObj);
 
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     // TakeObjName...() is for the display in the UI, for example "3 frames selected".
     virtual OUString TakeObjNameSingul() const override;
diff --git a/include/svx/polygn3d.hxx b/include/svx/polygn3d.hxx
index 9d5940adf9e4..1a1cd1b6b982 100644
--- a/include/svx/polygn3d.hxx
+++ b/include/svx/polygn3d.hxx
@@ -56,7 +56,7 @@ public:
     const basegfx::B2DPolyPolygon& GetPolyTexture2D() const { return aPolyTexture2D; }
 
     virtual sal_uInt16 GetObjIdentifier() const override;
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     virtual E3dPolygonObj* CloneSdrObject(SdrModel& rTargetModel) const override;
 
diff --git a/include/svx/sphere3d.hxx b/include/svx/sphere3d.hxx
index 345ae1991782..03a78ae36d68 100644
--- a/include/svx/sphere3d.hxx
+++ b/include/svx/sphere3d.hxx
@@ -67,7 +67,7 @@ public:
         { return GetObjectItemSet().Get(SDRATTR_3DOBJ_VERT_SEGS).GetValue(); }
 
     virtual sal_uInt16 GetObjIdentifier() const override;
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     virtual E3dSphereObj* CloneSdrObject(SdrModel& rTargetModel) const override;
 
diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx
index 32f9b0e49577..fb6bdaeba606 100644
--- a/include/svx/svdoashp.hxx
+++ b/include/svx/svdoashp.hxx
@@ -222,7 +222,7 @@ public:
 
     virtual void NbcSetOutlinerParaObject(std::unique_ptr<OutlinerParaObject> pTextObject) override;
 
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     // react on model/page change
     virtual void handlePageChange(SdrPage* pOldPage, SdrPage* pNewPage) override;
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index 86c1f06180f1..46d81b7f4bbb 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -767,8 +767,8 @@ public:
     // In the case of the conversion from TextObj to PathObj,
     // both modi (bLineToArea=true/false) would be identical.
     // The methods' default implementations report "I'm unable to do this" (false/null).
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const;
-    SdrObject* ConvertToPolyObj(bool bBezier, bool bLineToArea) const;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const;
+    SdrObjectUniquePtr ConvertToPolyObj(bool bBezier, bool bLineToArea) const;
 
     // convert this path object to contour object; bForceLineDash converts even
     // when there is no filled new polygon created from line-to-polygon conversion,
diff --git a/include/svx/svdocapt.hxx b/include/svx/svdocapt.hxx
index 89942a7b9154..c6d31fd0682f 100644
--- a/include/svx/svdocapt.hxx
+++ b/include/svx/svdocapt.hxx
@@ -140,7 +140,7 @@ protected:
     virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
 
 public:
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     const Point& GetTailPos() const;
     void SetTailPos(const Point& rPos);
diff --git a/include/svx/svdocirc.hxx b/include/svx/svdocirc.hxx
index b628811bdba3..7d26ba9bca75 100644
--- a/include/svx/svdocirc.hxx
+++ b/include/svx/svdocirc.hxx
@@ -131,7 +131,7 @@ public:
     virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
     virtual void NbcMirror(const Point& rRef1, const Point& rRef2) override;
     virtual void NbcShear (const Point& rRef, long nAngle, double tn, bool bVShear) override;
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
 private:
     virtual SdrObjGeoData* NewGeoData() const override;
diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx
index 5d7fac34850c..056c19ccae35 100644
--- a/include/svx/svdoedge.hxx
+++ b/include/svx/svdoedge.hxx
@@ -257,7 +257,7 @@ public:
     virtual void BrkCreate(SdrDragStat& rStat) override;
     virtual basegfx::B2DPolyPolygon TakeCreatePoly(const SdrDragStat& rDrag) const override;
     virtual PointerStyle GetCreatePointer() const override;
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     virtual sal_uInt32 GetSnapPointCount() const override;
     virtual Point GetSnapPoint(sal_uInt32 i) const override;
diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx
index b905db092f5d..2ea564bdbbb9 100644
--- a/include/svx/svdograf.hxx
+++ b/include/svx/svdograf.hxx
@@ -206,7 +206,7 @@ public:
     /// Returns the page number of the embedded data (typically to re-render or import it).
     sal_Int32 getEmbeddedPageNumber() const;
 
-    virtual SdrObject*      DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     virtual void            AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override;
 
diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx
index 1f2fcce6ec3f..f30afc12c62b 100644
--- a/include/svx/svdogrp.hxx
+++ b/include/svx/svdogrp.hxx
@@ -104,7 +104,7 @@ public:
 
     virtual void NbcReformatText() override;
 
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 };
diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx
index 4007d46be3a8..faf69212f32f 100644
--- a/include/svx/svdomeas.hxx
+++ b/include/svx/svdomeas.hxx
@@ -127,7 +127,7 @@ public:
     virtual Point GetPoint(sal_uInt32 i) const override;
     virtual void NbcSetPoint(const Point& rPnt, sal_uInt32 i) override;
 
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     virtual bool BegTextEdit(SdrOutliner& rOutl) override;
     virtual const Size& GetTextSize() const override;
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx
index c8fe2b14f09a..d62f989f9fe5 100644
--- a/include/svx/svdoole2.hxx
+++ b/include/svx/svdoole2.hxx
@@ -182,7 +182,7 @@ public:
     void SetWindow(const css::uno::Reference < css::awt::XWindow >& _xWindow);
 
     // #i118485# missing converter added
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 };
 
 class SVX_DLLPUBLIC SdrEmbedObjectLink : public sfx2::SvBaseLink
diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx
index 2e7671a6818d..027996240359 100644
--- a/include/svx/svdopath.hxx
+++ b/include/svx/svdopath.hxx
@@ -133,7 +133,7 @@ private:
     virtual void RestGeoData(const SdrObjGeoData& rGeo) override;
 
 public:
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     // Bezier-polygon getter/setter
     const basegfx::B2DPolyPolygon& GetPathPoly() const { return maPathPolygon; }
diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx
index 60e4968ecbe1..a633706ab5f4 100644
--- a/include/svx/svdorect.hxx
+++ b/include/svx/svdorect.hxx
@@ -119,7 +119,7 @@ public:
     virtual SdrGluePoint GetVertexGluePoint(sal_uInt16 nNum) const override;
     virtual SdrGluePoint GetCornerGluePoint(sal_uInt16 nNum) const override;
 
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
 };
diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 2ddee8a32cf3..6cb3b5377e12 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -499,7 +499,7 @@ public:
     virtual bool CalcFieldValue(const SvxFieldItem& rField, sal_Int32 nPara, sal_uInt16 nPos,
         bool bEdit, boost::optional<Color>& rpTxtColor, boost::optional<Color>& rpFldColor, OUString& rRet) const;
 
-    virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
+    virtual SdrObjectUniquePtr DoConvertToPolyObj(bool bBezier, bool bAddText) const override;
 
     void SetTextEditOutliner(SdrOutliner* pOutl) { pEdtOutl=pOutl; }
 
diff --git a/sd/source/ui/func/fulinend.cxx b/sd/source/ui/func/fulinend.cxx
index 6f9df0b16028..8d3886a6be4d 100644
--- a/sd/source/ui/func/fulinend.cxx
+++ b/sd/source/ui/func/fulinend.cxx
@@ -58,7 +58,7 @@ void FuLineEnd::DoExecute( SfxRequest& )
 
     const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     const SdrObject* pNewObj;
-    SdrObject* pConvPolyObj = nullptr;
+    SdrObjectUniquePtr pConvPolyObj;
 
     if( dynamic_cast< const SdrPathObj *>( pObj ) !=  nullptr )
     {
@@ -75,7 +75,8 @@ void FuLineEnd::DoExecute( SfxRequest& )
             // bCanConvToPath is sal_True for group objects,
             // but it crashes on ConvertToPathObj()!
         {
-            pNewObj = pConvPolyObj = pObj->ConvertToPolyObj( true, false );
+            pConvPolyObj = pObj->ConvertToPolyObj( true, false );
+            pNewObj = pConvPolyObj.get();
 
             if( !pNewObj || dynamic_cast< const SdrPathObj *>( pNewObj ) ==  nullptr )
                 return; // Cancel, additional security, but it does not help
@@ -87,7 +88,7 @@ void FuLineEnd::DoExecute( SfxRequest& )
     const ::basegfx::B2DPolyPolygon aPolyPolygon = static_cast<const SdrPathObj*>(pNewObj)->GetPathPoly();
 
     // Delete the created poly-object
-    SdrObject::Free( pConvPolyObj );
+    pConvPolyObj.reset();
 
     XLineEndListRef pLineEndList = mpDoc->GetLineEndList();
 
diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx
index f9827986f9da..72223999498a 100644
--- a/sd/source/ui/func/fumorph.cxx
+++ b/sd/source/ui/func/fumorph.cxx
@@ -90,8 +90,8 @@ void FuMorph::DoExecute( SfxRequest& )
     pCloneObj2->SetOutlinerParaObject(nullptr);
 
     // create path objects
-    SdrObject*  pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false);
-    SdrObject*  pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false);
+    SdrObjectUniquePtr pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false);
+    SdrObjectUniquePtr pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false);
     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     ScopedVclPtr<AbstractMorphDlg> pDlg( pFact->CreateMorphDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr, pObj1, pObj2) );
     if(pPolyObj1 && pPolyObj2 && (pDlg->Execute() == RET_OK))
@@ -173,9 +173,6 @@ void FuMorph::DoExecute( SfxRequest& )
     }
     SdrObject::Free( pCloneObj1 );
     SdrObject::Free( pCloneObj2 );
-
-    SdrObject::Free( pPolyObj1 );
-    SdrObject::Free( pPolyObj2 );
 }
 
 static ::basegfx::B2DPolygon ImpGetExpandedPolygon(
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
index 2d53139baea4..339f99fd3b59 100644
--- a/svx/source/customshapes/EnhancedCustomShape3d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -459,11 +459,10 @@ SdrObject* EnhancedCustomShape3d::Create3DObject(
             }
             else
             {
-                SdrObject* pNewObj = pNext->ConvertToPolyObj( false, false );
-                SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj  );
+                SdrObjectUniquePtr pNewObj = pNext->ConvertToPolyObj( false, false );
+                SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() );
                 if ( pPath )
                     aPolyPoly = pPath->GetPathPoly();
-                SdrObject::Free( pNewObj );
             }
 
             if( aPolyPoly.count() )
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
index 95cb473a86a2..a7b08f99afc4 100644
--- a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -459,7 +459,6 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom
 
             while ( aIter.IsMore() )
             {
-                SdrObject* pNewObj = nullptr;
                 basegfx::B2DPolyPolygon aPP;
                 const SdrObject* pNext = aIter.Next();
 
@@ -469,16 +468,14 @@ drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeom
                 }
                 else
                 {
-                    pNewObj = pNext->ConvertToPolyObj( false, false );
-                    SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj  );
+                    SdrObjectUniquePtr pNewObj = pNext->ConvertToPolyObj( false, false );
+                    SdrPathObj* pPath = dynamic_cast<SdrPathObj*>( pNewObj.get() );
                     if ( pPath )
                         aPP = pPath->GetPathPoly();
                 }
 
                 if ( aPP.count() )
                     aPolyPolygon.append(aPP);
-
-                SdrObject::Free( pNewObj );
             }
             SdrObject::Free( pObj );
             basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( aPolyPolygon,
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index 3a5d0b4ea6b4..55ebd74a2d32 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -317,7 +317,7 @@ void IMapWindow::SdrObjCreated( const SdrObject& rObj )
         case OBJ_CIRC:
         {
             SdrCircObj* pCircObj = const_cast<SdrCircObj*>( static_cast<const SdrCircObj*>(&rObj) );
-            SdrPathObj* pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ) );
+            SdrPathObj* pPathObj = static_cast<SdrPathObj*>( pCircObj->ConvertToPolyObj( false, false ).release() );
             tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0));
 
             // always use SdrObject::Free(...) for SdrObjects (!)
@@ -386,7 +386,7 @@ void IMapWindow::SdrObjChanged( const SdrObject& rObj )
             case OBJ_CIRC:
             {
                 const SdrCircObj& rCircObj = static_cast<const SdrCircObj&>(rObj);
-                SdrPathObj* pPathObj = static_cast<SdrPathObj*>( rCircObj.ConvertToPolyObj( false, false ) );
+                SdrPathObj* pPathObj = static_cast<SdrPathObj*>( rCircObj.ConvertToPolyObj( false, false ).release() );
                 tools::Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0));
 
                 IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, "", bActive, false );
diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx
index 8d2758f67fc6..2a092ef89fec 100644
--- a/svx/source/engine3d/cube3d.cxx
+++ b/svx/source/engine3d/cube3d.cxx
@@ -78,7 +78,7 @@ sal_uInt16 E3dCubeObj::GetObjIdentifier() const
 
 // Convert the object into a group object consisting of 6 polygons
 
-SdrObject *E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+SdrObjectUniquePtr E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
 {
     return nullptr;
 }
diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx
index bc5bbd32fce2..1b6b16557e9b 100644
--- a/svx/source/engine3d/lathe3d.cxx
+++ b/svx/source/engine3d/lathe3d.cxx
@@ -128,7 +128,7 @@ E3dLatheObj& E3dLatheObj::operator=(const E3dLatheObj& rObj)
 
 // Convert the object to group object consisting of n polygons
 
-SdrObject *E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+SdrObjectUniquePtr E3dLatheObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
 {
     return nullptr;
 }
diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx
index d5136106ab99..b69a4ad35231 100644
--- a/svx/source/engine3d/polygn3d.cxx
+++ b/svx/source/engine3d/polygn3d.cxx
@@ -213,7 +213,7 @@ void E3dPolygonObj::SetPolyTexture2D(const basegfx::B2DPolyPolygon& rNewPolyText
 
 // Convert the object into a group object consisting of 6 polygons
 
-SdrObject *E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+SdrObjectUniquePtr E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
 {
     return nullptr;
 }
diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx
index 4beaf3b1e811..0f5f9b5d88df 100644
--- a/svx/source/engine3d/sphere3d.cxx
+++ b/svx/source/engine3d/sphere3d.cxx
@@ -87,7 +87,7 @@ sal_uInt16 E3dSphereObj::GetObjIdentifier() const
 
 // Convert the object into a group object consisting of n polygons
 
-SdrObject *E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+SdrObjectUniquePtr E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
 {
     return nullptr;
 }
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
index 67b974b26cb0..832d71b42f68 100644
--- a/svx/source/engine3d/view3d.cxx
+++ b/svx/source/engine3d/view3d.cxx
@@ -789,7 +789,7 @@ void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, bool bExtrude
             ImpChangeSomeAttributesFor3DConversion(pObj);
 
         // convert completely to path objects
-        SdrObject* pNewObj1 = pObj->ConvertToPolyObj(false, false);
+        SdrObject* pNewObj1 = pObj->ConvertToPolyObj(false, false).release();
 
         if(pNewObj1)
         {
diff --git a/svx/source/engine3d/view3d1.cxx b/svx/source/engine3d/view3d1.cxx
index b7e9830ef3d4..6f275fb2a919 100644
--- a/svx/source/engine3d/view3d1.cxx
+++ b/svx/source/engine3d/view3d1.cxx
@@ -56,7 +56,7 @@ void E3dView::ConvertMarkedToPolyObj()
             auto pScene = dynamic_cast< const E3dScene* >(pObj);
             if (pScene)
             {
-                pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/);
+                pNewObj = pScene->ConvertToPolyObj(false/*bBezier*/, false/*bLineToArea*/).release();
                 if (pNewObj)
                 {
                     BegUndo(SvxResId(RID_SVX_3D_UNDO_EXTRUDE));
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 5a7bf23d64f4..f0836ed14f69 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -632,7 +632,7 @@ basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon1(const SdrObject* pObj)
     }
     else
     {
-        SdrObject* pConvObj = pObj->ConvertToPolyObj(true/*bCombine*/, false);
+        SdrObjectUniquePtr pConvObj = pObj->ConvertToPolyObj(true/*bCombine*/, false);
 
         if(pConvObj)
         {
@@ -655,15 +655,13 @@ basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon1(const SdrObject* pObj)
             }
             else
             {
-                pPath = dynamic_cast<SdrPathObj*>( pConvObj );
+                pPath = dynamic_cast<SdrPathObj*>( pConvObj.get() );
 
                 if(pPath)
                 {
                     aRetval = pPath->GetPathPoly();
                 }
             }
-
-            SdrObject::Free( pConvObj );
         }
     }
 
@@ -1970,24 +1968,20 @@ void SdrEditView::UnGroupMarked()
 
 SdrObject* SdrEditView::ImpConvertOneObj(SdrObject* pObj, bool bPath, bool bLineToArea)
 {
-    SdrObject* pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea);
-    if (pNewObj!=nullptr)
+    SdrObjectUniquePtr pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea);
+    if (pNewObj)
     {
-        SdrObjList* pOL=pObj->getParentSdrObjListFromSdrObject();
-        DBG_ASSERT(pOL!=nullptr,"ConvertTo: Object doesn't return object list");
-        if (pOL!=nullptr)
-        {
-            const bool bUndo = IsUndoEnabled();
-            if( bUndo )
-                AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj));
+        SdrObjList* pOL = pObj->getParentSdrObjListFromSdrObject();
+        const bool bUndo = IsUndoEnabled();
+        if( bUndo )
+            AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj));
 
-            pOL->ReplaceObject(pNewObj,pObj->GetOrdNum());
+        pOL->ReplaceObject(pNewObj.get(), pObj->GetOrdNum());
 
-            if( !bUndo )
-                SdrObject::Free(pObj);
-        }
+        if( !bUndo )
+            SdrObject::Free(pObj);
     }
-    return pNewObj;
+    return pNewObj.release();
 }
 
 void SdrEditView::ImpConvertTo(bool bPath, bool bLineToArea)
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
index e460361efe8d..f850e6fadf1f 100644
--- a/svx/source/svdraw/svdfmtf.cxx
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -500,7 +500,7 @@ void ImpSdrGDIMetaFileImport::InsertObj(SdrObject* pObj, bool bScale)
 
                 // here text needs to be clipped; to do so, convert to SdrObjects with polygons
                 // and add these recursively. Delete original object, do not add in this run
-                SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
+                SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true).release();
                 SdrObject::Free(pObj);
 
                 if(pConverted)
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index d42b0d17e81e..2b5da22e606d 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -2799,7 +2799,7 @@ basegfx::B2DPolyPolygon SdrObjCustomShape::TakeContour() const
     return basegfx::B2DPolyPolygon();
 }
 
-SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     // #i37011#
     SdrObjectUniquePtr pRetval;
@@ -2821,7 +2821,7 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co
         // Clone to same SdrModel
         SdrObject* pCandidate(pRenderedCustomShape->CloneSdrObject(pRenderedCustomShape->getSdrModelFromSdrObject()));
         DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
-        pRetval.reset(pCandidate->DoConvertToPolyObj(bBezier, bAddText));
+        pRetval = pCandidate->DoConvertToPolyObj(bBezier, bAddText);
         SdrObject::Free( pCandidate );
 
         if(pRetval)
@@ -2839,7 +2839,7 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co
         }
     }
 
-    return pRetval.release();
+    return pRetval;
 }
 
 void SdrObjCustomShape::NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr )
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 6b707aeae231..c1cb84e9b3c0 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -2531,15 +2531,14 @@ SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, bool bForceLineDash)
 }
 
 
-SdrObject* SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const
+SdrObjectUniquePtr SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const
 {
-    SdrObject* pRet = DoConvertToPolyObj(bBezier, true);
+    SdrObjectUniquePtr pRet = DoConvertToPolyObj(bBezier, true);
 
     if(pRet && bLineToArea)
     {
-        SdrObject* pNewRet = ConvertToContourObj(pRet);
-        delete pRet;
-        pRet = pNewRet;
+        SdrObject* pNewRet = ConvertToContourObj(pRet.get());
+        pRet.reset(pNewRet);
     }
 
     // #i73441# preserve LayerID
@@ -2552,7 +2551,7 @@ SdrObject* SdrObject::ConvertToPolyObj(bool bBezier, bool bLineToArea) const
 }
 
 
-SdrObject* SdrObject::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
+SdrObjectUniquePtr SdrObject::DoConvertToPolyObj(bool /*bBezier*/, bool /*bAddText*/) const
 {
     return nullptr;
 }
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
index d07dccc980dc..7e104c45c321 100644
--- a/svx/source/svdraw/svdocapt.cxx
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -694,26 +694,34 @@ void SdrCaptionObj::RestGeoData(const SdrObjGeoData& rGeo)
     aTailPoly=rCGeo.aTailPoly;
 }
 
-SdrObject* SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
-{
-    SdrObject* pRect=SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
-    SdrObject* pTail = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aTailPoly.getB2DPolygon()), false, bBezier).release();
-    SdrObject* pRet=(pTail!=nullptr) ? pTail : pRect;
-    if (pTail!=nullptr && pRect!=nullptr) {
-        bool bInsRect = true;
-        bool bInsTail = true;
-        SdrObjList* pOL=pTail->GetSubList();
-        if (pOL!=nullptr) { pRet=pRect; bInsTail = false; }
-        if (pOL==nullptr) pOL=pRect->GetSubList();
-        if (pOL!=nullptr) { pRet=pRect; bInsRect = false; }
-        if (pOL==nullptr)
+SdrObjectUniquePtr SdrCaptionObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+{
+    SdrObjectUniquePtr pRect = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
+    SdrObjectUniquePtr pTail = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aTailPoly.getB2DPolygon()), false, bBezier);
+    SdrObjectUniquePtr pRet;
+    if (pTail && !pRect)
+        pRet = std::move(pTail);
+    else if (pRect && !pTail)
+        pRet = std::move(pRect);
+    else if (pTail && pRect)
+    {
+        if (pTail->GetSubList())
+        {
+            pTail->GetSubList()->NbcInsertObject(pRect.release());
+            pRet = std::move(pTail);
+        }
+        else if (pRect->GetSubList())
+        {
+            pRect->GetSubList()->NbcInsertObject(pTail.release(),0);
+            pRet = std::move(pRect);
+        }
+        else
         {
             SdrObjGroup* pGrp = new SdrObjGroup(getSdrModelFromSdrObject());
-            pOL=pGrp->GetSubList();
-            pRet=pGrp;
+            pGrp->GetSubList()->NbcInsertObject(pRect.release());
+            pGrp->GetSubList()->NbcInsertObject(pTail.release(),0);
+            pRet.reset(pGrp);
         }
-        if (bInsRect) pOL->NbcInsertObject(pRect);
-        if (bInsTail) pOL->NbcInsertObject(pTail,0);
     }
     return pRet;
 }
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 6e05fce61690..29a5e54fb336 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -1147,7 +1147,7 @@ void SdrCircObj::ImpSetCircInfoToAttr()
     }
 }
 
-SdrObject* SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     const bool bFill(meCircleKind != SdrCircKind::Arc);
     const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle));
@@ -1158,7 +1158,7 @@ SdrObject* SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
         pRet = ImpConvertAddText(std::move(pRet), bBezier);
     }
 
-    return pRet.release();
+    return pRet;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index 97c057836359..a06fde26b304 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -2401,7 +2401,7 @@ void SdrEdgeObj::NbcShear(const Point& rRef, long nAngle, double tn, bool bVShea
     }
 }
 
-SdrObject* SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     basegfx::B2DPolyPolygon aPolyPolygon;
     aPolyPolygon.append(pEdgeTrack->getB2DPolygon());
@@ -2412,7 +2412,7 @@ SdrObject* SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
         pRet = ImpConvertAddText(std::move(pRet), bBezier);
     }
 
-    return pRet.release();
+    return pRet;
 }
 
 sal_uInt32 SdrEdgeObj::GetSnapPointCount() const
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 306f0543ab97..7e14a6d3bdd9 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -917,7 +917,7 @@ sal_Int32 SdrGrafObj::getEmbeddedPageNumber() const
    return mpGraphicObject->GetGraphic().getPageNumber();
 }
 
-SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
+SdrObjectUniquePtr SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
 {
     SdrObject* pRetval = nullptr;
     GraphicType aGraphicType(GetGraphicType());
@@ -964,7 +964,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
                 if( pRetval )
                 {
                     SdrObject* pHalfDone = pRetval;
-                    pRetval = pHalfDone->DoConvertToPolyObj(bBezier, bAddText);
+                    pRetval = pRetval->DoConvertToPolyObj(bBezier, bAddText).release();
                     SdrObject::Free( pHalfDone ); // resulting object is newly created
 
                     if( pRetval )
@@ -987,7 +987,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
             }
 
             // #i118485# convert line and fill
-            SdrObject* pLineFill = SdrRectObj::DoConvertToPolyObj(bBezier, false);
+            SdrObjectUniquePtr pLineFill = SdrRectObj::DoConvertToPolyObj(bBezier, false);
 
             if(pLineFill)
             {
@@ -1002,11 +1002,11 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
                         pGrp->GetSubList()->NbcInsertObject(pRetval);
                     }
 
-                    pGrp->GetSubList()->NbcInsertObject(pLineFill, 0);
+                    pGrp->GetSubList()->NbcInsertObject(pLineFill.release(), 0);
                 }
                 else
                 {
-                    pRetval = pLineFill;
+                    pRetval = pLineFill.release();
                 }
             }
 
@@ -1015,7 +1015,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
         case GraphicType::Bitmap:
         {
             // create basic object and add fill
-            pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
+            pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText).release();
 
             // save bitmap as an attribute
             if(pRetval)
@@ -1035,12 +1035,12 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
         case GraphicType::NONE:
         case GraphicType::Default:
         {
-            pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText);
+            pRetval = SdrRectObj::DoConvertToPolyObj(bBezier, bAddText).release();
             break;
         }
     }
 
-    return pRetval;
+    return SdrObjectUniquePtr(pRetval);
 }
 
 void SdrGrafObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
index c50ba9524908..4121332d441c 100644
--- a/svx/source/svdraw/svdogrp.cxx
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -775,19 +775,19 @@ void SdrObjGroup::NbcReformatText()
     NbcReformatAllTextObjects();
 }
 
-SdrObject* SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrObjGroup::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
-    SdrObject* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+    SdrObjectUniquePtr pGroup( new SdrObjGroup(getSdrModelFromSdrObject()) );
     const size_t nObjCount(GetObjCount());
 
     for(size_t a=0; a < nObjCount; ++a)
     {
         SdrObject* pIterObj(GetObj(a));
-        SdrObject* pResult(pIterObj->DoConvertToPolyObj(bBezier, bAddText));
+        SdrObjectUniquePtr pResult(pIterObj->DoConvertToPolyObj(bBezier, bAddText));
 
         // pResult can be NULL e.g. for empty objects
         if( pResult )
-            pGroup->GetSubList()->NbcInsertObject(pResult);
+            pGroup->GetSubList()->NbcInsertObject(pResult.release());
     }
 
     return pGroup;
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 7f01b2074582..c992fadae228 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -1131,7 +1131,7 @@ void SdrMeasureObj::RestGeoData(const SdrObjGeoData& rGeo)
     SetTextDirty();
 }
 
-SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     // get XOR Poly as base
     XPolyPolygon aTmpPolyPolygon(TakeXorPoly());
@@ -1259,11 +1259,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 
     if(bAddText)
     {
-        return ImpConvertAddText(std::move(pGroup), bBezier).release();
+        return ImpConvertAddText(std::move(pGroup), bBezier);
     }
     else
     {
-        return pGroup.release();
+        return pGroup;
     }
 }
 
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
index f0384fbc8d3e..604d6c8eb9a5 100644
--- a/svx/source/svdraw/svdoole2.cxx
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -1225,15 +1225,14 @@ SdrObjectUniquePtr SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText) const
     }
 }
 
-SdrObject* SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrOle2Obj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     // #i118485# missing converter added
     SdrObjectUniquePtr pRetval = createSdrGrafObjReplacement(true);
 
     if(pRetval)
     {
-        SdrObject* pRetval2 = pRetval->DoConvertToPolyObj(bBezier, bAddText);
-        return pRetval2;
+        return pRetval->DoConvertToPolyObj(bBezier, bAddText);
     }
 
     return nullptr;
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index e15e8a6b8e55..6cec19162691 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -2668,7 +2668,7 @@ SdrObject* SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index)
     return pNewObj;
 }
 
-SdrObject* SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     // #i89784# check for FontWork with activated HideContour
     const drawinglayer::attribute::SdrTextAttribute aText(
@@ -2706,7 +2706,7 @@ SdrObject* SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
         pRet = ImpConvertAddText(std::move(pRet), bBezier);
     }
 
-    return pRet.release();
+    return pRet;
 }
 
 SdrObjGeoData* SdrPathObj::NewGeoData() const
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index 43da02b4c7d2..5a4faf6b1337 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -554,7 +554,7 @@ SdrGluePoint SdrRectObj::GetCornerGluePoint(sal_uInt16 nPosNum) const
     return aGP;
 }
 
-SdrObject* SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     XPolygon aXP(ImpCalcXPoly(maRect,GetEckenradius()));
     { // TODO: this is only for the moment, until we have the new TakeContour()
@@ -579,7 +579,7 @@ SdrObject* SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
         pRet = ImpConvertAddText(std::move(pRet), bBezier);
     }
 
-    return pRet.release();
+    return pRet;
 }
 
 void SdrRectObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index d4203b212cd2..f3fe7dfe0a69 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -415,11 +415,11 @@ SdrObjectUniquePtr SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly
 }
 
 
-SdrObject* SdrTextObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
+SdrObjectUniquePtr SdrTextObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     if(bAddText)
     {
-        return ImpConvertContainedTextToSdrPathObjs(!bBezier).release();
+        return ImpConvertContainedTextToSdrPathObjs(!bBezier);
     }
 
     return nullptr;
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 6ac08e5e7f9d..a5f47cc94e8e 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -527,7 +527,7 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
 
                 // here text needs to be clipped; to do so, convert to SdrObjects with polygons
                 // and add these recursively. Delete original object, do not add in this run
-                SdrObject* pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
+                SdrObjectUniquePtr pConverted = pSdrTextObj->ConvertToPolyObj(true, true);
                 SdrObject::Free(pObj);
 
                 if (pConverted)
@@ -557,9 +557,6 @@ void ImpSdrPdfImport::InsertObj(SdrObject* pObj, bool bScale)
                             OSL_ENSURE(false, "SdrObject::Clone() failed (!)");
                         }
                     }
-
-                    // cleanup temporary conversion objects
-                    SdrObject::Free(pConverted);
                 }
 
                 break;


More information about the Libreoffice-commits mailing list