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

Michael Stahl Michael.Stahl at cib.de
Wed Apr 4 14:22:30 UTC 2018


 sw/source/filter/ww8/ww8graf2.cxx |   16 +++++++---------
 sw/source/filter/ww8/ww8par.hxx   |    2 +-
 2 files changed, 8 insertions(+), 10 deletions(-)

New commits:
commit ef13c536af9a63f0e9bdfa0a65b58a0b5dd9d16f
Author: Michael Stahl <Michael.Stahl at cib.de>
Date:   Wed Apr 4 14:15:09 2018 +0200

    sw: convert DELETEZ to unique_ptr in ww8graf2.cxx
    
    Change-Id: I8734a8293413dd8579db225948135df42a18c973
    Reviewed-on: https://gerrit.libreoffice.org/52376
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>

diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx
index 68695e277a24..6cda45844ac1 100644
--- a/sw/source/filter/ww8/ww8graf2.cxx
+++ b/sw/source/filter/ww8/ww8graf2.cxx
@@ -245,7 +245,7 @@ bool SwWW8ImplReader::GetPictGrafFromStream(Graphic& rGraphic, SvStream& rSrc)
     return ERRCODE_NONE == GraphicFilter::GetGraphicFilter().ImportGraphic(rGraphic, OUString(), rSrc);
 }
 
-bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, Graphic*& rpGraphic,
+bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, std::unique_ptr<Graphic>& rpGraphic,
     const WW8_PIC& rPic, SvStream* pSt, sal_uLong nFilePos, bool* pbInDoc)
 {                                                  // Write the graphic to the file
     *pbInDoc = true;                               // default
@@ -283,7 +283,7 @@ bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, Graphic*& rpGraphic,
 
     if (m_xWwFib->m_envr != 1) // !MAC as creator
     {
-        rpGraphic = new Graphic( aWMF );
+        rpGraphic.reset(new Graphic(aWMF));
         return true;
     }
 
@@ -295,10 +295,10 @@ bool SwWW8ImplReader::ReadGrafFile(OUString& rFileName, Graphic*& rpGraphic,
     long nData = rPic.lcb - ( pSt->Tell() - nPosFc );
     if (nData > 0)
     {
-        rpGraphic = new Graphic();
+        rpGraphic.reset(new Graphic());
         bOk = SwWW8ImplReader::GetPictGrafFromStream(*rpGraphic, *pSt);
         if (!bOk)
-            DELETEZ(rpGraphic);
+            rpGraphic.reset();
     }
     return bOk; // Contains graphic
 }
@@ -426,12 +426,11 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf1(WW8_PIC const & rPic, SvStream* pSt,
 
     OUString aFileName;
     bool bInDoc;
-    Graphic* pGraph = nullptr;
+    std::unique_ptr<Graphic> pGraph;
     bool bOk = ReadGrafFile(aFileName, pGraph, rPic, pSt, nFilePos, &bInDoc);
 
     if (!bOk)
     {
-        delete pGraph;
         return nullptr;                       // Graphic could not be read correctly
     }
 
@@ -445,10 +444,9 @@ SwFrameFormat* SwWW8ImplReader::ImportGraf1(WW8_PIC const & rPic, SvStream* pSt,
     }
 
     if (m_xWFlyPara && m_xWFlyPara->bGrafApo)
-        pRet = MakeGrafNotInContent(aPD,pGraph,aFileName,aGrfSet);
+        pRet = MakeGrafNotInContent(aPD, pGraph.get(), aFileName, aGrfSet);
     else
-        pRet = MakeGrafInContent(rPic,aPD,pGraph,aFileName,aGrfSet);
-    delete pGraph;
+        pRet = MakeGrafInContent(rPic, aPD, pGraph.get(), aFileName, aGrfSet);
     return pRet;
 }
 
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index a7718498f69b..d24057bb3504 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1496,7 +1496,7 @@ private:
     bool ProcessSpecial(bool &rbReSync, WW8_CP nStartCp);
     sal_uInt16 TabRowSprm(int nLevel) const;
 
-    bool ReadGrafFile(OUString& rFileName, Graphic*& rpGraphic,
+    bool ReadGrafFile(OUString& rFileName, std::unique_ptr<Graphic>& rpGraphic,
        const WW8_PIC& rPic, SvStream* pSt, sal_uLong nFilePos, bool* pDelIt);
 
     static void ReplaceObj(const SdrObject &rReplaceTextObj,


More information about the Libreoffice-commits mailing list