summaryrefslogtreecommitdiff
path: root/svx/source/sdr/attribute
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2015-05-24 17:21:47 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2015-05-24 21:50:10 +0200
commite9bb2e6f09d711833e659db3b229326d5e997266 (patch)
treea035b32b69876853dfd6be0f4a433712c298ff64 /svx/source/sdr/attribute
parent27e1a92d3bddf3c3e8595256e67aff006a402b6a (diff)
tdf#62525: use cow_wrapper for SdrTextAttribute
Change-Id: I8daf6d155c631cbdb850a6af95c92a578905d6e6
Diffstat (limited to 'svx/source/sdr/attribute')
-rw-r--r--svx/source/sdr/attribute/sdrtextattribute.cxx91
1 files changed, 20 insertions, 71 deletions
diff --git a/svx/source/sdr/attribute/sdrtextattribute.cxx b/svx/source/sdr/attribute/sdrtextattribute.cxx
index 57d2dfd065d7..45b55fbe84ba 100644
--- a/svx/source/sdr/attribute/sdrtextattribute.cxx
+++ b/svx/source/sdr/attribute/sdrtextattribute.cxx
@@ -25,7 +25,7 @@
#include <editeng/editobj.hxx>
#include <editeng/flditem.hxx>
#include <svx/sdr/properties/properties.hxx>
-
+#include <rtl/instance.hxx>
namespace drawinglayer
@@ -35,9 +35,6 @@ namespace drawinglayer
class ImpSdrTextAttribute
{
public:
- // refcounter
- sal_uInt32 mnRefCount;
-
// all-text attributes. The SdrText itself and a copy
// of the OPO
const SdrText* mpSdrText;
@@ -90,8 +87,7 @@ namespace drawinglayer
bool bInEditMode,
bool bFixedCellHeight,
bool bWrongSpell)
- : mnRefCount(0),
- mpSdrText(pSdrText),
+ : mpSdrText(pSdrText),
mpOutlinerParaObject(new OutlinerParaObject(rOutlinerParaObject)),
maSdrFormTextAttribute(),
maTextLeftDistance(aTextLeftDistance),
@@ -128,8 +124,7 @@ namespace drawinglayer
}
ImpSdrTextAttribute()
- : mnRefCount(0),
- mpSdrText(0),
+ : mpSdrText(0),
mpOutlinerParaObject(0),
maSdrFormTextAttribute(),
maTextLeftDistance(0),
@@ -151,14 +146,6 @@ namespace drawinglayer
{
}
- ~ImpSdrTextAttribute()
- {
- if(mpOutlinerParaObject)
- {
- delete mpOutlinerParaObject;
- }
- }
-
// data read access
const SdrText& getSdrText() const
{
@@ -241,24 +228,14 @@ namespace drawinglayer
&& isFixedCellHeight() == rCandidate.isFixedCellHeight()
&& isWrongSpell() == rCandidate.isWrongSpell());
}
-
- static ImpSdrTextAttribute* get_global_default()
- {
- static ImpSdrTextAttribute* pDefault = 0;
-
- if(!pDefault)
- {
- // use default constructor
- pDefault = new ImpSdrTextAttribute();
-
- // never delete; start with RefCount 1, not 0
- pDefault->mnRefCount++;
- }
-
- return pDefault;
- }
};
+ namespace
+ {
+ struct theGlobalDefault :
+ public rtl::Static< SdrTextAttribute::ImplType, theGlobalDefault > {};
+ }
+
SdrTextAttribute::SdrTextAttribute(
const SdrText& rSdrText,
const OutlinerParaObject& rOutlinerParaObject,
@@ -278,75 +255,47 @@ namespace drawinglayer
bool bInEditMode,
bool bFixedCellHeight,
bool bWrongSpell)
- : mpSdrTextAttribute(new ImpSdrTextAttribute(
- &rSdrText, rOutlinerParaObject, eFormTextStyle, aTextLeftDistance, aTextUpperDistance,
- aTextRightDistance, aTextLowerDistance, aSdrTextHorzAdjust, aSdrTextVertAdjust, bContour,
- bFitToSize, bAutoFit, bHideContour, bBlink, bScroll, bInEditMode, bFixedCellHeight, bWrongSpell))
+ : mpSdrTextAttribute(
+ ImpSdrTextAttribute(
+ &rSdrText, rOutlinerParaObject, eFormTextStyle, aTextLeftDistance,
+ aTextUpperDistance, aTextRightDistance, aTextLowerDistance,
+ aSdrTextHorzAdjust, aSdrTextVertAdjust, bContour, bFitToSize, bAutoFit,
+ bHideContour, bBlink, bScroll, bInEditMode, bFixedCellHeight, bWrongSpell))
{
}
SdrTextAttribute::SdrTextAttribute()
- : mpSdrTextAttribute(ImpSdrTextAttribute::get_global_default())
+ : mpSdrTextAttribute(theGlobalDefault::get())
{
- mpSdrTextAttribute->mnRefCount++;
}
SdrTextAttribute::SdrTextAttribute(const SdrTextAttribute& rCandidate)
: mpSdrTextAttribute(rCandidate.mpSdrTextAttribute)
{
- mpSdrTextAttribute->mnRefCount++;
}
SdrTextAttribute::~SdrTextAttribute()
{
- if(mpSdrTextAttribute->mnRefCount)
- {
- mpSdrTextAttribute->mnRefCount--;
- }
- else
- {
- delete mpSdrTextAttribute;
- }
}
bool SdrTextAttribute::isDefault() const
{
- return mpSdrTextAttribute == ImpSdrTextAttribute::get_global_default();
+ return mpSdrTextAttribute.same_object(theGlobalDefault::get());
}
SdrTextAttribute& SdrTextAttribute::operator=(const SdrTextAttribute& rCandidate)
{
- if(rCandidate.mpSdrTextAttribute != mpSdrTextAttribute)
- {
- if(mpSdrTextAttribute->mnRefCount)
- {
- mpSdrTextAttribute->mnRefCount--;
- }
- else
- {
- delete mpSdrTextAttribute;
- }
-
- mpSdrTextAttribute = rCandidate.mpSdrTextAttribute;
- mpSdrTextAttribute->mnRefCount++;
- }
-
+ mpSdrTextAttribute = rCandidate.mpSdrTextAttribute;
return *this;
}
bool SdrTextAttribute::operator==(const SdrTextAttribute& rCandidate) const
{
- if(rCandidate.mpSdrTextAttribute == mpSdrTextAttribute)
- {
- return true;
- }
-
+ // tdf#87509 default attr is always != non-default attr, even with same values
if(rCandidate.isDefault() != isDefault())
- {
return false;
- }
- return (*rCandidate.mpSdrTextAttribute == *mpSdrTextAttribute);
+ return rCandidate.mpSdrTextAttribute == mpSdrTextAttribute;
}
const SdrText& SdrTextAttribute::getSdrText() const