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

Xisco Fauli anistenis at gmail.com
Fri Jul 15 07:38:22 UTC 2016


 filter/source/msfilter/svdfppt.cxx  |   78 ++++++++++++------------------------
 include/filter/msfilter/svdfppt.hxx |   14 +++---
 2 files changed, 35 insertions(+), 57 deletions(-)

New commits:
commit e6d2827fc385353f07d1703714f715718576c130
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sun Jun 5 02:23:01 2016 +0200

    tdf#62525 vcl: use cow_wrapper for PPTCharPropSet
    
    Change-Id: I506688a495ac145a25d2094be48ea53497d1e8a8
    Reviewed-on: https://gerrit.libreoffice.org/25914
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index e66f43f..3b1d15b 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -4412,7 +4412,7 @@ PPTCharPropSet::PPTCharPropSet(sal_uInt32 nParagraph)
     : mnOriginalTextPos(0)
     , mnParagraph(nParagraph)
     , mpFieldItem(nullptr)
-    , pCharSet(new ImplPPTCharPropSet)
+    , mpImplPPTCharPropSet()
 {
     mnHylinkOrigColor = 0;
     mbIsHyperlink = false;
@@ -4421,12 +4421,11 @@ PPTCharPropSet::PPTCharPropSet(sal_uInt32 nParagraph)
 }
 
 PPTCharPropSet::PPTCharPropSet( const PPTCharPropSet& rCharPropSet )
+    : mpImplPPTCharPropSet( rCharPropSet.mpImplPPTCharPropSet )
 {
     mnHylinkOrigColor = rCharPropSet.mnHylinkOrigColor;
     mbIsHyperlink = rCharPropSet.mbIsHyperlink;
     mbHardHylinkOrigColor = rCharPropSet.mbHardHylinkOrigColor;
-    pCharSet = rCharPropSet.pCharSet;
-    pCharSet->mnRefCount++;
 
     mnParagraph = rCharPropSet.mnParagraph;
     mnOriginalTextPos = rCharPropSet.mnOriginalTextPos;
@@ -4438,10 +4437,8 @@ PPTCharPropSet::PPTCharPropSet( const PPTCharPropSet& rCharPropSet )
 }
 
 PPTCharPropSet::PPTCharPropSet( const PPTCharPropSet& rCharPropSet, sal_uInt32 nParagraph )
