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

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


 sw/source/filter/ww8/ww8graf.cxx |    2 +-
 sw/source/filter/ww8/ww8par.cxx  |   13 ++++++-------
 sw/source/filter/ww8/ww8par.hxx  |    9 ++++++---
 sw/source/filter/ww8/ww8par6.cxx |    8 ++++----
 4 files changed, 17 insertions(+), 15 deletions(-)

New commits:
commit 87836a7acd9a782f7a3513c11b4400b726b64eb7
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Jul 6 10:41:17 2017 +0100

    ofz: fix some leaks
    
    Change-Id: I35dcd9db95cd1bd567202b4cf61c8e166e17c099
    Reviewed-on: https://gerrit.libreoffice.org/39640
    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/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index e68dff6d9044..afec6649a14b 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2761,7 +2761,7 @@ SwFrameFormat *SwWW8ImplReader::AddAutoAnchor(SwFrameFormat *pFormat)
      */
     if ((pFormat) && (pFormat->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR))
     {
-        m_pAnchorStck->AddAnchor(*m_pPaM->GetPoint(), pFormat);
+        m_xAnchorStck->AddAnchor(*m_pPaM->GetPoint(), pFormat);
     }
     return pFormat;
 }
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 33901018139c..35fbe69fcdf0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1965,7 +1965,7 @@ void SwWW8ImplReader::ImportDopTypography(const WW8DopTypography &rTypo)
 WW8ReaderSave::WW8ReaderSave(SwWW8ImplReader* pRdr ,WW8_CP nStartCp) :
     maTmpPos(*pRdr->m_pPaM->GetPoint()),
     mpOldStck(pRdr->m_pCtrlStck),
-    mpOldAnchorStck(pRdr->m_pAnchorStck),
+    mxOldAnchorStck(std::move(pRdr->m_xAnchorStck)),
     mxOldRedlines(std::move(pRdr->m_xRedlineStack)),
     mxOldPlcxMan(pRdr->m_xPlcxMan),
     mpWFlyPara(pRdr->m_xWFlyPara.release()),
@@ -2003,7 +2003,7 @@ WW8ReaderSave::WW8ReaderSave(SwWW8ImplReader* pRdr ,WW8_CP nStartCp) :
 
     pRdr->m_xRedlineStack.reset(new sw::util::RedlineStack(pRdr->m_rDoc));
 
-    pRdr->m_pAnchorStck = new SwWW8FltAnchorStack(&pRdr->m_rDoc, pRdr->m_nFieldFlags);
+    pRdr->m_xAnchorStck.reset(new SwWW8FltAnchorStack(&pRdr->m_rDoc, pRdr->m_nFieldFlags));
 
     // Save the attribute manager: we need this as the newly created PLCFx Manager
     // access the same FKPs as the old one and their Start-End position changes.
@@ -2050,7 +2050,7 @@ void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr )
     pRdr->m_xRedlineStack = std::move(mxOldRedlines);
 
     pRdr->DeleteAnchorStack();
-    pRdr->m_pAnchorStck = mpOldAnchorStck;
+    pRdr->m_xAnchorStck = std::move(mxOldAnchorStck);
 
     *pRdr->m_pPaM->GetPoint() = maTmpPos;
 
@@ -2440,7 +2440,7 @@ void SwWW8ImplReader::AppendTextNode(SwPosition& rPos)
     m_rDoc.getIDocumentContentOperations().AppendTextNode(rPos);
 
     // We can flush all anchored graphics at the end of a paragraph.
-    m_pAnchorStck->Flush();
+    m_xAnchorStck->Flush();
 }
 
 bool SwWW8ImplReader::SetSpacing(SwPaM &rMyPam, int nSpace, bool bIsUpper )
@@ -4091,7 +4091,7 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType)
                 // #i43118# - refine condition: the anchor
                 // control stack has to have entries, otherwise it's not needed
                 // to insert a text node.
-                if (!bStartLine && !m_pAnchorStck->empty())
+                if (!bStartLine && !m_xAnchorStck->empty())
                 {
                     AppendTextNode(*m_pPaM->GetPoint());
                 }
