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

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


 include/svx/svdotext.hxx       |    4 ++--
 svx/source/svdraw/svdoashp.cxx |    8 ++++----
 svx/source/svdraw/svdocirc.cxx |    6 +++---
 svx/source/svdraw/svdoedge.cxx |    6 +++---
 svx/source/svdraw/svdograf.cxx |    2 +-
 svx/source/svdraw/svdomeas.cxx |    6 +++---
 svx/source/svdraw/svdopath.cxx |    8 ++++----
 svx/source/svdraw/svdorect.cxx |    8 ++++----
 svx/source/svdraw/svdotxtr.cxx |   22 +++++++++++-----------
 9 files changed, 35 insertions(+), 35 deletions(-)

New commits:
commit 396473a3d6ddd1f1ee2d4e0fd3bae5c41d2cc3fd
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Sep 5 20:52:48 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 6 08:50:50 2019 +0200

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

diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx
index 51dae6373526..2ddee8a32cf3 100644
--- a/include/svx/svdotext.hxx
+++ b/include/svx/svdotext.hxx
@@ -264,7 +264,7 @@ private:
                                        Fraction&        aFitXCorrection ) const;
     void ImpAutoFitText( SdrOutliner& rOutliner ) const;
     static void ImpAutoFitText( SdrOutliner& rOutliner, const Size& rShapeSize, bool bIsVerticalWriting );
-    SVX_DLLPRIVATE SdrObject* ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const;
+    SVX_DLLPRIVATE SdrObjectUniquePtr ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const;
     SVX_DLLPRIVATE void ImpRegisterLink();
     SVX_DLLPRIVATE void ImpDeregisterLink();
     SVX_DLLPRIVATE ImpSdrObjTextLinkUserData* GetLinkUserData() const;
@@ -278,7 +278,7 @@ private:
 protected:
     bool ImpCanConvTextToCurve() const;
     SdrPathObjUniquePtr ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, bool bClosed, bool bBezier) const;
-    SdrObject* ImpConvertAddText(SdrObject* pObj, bool bBezier) const;
+    SdrObjectUniquePtr ImpConvertAddText(SdrObjectUniquePtr pObj, bool bBezier) const;
     void ImpSetTextStyleSheetListeners();
     static void ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, Fraction& rFitXCorrection);
     static void ImpJustifyRect(tools::Rectangle& rRect);
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 70c523de5c56..d42b0d17e81e 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -2802,7 +2802,7 @@ basegfx::B2DPolyPolygon SdrObjCustomShape::TakeContour() const
 SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     // #i37011#
-    SdrObject* pRetval = nullptr;
+    SdrObjectUniquePtr pRetval;
     SdrObject* pRenderedCustomShape = nullptr;
 
     if ( !mXRenderedCustomShape.is() )
@@ -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 = pCandidate->DoConvertToPolyObj(bBezier, bAddText);
+        pRetval.reset(pCandidate->DoConvertToPolyObj(bBezier, bAddText));
         SdrObject::Free( pCandidate );
 
         if(pRetval)
@@ -2835,11 +2835,11 @@ SdrObject* SdrObjCustomShape::DoConvertToPolyObj(bool bBezier, bool bAddText) co
 
         if(bAddText && HasText() && !IsTextPath())
         {
-            pRetval = ImpConvertAddText(pRetval, bBezier);
+            pRetval = ImpConvertAddText(std::move(pRetval), bBezier);
         }
     }
 
-    return pRetval;
+    return pRetval.release();
 }
 
 void SdrObjCustomShape::NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr )
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 2af9ac8e6d09..6e05fce61690 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -1151,14 +1151,14 @@ SdrObject* SdrCircObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     const bool bFill(meCircleKind != SdrCircKind::Arc);
     const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle));
-    SdrObject* pRet = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aCircPolygon), bFill, bBezier).release();
+    SdrObjectUniquePtr pRet = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aCircPolygon), bFill, bBezier);
 
     if(bAddText)
     {
-        pRet = ImpConvertAddText(pRet, bBezier);
+        pRet = ImpConvertAddText(std::move(pRet), bBezier);
     }
 
-    return pRet;
+    return pRet.release();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index 07512a1e01d5..97c057836359 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -2405,14 +2405,14 @@ SdrObject* SdrEdgeObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     basegfx::B2DPolyPolygon aPolyPolygon;
     aPolyPolygon.append(pEdgeTrack->getB2DPolygon());
-    SdrObject* pRet = ImpConvertMakeObj(aPolyPolygon, false, bBezier).release();
+    SdrObjectUniquePtr pRet = ImpConvertMakeObj(aPolyPolygon, false, bBezier);
 
     if(bAddText)
     {
-        pRet = ImpConvertAddText(pRet, bBezier);
+        pRet = ImpConvertAddText(std::move(pRet), bBezier);
     }
 
-    return pRet;
+    return pRet.release();
 }
 
 sal_uInt32 SdrEdgeObj::GetSnapPointCount() const
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 329bbaf768ea..306f0543ab97 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -957,7 +957,7 @@ SdrObject* SdrGrafObj::DoConvertToPolyObj(bool bBezier, bool bAddText ) const
 
                 if(bAddText)
                 {
-                    pRetval = ImpConvertAddText(pRetval, bBezier);
+                    pRetval = ImpConvertAddText(SdrObjectUniquePtr(pRetval), bBezier).release();
                 }
 
                 // convert all children
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index 6e5591a129e4..7f01b2074582 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -1141,7 +1141,7 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
     SfxStyleSheet* pStyleSheet = GetStyleSheet();
 
     // prepare group
