[Libreoffice-commits] core.git: 9 commits - drawinglayer/inc drawinglayer/source

Thomas Arnhold thomas at arnhold.org
Wed Apr 3 02:36:06 PDT 2013


 drawinglayer/inc/drawinglayer/attribute/sdrfillattribute.hxx         |    6 
 drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx   |    6 
 drawinglayer/inc/drawinglayer/attribute/sdrlightattribute3d.hxx      |    6 
 drawinglayer/inc/drawinglayer/attribute/sdrlightingattribute3d.hxx   |    6 
 drawinglayer/inc/drawinglayer/attribute/sdrlineattribute.hxx         |    7 
 drawinglayer/inc/drawinglayer/attribute/sdrlinestartendattribute.hxx |    6 
 drawinglayer/inc/drawinglayer/attribute/sdrobjectattribute3d.hxx     |    6 
 drawinglayer/inc/drawinglayer/attribute/sdrsceneattribute3d.hxx      |    6 
 drawinglayer/inc/drawinglayer/attribute/strokeattribute.hxx          |    7 
 drawinglayer/source/attribute/sdrfillattribute.cxx                   |   86 ++-------
 drawinglayer/source/attribute/sdrfillbitmapattribute.cxx             |   92 ++-------
 drawinglayer/source/attribute/sdrlightattribute3d.cxx                |   79 ++------
 drawinglayer/source/attribute/sdrlightingattribute3d.cxx             |   80 ++------
 drawinglayer/source/attribute/sdrlineattribute.cxx                   |   93 ++-------
 drawinglayer/source/attribute/sdrlinestartendattribute.cxx           |   92 ++-------
 drawinglayer/source/attribute/sdrobjectattribute3d.cxx               |   95 ++--------
 drawinglayer/source/attribute/sdrsceneattribute3d.cxx                |   85 ++------
 drawinglayer/source/attribute/strokeattribute.cxx                    |   80 ++------
 18 files changed, 248 insertions(+), 590 deletions(-)

New commits:
commit 7470c93a7b70eec967a52ddbf8a3c9430d3b6f2f
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 02:43:01 2013 +0200

    fdo#62525: use cow_wrapper for Sdr3DObjectAttribute
    
    Change-Id: I80e378f6a88068f5d3b36c6187b41ab8d968a0c3

diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrobjectattribute3d.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrobjectattribute3d.hxx
index 809efa5..860093a 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrobjectattribute3d.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrobjectattribute3d.hxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/drawing/TextureProjectionMode.hpp>
 #include <com/sun/star/drawing/TextureKind2.hpp>
 #include <com/sun/star/drawing/TextureMode.hpp>
+#include <o3tl/cow_wrapper.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // predefines
@@ -43,8 +44,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC Sdr3DObjectAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpSdr3DObjectAttribute > ImplType;
+
         private:
-            ImpSdr3DObjectAttribute*            mpSdr3DObjectAttribute;
+            ImplType mpSdr3DObjectAttribute;
 
         public:
             // constructors/destructor
diff --git a/drawinglayer/source/attribute/sdrobjectattribute3d.cxx b/drawinglayer/source/attribute/sdrobjectattribute3d.cxx
index a0b1e45..77926c5 100644
--- a/drawinglayer/source/attribute/sdrobjectattribute3d.cxx
+++ b/drawinglayer/source/attribute/sdrobjectattribute3d.cxx
@@ -19,6 +19,7 @@
 
 #include <drawinglayer/attribute/sdrobjectattribute3d.hxx>
 #include <drawinglayer/attribute/materialattribute3d.hxx>
+#include <rtl/instance.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -29,9 +30,6 @@ namespace drawinglayer
         class ImpSdr3DObjectAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                              mnRefCount;
-
             // 3D object attribute definitions
             ::com::sun::star::drawing::NormalsKind              maNormalsKind;              // normals type (0..2)
             ::com::sun::star::drawing::TextureProjectionMode    maTextureProjectionX;       // texture projection type X (0..2)
@@ -59,8 +57,7 @@ namespace drawinglayer
                 bool bShadow3D,
                 bool bTextureFilter,
                 bool bReducedLineGeometry)
-            :   mnRefCount(0),
-                maNormalsKind(aNormalsKind),
+            :   maNormalsKind(aNormalsKind),
                 maTextureProjectionX(aTextureProjectionX),
                 maTextureProjectionY(aTextureProjectionY),
                 maTextureKind(aTextureKind),
@@ -74,6 +71,21 @@ namespace drawinglayer
             {
             }
 
+            ImpSdr3DObjectAttribute()
+            :   maNormalsKind(::com::sun::star::drawing::NormalsKind_SPECIFIC),
+                maTextureProjectionX(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC),
+                maTextureProjectionY(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC),
+                maTextureKind(::com::sun::star::drawing::TextureKind2_LUMINANCE),
+                maTextureMode(::com::sun::star::drawing::TextureMode_REPLACE),
+                maMaterial(MaterialAttribute3D()),
+                mbNormalsInvert(false),
+                mbDoubleSided(false),
+                mbShadow3D(false),
+                mbTextureFilter(false),
+                mbReducedLineGeometry(false)
+            {
+            }
+
             // data read access
             ::com::sun::star::drawing::NormalsKind getNormalsKind() const { return maNormalsKind; }
             ::com::sun::star::drawing::TextureProjectionMode getTextureProjectionX() const { return maTextureProjectionX; }
@@ -101,34 +113,14 @@ namespace drawinglayer
                     && getTextureFilter() == rCandidate.getTextureFilter()
                     && getReducedLineGeometry() == rCandidate.getReducedLineGeometry());
             }
-
-            static ImpSdr3DObjectAttribute* get_global_default()
-            {
-                static ImpSdr3DObjectAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpSdr3DObjectAttribute(
-                        ::com::sun::star::drawing::NormalsKind_SPECIFIC,
-                        ::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC,
-                        ::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC,
-                        ::com::sun::star::drawing::TextureKind2_LUMINANCE,
-                        ::com::sun::star::drawing::TextureMode_REPLACE,
-                        MaterialAttribute3D(),
-                        false,
-                        false,
-                        false,
-                        false,
-                        false);
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< Sdr3DObjectAttribute::ImplType, theGlobalDefault > {};
+        }
+
         Sdr3DObjectAttribute::Sdr3DObjectAttribute(
             ::com::sun::star::drawing::NormalsKind  aNormalsKind,
             ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX,
@@ -141,7 +133,7 @@ namespace drawinglayer
             bool bShadow3D,
             bool bTextureFilter,
             bool bReducedLineGeometry)
