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

Xisco Fauli anistenis at gmail.com
Wed May 25 06:52:30 UTC 2016


 editeng/source/items/xmlcnitm.cxx |   18 ++++++++----------
 include/editeng/xmlcnitm.hxx      |    3 ++-
 2 files changed, 10 insertions(+), 11 deletions(-)

New commits:
commit 62ddce422ce80592107d9125e8e9bd59f7f770a5
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Mon May 23 01:53:33 2016 +0200

    tdf#89329: use unique_ptr for pImpl in xmlcnitm
    
    Change-Id: Iec37e509b78e58e90591bad26735ff31462eaf5c
    Reviewed-on: https://gerrit.libreoffice.org/25328
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/editeng/source/items/xmlcnitm.cxx b/editeng/source/items/xmlcnitm.cxx
index 0fe0bce..6b4dca4 100644
--- a/editeng/source/items/xmlcnitm.cxx
+++ b/editeng/source/items/xmlcnitm.cxx
@@ -30,28 +30,27 @@ using namespace ::com::sun::star::xml;
 
 
 SvXMLAttrContainerItem::SvXMLAttrContainerItem( sal_uInt16 _nWhich ) :
-    SfxPoolItem( _nWhich )
+    SfxPoolItem( _nWhich ),
+    pImpl( new SvXMLAttrContainerData )
 {
-    pImpl = new SvXMLAttrContainerData;
 }
 
 SvXMLAttrContainerItem::SvXMLAttrContainerItem(
                                         const SvXMLAttrContainerItem& rItem ) :
-    SfxPoolItem( rItem )
+    SfxPoolItem( rItem ),
+    pImpl( new SvXMLAttrContainerData( *rItem.pImpl ) )
 {
-    pImpl = new SvXMLAttrContainerData( *rItem.pImpl );
 }
 
 SvXMLAttrContainerItem::~SvXMLAttrContainerItem()
 {
-    delete pImpl;
 }
 
 bool SvXMLAttrContainerItem::operator==( const SfxPoolItem& rItem ) const
 {
     DBG_ASSERT( dynamic_cast< const SvXMLAttrContainerItem* >(&rItem) !=  nullptr,
                "SvXMLAttrContainerItem::operator ==(): Bad type");
-    return *pImpl == *static_cast<const SvXMLAttrContainerItem&>(rItem).pImpl;
+    return *pImpl.get() == *static_cast<const SvXMLAttrContainerItem&>(rItem).pImpl.get();
 }
 
 bool SvXMLAttrContainerItem::GetPresentation(
@@ -73,7 +72,7 @@ sal_uInt16 SvXMLAttrContainerItem::GetVersion( sal_uInt16 /*nFileFormatVersion*/
 bool SvXMLAttrContainerItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
 {
     Reference<XNameContainer> xContainer =
-        new SvUnoAttributeContainer( new SvXMLAttrContainerData( *pImpl ) );
+        new SvUnoAttributeContainer( new SvXMLAttrContainerData( *pImpl.get() ) );
 
     rVal.setValue( &xContainer, cppu::UnoType<XNameContainer>::get());
     return true;
@@ -94,8 +93,7 @@ bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nM
 
     if( pContainer )
     {
-        delete pImpl;
-        pImpl = new SvXMLAttrContainerData( * pContainer->GetContainerImpl() );
+        pImpl.reset( new SvXMLAttrContainerData( * pContainer->GetContainerImpl() ) );
     }
     else
     {
@@ -147,7 +145,7 @@ bool SvXMLAttrContainerItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nM
             }
 
             if( nAttr == nCount )
-                pImpl = pNewImpl.release();
+                pImpl.reset( pNewImpl.release() );
             else
                 return false;
         }
diff --git a/include/editeng/xmlcnitm.hxx b/include/editeng/xmlcnitm.hxx
index d6c5849..2ce157e 100644
--- a/include/editeng/xmlcnitm.hxx
+++ b/include/editeng/xmlcnitm.hxx
@@ -22,6 +22,7 @@
 
 #include <svl/poolitem.hxx>
 #include <editeng/editengdllapi.h>
+#include <memory>
 
 class SvXMLNamespaceMap;
 
@@ -30,7 +31,7 @@ class SvXMLAttrContainerData;
 
 class EDITENG_DLLPUBLIC SvXMLAttrContainerItem: public SfxPoolItem
 {
-    SvXMLAttrContainerData  *pImpl;
+    std::unique_ptr<SvXMLAttrContainerData> pImpl;
 
 public:
 


More information about the Libreoffice-commits mailing list