-    SdrObjGroup* pGroup = new SdrObjGroup(getSdrModelFromSdrObject());
+    std::unique_ptr<SdrObjGroup,SdrObjectFreeOp> pGroup(new SdrObjGroup(getSdrModelFromSdrObject()));
 
     // prepare parameters
     basegfx::B2DPolyPolygon aPolyPoly;
@@ -1259,11 +1259,11 @@ SdrObject* SdrMeasureObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 
     if(bAddText)
     {
-        return ImpConvertAddText(pGroup, bBezier);
+        return ImpConvertAddText(std::move(pGroup), bBezier).release();
     }
     else
     {
-        return pGroup;
+        return pGroup.release();
     }
 }
 
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index e15e2c9e12a8..e15e8a6b8e55 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -2676,7 +2676,7 @@ SdrObject* SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
     const bool bHideContour(
         !aText.isDefault() && !aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour());
 
-    SdrObject* pRet = nullptr;
+    SdrObjectUniquePtr pRet;
 
     if(!bHideContour)
     {
@@ -2698,15 +2698,15 @@ SdrObject* SdrPathObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
                 pPath->SetPathPoly(basegfx::utils::expandToCurve(pPath->GetPathPoly()));
             }
         }
-        pRet = pPath.release();
+        pRet = std::move(pPath);
     }
 
     if(bAddText)
     {
-        pRet = ImpConvertAddText(pRet, bBezier);
+        pRet = ImpConvertAddText(std::move(pRet), bBezier);
     }
 
-    return pRet;
+    return pRet.release();
 }
 
 SdrObjGeoData* SdrPathObj::NewGeoData() const
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index 6b8c328b154f..43da02b4c7d2 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -564,22 +564,22 @@ SdrObject* SdrRectObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 
     basegfx::B2DPolyPolygon aPolyPolygon(aXP.getB2DPolygon());
     aPolyPolygon.removeDoublePoints();
-    SdrObject* pRet = nullptr;
+    SdrObjectUniquePtr pRet;
 
     // small correction: Do not create something when no fill and no line. To
     // be sure to not damage something with non-text frames, do this only
     // when used with bAddText==false from other converters
     if((bAddText && !IsTextFrame()) || HasFill() || HasLine())
     {
-        pRet = ImpConvertMakeObj(aPolyPolygon, true, bBezier).release();
+        pRet = ImpConvertMakeObj(aPolyPolygon, true, bBezier);
     }
 
     if(bAddText)
     {
-        pRet = ImpConvertAddText(pRet, bBezier);
+        pRet = ImpConvertAddText(std::move(pRet), bBezier);
     }
 
-    return pRet;
+    return pRet.release();
 }
 
 void SdrRectObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index 6a9050b6cb6c..d4203b212cd2 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -287,9 +287,9 @@ void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2)
 }
 
 
-SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
+SdrObjectUniquePtr SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
 {
-    SdrObject* pRetval = nullptr;
+    SdrObjectUniquePtr pRetval;
 
     if(!ImpCanConvTextToCurve())
     {
@@ -398,7 +398,7 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
             }
             else if(1 == pObjectList->GetObjCount())
             {
-                pRetval = pObjectList->RemoveObject(0);
+                pRetval.reset(pObjectList->RemoveObject(0));
 
                 // always use SdrObject::Free(...) for SdrObjects (!)
                 SdrObject* pTemp(pGroup);
@@ -406,7 +406,7 @@ SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
             }
             else
             {
-                pRetval = pGroup;
+                pRetval.reset(pGroup);
             }
         }
     }
@@ -419,7 +419,7 @@ SdrObject* SdrTextObj::DoConvertToPolyObj(bool bBezier, bool bAddText) const
 {
     if(bAddText)
     {
-        return ImpConvertContainedTextToSdrPathObjs(!bBezier);
+        return ImpConvertContainedTextToSdrPathObjs(!bBezier).release();
     }
 
     return nullptr;
@@ -464,14 +464,14 @@ SdrPathObjUniquePtr SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon&
     return pPathObj;
 }
 
-SdrObject* SdrTextObj::ImpConvertAddText(SdrObject* pObj, bool bBezier) const
+SdrObjectUniquePtr SdrTextObj::ImpConvertAddText(SdrObjectUniquePtr pObj, bool bBezier) const
 {
     if(!ImpCanConvTextToCurve())
     {
         return pObj;
     }
 
-    SdrObject* pText = ImpConvertContainedTextToSdrPathObjs(!bBezier);
+    SdrObjectUniquePtr pText = ImpConvertContainedTextToSdrPathObjs(!bBezier);
 
     if(!pText)
     {
@@ -487,17 +487,17 @@ SdrObject* SdrTextObj::ImpConvertAddText(SdrObject* pObj, bool bBezier) const
     {
         // is already group object, add partial shape in front
         SdrObjList* pOL=pText->GetSubList();
-        pOL->InsertObject(pObj,0);
+        pOL->InsertObject(pObj.release(),0);
 
         return pText;
     }
     else
     {
         // not yet a group, create one and add partial and new shapes
-        SdrObjGroup* pGrp=new SdrObjGroup(getSdrModelFromSdrObject());
+        std::unique_ptr<SdrObjGroup, SdrObjectFreeOp> pGrp(new SdrObjGroup(getSdrModelFromSdrObject()));
         SdrObjList* pOL=pGrp->GetSubList();
-        pOL->InsertObject(pObj);
-        pOL->InsertObject(pText);
+        pOL->InsertObject(pObj.release());
+        pOL->InsertObject(pText.release());
 
         return pGrp;
     }


More information about the Libreoffice-commits mailing list