-        :   mpSdr3DObjectAttribute(new ImpSdr3DObjectAttribute(
+        :   mpSdr3DObjectAttribute(ImpSdr3DObjectAttribute(
                 aNormalsKind, aTextureProjectionX, aTextureProjectionY, aTextureKind, aTextureMode,
                 rMaterial, bNormalsInvert, bDoubleSided, bShadow3D, bTextureFilter, bReducedLineGeometry))
         {
@@ -150,59 +142,26 @@ namespace drawinglayer
         Sdr3DObjectAttribute::Sdr3DObjectAttribute(const Sdr3DObjectAttribute& rCandidate)
         :   mpSdr3DObjectAttribute(rCandidate.mpSdr3DObjectAttribute)
         {
-            mpSdr3DObjectAttribute->mnRefCount++;
         }
 
         Sdr3DObjectAttribute::~Sdr3DObjectAttribute()
         {
-            if(mpSdr3DObjectAttribute->mnRefCount)
-            {
-                mpSdr3DObjectAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpSdr3DObjectAttribute;
-            }
         }
 
         bool Sdr3DObjectAttribute::isDefault() const
         {
-            return mpSdr3DObjectAttribute == ImpSdr3DObjectAttribute::get_global_default();
+            return mpSdr3DObjectAttribute.same_object(theGlobalDefault::get());
         }
 
         Sdr3DObjectAttribute& Sdr3DObjectAttribute::operator=(const Sdr3DObjectAttribute& rCandidate)
         {
-            if(rCandidate.mpSdr3DObjectAttribute != mpSdr3DObjectAttribute)
-            {
-                if(mpSdr3DObjectAttribute->mnRefCount)
-                {
-                    mpSdr3DObjectAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpSdr3DObjectAttribute;
-                }
-
-                mpSdr3DObjectAttribute = rCandidate.mpSdr3DObjectAttribute;
-                mpSdr3DObjectAttribute->mnRefCount++;
-            }
-
+            mpSdr3DObjectAttribute = rCandidate.mpSdr3DObjectAttribute;
             return *this;
         }
 
         bool Sdr3DObjectAttribute::operator==(const Sdr3DObjectAttribute& rCandidate) const
         {
-            if(rCandidate.mpSdr3DObjectAttribute == mpSdr3DObjectAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpSdr3DObjectAttribute == *mpSdr3DObjectAttribute);
+            return rCandidate.mpSdr3DObjectAttribute == mpSdr3DObjectAttribute;
         }
 
         ::com::sun::star::drawing::NormalsKind Sdr3DObjectAttribute::getNormalsKind() const
commit d3dff92c74bdf0fdb8b638d85fd5a41a64bd96c9
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 02:35:54 2013 +0200

    fdo#62525: use cow_wrapper for SdrSceneAttribute
    
    Change-Id: Iaedb5080f341482c3ac4f4e0548be49801c5f0b2

diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrsceneattribute3d.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrsceneattribute3d.hxx
index 27107e4..61d4d8a 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrsceneattribute3d.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrsceneattribute3d.hxx
@@ -24,6 +24,7 @@
 
 #include <com/sun/star/drawing/ProjectionMode.hpp>
 #include <com/sun/star/drawing/ShadeMode.hpp>
+#include <o3tl/cow_wrapper.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // predefines
@@ -40,8 +41,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC SdrSceneAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpSdrSceneAttribute > ImplType;
+
         private:
-            ImpSdrSceneAttribute*               mpSdrSceneAttribute;
+            ImplType mpSdrSceneAttribute;
 
         public:
             /// constructors/assignmentoperator/destructor
diff --git a/drawinglayer/source/attribute/sdrsceneattribute3d.cxx b/drawinglayer/source/attribute/sdrsceneattribute3d.cxx
index 6f27014..f5d0e82 100644
--- a/drawinglayer/source/attribute/sdrsceneattribute3d.cxx
+++ b/drawinglayer/source/attribute/sdrsceneattribute3d.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
+#include <rtl/instance.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -28,9 +29,6 @@ namespace drawinglayer
         class ImpSdrSceneAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                              mnRefCount;
-
             // 3D scene attribute definitions
             double                                      mfDistance;
             double                                      mfShadowSlant;
@@ -47,8 +45,7 @@ namespace drawinglayer
                 ::com::sun::star::drawing::ProjectionMode aProjectionMode,
                 ::com::sun::star::drawing::ShadeMode aShadeMode,
                 bool bTwoSidedLighting)
-            :   mnRefCount(0),
-                mfDistance(fDistance),
+            :   mfDistance(fDistance),
                 mfShadowSlant(fShadowSlant),
                 maProjectionMode(aProjectionMode),
                 maShadeMode(aShadeMode),
@@ -56,6 +53,15 @@ namespace drawinglayer
             {
             }
 
+            ImpSdrSceneAttribute()
+            :   mfDistance(0.0),
+                mfShadowSlant(0.0),
+                maProjectionMode(::com::sun::star::drawing::ProjectionMode_PARALLEL),
+                maShadeMode(::com::sun::star::drawing::ShadeMode_FLAT),
+                mbTwoSidedLighting(false)
+            {
+            }
+
             // data read access
             double getDistance() const { return mfDistance; }
             double getShadowSlant() const { return mfShadowSlant; }
@@ -71,100 +77,53 @@ namespace drawinglayer
                     && getShadeMode() == rCandidate.getShadeMode()
                     && getTwoSidedLighting() == rCandidate.getTwoSidedLighting());
             }
-
-            static ImpSdrSceneAttribute* get_global_default()
-            {
-                static ImpSdrSceneAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpSdrSceneAttribute(
-                        0.0, 0.0,
-                        ::com::sun::star::drawing::ProjectionMode_PARALLEL,
-                        ::com::sun::star::drawing::ShadeMode_FLAT,
-                        false);
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< SdrSceneAttribute::ImplType, theGlobalDefault > {};
+        }
+
         SdrSceneAttribute::SdrSceneAttribute(
             double fDistance,
             double fShadowSlant,
             ::com::sun::star::drawing::ProjectionMode aProjectionMode,
             ::com::sun::star::drawing::ShadeMode aShadeMode,
             bool bTwoSidedLighting)