+    : mpImplPPTCharPropSet(rCharPropSet.mpImplPPTCharPropSet)
 {
-    pCharSet = rCharPropSet.pCharSet;
-    pCharSet->mnRefCount++;
-
     mnHylinkOrigColor = rCharPropSet.mnHylinkOrigColor;
     mbIsHyperlink = rCharPropSet.mbIsHyperlink;
     mbHardHylinkOrigColor = rCharPropSet.mbHardHylinkOrigColor;
@@ -4455,8 +4452,6 @@ PPTCharPropSet::PPTCharPropSet( const PPTCharPropSet& rCharPropSet, sal_uInt32 n
 
 PPTCharPropSet::~PPTCharPropSet()
 {
-    if ( ! ( --pCharSet->mnRefCount ) )
-        delete pCharSet;
     delete mpFieldItem;
 }
 
@@ -4464,11 +4459,7 @@ PPTCharPropSet& PPTCharPropSet::operator=( const PPTCharPropSet& rCharPropSet )
 {
     if ( this != &rCharPropSet )
     {
-        if ( ! ( --pCharSet->mnRefCount ) )
-            delete pCharSet;
-        pCharSet = rCharPropSet.pCharSet;
-        pCharSet->mnRefCount++;
-
+        mpImplPPTCharPropSet = rCharPropSet.mpImplPPTCharPropSet;
         mnOriginalTextPos = rCharPropSet.mnOriginalTextPos;
         mnParagraph = rCharPropSet.mnParagraph;
         maString = rCharPropSet.maString;
@@ -4477,38 +4468,25 @@ PPTCharPropSet& PPTCharPropSet::operator=( const PPTCharPropSet& rCharPropSet )
     return *this;
 }
 
-void PPTCharPropSet::ImplMakeUnique()
-{
-    if ( pCharSet->mnRefCount > 1 )
-    {
-        ImplPPTCharPropSet& rOld = *pCharSet;
-        rOld.mnRefCount--;
-        pCharSet = new ImplPPTCharPropSet( rOld );
-        pCharSet->mnRefCount = 1;
-    }
-}
-
 void PPTCharPropSet::SetFont( sal_uInt16 nFont )
 {
     sal_uInt32  nMask = 1 << PPT_CharAttr_Font;
-    bool bDoNotMake = (pCharSet->mnAttrSet & nMask) != 0;
+    bool bDoNotMake = (mpImplPPTCharPropSet->mnAttrSet & nMask) != 0;
 
     if ( bDoNotMake )
-        bDoNotMake = nFont == pCharSet->mnFont;
+        bDoNotMake = nFont == mpImplPPTCharPropSet->mnFont;
 
     if ( !bDoNotMake )
     {
-        ImplMakeUnique();
-        pCharSet->mnFont = nFont;
-        pCharSet->mnAttrSet |= nMask;
+        mpImplPPTCharPropSet->mnFont = nFont;
+        mpImplPPTCharPropSet->mnAttrSet |= nMask;
     }
 }
 
 void PPTCharPropSet::SetColor( sal_uInt32 nColor )
 {
-    ImplMakeUnique();
-    pCharSet->mnColor = nColor;
-    pCharSet->mnAttrSet |= 1 << PPT_CharAttr_FontColor;
+    mpImplPPTCharPropSet->mnColor = nColor;
+    mpImplPPTCharPropSet->mnAttrSet |= 1 << PPT_CharAttr_FontColor;
 }
 
 PPTRuler::PPTRuler()
@@ -5147,7 +5125,7 @@ void PPTStyleTextPropReader::ReadCharProps( SvStream& rIn, PPTCharPropSet& aChar
             OSL_FAIL( "SJ:PPTStyleTextPropReader::could not get this PPT_PST_StyleTextPropAtom by reading the character attributes" );
         }
     }
-    ImplPPTCharPropSet& aSet = *aCharPropSet.pCharSet;
+    ImplPPTCharPropSet& aSet = *aCharPropSet.mpImplPPTCharPropSet;
 
     // character attributes
     rIn.ReadUInt32( nMask );
@@ -5399,8 +5377,8 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, const DffRecordHeader& rTextHe
                         }
                         PPTCharPropSet* pCPropSet = new PPTCharPropSet( aCharPropSet, nCurrentPara );
                         pCPropSet->maString = aString.copy(nCharAnzRead, 1);
-                        if ( aCharPropSet.pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Symbol ) )
-                            pCPropSet->SetFont( aCharPropSet.pCharSet->mnSymbolFont );
+                        if ( aCharPropSet.mpImplPPTCharPropSet->mnAttrSet & ( 1 << PPT_CharAttr_Symbol ) )
+                            pCPropSet->SetFont( aCharPropSet.mpImplPPTCharPropSet->mnSymbolFont );
                         aCharPropList.push_back( pCPropSet );
                         nCharCount--;
                         nCharAnzRead++;
@@ -5496,7 +5474,7 @@ bool PPTPortionObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& rRetValue, TSS_Type
     sal_uInt32  nMask = 1 << nAttr;
     rRetValue = 0;
 
