[Libreoffice-commits] core.git: filter/Library_msfilter.mk filter/source include/filter

Noel Grandin noel.grandin at collabora.co.uk
Mon Apr 10 09:57:30 UTC 2017


 filter/Library_msfilter.mk          |    1 
 filter/source/msfilter/svdfppt.cxx  |   61 +++++++++++++++---------------------
 include/filter/msfilter/svdfppt.hxx |   15 ++++----
 3 files changed, 35 insertions(+), 42 deletions(-)

New commits:
commit d608fa64b7ca3af99288ac7b904747cc09b23315
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Apr 7 16:15:59 2017 +0200

    loplugin:inlinefields in PPTTextRulerInterpreter
    
    Change-Id: Ic814a5dce507b5a0cb49a093a60bd71768ee40d5
    Reviewed-on: https://gerrit.libreoffice.org/36348
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/filter/Library_msfilter.mk b/filter/Library_msfilter.mk
index 5a5ea9f16cd3..87e89c6a3d33 100644
--- a/filter/Library_msfilter.mk
+++ b/filter/Library_msfilter.mk
@@ -35,6 +35,7 @@ $(eval $(call gb_Library_use_libraries,msfilter,\
 	sfx \
 	xo \
 	sb \
+	salhelper \
 	svt \
 	tk \
 	vcl \
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 92d9025f75f9..1aa144dee9e1 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -4529,8 +4529,7 @@ void PPTCharPropSet::SetColor( sal_uInt32 nColor )
 }
 
 PPTRuler::PPTRuler()
-    : nRefCount(1)
-    , nFlags(0)
+    : nFlags(0)
     , nDefaultTab(0x240)
     , pTab(nullptr)
     , nTabCount(0)
@@ -4545,18 +4544,17 @@ PPTRuler::~PPTRuler()
 
 
 PPTTextRulerInterpreter::PPTTextRulerInterpreter() :
-    mpImplRuler ( new PPTRuler() )
+    mxImplRuler ( new PPTRuler() )
 {
 }
 
 PPTTextRulerInterpreter::PPTTextRulerInterpreter( PPTTextRulerInterpreter& rRuler )
 {
-    mpImplRuler = rRuler.mpImplRuler;
-    mpImplRuler->nRefCount++;
+    mxImplRuler = rRuler.mxImplRuler;
 }
 
 PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, DffRecordHeader& rHeader, SvStream& rIn ) :