-        :   mpSdrSceneAttribute(new ImpSdrSceneAttribute(
+        :   mpSdrSceneAttribute(ImpSdrSceneAttribute(
                 fDistance, fShadowSlant, aProjectionMode, aShadeMode, bTwoSidedLighting))
         {
         }
 
         SdrSceneAttribute::SdrSceneAttribute()
-        :   mpSdrSceneAttribute(ImpSdrSceneAttribute::get_global_default())
+        :   mpSdrSceneAttribute(theGlobalDefault::get())
         {
-            mpSdrSceneAttribute->mnRefCount++;
         }
 
         SdrSceneAttribute::SdrSceneAttribute(const SdrSceneAttribute& rCandidate)
         :   mpSdrSceneAttribute(rCandidate.mpSdrSceneAttribute)
         {
-            mpSdrSceneAttribute->mnRefCount++;
         }
 
         SdrSceneAttribute::~SdrSceneAttribute()
         {
-            if(mpSdrSceneAttribute->mnRefCount)
-            {
-                mpSdrSceneAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpSdrSceneAttribute;
-            }
         }
 
         bool SdrSceneAttribute::isDefault() const
         {
-            return mpSdrSceneAttribute == ImpSdrSceneAttribute::get_global_default();
+            return mpSdrSceneAttribute.same_object(theGlobalDefault::get());
         }
 
         SdrSceneAttribute& SdrSceneAttribute::operator=(const SdrSceneAttribute& rCandidate)
         {
-            if(rCandidate.mpSdrSceneAttribute != mpSdrSceneAttribute)
-            {
-                if(mpSdrSceneAttribute->mnRefCount)
-                {
-                    mpSdrSceneAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpSdrSceneAttribute;
-                }
-
-                mpSdrSceneAttribute = rCandidate.mpSdrSceneAttribute;
-                mpSdrSceneAttribute->mnRefCount++;
-            }
-
+            mpSdrSceneAttribute = rCandidate.mpSdrSceneAttribute;
             return *this;
         }
 
         bool SdrSceneAttribute::operator==(const SdrSceneAttribute& rCandidate) const
         {
-            if(rCandidate.mpSdrSceneAttribute == mpSdrSceneAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpSdrSceneAttribute == *mpSdrSceneAttribute);
+            return rCandidate.mpSdrSceneAttribute == mpSdrSceneAttribute;
         }
 
         double SdrSceneAttribute::getShadowSlant() const
commit 12012150d2027f78e872dc15b063b12a60d3a7d9
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 02:28:07 2013 +0200

    fdo#62525: use cow_wrapper for SdrLineStartEndAttribute
    
    Change-Id: I714011f70ae4c1b9a1dcce5cb3653e918cc742b4

diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrlinestartendattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrlinestartendattribute.hxx
index 2715bb7..19c1a51 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrlinestartendattribute.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrlinestartendattribute.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRLINESTARTENDATTRIBUTE_HXX
 
 #include <drawinglayer/drawinglayerdllapi.h>
+#include <o3tl/cow_wrapper.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // predefines
@@ -41,8 +42,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC SdrLineStartEndAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpSdrLineStartEndAttribute > ImplType;
+
         private:
-            ImpSdrLineStartEndAttribute*               mpSdrLineStartEndAttribute;
+            ImplType mpSdrLineStartEndAttribute;
 
         public:
             /// constructors/assignmentoperator/destructor
diff --git a/drawinglayer/source/attribute/sdrlinestartendattribute.cxx b/drawinglayer/source/attribute/sdrlinestartendattribute.cxx
index 1fe894d..c4851da 100644
--- a/drawinglayer/source/attribute/sdrlinestartendattribute.cxx
+++ b/drawinglayer/source/attribute/sdrlinestartendattribute.cxx
@@ -19,6 +19,7 @@
 
 #include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
 #include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <rtl/instance.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -29,9 +30,6 @@ namespace drawinglayer
         class ImpSdrLineStartEndAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                              mnRefCount;
-
             // line arrow definitions
             basegfx::B2DPolyPolygon                 maStartPolyPolygon;     // start Line PolyPolygon
             basegfx::B2DPolyPolygon                 maEndPolyPolygon;       // end Line PolyPolygon
@@ -53,8 +51,7 @@ namespace drawinglayer
                 bool bEndActive,
                 bool bStartCentered,
                 bool bEndCentered)
-            :   mnRefCount(0),
-                maStartPolyPolygon(rStartPolyPolygon),
+            :   maStartPolyPolygon(rStartPolyPolygon),
                 maEndPolyPolygon(rEndPolyPolygon),
                 mfStartWidth(fStartWidth),
                 mfEndWidth(fEndWidth),
@@ -65,6 +62,18 @@ namespace drawinglayer
             {
             }
 
+            ImpSdrLineStartEndAttribute()
+            :   maStartPolyPolygon(basegfx::B2DPolyPolygon()),
+                maEndPolyPolygon(basegfx::B2DPolyPolygon()),
+                mfStartWidth(0.0),
+                mfEndWidth(0.0),
+                mbStartActive(false),
+                mbEndActive(false),
+                mbStartCentered(false),
+                mbEndCentered(false)
+            {
+            }
+
             // data read access
             const basegfx::B2DPolyPolygon& getStartPolyPolygon() const { return maStartPolyPolygon; }
             const basegfx::B2DPolyPolygon& getEndPolyPolygon() const { return maEndPolyPolygon; }
@@ -86,31 +95,14 @@ namespace drawinglayer
                     && isStartCentered() == rCandidate.isStartCentered()
                     && isEndCentered() == rCandidate.isEndCentered());
             }
-
-            static ImpSdrLineStartEndAttribute* get_global_default()
-            {
-                static ImpSdrLineStartEndAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpSdrLineStartEndAttribute(
-                        basegfx::B2DPolyPolygon(),
-                        basegfx::B2DPolyPolygon(),
-                        0.0,
-                        0.0,
-                        false,
-                        false,
-                        false,
-                        false);
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< SdrLineStartEndAttribute::ImplType, theGlobalDefault > {};
+        }
+
         SdrLineStartEndAttribute::SdrLineStartEndAttribute(
             const basegfx::B2DPolyPolygon& rStartPolyPolygon,
             const basegfx::B2DPolyPolygon& rEndPolyPolygon,
@@ -120,73 +112,39 @@ namespace drawinglayer
             bool bEndActive,
             bool bStartCentered,
             bool bEndCentered)
