[Libreoffice-commits] .: sd/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jan 22 07:30:52 PST 2013


 sd/source/filter/eppt/pptx-text.cxx |   57 +++++++++++++++++++++---------------
 sd/source/filter/eppt/text.hxx      |   45 ++++++++++------------------
 2 files changed, 50 insertions(+), 52 deletions(-)

New commits:
commit ec8ff9ff68622a510319c404f4745a336e65d314
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jan 22 16:12:03 2013 +0100

    replace manual ref count with shared_ptr
    
    Change-Id: I11dbebe78f6945afd0b88b53e482dea47ddd192d

diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx
index 481666b..ff5532c 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 e690238..feb291a 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


More information about the Libreoffice-commits mailing list