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

Caolán McNamara caolanm at redhat.com
Thu Sep 15 19:55:11 UTC 2016


 filter/source/svg/svgexport.cxx  |   22 +++++-----------------
 filter/source/svg/svgfilter.hxx  |   18 ++++++++----------
 sc/source/ui/inc/undostyl.hxx    |    9 ++++-----
 sc/source/ui/undo/undostyl.cxx   |   24 +++++-------------------
 sw/source/filter/ww8/ww8par.hxx  |    9 ++-------
 sw/source/filter/ww8/ww8par2.cxx |    6 +++---
 sw/source/filter/ww8/ww8par6.cxx |   13 ++++++-------
 7 files changed, 33 insertions(+), 68 deletions(-)

New commits:
commit 6dee1b1a8c12770d1e8139819aa532056deb3ed5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 15 12:02:44 2016 +0100

    use std::unique_ptr
    
    Change-Id: Ibdbb7c32435684c7166ff3437a9fe812b3760356

diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 9c9ac5f..77964a8 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -373,48 +373,36 @@ SVGExport::SVGExport(
         XML_NAMESPACE_ANIMATION);
 }
 
-
 SVGExport::~SVGExport()
 {
     GetDocHandler()->endDocument();
 }
 
-
-ObjectRepresentation::ObjectRepresentation() :
-    mpMtf( nullptr )
+ObjectRepresentation::ObjectRepresentation()
 {
 }
 
-
 ObjectRepresentation::ObjectRepresentation( const Reference< XInterface >& rxObject,
                                             const GDIMetaFile& rMtf ) :
     mxObject( rxObject ),
-    mpMtf( new GDIMetaFile( rMtf ) )
+    mxMtf( new GDIMetaFile( rMtf ) )
 {
 }
 
-
 ObjectRepresentation::ObjectRepresentation( const ObjectRepresentation& rPresentation ) :
     mxObject( rPresentation.mxObject ),
-    mpMtf( rPresentation.mpMtf ? new GDIMetaFile( *rPresentation.mpMtf ) : nullptr )
-{
-}
-
-
-ObjectRepresentation::~ObjectRepresentation()
+    mxMtf( rPresentation.mxMtf ? new GDIMetaFile( *rPresentation.mxMtf ) : nullptr )
 {
-    delete mpMtf;
 }
 
-
 ObjectRepresentation& ObjectRepresentation::operator=( const ObjectRepresentation& rPresentation )
 {
     // Check for self-assignment
     if (this == &rPresentation)
         return *this;
+
     mxObject = rPresentation.mxObject;
-    delete mpMtf;
-    mpMtf = rPresentation.mpMtf ? new GDIMetaFile( *rPresentation.mpMtf ) : nullptr;
+    mxMtf.reset(rPresentation.mxMtf ? new GDIMetaFile(*rPresentation.mxMtf) : nullptr);
 
     return *this;
 }
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 447bf77..2d47638 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -123,21 +123,19 @@ class ObjectRepresentation
 private:
 
     Reference< XInterface >         mxObject;
-    GDIMetaFile*                    mpMtf;
+    std::unique_ptr<GDIMetaFile>    mxMtf;
 
 public:
+    ObjectRepresentation();
+    ObjectRepresentation(const Reference< XInterface >& rxIf,
+                         const GDIMetaFile& rMtf);
+    ObjectRepresentation(const ObjectRepresentation& rPresentation);
 
-                                      ObjectRepresentation();
-                                      ObjectRepresentation( const Reference< XInterface >& rxIf,
-                                                            const GDIMetaFile& rMtf );
-                                      ObjectRepresentation( const ObjectRepresentation& rPresentation );
-                                      ~ObjectRepresentation();
-
-    ObjectRepresentation&             operator=( const ObjectRepresentation& rPresentation );
+    ObjectRepresentation& operator=(const ObjectRepresentation& rPresentation);
 
     const Reference< XInterface >&    GetObject() const { return mxObject; }
-    bool                          HasRepresentation() const { return mpMtf != nullptr; }
-    const GDIMetaFile&                GetRepresentation() const { return *mpMtf; }
+    bool                              HasRepresentation() const { return static_cast<bool>(mxMtf); }
+    const GDIMetaFile&                GetRepresentation() const { return *mxMtf; }
 };
 
 struct PagePropertySet