-        :   mpSdrLineStartEndAttribute(new ImpSdrLineStartEndAttribute(
+        :   mpSdrLineStartEndAttribute(ImpSdrLineStartEndAttribute(
                 rStartPolyPolygon, rEndPolyPolygon, fStartWidth, fEndWidth, bStartActive, bEndActive, bStartCentered, bEndCentered))
         {
         }
 
         SdrLineStartEndAttribute::SdrLineStartEndAttribute()
-        :   mpSdrLineStartEndAttribute(ImpSdrLineStartEndAttribute::get_global_default())
+        :   mpSdrLineStartEndAttribute(theGlobalDefault::get())
         {
-            mpSdrLineStartEndAttribute->mnRefCount++;
         }
 
         SdrLineStartEndAttribute::SdrLineStartEndAttribute(const SdrLineStartEndAttribute& rCandidate)
         :   mpSdrLineStartEndAttribute(rCandidate.mpSdrLineStartEndAttribute)
         {
-            mpSdrLineStartEndAttribute->mnRefCount++;
         }
 
         SdrLineStartEndAttribute::~SdrLineStartEndAttribute()
         {
-            if(mpSdrLineStartEndAttribute->mnRefCount)
-            {
-                mpSdrLineStartEndAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpSdrLineStartEndAttribute;
-            }
         }
 
         bool SdrLineStartEndAttribute::isDefault() const
         {
-            return mpSdrLineStartEndAttribute == ImpSdrLineStartEndAttribute::get_global_default();
+            return mpSdrLineStartEndAttribute.same_object(theGlobalDefault::get());
         }
 
         SdrLineStartEndAttribute& SdrLineStartEndAttribute::operator=(const SdrLineStartEndAttribute& rCandidate)
         {
-            if(rCandidate.mpSdrLineStartEndAttribute != mpSdrLineStartEndAttribute)
-            {
-                if(mpSdrLineStartEndAttribute->mnRefCount)
-                {
-                    mpSdrLineStartEndAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpSdrLineStartEndAttribute;
-                }
-
-                mpSdrLineStartEndAttribute = rCandidate.mpSdrLineStartEndAttribute;
-                mpSdrLineStartEndAttribute->mnRefCount++;
-            }
-
+            mpSdrLineStartEndAttribute = rCandidate.mpSdrLineStartEndAttribute;
             return *this;
         }
 
         bool SdrLineStartEndAttribute::operator==(const SdrLineStartEndAttribute& rCandidate) const
         {
-            if(rCandidate.mpSdrLineStartEndAttribute == mpSdrLineStartEndAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpSdrLineStartEndAttribute == *mpSdrLineStartEndAttribute);
+            return rCandidate.mpSdrLineStartEndAttribute == mpSdrLineStartEndAttribute;
         }
 
         const basegfx::B2DPolyPolygon& SdrLineStartEndAttribute::getStartPolyPolygon() const
commit 92261a33c8ebd2d1c4d35b1b526e98abe746955e
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 02:21:35 2013 +0200

    fdo#62525: use cow_wrapper for StrokeAttribute
    
    Change-Id: Icf5daca279902b90da98069338638c3ad432e69a

diff --git a/drawinglayer/inc/drawinglayer/attribute/strokeattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/strokeattribute.hxx
index 3759213..6d4cea9 100644
--- a/drawinglayer/inc/drawinglayer/attribute/strokeattribute.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/strokeattribute.hxx
@@ -21,7 +21,7 @@
 #define INCLUDED_DRAWINGLAYER_ATTRIBUTE_STROKEATTRIBUTE_HXX
 
 #include <drawinglayer/drawinglayerdllapi.h>
-
+#include <o3tl/cow_wrapper.hxx>
 #include <vector>
 
 //////////////////////////////////////////////////////////////////////////////
@@ -39,8 +39,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC StrokeAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpStrokeAttribute > ImplType;
+
         private:
-            ImpStrokeAttribute*         mpStrokeAttribute;
+            ImplType mpStrokeAttribute;
 
         public:
             /// constructors/assignmentoperator/destructor
diff --git a/drawinglayer/source/attribute/strokeattribute.cxx b/drawinglayer/source/attribute/strokeattribute.cxx
index d6da1a2..c6c5b69 100644
--- a/drawinglayer/source/attribute/strokeattribute.cxx
+++ b/drawinglayer/source/attribute/strokeattribute.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <drawinglayer/attribute/strokeattribute.hxx>
+#include <rtl/instance.hxx>
 #include <numeric>
 
 //////////////////////////////////////////////////////////////////////////////
@@ -29,9 +30,6 @@ namespace drawinglayer
         class ImpStrokeAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                              mnRefCount;
-
             // data definitions
             ::std::vector< double >                     maDotDashArray;         // array of double which defines the dot-dash pattern
             double                                      mfFullDotDashLen;       // sum of maDotDashArray (for convenience)
@@ -39,12 +37,17 @@ namespace drawinglayer
             ImpStrokeAttribute(
                 const ::std::vector< double >& rDotDashArray,
                 double fFullDotDashLen)
-            :   mnRefCount(0),
-                maDotDashArray(rDotDashArray),
+            :   maDotDashArray(rDotDashArray),
                 mfFullDotDashLen(fFullDotDashLen)
             {
             }
 
+            ImpStrokeAttribute()
+            :   maDotDashArray(std::vector< double >()),
+                mfFullDotDashLen(0.0)
+            {
+            }
+
             // data read access
             const ::std::vector< double >& getDotDashArray() const { return maDotDashArray; }
             double getFullDotDashLen() const
@@ -64,95 +67,50 @@ namespace drawinglayer
                 return (getDotDashArray() == rCandidate.getDotDashArray()
                     && getFullDotDashLen() == rCandidate.getFullDotDashLen());
             }
-
-            static ImpStrokeAttribute* get_global_default()
-            {
-                static ImpStrokeAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpStrokeAttribute(
-                        std::vector< double >(),
-                        0.0);
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< StrokeAttribute::ImplType, theGlobalDefault > {};
+        }
+
         StrokeAttribute::StrokeAttribute(
             const ::std::vector< double >& rDotDashArray,
             double fFullDotDashLen)
-        :   mpStrokeAttribute(new ImpStrokeAttribute(
+        :   mpStrokeAttribute(ImpStrokeAttribute(
                 rDotDashArray, fFullDotDashLen))
         {
         }
 
         StrokeAttribute::StrokeAttribute()
-        :   mpStrokeAttribute(ImpStrokeAttribute::get_global_default())
+        :   mpStrokeAttribute(theGlobalDefault::get())
         {
-            mpStrokeAttribute->mnRefCount++;
         }
 
         StrokeAttribute::StrokeAttribute(const StrokeAttribute& rCandidate)
         :   mpStrokeAttribute(rCandidate.mpStrokeAttribute)
         {
-            mpStrokeAttribute->mnRefCount++;
         }
 
         StrokeAttribute::~StrokeAttribute()
         {
-            if(mpStrokeAttribute->mnRefCount)
-            {
-                mpStrokeAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpStrokeAttribute;
-            }
         }
 
         bool StrokeAttribute::isDefault() const
         {
-            return mpStrokeAttribute == ImpStrokeAttribute::get_global_default();
+            return mpStrokeAttribute.same_object(theGlobalDefault::get());
         }
 
         StrokeAttribute& StrokeAttribute::operator=(const StrokeAttribute& rCandidate)
         {
-            if(rCandidate.mpStrokeAttribute != mpStrokeAttribute)
-            {
-                if(mpStrokeAttribute->mnRefCount)
-                {
-                    mpStrokeAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpStrokeAttribute;
-                }
-
-                mpStrokeAttribute = rCandidate.mpStrokeAttribute;
-                mpStrokeAttribute->mnRefCount++;
-            }
-
+            mpStrokeAttribute = rCandidate.mpStrokeAttribute;
             return *this;
         }
 
         bool StrokeAttribute::operator==(const StrokeAttribute& rCandidate) const
         {
-            if(rCandidate.mpStrokeAttribute == mpStrokeAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpStrokeAttribute == *mpStrokeAttribute);
+            return rCandidate.mpStrokeAttribute == mpStrokeAttribute;
         }
 
         const ::std::vector< double >& StrokeAttribute::getDotDashArray() const
commit 8ee042bdb5502228fecf9a05da491bbb2cb3efc5
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 02:12:42 2013 +0200

    fdo#62525: use cow_wrapper for SdrLineAttribute
    
    Change-Id: I62b897bd49ef05a3862cb2cd91c3aa13f621e9fd

diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrlineattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrlineattribute.hxx
index f487b4d..bedbd9f 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrlineattribute.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrlineattribute.hxx
@@ -21,9 +21,9 @@
 #define INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRLINEATTRIBUTE_HXX
 
 #include <drawinglayer/drawinglayerdllapi.h>
-
 #include <basegfx/vector/b2enums.hxx>
 #include <com/sun/star/drawing/LineCap.hpp>
+#include <o3tl/cow_wrapper.hxx>
 #include <vector>
 
 //////////////////////////////////////////////////////////////////////////////
@@ -45,8 +45,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC SdrLineAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpSdrLineAttribute > ImplType;
+
         private:
-            ImpSdrLineAttribute*                mpSdrLineAttribute;
+            ImplType mpSdrLineAttribute;
 
         public:
             /// constructors/assignmentoperator/destructor
diff --git a/drawinglayer/source/attribute/sdrlineattribute.cxx b/drawinglayer/source/attribute/sdrlineattribute.cxx
index 1da5a79..60951d9 100644
--- a/drawinglayer/source/attribute/sdrlineattribute.cxx
+++ b/drawinglayer/source/attribute/sdrlineattribute.cxx
@@ -19,6 +19,7 @@
 
 #include <drawinglayer/attribute/sdrlineattribute.hxx>
 #include <basegfx/color/bcolor.hxx>
+#include <rtl/instance.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -29,9 +30,6 @@ namespace drawinglayer
         class ImpSdrLineAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                              mnRefCount;
-
             // line definitions
             basegfx::B2DLineJoin                    meJoin;             // B2DLINEJOIN_* defines
             double                                  mfWidth;            // 1/100th mm, 0.0==hair
@@ -49,8 +47,7 @@ namespace drawinglayer
                 com::sun::star::drawing::LineCap eCap,
                 const ::std::vector< double >& rDotDashArray,
                 double fFullDotDashLen)
-            :   mnRefCount(0),
-                meJoin(eJoin),
+            :   meJoin(eJoin),
                 mfWidth(fWidth),
                 mfTransparence(fTransparence),
                 maColor(rColor),
@@ -61,8 +58,7 @@ namespace drawinglayer
             }
 
             explicit ImpSdrLineAttribute(const basegfx::BColor& rColor)
-            :   mnRefCount(0),
-                meJoin(basegfx::B2DLINEJOIN_NONE),
+            :   meJoin(basegfx::B2DLINEJOIN_NONE),
                 mfWidth(0.0),
                 mfTransparence(0.0),
                 maColor(rColor),
@@ -72,6 +68,17 @@ namespace drawinglayer
             {
             }
 
+            ImpSdrLineAttribute()
+            :   meJoin(basegfx::B2DLINEJOIN_ROUND),
+                mfWidth(0.0),
+                mfTransparence(0.0),
+                maColor(basegfx::BColor()),
+                meCap(com::sun::star::drawing::LineCap_BUTT),
+                maDotDashArray(std::vector< double >()),
+                mfFullDotDashLen(0.0)
+            {
+            }
+
             // data read access
             basegfx::B2DLineJoin getJoin() const { return meJoin; }
             double getWidth() const { return mfWidth; }
@@ -90,30 +97,14 @@ namespace drawinglayer
                     && getCap() == rCandidate.getCap()
                     && getDotDashArray() == rCandidate.getDotDashArray());
             }
