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

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


 include/svx/sdr/attribute/sdrallfillattributeshelper.hxx |    8 ++++----
 svx/source/sdr/attribute/sdrallfillattributeshelper.cxx  |   15 +++++----------
 2 files changed, 9 insertions(+), 14 deletions(-)

New commits:
commit 30067dafa988d4c6dd970c817eca283ac8946728
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sun Aug 22 16:52:19 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Aug 22 18:54:30 2021 +0200

    no need to use shared_ptr in SdrAllFillAttributesHelper
    
    these types are already COW types
    
    Change-Id: I7e4375ac50b8d887869123eeb99d3eaef0d28169
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120851
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/sdr/attribute/sdrallfillattributeshelper.hxx b/include/svx/sdr/attribute/sdrallfillattributeshelper.hxx
index c8c22af9b71c..c9bb786a8091 100644
--- a/include/svx/sdr/attribute/sdrallfillattributeshelper.hxx
+++ b/include/svx/sdr/attribute/sdrallfillattributeshelper.hxx
@@ -24,7 +24,7 @@
 #include <drawinglayer/attribute/sdrfillattribute.hxx>
 #include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
 #include <svl/itemset.hxx>
-#include <memory>
+#include <optional>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -37,9 +37,9 @@ namespace drawinglayer::attribute
         private:
             basegfx::B2DRange                                                   maLastPaintRange;
             basegfx::B2DRange                                                   maLastDefineRange;
-            std::shared_ptr< drawinglayer::attribute::SdrFillAttribute >      maFillAttribute;
-            std::shared_ptr< drawinglayer::attribute::FillGradientAttribute > maFillGradientAttribute;
-            drawinglayer::primitive2d::Primitive2DContainer                      maPrimitives;
+            std::optional<drawinglayer::attribute::SdrFillAttribute>            maFillAttribute;
+            std::optional<drawinglayer::attribute::FillGradientAttribute>       maFillGradientAttribute;
+            drawinglayer::primitive2d::Primitive2DContainer                     maPrimitives;
 
             void createPrimitive2DSequence(
                 const basegfx::B2DRange& rPaintRange,
diff --git a/svx/source/sdr/attribute/sdrallfillattributeshelper.cxx b/svx/source/sdr/attribute/sdrallfillattributeshelper.cxx
index 57945facb4bb..5605ba4aba6f 100644
--- a/svx/source/sdr/attribute/sdrallfillattributeshelper.cxx
+++ b/svx/source/sdr/attribute/sdrallfillattributeshelper.cxx
@@ -57,8 +57,7 @@ namespace drawinglayer::attribute
             maFillGradientAttribute(),
             maPrimitives()
         {
-            maFillAttribute =
-                std::make_shared<drawinglayer::attribute::SdrFillAttribute>(
+            maFillAttribute = drawinglayer::attribute::SdrFillAttribute(
                     0.0,
                     rColor.GetRGBColor().getBColor(),
                     drawinglayer::attribute::FillGradientAttribute(),
@@ -70,11 +69,9 @@ namespace drawinglayer::attribute
         :   maLastPaintRange(),
             maLastDefineRange(),
             maFillAttribute(
-                std::make_shared<drawinglayer::attribute::SdrFillAttribute>(
-                    drawinglayer::primitive2d::createNewSdrFillAttribute(rSet))),
+                    drawinglayer::primitive2d::createNewSdrFillAttribute(rSet)),
             maFillGradientAttribute(
-                std::make_shared<drawinglayer::attribute::FillGradientAttribute>(
-                    drawinglayer::primitive2d::createNewTransparenceGradientAttribute(rSet))),
+                    drawinglayer::primitive2d::createNewTransparenceGradientAttribute(rSet)),
             maPrimitives()
         {
         }
@@ -115,8 +112,7 @@ namespace drawinglayer::attribute
         {
             if(!maFillAttribute)
             {
-                const_cast< SdrAllFillAttributesHelper* >(this)->maFillAttribute =
-                    std::make_shared<drawinglayer::attribute::SdrFillAttribute>();
+                const_cast< SdrAllFillAttributesHelper* >(this)->maFillAttribute.emplace();
             }
 
             return *maFillAttribute;
@@ -126,8 +122,7 @@ namespace drawinglayer::attribute
         {
             if(!maFillGradientAttribute)
             {
-                const_cast< SdrAllFillAttributesHelper* >(this)->maFillGradientAttribute =
-                    std::make_shared<drawinglayer::attribute::FillGradientAttribute>();
+                const_cast< SdrAllFillAttributesHelper* >(this)->maFillGradientAttribute.emplace();
             }
 
             return *maFillGradientAttribute;


More information about the Libreoffice-commits mailing list