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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Aug 22 08:32:16 UTC 2021


 include/svx/svdoedge.hxx       |    6 ++++--
 include/svx/svdorect.hxx       |    6 +++---
 svx/source/svdraw/svdocirc.cxx |    4 ++--
 svx/source/svdraw/svdoedge.cxx |    6 +++---
 svx/source/svdraw/svdorect.cxx |    7 ++-----
 5 files changed, 14 insertions(+), 15 deletions(-)

New commits:
commit feb59fca82df3762c4eb3b9ac2c96e9fa387bed1
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Aug 21 19:33:43 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 22 10:31:42 2021 +0200

    no need to use unique_ptr for XPolygon
    
    it is already a COW type
    
    Change-Id: I94370d20fbe9d7f6b1bd57f339911a75cbef6484
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120824
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx
index 838595e70273..ee0e64b08281 100644
--- a/include/svx/svdoedge.hxx
+++ b/include/svx/svdoedge.hxx
@@ -20,9 +20,11 @@
 #pragma once
 
 #include <memory>
+#include <optional>
 #include <svx/svdotext.hxx>
 #include <svx/svdglue.hxx>
 #include <svx/svxdllapi.h>
+#include <svx/xpoly.hxx>
 
 
 class SdrDragMethod;
@@ -112,7 +114,7 @@ class SdrEdgeObjGeoData final : public SdrTextObjGeoData
 public:
     SdrObjConnection            aCon1;  // connection status of the beginning of the line
     SdrObjConnection            aCon2;  // connection status of the end of the line
-    std::unique_ptr<XPolygon>   pEdgeTrack;
+    std::optional<XPolygon>     pEdgeTrack;
     bool                        bEdgeTrackDirty; // true -> connector track needs to be recalculated
     bool                        bEdgeTrackUserDefined;
     SdrEdgeInfoRec              aEdgeInfo;
@@ -139,7 +141,7 @@ private:
     SdrObjConnection            aCon1;  // Connection status of the beginning of the line
     SdrObjConnection            aCon2;  // Connection status of the end of the line
 
-    std::unique_ptr<XPolygon>   pEdgeTrack;
+    std::optional<XPolygon>     pEdgeTrack;
     sal_uInt16                  nNotifyingCount; // Locking
     SdrEdgeInfoRec              aEdgeInfo;
 
diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx
index 4e52c6289faa..ac7879cb5212 100644
--- a/include/svx/svdorect.hxx
+++ b/include/svx/svdorect.hxx
@@ -20,13 +20,13 @@
 #pragma once
 
 #include <memory>
+#include <optional>
 #include <svx/svdotext.hxx>
+#include <svx/xpoly.hxx>
 #include <svx/svxdllapi.h>
 
 
 // Forward declaration
-class XPolygon;
-
 namespace sdr::properties {
     class RectangleProperties;
 }
@@ -46,7 +46,7 @@ protected:
     virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override;
     virtual std::unique_ptr<sdr::properties::BaseProperties> CreateObjectSpecificProperties() override;
 
-    std::unique_ptr<XPolygon> mpXPoly;
+    std::optional<XPolygon> mpXPoly;
 
 protected:
     XPolygon ImpCalcXPoly(const tools::Rectangle& rRect1, tools::Long nRad1) const;
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 10c56a53db0f..9dc3a1d2d812 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -313,8 +313,8 @@ basegfx::B2DPolygon SdrCircObj::ImpCalcXPolyCirc(const SdrCircKind eCircleKind,
 
 void SdrCircObj::RecalcXPoly()
 {
-    const basegfx::B2DPolygon aPolyCirc(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle));
-    mpXPoly.reset( new XPolygon(aPolyCirc) );
+    basegfx::B2DPolygon aPolyCirc(ImpCalcXPolyCirc(meCircleKind, maRect, nStartAngle, nEndAngle));
+    mpXPoly = XPolygon(aPolyCirc);
 }
 
 OUString SdrCircObj::TakeObjNameSingul() const
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
index 6af9b933c2e5..c48d954c9ace 100644
--- a/svx/source/svdraw/svdoedge.cxx
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -166,7 +166,7 @@ SdrEdgeObj::SdrEdgeObj(SdrModel& rSdrModel)
 {
     m_bClosedObj=false;
     m_bIsEdge=true;
-    pEdgeTrack.reset(new XPolygon);
+    pEdgeTrack = XPolygon();
 }
 
 SdrEdgeObj::SdrEdgeObj(SdrModel& rSdrModel, SdrEdgeObj const & rSource)
@@ -181,7 +181,7 @@ SdrEdgeObj::SdrEdgeObj(SdrModel& rSdrModel, SdrEdgeObj const & rSource)
 {
     m_bClosedObj = false;
     m_bIsEdge = true;
-    pEdgeTrack.reset(new XPolygon(*rSource.pEdgeTrack));
+    pEdgeTrack = rSource.pEdgeTrack;
     bEdgeTrackDirty=rSource.bEdgeTrackDirty;
     aCon1          =rSource.aCon1;
     aCon2          =rSource.aCon2;
@@ -2469,7 +2469,7 @@ void SdrEdgeObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
 }
 
 SdrEdgeObjGeoData::SdrEdgeObjGeoData()
-    : pEdgeTrack(new XPolygon)
+    : pEdgeTrack(std::in_place)
     , bEdgeTrackDirty(false)
     , bEdgeTrackUserDefined(false)
 {
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
index cd91f6f06c31..bd3c53bac1ad 100644
--- a/svx/source/svdraw/svdorect.cxx
+++ b/svx/source/svdraw/svdorect.cxx
@@ -61,10 +61,7 @@ SdrRectObj::SdrRectObj(SdrModel& rSdrModel, SdrRectObj const & rSource)
 :   SdrTextObj(rSdrModel, rSource)
 {
     m_bClosedObj=true;
-    if ( rSource.mpXPoly )
-        mpXPoly.reset( new XPolygon( *rSource.mpXPoly ) );
-    else
-        mpXPoly.reset();
+    mpXPoly = rSource.mpXPoly;
 }
 
 SdrRectObj::SdrRectObj(
@@ -133,7 +130,7 @@ XPolygon SdrRectObj::ImpCalcXPoly(const tools::Rectangle& rRect1, tools::Long nR
 
 void SdrRectObj::RecalcXPoly()
 {
-    mpXPoly.reset( new XPolygon(ImpCalcXPoly(maRect,GetEckenradius())) );
+    mpXPoly = ImpCalcXPoly(maRect,GetEckenradius());
 }
 
 const XPolygon& SdrRectObj::GetXPoly() const


More information about the Libreoffice-commits mailing list