-
-            static ImpSdrLineAttribute* get_global_default()
-            {
-                static ImpSdrLineAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpSdrLineAttribute(
-                        basegfx::B2DLINEJOIN_ROUND,
-                        0.0,
-                        0.0,
-                        basegfx::BColor(),
-                        com::sun::star::drawing::LineCap_BUTT,
-                        std::vector< double >(),
-                        0.0);
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< SdrLineAttribute::ImplType, theGlobalDefault > {};
+        }
+
         SdrLineAttribute::SdrLineAttribute(
             basegfx::B2DLineJoin eJoin,
             double fWidth,
@@ -123,7 +114,7 @@ namespace drawinglayer
             const ::std::vector< double >& rDotDashArray,
             double fFullDotDashLen)
         :   mpSdrLineAttribute(
-                new ImpSdrLineAttribute(
+                ImpSdrLineAttribute(
                     eJoin,
                     fWidth,
                     fTransparence,
@@ -136,67 +127,33 @@ namespace drawinglayer
         }
 
         SdrLineAttribute::SdrLineAttribute()
-        :   mpSdrLineAttribute(ImpSdrLineAttribute::get_global_default())
+        :   mpSdrLineAttribute(theGlobalDefault::get())
         {
-            mpSdrLineAttribute->mnRefCount++;
         }
 
         SdrLineAttribute::SdrLineAttribute(const SdrLineAttribute& rCandidate)
         :   mpSdrLineAttribute(rCandidate.mpSdrLineAttribute)
         {
-            mpSdrLineAttribute->mnRefCount++;
         }
 
         SdrLineAttribute::~SdrLineAttribute()
         {
-            if(mpSdrLineAttribute->mnRefCount)
-            {
-                mpSdrLineAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpSdrLineAttribute;
-            }
         }
 
         bool SdrLineAttribute::isDefault() const
         {
-            return mpSdrLineAttribute == ImpSdrLineAttribute::get_global_default();
+            return mpSdrLineAttribute.same_object(theGlobalDefault::get());
         }
 
         SdrLineAttribute& SdrLineAttribute::operator=(const SdrLineAttribute& rCandidate)
         {
-            if(rCandidate.mpSdrLineAttribute != mpSdrLineAttribute)
-            {
-                if(mpSdrLineAttribute->mnRefCount)
-                {
-                    mpSdrLineAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpSdrLineAttribute;
-                }
-
-                mpSdrLineAttribute = rCandidate.mpSdrLineAttribute;
-                mpSdrLineAttribute->mnRefCount++;
-            }
-
+            mpSdrLineAttribute = rCandidate.mpSdrLineAttribute;
             return *this;
         }
 
         bool SdrLineAttribute::operator==(const SdrLineAttribute& rCandidate) const
         {
-            if(rCandidate.mpSdrLineAttribute == mpSdrLineAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpSdrLineAttribute == *mpSdrLineAttribute);
+            return rCandidate.mpSdrLineAttribute == mpSdrLineAttribute;
         }
 
         basegfx::B2DLineJoin SdrLineAttribute::getJoin() const
commit 4f989f306898db0b9732301b03e2b4d02159869d
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 02:05:40 2013 +0200

    fdo#62525: use cow_wrapper for SdrLightingAttribute
    
    Change-Id: Ibd6bd31ef78f2e853ff668f64202eff89afb1234

diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrlightingattribute3d.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrlightingattribute3d.hxx
index 08b333c..0c3bb96 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrlightingattribute3d.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrlightingattribute3d.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRLIGHTINGATTRIBUTE3D_HXX
 
 #include <drawinglayer/drawinglayerdllapi.h>
+#include <o3tl/cow_wrapper.hxx>
 
 #include <vector>
 
@@ -45,8 +46,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC SdrLightingAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpSdrLightingAttribute > ImplType;
+
         private:
-            ImpSdrLightingAttribute*            mpSdrLightingAttribute;
+            ImplType mpSdrLightingAttribute;
 
         public:
             /// constructors/assignmentoperator/destructor
diff --git a/drawinglayer/source/attribute/sdrlightingattribute3d.cxx b/drawinglayer/source/attribute/sdrlightingattribute3d.cxx
index 3402840..b7ee605 100644
--- a/drawinglayer/source/attribute/sdrlightingattribute3d.cxx
+++ b/drawinglayer/source/attribute/sdrlightingattribute3d.cxx
@@ -21,6 +21,7 @@
 #include <basegfx/color/bcolor.hxx>
 #include <basegfx/vector/b3dvector.hxx>
 #include <drawinglayer/attribute/sdrlightattribute3d.hxx>
+#include <rtl/instance.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -31,9 +32,6 @@ namespace drawinglayer
         class ImpSdrLightingAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                              mnRefCount;
-
             // 3D light attribute definitions
             basegfx::BColor                         maAmbientLight;
             ::std::vector< Sdr3DLightAttribute >    maLightVector;
@@ -41,12 +39,17 @@ namespace drawinglayer
             ImpSdrLightingAttribute(
                 const basegfx::BColor& rAmbientLight,
                 const ::std::vector< Sdr3DLightAttribute >& rLightVector)
-            :   mnRefCount(0),
-                maAmbientLight(rAmbientLight),
+            :   maAmbientLight(rAmbientLight),
                 maLightVector(rLightVector)
             {
             }
 
+            ImpSdrLightingAttribute()
+            :   maAmbientLight(basegfx::BColor()),
+                maLightVector(std::vector< Sdr3DLightAttribute >())
+            {
+            }
+
             // data read access
             const basegfx::BColor& getAmbientLight() const { return maAmbientLight; }
             const ::std::vector< Sdr3DLightAttribute >& getLightVector() const { return maLightVector; }
@@ -56,95 +59,50 @@ namespace drawinglayer
                 return (getAmbientLight() == rCandidate.getAmbientLight()
                     && getLightVector() == rCandidate.getLightVector());
             }
-
-            static ImpSdrLightingAttribute* get_global_default()
-            {
-                static ImpSdrLightingAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpSdrLightingAttribute(
-                        basegfx::BColor(),
-                        std::vector< Sdr3DLightAttribute >());
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< SdrLightingAttribute::ImplType, theGlobalDefault > {};
+        }
+
         SdrLightingAttribute::SdrLightingAttribute(
             const basegfx::BColor& rAmbientLight,
             const ::std::vector< Sdr3DLightAttribute >& rLightVector)
-        :   mpSdrLightingAttribute(new ImpSdrLightingAttribute(
+        :   mpSdrLightingAttribute(ImpSdrLightingAttribute(
                 rAmbientLight, rLightVector))
         {
         }
 
         SdrLightingAttribute::SdrLightingAttribute()
-        :   mpSdrLightingAttribute(ImpSdrLightingAttribute::get_global_default())
+        :   mpSdrLightingAttribute(theGlobalDefault::get())
         {
-            mpSdrLightingAttribute->mnRefCount++;
         }
 
         SdrLightingAttribute::SdrLightingAttribute(const SdrLightingAttribute& rCandidate)
         :   mpSdrLightingAttribute(rCandidate.mpSdrLightingAttribute)
         {
-            mpSdrLightingAttribute->mnRefCount++;
         }
 
         SdrLightingAttribute::~SdrLightingAttribute()
         {
-            if(mpSdrLightingAttribute->mnRefCount)
-            {
-                mpSdrLightingAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpSdrLightingAttribute;
-            }
         }
 
         bool SdrLightingAttribute::isDefault() const
         {
-            return mpSdrLightingAttribute == ImpSdrLightingAttribute::get_global_default();
+            return mpSdrLightingAttribute.same_object(theGlobalDefault::get());
         }
 
         SdrLightingAttribute& SdrLightingAttribute::operator=(const SdrLightingAttribute& rCandidate)
         {
-            if(rCandidate.mpSdrLightingAttribute != mpSdrLightingAttribute)
-            {
-                if(mpSdrLightingAttribute->mnRefCount)
-                {
-                    mpSdrLightingAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpSdrLightingAttribute;
-                }
-
-                mpSdrLightingAttribute = rCandidate.mpSdrLightingAttribute;
-                mpSdrLightingAttribute->mnRefCount++;
-            }
-
+            mpSdrLightingAttribute = rCandidate.mpSdrLightingAttribute;
             return *this;
         }
 
         bool SdrLightingAttribute::operator==(const SdrLightingAttribute& rCandidate) const
         {
-            if(rCandidate.mpSdrLightingAttribute == mpSdrLightingAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpSdrLightingAttribute == *mpSdrLightingAttribute);
+            return rCandidate.mpSdrLightingAttribute == mpSdrLightingAttribute;
         }
 
         const ::std::vector< Sdr3DLightAttribute >& SdrLightingAttribute::getLightVector() const
commit f61b5c3654fc011ab0c6e042f6df010e39536d85
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 02:00:06 2013 +0200

    fdo#62525: use cow_wrapper for Sdr3DLightAttribute
    
    Change-Id: I9639746d072642d46c3f0766c473425221b1706a

diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrlightattribute3d.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrlightattribute3d.hxx
index fe2e998..f9e3579 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrlightattribute3d.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrlightattribute3d.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRLIGHTATTRIBUTE3D_HXX
 
 #include <drawinglayer/drawinglayerdllapi.h>
+#include <o3tl/cow_wrapper.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // predefines
@@ -42,8 +43,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC Sdr3DLightAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpSdr3DLightAttribute > ImplType;
+
         private:
-            ImpSdr3DLightAttribute*             mpSdr3DLightAttribute;
+            ImplType mpSdr3DLightAttribute;
 
         public:
             // constructors/destructor
diff --git a/drawinglayer/source/attribute/sdrlightattribute3d.cxx b/drawinglayer/source/attribute/sdrlightattribute3d.cxx
index 51cdaf6..8b900fb 100644
--- a/drawinglayer/source/attribute/sdrlightattribute3d.cxx
+++ b/drawinglayer/source/attribute/sdrlightattribute3d.cxx
@@ -20,6 +20,7 @@
 #include <drawinglayer/attribute/sdrlightattribute3d.hxx>
 #include <basegfx/color/bcolor.hxx>
 #include <basegfx/vector/b3dvector.hxx>
+#include <rtl/instance.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -30,9 +31,6 @@ namespace drawinglayer
         class ImpSdr3DLightAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                              mnRefCount;
-
             // 3D light attribute definitions
             basegfx::BColor                         maColor;
             basegfx::B3DVector                      maDirection;
@@ -44,13 +42,19 @@ namespace drawinglayer
                 const basegfx::BColor& rColor,
                 const basegfx::B3DVector& rDirection,
                 bool bSpecular)
-            :   mnRefCount(0),
-                maColor(rColor),
+            :   maColor(rColor),
                 maDirection(rDirection),
                 mbSpecular(bSpecular)
             {
             }
 
+            ImpSdr3DLightAttribute()
+            :   maColor(basegfx::BColor()),
+                maDirection(basegfx::B3DVector()),
+                mbSpecular(false)
+            {
+            }
+
             // data read access
             const basegfx::BColor& getColor() const { return maColor; }
             const basegfx::B3DVector& getDirection() const { return maDirection; }
@@ -62,31 +66,19 @@ namespace drawinglayer
                     && getDirection() == rCandidate.getDirection()
                     && getSpecular() == rCandidate.getSpecular());
             }
