[Libreoffice-commits] core.git: sw/source

Caolán McNamara caolanm at redhat.com
Thu Jul 6 13:14:17 UTC 2017


 sw/source/filter/ww8/ww8par.cxx  |   30 ++++++++++++++----------------
 sw/source/filter/ww8/ww8par.hxx  |    4 ++--
 sw/source/filter/ww8/ww8par2.cxx |   18 +++++++++---------
 sw/source/filter/ww8/ww8par3.cxx |    8 ++++----
 sw/source/filter/ww8/ww8par6.cxx |   38 +++++++++++++++++++-------------------
 5 files changed, 48 insertions(+), 50 deletions(-)

New commits:
commit 09980e52eb247ccdd0ad3a8b96d47db4e6bdd47a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 6 09:58:19 2017 +0100

    ofz: fix some leaks
    
    Change-Id: I9f5640461d09103ed6da4613e7ca520bc54b3c51
    Reviewed-on: https://gerrit.libreoffice.org/39633
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 94a114b1d245..f3f468fca999 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2220,7 +2220,7 @@ bool SwWW8ImplReader::isValid_HdFt_CP(WW8_CP nHeaderCP) const
 bool SwWW8ImplReader::HasOwnHeaderFooter(sal_uInt8 nWhichItems, sal_uInt8 grpfIhdt,
     int nSect)
 {
-    if (m_pHdFt)
+    if (m_xHdFt)
     {
         WW8_CP nStart, nLen;
         sal_uInt8 nNumber = 5;
@@ -2231,10 +2231,10 @@ bool SwWW8ImplReader::HasOwnHeaderFooter(sal_uInt8 nWhichItems, sal_uInt8 grpfIh
             {
                 bool bOk = true;
                 if( m_bVer67 )
-                    bOk = ( m_pHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nStart >= 0 && nLen >= 2 );
+                    bOk = ( m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nStart >= 0 && nLen >= 2 );
                 else
                 {
-                    m_pHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
+                    m_xHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
                     bOk = ( 2 <= nLen ) && isValid_HdFt_CP(nStart);
                 }
 
@@ -2252,7 +2252,7 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
     sal_uInt8 grpfIhdt = rSection.maSep.grpfIhdt;
     SwPageDesc *pPD = rSection.mpPage;
 
-    if( m_pHdFt )
+    if( m_xHdFt )
     {
         WW8_CP nStart, nLen;
         sal_uInt8 nNumber = 5;
@@ -2266,10 +2266,10 @@ void SwWW8ImplReader::Read_HdFt(int nSect, const SwPageDesc *pPrev,
             {
                 bool bOk = true;
                 if( m_bVer67 )
-                    bOk = ( m_pHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nLen >= 2 );
+                    bOk = ( m_xHdFt->GetTextPos(grpfIhdt, nI, nStart, nLen ) && nLen >= 2 );
                 else
                 {
-                    m_pHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
+                    m_xHdFt->GetTextPosExact( static_cast< short >(nNumber + (nSect+1)*6), nStart, nLen);
                     bOk = ( 2 <= nLen ) && isValid_HdFt_CP(nStart);
                 }
 
@@ -2366,8 +2366,8 @@ void wwSectionManager::SetHdFt(wwSection &rSection, int nSect,
 
     // Header/Footer - Update Index
     // So that the index is still valid later on
-    if (mrReader.m_pHdFt)
-        mrReader.m_pHdFt->UpdateIndex(rSection.maSep.grpfIhdt);
+    if (mrReader.m_xHdFt)
+        mrReader.m_xHdFt->UpdateIndex(rSection.maSep.grpfIhdt);
 
 }
 
@@ -4148,12 +4148,10 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
     , m_pSBase(nullptr)
     , m_aTextNodesHavingFirstLineOfstSet()
     , m_aTextNodesHavingLeftIndentSet()
-    , m_pStyles(nullptr)
     , m_pAktColl(nullptr)
     , m_pAktItemSet(nullptr)
     , m_pDfltTextFormatColl(nullptr)
     , m_pStandardFormatColl(nullptr)
-    , m_pHdFt(nullptr)
     , m_pTableDesc(nullptr)
     , m_pDrawModel(nullptr)
     , m_pDrawPg(nullptr)
@@ -4999,8 +4997,8 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
             BEFORE the import of the lists !!
     */
     ::SetProgressState(m_nProgress, m_pDocShell);    // Update
-    m_pStyles = new WW8RStyle( *m_pWwFib, this );     // Styles
-    m_pStyles->Import();
+    m_xStyles.reset(new WW8RStyle(*m_pWwFib, this)); // Styles
+    m_xStyles->Import();
 
     /*
         In the end: (also see WW8PAR3.CXX)
@@ -5009,7 +5007,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
         AFTER we imported the Styles and AFTER we imported the Lists!
     */
     ::SetProgressState(m_nProgress, m_pDocShell); // Update
-    m_pStyles->PostProcessStyles();
+    m_xStyles->PostProcessStyles();
 
     if (!m_vColl.empty())
         SetOutlineStyles();
@@ -5056,7 +5054,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
     }
 
     if( m_pWwFib->m_lcbPlcfhdd )
-        m_pHdFt = new WW8PLCF_HdFt( m_pTableStream, *m_pWwFib, *m_pWDop );
+        m_xHdFt.reset(new WW8PLCF_HdFt(m_pTableStream, *m_pWwFib, *m_pWDop));
 
     if (!m_bNewDoc)
     {
@@ -5241,13 +5239,13 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
 
     m_vColl.clear();
 
-    DELETEZ( m_pStyles );
+    m_xStyles.reset();
 
     if( m_pFormImpl )
         DeleteFormImpl();
     GrafikDtor();
     DELETEZ( m_pMSDffManager );
-    DELETEZ( m_pHdFt );
+    m_xHdFt.reset();
     DELETEZ( m_pSBase );
     delete m_pWDop;
     DELETEZ( m_pFonts );
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 8dd996aea741..1cd272dcf491 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1204,7 +1204,7 @@ private:
     std::set<const SwNode*> m_aTextNodesHavingFirstLineOfstSet; // #i103711#
     std::set<const SwNode*> m_aTextNodesHavingLeftIndentSet; // #i105414#
 
-    WW8RStyle* m_pStyles;     // pointer to the style reading class
+    std::unique_ptr<WW8RStyle> m_xStyles;     // pointer to the style reading class
     SwFormat* m_pAktColl;        // collection to be created now
                             // ( always 0 outside of a Style-Def )
     SfxItemSet* m_pAktItemSet;// character attributes to be read in now
@@ -1213,7 +1213,7 @@ private:
     const SwTextFormatColl* m_pDfltTextFormatColl;    // Default
     SwFormat* m_pStandardFormatColl;// "Standard"
 
-    WW8PLCF_HdFt* m_pHdFt;        // pointer to Header / Footer - scanner class
+    std::unique_ptr<WW8PLCF_HdFt> m_xHdFt;        // pointer to Header / Footer - scanner class
 
     std::unique_ptr<WW8FlyPara> m_xWFlyPara;      // WW-parameter
     std::unique_ptr<WW8SwFlyPara> m_xSFlyPara;    // Sw parameters created from previous
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index beee5a928ccc..eb9d7151d4db 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -850,8 +850,8 @@ void SwWW8ImplReader::SetAnld(SwNumRule* pNumR, WW8_ANLD const * pAD, sal_uInt8
 
 SwNumRule* SwWW8ImplReader::GetStyRule()
 {
-    if( m_pStyles->pStyRule )         // Bullet-Style already present
-        return m_pStyles->pStyRule;
+    if( m_xStyles->pStyRule )         // Bullet-Style already present
+        return m_xStyles->pStyRule;
 
     const OUString aBaseName("WW8StyleNum");
     const OUString aName( m_rDoc.GetUniqueNumRuleName( &aBaseName, false) );
@@ -859,11 +859,11 @@ SwNumRule* SwWW8ImplReader::GetStyRule()
     // #i86652#
     sal_uInt16 nRul = m_rDoc.MakeNumRule( aName, nullptr, false,
                                     SvxNumberFormat::LABEL_ALIGNMENT );
-    m_pStyles->pStyRule = m_rDoc.GetNumRuleTable()[nRul];
+    m_xStyles->pStyRule = m_rDoc.GetNumRuleTable()[nRul];
     // Auto == false-> Nummerierungsvorlage
-    m_pStyles->pStyRule->SetAutoRule(false);
+    m_xStyles->pStyRule->SetAutoRule(false);
 
-    return m_pStyles->pStyRule;
+    return m_xStyles->pStyRule;
 }
 
 // Sprm 13
@@ -898,7 +898,7 @@ void SwWW8ImplReader::Read_ANLevelNo( sal_uInt16, const sal_uInt8* pData, short
             else if( *pData == 10 || *pData == 11 )
             {
                 // remember type, the rest happens at Sprm 12
-                m_pStyles->nWwNumLevel = *pData;
+                m_xStyles->nWwNumLevel = *pData;
             }
         }
     }
@@ -945,7 +945,7 @@ void SwWW8ImplReader::Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, shor
 
         // Missing Levels need not be replenished
         m_rDoc.SetOutlineNumRule( aNR );
-    }else if( m_pStyles->nWwNumLevel == 10 || m_pStyles->nWwNumLevel == 11 ){
+    }else if( m_xStyles->nWwNumLevel == 10 || m_xStyles->nWwNumLevel == 11 ){
         SwNumRule* pNR = GetStyRule();
         SetAnld(pNR, reinterpret_cast<WW8_ANLD const *>(pData), 0, false);
         m_pAktColl->SetFormatAttr( SwNumRuleItem( pNR->GetName() ) );
@@ -3668,7 +3668,7 @@ sal_uInt16 SwWW8ImplReader::StyleUsingLFO( sal_uInt16 nLFOIndex ) const
     sal_uInt16 nRes = USHRT_MAX;
     if( !m_vColl.empty() )
     {
-        for(sal_uInt16 nI = 0; nI < m_pStyles->GetCount(); nI++ )
+        for(sal_uInt16 nI = 0; nI < m_xStyles->GetCount(); nI++ )
             if(    m_vColl[ nI ].m_bValid
                 && (nLFOIndex == m_vColl[ nI ].m_nLFOIndex) )
                 nRes = nI;
@@ -3681,7 +3681,7 @@ const SwFormat* SwWW8ImplReader::GetStyleWithOrgWWName( OUString& rName ) const
     SwFormat* pRet = nullptr;
     if( !m_vColl.empty() )
     {
-        for(sal_uInt16 nI = 0; nI < m_pStyles->GetCount(); nI++ )
+        for(sal_uInt16 nI = 0; nI < m_xStyles->GetCount(); nI++ )
             if(    m_vColl[ nI ].m_bValid
                 && (rName.equals( m_vColl[ nI ].GetOrgWWName())) )
             {
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 76fe2e8621ff..1bcc38ceca18 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1908,8 +1908,8 @@ void SwWW8ImplReader::Read_ListLevel(sal_uInt16, const sal_uInt8* pData,
     {
         // the actual level is finished, what should we do ?
         m_nListLevel = WW8ListManager::nMaxLevel;
-        if (m_pStyles && !m_bVer67)
-            m_pStyles->nWwNumLevel = 0;
+        if (m_xStyles && !m_bVer67)
+            m_xStyles->nWwNumLevel = 0;
     }
     else
     {
@@ -1920,7 +1920,7 @@ void SwWW8ImplReader::Read_ListLevel(sal_uInt16, const sal_uInt8* pData,
         // the Streamdata is zero based
         m_nListLevel = *pData;
 
-        if (m_pStyles && !m_bVer67)
+        if (m_xStyles && !m_bVer67)
         {
             /*
             if this is the case, then if the numbering is actually stored in
@@ -1928,7 +1928,7 @@ void SwWW8ImplReader::Read_ListLevel(sal_uInt16, const sal_uInt8* pData,
             to set the ww6 list level information which we will need when we
             reach the true ww6 list def.  So set it now
             */
-            m_pStyles->nWwNumLevel = m_nListLevel;
+            m_xStyles->nWwNumLevel = m_nListLevel;
         }
 
         if (WW8ListManager::nMaxLevel <= m_nListLevel )
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 8145743f47e5..d79260709827 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -269,7 +269,7 @@ void SwWW8ImplReader::SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &r
 
     //Get the size of word's default styles font
     sal_uInt32 nCharWidth=240;
-    for (sal_uInt16 nI = 0; nI < m_pStyles->GetCount(); ++nI)
+    for (sal_uInt16 nI = 0; nI < m_xStyles->GetCount(); ++nI)
     {
         if (m_vColl[nI].m_bValid && m_vColl[nI].m_pFormat &&
             m_vColl[nI].IsWW8BuiltInDefaultStyle())
@@ -1144,7 +1144,7 @@ void wwSectionManager::CreateSep(const long nTextPos)
 
     if (eVer <= ww::eWW7)
         aNewSection.maSep.grpfIhdt = ReadBSprm(pSep, eVer <= ww::eWW2 ? 128 : 153, 0);
-    else if (mrReader.m_pHdFt)
+    else if (mrReader.m_xHdFt)
     {
         aNewSection.maSep.grpfIhdt = WW8_HEADER_ODD | WW8_FOOTER_ODD
             | WW8_HEADER_FIRST | WW8_FOOTER_FIRST;
@@ -1165,7 +1165,7 @@ void wwSectionManager::CreateSep(const long nTextPos)
             if (aNewSection.maSep.grpfIhdt & nMask)
             {
                 WW8_CP nStart, nLen;
-                mrReader.m_pHdFt->GetTextPosExact( static_cast< short >(nI + ( maSegments.size() + 1) * 6), nStart, nLen);
+                mrReader.m_xHdFt->GetTextPosExact( static_cast< short >(nI + ( maSegments.size() + 1) * 6), nStart, nLen);
                 //No header or footer, inherit pervious one, or set to zero
                 //if no previous one
                 if (!nLen)
@@ -3449,8 +3449,8 @@ void SwWW8ImplReader::Read_TextColor( sal_uInt16, const sal_uInt8* pData, short
             b = 0;
 
         NewAttr( SvxColorItem(Color(GetCol(b)), RES_CHRATR_COLOR));
-        if (m_pAktColl && m_pStyles)
-            m_pStyles->bTextColChanged = true;
+        if (m_pAktColl && m_xStyles)
+            m_xStyles->bTextColChanged = true;
     }
 }
 
@@ -3462,8 +3462,8 @@ void SwWW8ImplReader::Read_TextForeColor(sal_uInt16, const sal_uInt8* pData, sho
     {
         Color aColor(msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)));
         NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR));
-        if (m_pAktColl && m_pStyles)
-            m_pStyles->bTextColChanged = true;
+        if (m_pAktColl && m_xStyles)
+            m_xStyles->bTextColChanged = true;
     }
 }
 
@@ -3684,15 +3684,15 @@ void SwWW8ImplReader::ResetCJKCharSetVars()
 
 void SwWW8ImplReader::openFont(sal_uInt16 nFCode, sal_uInt16 nId)
 {
-    if (SetNewFontAttr(nFCode, true, nId) && m_pAktColl && m_pStyles)
+    if (SetNewFontAttr(nFCode, true, nId) && m_pAktColl && m_xStyles)
     {
         // remember for simulating default font
         if (RES_CHRATR_CJK_FONT == nId)
-            m_pStyles->bCJKFontChanged = true;
+            m_xStyles->bCJKFontChanged = true;
         else if (RES_CHRATR_CTL_FONT == nId)
-            m_pStyles->bCTLFontChanged = true;
+            m_xStyles->bCTLFontChanged = true;
         else
-            m_pStyles->bFontChanged = true;
+            m_xStyles->bFontChanged = true;
     }
 }
 
@@ -3802,16 +3802,16 @@ void SwWW8ImplReader::Read_FontSize( sal_uInt16 nId, const sal_uInt8* pData, sho
             aSz.SetWhich( RES_CHRATR_CTL_FONTSIZE );
             NewAttr( aSz );
         }
-        if (m_pAktColl && m_pStyles)            // Style-Def ?
+        if (m_pAktColl && m_xStyles)            // Style-Def ?
         {
             // remember for simulating default font size
             if (nId == RES_CHRATR_CTL_FONTSIZE)
-                m_pStyles->bFCTLSizeChanged = true;
+                m_xStyles->bFCTLSizeChanged = true;
             else
             {
-                m_pStyles->bFSizeChanged = true;
+                m_xStyles->bFSizeChanged = true;
                 if (eVersion <= ww::eWW6)
-                    m_pStyles->bFCTLSizeChanged= true;
+                    m_xStyles->bFCTLSizeChanged= true;
             }
         }
     }
@@ -4847,7 +4847,7 @@ void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8*, short nLen)
         sal_uInt8 nBorder;
 
         if( m_pAktColl )
-            nBorder = ::lcl_ReadBorders(m_bVer67, aBrcs, nullptr, m_pStyles);
+            nBorder = ::lcl_ReadBorders(m_bVer67, aBrcs, nullptr, m_xStyles.get());
         else
             nBorder = ::lcl_ReadBorders(m_bVer67, aBrcs, m_xPlcxMan ? m_xPlcxMan->GetPapPLCF() : nullptr);
 
@@ -4977,8 +4977,8 @@ void SwWW8ImplReader::Read_WidowControl( sal_uInt16, const sal_uInt8* pData, sho
         NewAttr( SvxWidowsItem( nL, RES_PARATR_WIDOWS ) );     // Off -> nLines = 0
         NewAttr( SvxOrphansItem( nL, RES_PARATR_ORPHANS ) );
 
-        if( m_pAktColl && m_pStyles )           // Style-Def ?
-            m_pStyles->bWidowsChanged = true; // save for simulation
+        if( m_pAktColl && m_xStyles )           // Style-Def ?
+            m_xStyles->bWidowsChanged = true; // save for simulation
                                             // Default-Widows
     }
 }
@@ -5062,7 +5062,7 @@ void SwWW8ImplReader::Read_ApoPPC( sal_uInt16, const sal_uInt8* pData, short )
         SwWW8StyInf& rSI = m_vColl[m_nAktColl];
         if (!rSI.m_xWWFly)
             rSI.m_xWWFly.reset(new WW8FlyPara(m_bVer67));
-        rSI.m_xWWFly->Read(*pData, m_pStyles);
+        rSI.m_xWWFly->Read(*pData, m_xStyles.get());
         if (rSI.m_xWWFly->IsEmpty())
         {
             m_vColl[m_nAktColl].m_xWWFly.reset();


More information about the Libreoffice-commits mailing list