-    mpImplRuler ( new PPTRuler() )
+    mxImplRuler ( new PPTRuler() )
 {
     if ( nFileOfs != 0xffffffff )
     {
@@ -4579,14 +4577,14 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, DffRecord
 
             sal_Int16   nTCount(0);
             sal_Int32   i;
-            rIn.ReadInt32( mpImplRuler->nFlags );
+            rIn.ReadInt32( mxImplRuler->nFlags );
 
             // number of indent levels, unused now
-            if ( mpImplRuler->nFlags & 2 )
+            if ( mxImplRuler->nFlags & 2 )
                 rIn.ReadInt16( nTCount );
-            if ( mpImplRuler->nFlags & 1 )
-                rIn.ReadUInt16( mpImplRuler->nDefaultTab );
-            if ( mpImplRuler->nFlags & 4 )
+            if ( mxImplRuler->nFlags & 1 )
+                rIn.ReadUInt16( mxImplRuler->nDefaultTab );
+            if ( mxImplRuler->nFlags & 4 )
             {
                 rIn.ReadInt16(nTCount);
 
@@ -4597,12 +4595,12 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, DffRecord
 
                 if (nTCount && bRecordOk)
                 {
-                    mpImplRuler->nTabCount = nTabCount;
-                    mpImplRuler->pTab.reset( new PPTTabEntry[ mpImplRuler->nTabCount ] );
+                    mxImplRuler->nTabCount = nTabCount;
+                    mxImplRuler->pTab.reset( new PPTTabEntry[ mxImplRuler->nTabCount ] );
                     for ( i = 0; i < nTCount; i++ )
                     {
-                        rIn.ReadUInt16( mpImplRuler->pTab[ i ].nOffset )
-                           .ReadUInt16( mpImplRuler->pTab[ i ].nStyle );
+                        rIn.ReadUInt16( mxImplRuler->pTab[ i ].nOffset )
+                           .ReadUInt16( mxImplRuler->pTab[ i ].nStyle );
                     }
                 }
             }
@@ -4611,11 +4609,11 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, DffRecord
             {
                 for ( i = 0; i < 5; i++ )
                 {
-                    if ( mpImplRuler->nFlags & ( 8 << i ) )
-                        rIn.ReadUInt16( mpImplRuler->nTextOfs[ i ] );
-                    if ( mpImplRuler->nFlags & ( 256 << i ) )
-                        rIn.ReadUInt16( mpImplRuler->nBulletOfs[ i ] );
-                    if( mpImplRuler->nBulletOfs[ i ] > 0x7fff)
+                    if ( mxImplRuler->nFlags & ( 8 << i ) )
+                        rIn.ReadUInt16( mxImplRuler->nTextOfs[ i ] );
+                    if ( mxImplRuler->nFlags & ( 256 << i ) )
+                        rIn.ReadUInt16( mxImplRuler->nBulletOfs[ i ] );
+                    if( mxImplRuler->nBulletOfs[ i ] > 0x7fff)
                     {
                         // workaround
                         // when bullet offset is > 0x7fff, the paragraph should look like
@@ -4624,8 +4622,8 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, DffRecord
 
                         // we add to bullet para indent 0xffff - bullet offset. it looks like
                         // best we can do for now
-                        mpImplRuler->nTextOfs[ i ] += 0xffff - mpImplRuler->nBulletOfs[ i ];
-                        mpImplRuler->nBulletOfs[ i ] = 0;
+                        mxImplRuler->nTextOfs[ i ] += 0xffff - mxImplRuler->nBulletOfs[ i ];
+                        mxImplRuler->nBulletOfs[ i ] = 0;
                     }
                 }
             }
@@ -4636,25 +4634,25 @@ PPTTextRulerInterpreter::PPTTextRulerInterpreter( sal_uInt32 nFileOfs, DffRecord
 
 bool PPTTextRulerInterpreter::GetDefaultTab( sal_uInt32 /*nLevel*/, sal_uInt16& nValue ) const
 {
-    if ( ! ( mpImplRuler->nFlags & 1 ) )
+    if ( ! ( mxImplRuler->nFlags & 1 ) )
         return false;
-    nValue = mpImplRuler->nDefaultTab;
+    nValue = mxImplRuler->nDefaultTab;
     return true;
 }
 
 bool PPTTextRulerInterpreter::GetTextOfs( sal_uInt32 nLevel, sal_uInt16& nValue ) const
 {
-    if ( ! ( ( nLevel < 5 ) && ( mpImplRuler->nFlags & ( 8 << nLevel ) ) ) )
+    if ( ! ( ( nLevel < 5 ) && ( mxImplRuler->nFlags & ( 8 << nLevel ) ) ) )
         return false;
-    nValue = mpImplRuler->nTextOfs[ nLevel ];
+    nValue = mxImplRuler->nTextOfs[ nLevel ];
     return true;
 }
 
 bool PPTTextRulerInterpreter::GetBulletOfs( sal_uInt32 nLevel, sal_uInt16& nValue ) const
 {
-    if ( ! ( ( nLevel < 5 ) && ( mpImplRuler->nFlags & ( 256 << nLevel ) ) ) )
+    if ( ! ( ( nLevel < 5 ) && ( mxImplRuler->nFlags & ( 256 << nLevel ) ) ) )
         return false;
-    nValue = mpImplRuler->nBulletOfs[ nLevel ];
+    nValue = mxImplRuler->nBulletOfs[ nLevel ];
     return true;
 }
 
@@ -4662,18 +4660,13 @@ PPTTextRulerInterpreter& PPTTextRulerInterpreter::operator=( PPTTextRulerInterpr
 {
     if ( this != &rRuler )
     {
-        if ( ! ( --mpImplRuler->nRefCount ) )
-            delete mpImplRuler;
-        mpImplRuler = rRuler.mpImplRuler;
-        mpImplRuler->nRefCount++;
+        mxImplRuler = rRuler.mxImplRuler;
     }
     return *this;
 }
 
 PPTTextRulerInterpreter::~PPTTextRulerInterpreter()
 {
-    if ( ! ( --mpImplRuler->nRefCount ) )
-        delete mpImplRuler;
 }
 
 PPTTextParagraphStyleAtomInterpreter::PPTTextParagraphStyleAtomInterpreter() :
diff --git a/include/filter/msfilter/svdfppt.hxx b/include/filter/msfilter/svdfppt.hxx
index a34b601013ae..f554333d26b1 100644
--- a/include/filter/msfilter/svdfppt.hxx
+++ b/include/filter/msfilter/svdfppt.hxx
@@ -46,6 +46,7 @@
 #include <tools/ref.hxx>
 #include <tools/solar.h>
 #include <vcl/graph.hxx>
+#include <salhelper/simplereferenceobject.hxx>
 
 namespace boost {
     template <class T> class optional;
@@ -962,10 +963,8 @@ struct PPTTabEntry
     sal_uInt16  nStyle;
 };
 
-struct PPTRuler
+struct PPTRuler : public salhelper::SimpleReferenceObject
 {
-        sal_uInt32          nRefCount;
-
         sal_Int32           nFlags;
         sal_uInt16          nDefaultTab;
         sal_uInt16          nTextOfs[nMaxPPTLevels];
@@ -975,12 +974,12 @@ struct PPTRuler
         sal_uInt16          nTabCount;
 
         PPTRuler();
-        ~PPTRuler();
+        virtual ~PPTRuler() override;
 };
 
 struct PPTTextRulerInterpreter
 {
-        PPTRuler    *mpImplRuler;
+        rtl::Reference<PPTRuler>    mxImplRuler;
 
                     PPTTextRulerInterpreter();
                     PPTTextRulerInterpreter( PPTTextRulerInterpreter& rRuler );
@@ -992,12 +991,12 @@ struct PPTTextRulerInterpreter
                     ~PPTTextRulerInterpreter();
 
         sal_uInt16  GetTabOffsetByIndex( sal_uInt16 nIndex ) const
-                    { return mpImplRuler->pTab[ nIndex ].nOffset; };
+                    { return mxImplRuler->pTab[ nIndex ].nOffset; };
 
         sal_uInt16  GetTabStyleByIndex( sal_uInt16 nIndex ) const
-                    { return mpImplRuler->pTab[ nIndex ].nStyle; };
+                    { return mxImplRuler->pTab[ nIndex ].nStyle; };
 
-        sal_uInt16  GetTabCount() const { return mpImplRuler->nTabCount; };
+        sal_uInt16  GetTabCount() const { return mxImplRuler->nTabCount; };
         bool        GetDefaultTab( sal_uInt32 nLevel, sal_uInt16& nValue ) const;
         bool        GetTextOfs( sal_uInt32 nLevel, sal_uInt16& nValue ) const;
         bool        GetBulletOfs( sal_uInt32 nLevel, sal_uInt16& nValue ) const;


More information about the Libreoffice-commits mailing list