-
-            static ImpSdr3DLightAttribute* get_global_default()
-            {
-                static ImpSdr3DLightAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpSdr3DLightAttribute(
-                        basegfx::BColor(),
-                        basegfx::B3DVector(),
-                        false);
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< Sdr3DLightAttribute::ImplType, theGlobalDefault > {};
+        }
+
         Sdr3DLightAttribute::Sdr3DLightAttribute(
             const basegfx::BColor& rColor,
             const basegfx::B3DVector& rDirection,
             bool bSpecular)
-        :   mpSdr3DLightAttribute(new ImpSdr3DLightAttribute(
+        :   mpSdr3DLightAttribute(ImpSdr3DLightAttribute(
                 rColor, rDirection, bSpecular))
         {
         }
@@ -94,59 +86,26 @@ namespace drawinglayer
         Sdr3DLightAttribute::Sdr3DLightAttribute(const Sdr3DLightAttribute& rCandidate)
         :   mpSdr3DLightAttribute(rCandidate.mpSdr3DLightAttribute)
         {
-            mpSdr3DLightAttribute->mnRefCount++;
         }
 
         Sdr3DLightAttribute::~Sdr3DLightAttribute()
         {
-            if(mpSdr3DLightAttribute->mnRefCount)
-            {
-                mpSdr3DLightAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpSdr3DLightAttribute;
-            }
         }
 
         bool Sdr3DLightAttribute::isDefault() const
         {
-            return mpSdr3DLightAttribute == ImpSdr3DLightAttribute::get_global_default();
+            return mpSdr3DLightAttribute.same_object(theGlobalDefault::get());
         }
 
         Sdr3DLightAttribute& Sdr3DLightAttribute::operator=(const Sdr3DLightAttribute& rCandidate)
         {
-            if(rCandidate.mpSdr3DLightAttribute != mpSdr3DLightAttribute)
-            {
-                if(mpSdr3DLightAttribute->mnRefCount)
-                {
-                    mpSdr3DLightAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpSdr3DLightAttribute;
-                }
-
-                mpSdr3DLightAttribute = rCandidate.mpSdr3DLightAttribute;
-                mpSdr3DLightAttribute->mnRefCount++;
-            }
-
+            mpSdr3DLightAttribute = rCandidate.mpSdr3DLightAttribute;
             return *this;
         }
 
         bool Sdr3DLightAttribute::operator==(const Sdr3DLightAttribute& rCandidate) const
         {
-            if(rCandidate.mpSdr3DLightAttribute == mpSdr3DLightAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpSdr3DLightAttribute == *mpSdr3DLightAttribute);
+            return rCandidate.mpSdr3DLightAttribute == mpSdr3DLightAttribute;
         }
 
         const basegfx::BColor& Sdr3DLightAttribute::getColor() const
commit f5cf7f36f90f454fd40c5894fbdf5ae070b6b59e
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 01:54:49 2013 +0200

    fdo#62525: use cow_wrapper for SdrFillBitmapAttribute
    
    Change-Id: Ib8bb849b179be12680c5adae6bf89afc5ad31563

diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx
index 602455e..78417f3 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrfillbitmapattribute.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRFILLBITMAPATTRIBUTE_HXX
 
 #include <drawinglayer/drawinglayerdllapi.h>
+#include <o3tl/cow_wrapper.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // predefines
@@ -45,8 +46,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC SdrFillBitmapAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpSdrFillBitmapAttribute > ImplType;
+
         private:
-            ImpSdrFillBitmapAttribute*          mpSdrFillBitmapAttribute;
+            ImplType mpSdrFillBitmapAttribute;
 
         public:
             /// constructors/assignmentoperator/destructor
diff --git a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx b/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx
index 5d86525..b21566f 100644
--- a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx
+++ b/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx
@@ -19,6 +19,7 @@
 
 #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
 #include <drawinglayer/attribute/fillbitmapattribute.hxx>
+#include <rtl/instance.hxx>
 #include <vcl/bitmapex.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
@@ -30,9 +31,6 @@ namespace drawinglayer
         class ImpSdrFillBitmapAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                              mnRefCount;
-
             // data definitions
             BitmapEx                                maBitmapEx;
             basegfx::B2DVector                      maSize;
@@ -54,8 +52,7 @@ namespace drawinglayer
                 bool bTiling,
                 bool bStretch,
                 bool bLogSize)
-            :   mnRefCount(0),
-                maBitmapEx(rBitmapEx),
+            :   maBitmapEx(rBitmapEx),
                 maSize(rSize),
                 maOffset(rOffset),
                 maOffsetPosition(rOffsetPosition),
@@ -66,6 +63,18 @@ namespace drawinglayer
             {
             }
 
+            ImpSdrFillBitmapAttribute()
+            :   maBitmapEx(BitmapEx()),
+                maSize(basegfx::B2DVector()),
+                maOffset(basegfx::B2DVector()),
+                maOffsetPosition(basegfx::B2DVector()),
+                maRectPoint(basegfx::B2DVector()),
+                mbTiling(false),
+                mbStretch(false),
+                mbLogSize(false)
+            {
+            }
+
             // data read access
             const BitmapEx& getBitmapEx() const { return maBitmapEx; }
             const basegfx::B2DVector& getSize() const { return maSize; }
@@ -87,31 +96,14 @@ namespace drawinglayer
                     && getStretch() == rCandidate.getStretch()
                     && getLogSize() == rCandidate.getLogSize());
             }