-    bool bIsHardAttribute = ( ( pCharSet->mnAttrSet & nMask ) != 0 );
+    bool bIsHardAttribute = ( ( mpImplPPTCharPropSet->mnAttrSet & nMask ) != 0 );
 
     if ( bIsHardAttribute )
     {
@@ -5508,22 +5486,22 @@ bool PPTPortionObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& rRetValue, TSS_Type
             case PPT_CharAttr_Shadow :
             case PPT_CharAttr_Strikeout :
             case PPT_CharAttr_Embossed :
-                rRetValue = ( pCharSet->mnFlags & nMask ) ? 1 : 0;
+                rRetValue = ( mpImplPPTCharPropSet->mnFlags & nMask ) ? 1 : 0;
             break;
             case PPT_CharAttr_Font :
-                rRetValue = pCharSet->mnFont;
+                rRetValue = mpImplPPTCharPropSet->mnFont;
             break;
             case PPT_CharAttr_AsianOrComplexFont :
-                rRetValue = pCharSet->mnAsianOrComplexFont;
+                rRetValue = mpImplPPTCharPropSet->mnAsianOrComplexFont;
             break;
             case PPT_CharAttr_FontHeight :
-                rRetValue = pCharSet->mnFontHeight;
+                rRetValue = mpImplPPTCharPropSet->mnFontHeight;
             break;
             case PPT_CharAttr_FontColor :
-                rRetValue = pCharSet->mnColor;
+                rRetValue = mpImplPPTCharPropSet->mnColor;
             break;
             case PPT_CharAttr_Escapement :
-                rRetValue = pCharSet->mnEscapement;
+                rRetValue = mpImplPPTCharPropSet->mnEscapement;
             break;
             default :
                 OSL_FAIL( "SJ:PPTPortionObj::GetAttrib ( hard attribute does not exist )" );
@@ -5901,9 +5879,9 @@ void PPTParagraphObj::UpdateBulletRelSize( sal_uInt32& nBulletRelSize ) const
         if (!m_PortionList.empty())
         {
             PPTPortionObj const& rPortion = *m_PortionList.front();
-            if (rPortion.pCharSet->mnAttrSet & (1 << PPT_CharAttr_FontHeight))
+            if (rPortion.mpImplPPTCharPropSet->mnAttrSet & (1 << PPT_CharAttr_FontHeight))
             {
-                nFontHeight = rPortion.pCharSet->mnFontHeight;
+                nFontHeight = rPortion.mpImplPPTCharPropSet->mnFontHeight;
             }
         }
         // if we do not have a hard attributed fontheight, the fontheight is taken from the style
@@ -5944,9 +5922,9 @@ bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& rRetValue, TSS_Ty
                 if ((nDestinationInstance != TSS_Type::Unknown) && !m_PortionList.empty())
                 {
                     PPTPortionObj const& rPortion = *m_PortionList.front();
-                    if (rPortion.pCharSet->mnAttrSet & (1 << PPT_CharAttr_FontColor))
+                    if (rPortion.mpImplPPTCharPropSet->mnAttrSet & (1 << PPT_CharAttr_FontColor))
                     {
-                        rRetValue = rPortion.pCharSet->mnColor;
+                        rRetValue = rPortion.mpImplPPTCharPropSet->mnColor;
                     }
                     else
                     {
@@ -5972,9 +5950,9 @@ bool PPTParagraphObj::GetAttrib( sal_uInt32 nAttr, sal_uInt32& rRetValue, TSS_Ty
                 if ((nDestinationInstance != TSS_Type::Unknown) && !m_PortionList.empty())
                 {
                     PPTPortionObj const& rPortion = *m_PortionList.front();
-                    if (rPortion.pCharSet->mnAttrSet & ( 1 << PPT_CharAttr_Font ) )
+                    if (rPortion.mpImplPPTCharPropSet->mnAttrSet & ( 1 << PPT_CharAttr_Font ) )
                     {
-                        rRetValue = rPortion.pCharSet->mnFont;
+                        rRetValue = rPortion.mpImplPPTCharPropSet->mnFont;
                     }
                     else
                     {
@@ -7036,8 +7014,8 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                                             const SvxURLField* pField = static_cast<const SvxURLField*>((*FE)->pField1->GetField());
 
                                                             pCurrent->mbIsHyperlink = true;
-                                                            pCurrent->mnHylinkOrigColor = pCurrent->pCharSet->mnColor;
-                                                            pCurrent->mbHardHylinkOrigColor = ( ( pCurrent->pCharSet->mnAttrSet >>PPT_CharAttr_FontColor ) & 1)>0;
+                                                            pCurrent->mnHylinkOrigColor = pCurrent->mpImplPPTCharPropSet->mnColor;
+                                                            pCurrent->mbHardHylinkOrigColor = ( ( pCurrent->mpImplPPTCharPropSet->mnAttrSet >>PPT_CharAttr_FontColor ) & 1)>0;
 
                                                             if ( pCurrent->mpFieldItem )
                                                             {
diff --git a/include/filter/msfilter/svdfppt.hxx b/include/filter/msfilter/svdfppt.hxx
index 6795602..cec7c3d 100644
--- a/include/filter/msfilter/svdfppt.hxx
+++ b/include/filter/msfilter/svdfppt.hxx
@@ -915,8 +915,6 @@ struct PPTParaPropSet
 
 struct ImplPPTCharPropSet
 {
-    sal_uInt32  mnRefCount;
-
     sal_uInt32  mnAttrSet;
     sal_uInt16  mnFlags;
     sal_uInt32  mnColor;
@@ -928,8 +926,7 @@ struct ImplPPTCharPropSet
     sal_uInt16  mnSymbolFont;
 
     ImplPPTCharPropSet()
-        : mnRefCount ( 1 )
-        , mnAttrSet( 0 )
+        : mnAttrSet( 0 )
         , mnFlags( 0 )
         , mnColor( 0 )
         , mnFont( 0 )
@@ -958,8 +955,6 @@ struct PPTCharPropSet
     SvxFieldItem*       mpFieldItem;
     sal_uInt16          mnLanguage[ 3 ];
 
-    ImplPPTCharPropSet* pCharSet;
-
     void                SetFont( sal_uInt16 nFont );
     void                SetColor( sal_uInt32 nColor );
 
@@ -970,8 +965,13 @@ struct PPTCharPropSet
 
     PPTCharPropSet&     operator=( const PPTCharPropSet& rCharPropSet );
 
+    friend class PPTTextObj;
+    friend class PPTParagraphObj;
+    friend class PPTPortionObj;
+    friend struct PPTStyleTextPropReader;
+
 private:
-    void                ImplMakeUnique();
+    o3tl::cow_wrapper< ImplPPTCharPropSet > mpImplPPTCharPropSet;
 };
 
 struct PPTTabEntry


More information about the Libreoffice-commits mailing list