@@ -4126,7 +4126,6 @@ SwWW8ImplReader::SwWW8ImplReader(sal_uInt8 nVersionPara, SotStorage* pStorage,
     , m_pPaM(nullptr)
     , m_pCtrlStck(nullptr)
     , m_pReffingStck(nullptr)
-    , m_pAnchorStck(nullptr)
     , m_aSectionManager(*this)
     , m_aExtraneousParas(rD)
     , m_aInsertedTables(rD)
@@ -4914,7 +4913,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss)
     m_xReffedStck.reset(new SwWW8ReferencedFltEndStack(&m_rDoc, m_nFieldFlags));
     m_pReffingStck = new SwWW8FltRefStack(&m_rDoc, m_nFieldFlags);
 
-    m_pAnchorStck = new SwWW8FltAnchorStack(&m_rDoc, m_nFieldFlags);
+    m_xAnchorStck.reset(new SwWW8FltAnchorStack(&m_rDoc, m_nFieldFlags));
 
     size_t nPageDescOffset = m_rDoc.GetPageDescCnt();
 
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index f9f2364cc227..c737d0503d12 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -581,7 +581,7 @@ private:
     std::deque<bool> maOldApos;
     std::deque<WW8FieldEntry> maOldFieldStack;
     SwWW8FltControlStack* mpOldStck;
-    SwWW8FltAnchorStack* mpOldAnchorStck;
+    std::unique_ptr<SwWW8FltAnchorStack> mxOldAnchorStck;
     std::unique_ptr<sw::util::RedlineStack> mxOldRedlines;
     std::shared_ptr<WW8PLCFMan> mxOldPlcxMan;
     WW8FlyPara* mpWFlyPara;
@@ -1110,7 +1110,7 @@ private:
     anchored to character before a character to be anchored to has been
     inserted. Is emptied at the end of each paragraph.
     */
-    SwWW8FltAnchorStack* m_pAnchorStck;
+    std::unique_ptr<SwWW8FltAnchorStack> m_xAnchorStck;
 
     /*
     A stack of fields identifiers to keep track of any open fields that need
@@ -1383,7 +1383,10 @@ private:
         DeleteStack( m_pReffingStck );
         m_pReffingStck = nullptr;
     }
-    void DeleteAnchorStack()  { DeleteStack( m_pAnchorStck ); m_pAnchorStck = nullptr; }
+    void DeleteAnchorStack()
+    {
+        DeleteStack(m_xAnchorStck.release());
+    }
     void emulateMSWordAddTextToParagraph(const OUString& rAddString);
     void simpleAddTextToParagraph(const OUString& rAddString);
     bool HandlePageBreakChar();
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 73646998052f..188021deffea 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2388,7 +2388,7 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
 
         if (RndStdIds::FLY_AS_CHAR != m_xSFlyPara->eAnchor && m_xSFlyPara->pFlyFormat)
         {
-            m_pAnchorStck->AddAnchor(*m_pPaM->GetPoint(), m_xSFlyPara->pFlyFormat);
+            m_xAnchorStck->AddAnchor(*m_pPaM->GetPoint(), m_xSFlyPara->pFlyFormat);
         }
 
         // remember Pos in body text
@@ -2397,8 +2397,8 @@ bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *p
         //remove fltanchors, otherwise they will be closed inside the
         //frame, which makes no sense, restore them after the frame is
         //closed
-        m_xSFlyPara->xOldAnchorStck.reset(m_pAnchorStck);
-        m_pAnchorStck = new SwWW8FltAnchorStack(&m_rDoc, m_nFieldFlags);
+        m_xSFlyPara->xOldAnchorStck = std::move(m_xAnchorStck);
+        m_xAnchorStck.reset(new SwWW8FltAnchorStack(&m_rDoc, m_nFieldFlags));
 
         if (m_xSFlyPara->pFlyFormat)
             MoveInsideFly(m_xSFlyPara->pFlyFormat);
@@ -2547,7 +2547,7 @@ void SwWW8ImplReader::StopApo()
             m_xSFlyPara->pFlyFormat->SetFormatAttr(SvxBrushItem(aBg, RES_BACKGROUND));
 
         DeleteAnchorStack();
-        m_pAnchorStck = m_xSFlyPara->xOldAnchorStck.release();
+        m_xAnchorStck = std::move(m_xSFlyPara->xOldAnchorStck);
 
         // When inserting a graphic into the fly frame using the auto
         // function, the extension of the SW-fly has to be set


More information about the Libreoffice-commits mailing list