diff --git a/sc/source/ui/inc/undostyl.hxx b/sc/source/ui/inc/undostyl.hxx
index 3674b31..d7d96ab 100644
--- a/sc/source/ui/inc/undostyl.hxx
+++ b/sc/source/ui/inc/undostyl.hxx
@@ -31,19 +31,18 @@ class ScStyleSaveData
 private:
     OUString        aName;
     OUString        aParent;
-    SfxItemSet*     pItems;
+    std::unique_ptr<SfxItemSet>  xItems;
 
 public:
-                        ScStyleSaveData();
-                        ScStyleSaveData( const ScStyleSaveData& rOther );
-                        ~ScStyleSaveData();
+    ScStyleSaveData();
+    ScStyleSaveData( const ScStyleSaveData& rOther );
     ScStyleSaveData&    operator=( const ScStyleSaveData& rOther );
 
     void                InitFromStyle( const SfxStyleSheetBase* pSource );
 
     const OUString&     GetName() const     { return aName; }
     const OUString&     GetParent() const   { return aParent; }
-    const SfxItemSet*   GetItems() const    { return pItems; }
+    const SfxItemSet*   GetItems() const    { return xItems.get(); }
 };
 
 class ScUndoModifyStyle: public ScSimpleUndo
diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx
index 96ad6cc..71a6e18 100644
--- a/sc/source/ui/undo/undostyl.cxx
+++ b/sc/source/ui/undo/undostyl.cxx
@@ -32,8 +32,7 @@
 
 //      modify style (cell or page style)
 
-ScStyleSaveData::ScStyleSaveData() :
-    pItems( nullptr )
+ScStyleSaveData::ScStyleSaveData()
 {
 }
 
@@ -41,27 +40,15 @@ ScStyleSaveData::ScStyleSaveData( const ScStyleSaveData& rOther ) :
     aName( rOther.aName ),
     aParent( rOther.aParent )
 {
-    if (rOther.pItems)
-        pItems = new SfxItemSet( *rOther.pItems );
-    else
-        pItems = nullptr;
-}
-
-ScStyleSaveData::~ScStyleSaveData()
-{
-    delete pItems;
+    if (rOther.xItems)
+        xItems.reset(new SfxItemSet(*rOther.xItems));
 }
 
 ScStyleSaveData& ScStyleSaveData::operator=( const ScStyleSaveData& rOther )
 {
     aName   = rOther.aName;
     aParent = rOther.aParent;
-
-    delete pItems;
-    if (rOther.pItems)
-        pItems = new SfxItemSet( *rOther.pItems );
-    else
-        pItems = nullptr;
+    xItems.reset(rOther.xItems ? new SfxItemSet(*rOther.xItems) : nullptr);
 
     return *this;
 }
@@ -72,8 +59,7 @@ void ScStyleSaveData::InitFromStyle( const SfxStyleSheetBase* pSource )
     {
         aName   = pSource->GetName();
         aParent = pSource->GetParent();
-        delete pItems;
-        pItems = new SfxItemSet( const_cast<SfxStyleSheetBase*>(pSource)->GetItemSet() );
+        xItems.reset(new SfxItemSet(const_cast<SfxStyleSheetBase*>(pSource)->GetItemSet()));
     }
     else
         *this = ScStyleSaveData();      // empty
commit a84a94ff53ee37c191da6e697d3fce0684418b2d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 15 11:53:39 2016 +0100

    use std::unique_ptr and remove custom dtor for coverity#1371321
    
    Change-Id: Idf1e423fe78d44bca351624e81bcca85205a644b

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index ca835d9..52b3626 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -221,7 +221,7 @@ public:
     rtl_TextEncoding m_eRTLFontSrcCharSet;    // rtl_TextEncoding for the font
     rtl_TextEncoding m_eCJKFontSrcCharSet;    // rtl_TextEncoding for the font
     SwFormat*      m_pFormat;
-    WW8FlyPara* m_pWWFly;
+    std::unique_ptr<WW8FlyPara> m_xWWFly;
     SwNumRule*  m_pOutlineNumrule;
     long        m_nFilePos;
     sal_uInt16      m_nBase;