-
-            static ImpSdrFillBitmapAttribute* get_global_default()
-            {
-                static ImpSdrFillBitmapAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpSdrFillBitmapAttribute(
-                        BitmapEx(),
-                        basegfx::B2DVector(),
-                        basegfx::B2DVector(),
-                        basegfx::B2DVector(),
-                        basegfx::B2DVector(),
-                        false,
-                        false,
-                        false);
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< SdrFillBitmapAttribute::ImplType, theGlobalDefault > {};
+        }
+
         SdrFillBitmapAttribute::SdrFillBitmapAttribute(
             const BitmapEx& rBitmapEx,
             const basegfx::B2DVector& rSize,
@@ -122,7 +114,7 @@ namespace drawinglayer
             bool bStretch,
             bool bLogSize)
         :   mpSdrFillBitmapAttribute(
-                new ImpSdrFillBitmapAttribute(
+                ImpSdrFillBitmapAttribute(
                     rBitmapEx,
                     rSize,
                     rOffset,
@@ -135,67 +127,33 @@ namespace drawinglayer
         }
 
         SdrFillBitmapAttribute::SdrFillBitmapAttribute()
-        :   mpSdrFillBitmapAttribute(ImpSdrFillBitmapAttribute::get_global_default())
+        :   mpSdrFillBitmapAttribute(theGlobalDefault::get())
         {
-            mpSdrFillBitmapAttribute->mnRefCount++;
         }
 
         SdrFillBitmapAttribute::SdrFillBitmapAttribute(const SdrFillBitmapAttribute& rCandidate)
         :   mpSdrFillBitmapAttribute(rCandidate.mpSdrFillBitmapAttribute)
         {
-            mpSdrFillBitmapAttribute->mnRefCount++;
         }
 
         SdrFillBitmapAttribute::~SdrFillBitmapAttribute()
         {
-            if(mpSdrFillBitmapAttribute->mnRefCount)
-            {
-                mpSdrFillBitmapAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpSdrFillBitmapAttribute;
-            }
         }
 
         bool SdrFillBitmapAttribute::isDefault() const
         {
-            return mpSdrFillBitmapAttribute == ImpSdrFillBitmapAttribute::get_global_default();
+            return mpSdrFillBitmapAttribute.same_object(theGlobalDefault::get());
         }
 
         SdrFillBitmapAttribute& SdrFillBitmapAttribute::operator=(const SdrFillBitmapAttribute& rCandidate)
         {
-            if(rCandidate.mpSdrFillBitmapAttribute != mpSdrFillBitmapAttribute)
-            {
-                if(mpSdrFillBitmapAttribute->mnRefCount)
-                {
-                    mpSdrFillBitmapAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpSdrFillBitmapAttribute;
-                }
-
-                mpSdrFillBitmapAttribute = rCandidate.mpSdrFillBitmapAttribute;
-                mpSdrFillBitmapAttribute->mnRefCount++;
-            }
-
+            mpSdrFillBitmapAttribute = rCandidate.mpSdrFillBitmapAttribute;
             return *this;
         }
 
         bool SdrFillBitmapAttribute::operator==(const SdrFillBitmapAttribute& rCandidate) const
         {
-            if(rCandidate.mpSdrFillBitmapAttribute == mpSdrFillBitmapAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpSdrFillBitmapAttribute == *mpSdrFillBitmapAttribute);
+            return rCandidate.mpSdrFillBitmapAttribute == mpSdrFillBitmapAttribute;
         }
 
         const BitmapEx& SdrFillBitmapAttribute::getBitmapEx() const
commit f98bee58fbf1e4862477fb6aa014447746f1ef9d
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Wed Apr 3 01:47:25 2013 +0200

    fdo#62525: use cow_wrapper for SdrFillAttribute
    
    Change-Id: I827e1edb2c6ec2fc3e16fde6f105063e59d40f66

diff --git a/drawinglayer/inc/drawinglayer/attribute/sdrfillattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/sdrfillattribute.hxx
index 038916f..7fd3d38 100644
--- a/drawinglayer/inc/drawinglayer/attribute/sdrfillattribute.hxx
+++ b/drawinglayer/inc/drawinglayer/attribute/sdrfillattribute.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_DRAWINGLAYER_ATTRIBUTE_SDRFILLATTRIBUTE_HXX
 
 #include <drawinglayer/drawinglayerdllapi.h>
+#include <o3tl/cow_wrapper.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // predefines
@@ -44,8 +45,11 @@ namespace drawinglayer
     {
         class DRAWINGLAYER_DLLPUBLIC SdrFillAttribute
         {
+        public:
+            typedef o3tl::cow_wrapper< ImpSdrFillAttribute > ImplType;
+
         private:
-            ImpSdrFillAttribute*            mpSdrFillAttribute;
+            ImplType mpSdrFillAttribute;
 
         public:
             /// constructors/assignmentoperator/destructor
diff --git a/drawinglayer/source/attribute/sdrfillattribute.cxx b/drawinglayer/source/attribute/sdrfillattribute.cxx
index 421e34c..98c6450 100644
--- a/drawinglayer/source/attribute/sdrfillattribute.cxx
+++ b/drawinglayer/source/attribute/sdrfillattribute.cxx
@@ -22,6 +22,7 @@
 #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
 #include <drawinglayer/attribute/fillhatchattribute.hxx>
 #include <drawinglayer/attribute/fillgradientattribute.hxx>
+#include <rtl/instance.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -32,9 +33,6 @@ namespace drawinglayer
         class ImpSdrFillAttribute
         {
         public:
-            // refcounter
-            sal_uInt32                          mnRefCount;
-
             // fill definitions
             double                              mfTransparence;     // [0.0 .. 1.0], 0.0==no transp.
             basegfx::BColor                     maColor;            // fill color
@@ -49,8 +47,7 @@ namespace drawinglayer
                 const FillGradientAttribute& rGradient,
                 const FillHatchAttribute& rHatch,
                 const SdrFillBitmapAttribute& rBitmap)
-            :   mnRefCount(0),
-                mfTransparence(fTransparence),
+            :   mfTransparence(fTransparence),
                 maColor(rColor),
                 maGradient(rGradient),
                 maHatch(rHatch),
@@ -58,6 +55,15 @@ namespace drawinglayer
             {
             }
 
+            ImpSdrFillAttribute()
+            :   mfTransparence(0.0),
+                maColor(basegfx::BColor()),
+                maGradient(FillGradientAttribute()),
+                maHatch(FillHatchAttribute()),
+                maBitmap(SdrFillBitmapAttribute())
+            {
+            }
+
             // data read access
             double getTransparence() const { return mfTransparence; }
             const basegfx::BColor& getColor() const { return maColor; }
@@ -74,101 +80,53 @@ namespace drawinglayer
                     && getHatch() == rCandidate.getHatch()
                     && getBitmap() == rCandidate.getBitmap());
             }
-
-            static ImpSdrFillAttribute* get_global_default()
-            {
-                static ImpSdrFillAttribute* pDefault = 0;
-
-                if(!pDefault)
-                {
-                    pDefault = new ImpSdrFillAttribute(
-                        0.0,
-                        basegfx::BColor(),
-                        FillGradientAttribute(),
-                        FillHatchAttribute(),
-                        SdrFillBitmapAttribute());
-
-                    // never delete; start with RefCount 1, not 0
-                    pDefault->mnRefCount++;
-                }
-
-                return pDefault;
-            }
         };
 
+        namespace
+        {
+            struct theGlobalDefault :
+                public rtl::Static< SdrFillAttribute::ImplType, theGlobalDefault > {};
+        }
+
         SdrFillAttribute::SdrFillAttribute(
             double fTransparence,
             const basegfx::BColor& rColor,
             const FillGradientAttribute& rGradient,
             const FillHatchAttribute& rHatch,
             const SdrFillBitmapAttribute& rBitmap)
-        :   mpSdrFillAttribute(new ImpSdrFillAttribute(
+        :   mpSdrFillAttribute(ImpSdrFillAttribute(
                 fTransparence, rColor, rGradient, rHatch, rBitmap))
         {
         }
 
         SdrFillAttribute::SdrFillAttribute()
-        :   mpSdrFillAttribute(ImpSdrFillAttribute::get_global_default())
+        :   mpSdrFillAttribute(theGlobalDefault::get())
         {
-            mpSdrFillAttribute->mnRefCount++;
         }
 
         SdrFillAttribute::SdrFillAttribute(const SdrFillAttribute& rCandidate)
         :   mpSdrFillAttribute(rCandidate.mpSdrFillAttribute)
         {
-            mpSdrFillAttribute->mnRefCount++;
         }
 
         SdrFillAttribute::~SdrFillAttribute()
         {
-            if(mpSdrFillAttribute->mnRefCount)
-            {
-                mpSdrFillAttribute->mnRefCount--;
-            }
-            else
-            {
-                delete mpSdrFillAttribute;
-            }
         }
 
         bool SdrFillAttribute::isDefault() const
         {
-            return mpSdrFillAttribute == ImpSdrFillAttribute::get_global_default();
+            return mpSdrFillAttribute.same_object(theGlobalDefault::get());
         }
 
         SdrFillAttribute& SdrFillAttribute::operator=(const SdrFillAttribute& rCandidate)
         {
-            if(rCandidate.mpSdrFillAttribute != mpSdrFillAttribute)
-            {
-                if(mpSdrFillAttribute->mnRefCount)
-                {
-                    mpSdrFillAttribute->mnRefCount--;
-                }
-                else
-                {
-                    delete mpSdrFillAttribute;
-                }
-
-                mpSdrFillAttribute = rCandidate.mpSdrFillAttribute;
-                mpSdrFillAttribute->mnRefCount++;
-            }
-
+            mpSdrFillAttribute = rCandidate.mpSdrFillAttribute;
             return *this;
         }
 
         bool SdrFillAttribute::operator==(const SdrFillAttribute& rCandidate) const
         {
-            if(rCandidate.mpSdrFillAttribute == mpSdrFillAttribute)
-            {
-                return true;
-            }
-
-            if(rCandidate.isDefault() != isDefault())
-            {
-                return false;
-            }
-
-            return (*rCandidate.mpSdrFillAttribute == *mpSdrFillAttribute);
+            return rCandidate.mpSdrFillAttribute == mpSdrFillAttribute;
         }
 
         double SdrFillAttribute::getTransparence() const


More information about the Libreoffice-commits mailing list