summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-01-22 16:12:03 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-01-22 16:16:16 +0100
commitec8ff9ff68622a510319c404f4745a336e65d314 (patch)
treec02035554c7630e31b6849fd29670ad7ac4d1256 /sd
parent77479d619b3d22fc521be87a98587f031382b156 (diff)
replace manual ref count with shared_ptr
Change-Id: I11dbebe78f6945afd0b88b53e482dea47ddd192d
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/eppt/pptx-text.cxx57
-rw-r--r--sd/source/filter/eppt/text.hxx45
2 files changed, 50 insertions, 52 deletions
diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx
index 481666b1e6a9..ff5532c3d475 100644
--- a/sd/source/filter/eppt/pptx-text.cxx
+++ b/sd/source/filter/eppt/pptx-text.cxx
@@ -1180,10 +1180,21 @@ ParagraphObj& ParagraphObj::operator=( const ParagraphObj& rParagraphObj )
return *this;
}
+struct ImplTextObj
+{
+ sal_uInt32 mnTextSize;
+ int mnInstance;
+ std::vector<ParagraphObj*> maList;
+ sal_Bool mbHasExtendedBullets;
+ sal_Bool mbFixedCellHeightUsed;
+
+ ImplTextObj( int nInstance );
+ ~ImplTextObj();
+};
+
ImplTextObj::ImplTextObj( int nInstance )
: maList()
{
- mnRefCount = 1;
mnTextSize = 0;
mnInstance = nInstance;
mbHasExtendedBullets = sal_False;
@@ -1197,10 +1208,9 @@ ImplTextObj::~ImplTextObj()
}
TextObj::TextObj( ::com::sun::star::uno::Reference< ::com::sun::star::text::XSimpleText > & rXTextRef,
- int nInstance, FontCollection& rFontCollection, PPTExBulletProvider& rProv )
+ int nInstance, FontCollection& rFontCollection, PPTExBulletProvider& rProv ):
+ mpImplTextObj(new ImplTextObj(nInstance))
{
- mpImplTextObj = new ImplTextObj( nInstance );
-
::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumerationAccess >
aXTextParagraphEA( rXTextRef, ::com::sun::star::uno::UNO_QUERY );
@@ -1230,35 +1240,36 @@ TextObj::TextObj( ::com::sun::star::uno::Reference< ::com::sun::star::text::XSim
ImplCalculateTextPositions();
}
-TextObj::TextObj( const TextObj& rTextObj )
+void TextObj::ImplCalculateTextPositions()
{
- mpImplTextObj = const_cast<TextObj&>(rTextObj).mpImplTextObj;
- mpImplTextObj->mnRefCount++;
+ mpImplTextObj->mnTextSize = 0;
+ for ( sal_uInt32 i = 0; i < ParagraphCount(); ++i )
+ mpImplTextObj->mnTextSize += GetParagraph(i)->ImplCalculateTextPositions( mpImplTextObj->mnTextSize );
}
-TextObj::~TextObj()
+ParagraphObj* TextObj::GetParagraph(int idx)
{
- if ( ! ( --mpImplTextObj->mnRefCount ) )
- delete mpImplTextObj;
+ return mpImplTextObj->maList[idx];
}
-void TextObj::ImplCalculateTextPositions()
+sal_uInt32 TextObj::ParagraphCount() const
{
- mpImplTextObj->mnTextSize = 0;
- for ( sal_uInt32 i = 0; i < ParagraphCount(); ++i )
- mpImplTextObj->mnTextSize += GetParagraph(i)->ImplCalculateTextPositions( mpImplTextObj->mnTextSize );
+ return mpImplTextObj->maList.size();
}
-TextObj& TextObj::operator=( TextObj& rTextObj )
+sal_uInt32 TextObj::Count() const
{
- if ( this != &rTextObj )
- {
- if ( ! ( --mpImplTextObj->mnRefCount ) )
- delete mpImplTextObj;
- mpImplTextObj = rTextObj.mpImplTextObj;
- mpImplTextObj->mnRefCount++;
- }
- return *this;
+ return mpImplTextObj->mnTextSize;
+}
+
+int TextObj::GetInstance() const
+{
+ return mpImplTextObj->mnInstance;
+}
+
+sal_Bool TextObj::HasExtendedBullets()
+{
+ return mpImplTextObj->mbHasExtendedBullets;
}
FontCollectionEntry::~FontCollectionEntry()
diff --git a/sd/source/filter/eppt/text.hxx b/sd/source/filter/eppt/text.hxx
index e69023852ea5..feb291a42f71 100644
--- a/sd/source/filter/eppt/text.hxx
+++ b/sd/source/filter/eppt/text.hxx
@@ -27,6 +27,8 @@
#include <com/sun/star/awt/FontDescriptor.hpp>
#include <com/sun/star/lang/Locale.hpp>
+#include <boost/shared_ptr.hpp>
+
namespace com { namespace sun { namespace star {
namespace awt { struct FontDescriptor; }
namespace beans { class XPropertyState; }
@@ -219,38 +221,23 @@ class ParagraphObj : public std::vector<PortionObj*>, public PropStateValue, pub
ParagraphObj& operator=( const ParagraphObj& rParagraphObj );
};
-struct ImplTextObj
-{
- sal_uInt32 mnRefCount;
- sal_uInt32 mnTextSize;
- int mnInstance;
- std::vector<ParagraphObj*> maList;
- sal_Bool mbHasExtendedBullets;
- sal_Bool mbFixedCellHeightUsed;
-
- ImplTextObj( int nInstance );
- ~ImplTextObj();
-};
+struct ImplTextObj;
class TextObj
{
- ImplTextObj* mpImplTextObj;
- void ImplCalculateTextPositions();
-
- public :
- TextObj( ::com::sun::star::uno::Reference< ::com::sun::star::text::XSimpleText > &
- rXText, int nInstance, FontCollection& rFontCollection, PPTExBulletProvider& rBuProv );
- TextObj( const TextObj& rTextObj );
- ~TextObj();
-
- ParagraphObj* GetParagraph(int idx) { return mpImplTextObj->maList[idx]; };
- sal_uInt32 ParagraphCount() const { return mpImplTextObj->maList.size(); };
- sal_uInt32 Count() const { return mpImplTextObj->mnTextSize; };
- int GetInstance() const { return mpImplTextObj->mnInstance; };
- sal_Bool HasExtendedBullets(){ return mpImplTextObj->mbHasExtendedBullets; };
- void WriteTextSpecInfo( SvStream* pStrm );
-
- TextObj& operator=( TextObj& rTextObj );
+ boost::shared_ptr<ImplTextObj> mpImplTextObj;
+ void ImplCalculateTextPositions();
+
+public :
+ TextObj( ::com::sun::star::uno::Reference< ::com::sun::star::text::XSimpleText > &
+ rXText, int nInstance, FontCollection& rFontCollection, PPTExBulletProvider& rBuProv );
+
+ ParagraphObj* GetParagraph(int idx);
+ sal_uInt32 ParagraphCount() const;
+ sal_uInt32 Count() const;
+ int GetInstance() const;
+ sal_Bool HasExtendedBullets();
+ void WriteTextSpecInfo( SvStream* pStrm );
};
#endif