@@ -261,7 +261,7 @@ public:
         m_eRTLFontSrcCharSet(0),
         m_eCJKFontSrcCharSet(0),
         m_pFormat( nullptr ),
-        m_pWWFly( nullptr ),
+        m_xWWFly( nullptr ),
         m_pOutlineNumrule( nullptr ),
         m_nFilePos( 0 ),
         m_nBase( 0 ),
@@ -284,11 +284,6 @@ public:
 
     {}
 
-    ~SwWW8StyInf()
-    {
-        delete m_pWWFly;
-    }
-
     void SetOrgWWIdent( const OUString& rName, const sal_uInt16 nId )
     {
         m_sWWStyleName = rName;
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index d00ff35..b21feb2 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -482,7 +482,7 @@ ApoTestResults SwWW8ImplReader::TestApo(int nCellLevel, bool bTableRowEnd,
     // Frame in Style Definition (word appears to ignore them if inside an
     // text autoshape)
     if (!m_bTxbxFlySection && m_nAktColl < m_vColl.size())
-        aRet.mpStyleApo = StyleExists(m_nAktColl) ? m_vColl[m_nAktColl].m_pWWFly : nullptr;
+        aRet.mpStyleApo = StyleExists(m_nAktColl) ? m_vColl[m_nAktColl].m_xWWFly.get() : nullptr;
 
     /*
     #i1140#
@@ -3863,8 +3863,8 @@ bool WW8RStyle::PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisSty
             rSI.m_bParaAutoBefore = pj->m_bParaAutoBefore;
             rSI.m_bParaAutoAfter = pj->m_bParaAutoAfter;
 
-            if (pj->m_pWWFly)
-                rSI.m_pWWFly = new WW8FlyPara(pIo->m_bVer67, pj->m_pWWFly);
+            if (pj->m_xWWFly)
+                rSI.m_xWWFly.reset(new WW8FlyPara(pIo->m_bVer67, pj->m_xWWFly.get()));
         }
     }
     else if( pIo->m_bNewDoc && bStyExist )
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index fb22f8a..3492daa 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -1655,7 +1655,7 @@ void WW8FlyPara::ReadFull(sal_uInt8 nOrigSp29, SwWW8ImplReader* pIo)
             WW8FlyPara *pNowStyleApo=nullptr;
             sal_uInt16 nColl = pPap->GetIstd();
             ww::sti eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc( static_cast< sal_uInt8 >(nColl) ) : static_cast<ww::sti>(nColl);
-            while (eSti != ww::stiNil && nColl < pIo->m_vColl.size() && nullptr == (pNowStyleApo = pIo->m_vColl[nColl].m_pWWFly))
+            while (eSti != ww::stiNil && nColl < pIo->m_vColl.size() && nullptr == (pNowStyleApo = pIo->m_vColl[nColl].m_xWWFly.get()))
             {
                 nColl = pIo->m_vColl[nColl].m_nBase;
                 eSti = eVer < ww::eWW6 ? ww::GetCanonicalStiFromStc( static_cast< sal_uInt8 >(nColl) ) : static_cast<ww::sti>(nColl);
@@ -4977,13 +4977,12 @@ void SwWW8ImplReader::Read_ApoPPC( sal_uInt16, const sal_uInt8* pData, short )
     if (m_pAktColl && m_nAktColl < m_vColl.size()) // only for Styledef, sonst anders geloest
     {
         SwWW8StyInf& rSI = m_vColl[m_nAktColl];
-        if (!rSI.m_pWWFly)
-            rSI.m_pWWFly = new WW8FlyPara(m_bVer67);
-        rSI.m_pWWFly->Read(*pData, m_pStyles);
-        if (rSI.m_pWWFly->IsEmpty())
+        if (!rSI.m_xWWFly)
+            rSI.m_xWWFly.reset(new WW8FlyPara(m_bVer67));
+        rSI.m_xWWFly->Read(*pData, m_pStyles);
+        if (rSI.m_xWWFly->IsEmpty())
         {
-            delete m_vColl[m_nAktColl].m_pWWFly;
-            m_vColl[m_nAktColl].m_pWWFly = nullptr;
+            m_vColl[m_nAktColl].m_xWWFly.reset();
         }
     }
 }


More information about the Libreoffice-commits mailing list