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

Noel Grandin noel.grandin at collabora.co.uk
Wed Jan 31 06:46:38 UTC 2018


 include/xmloff/xmlexp.hxx     |   14 +++++++-------
 xmloff/source/core/xmlexp.cxx |   42 +++++++++++++++++++++---------------------
 2 files changed, 28 insertions(+), 28 deletions(-)

New commits:
commit a8c1083553ee4c0d85bacef4ea4cdef0de8927d3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jan 17 11:08:46 2018 +0200

    loplugin:useuniqueptr in SvXMLExport
    
    Change-Id: I8ce26b7cddeb74fd86f60896c84bf3574ccbc9bc
    Reviewed-on: https://gerrit.libreoffice.org/48421
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/xmloff/xmlexp.hxx b/include/xmloff/xmlexp.hxx
index ad934e1f612a..fe73d0d6ab5d 100644
--- a/include/xmloff/xmlexp.hxx
+++ b/include/xmloff/xmlexp.hxx
@@ -140,10 +140,10 @@ class XMLOFF_DLLPUBLIC SvXMLExport : public cppu::WeakImplHelper<
     OUString     msEmbeddedObjectProtocol;
     OUString     msFilterName;
     OUString     msImgFilterName;
-    SvXMLNamespaceMap           *mpNamespaceMap;    // the namepspace map
+    std::unique_ptr<SvXMLNamespaceMap> mpNamespaceMap;    // the namepspace map
     SvXMLUnitConverter          maUnitConv;        // the unit converter
-    SvXMLNumFmtExport           *mpNumExport;
-    ProgressBarHelper           *mpProgressBarHelper;
+    std::unique_ptr<SvXMLNumFmtExport> mpNumExport;
+    std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
 
     rtl::Reference< XMLTextParagraphExport > mxTextParagraphExport;
     rtl::Reference< XMLShapeExport > mxShapeExport;
@@ -152,9 +152,9 @@ class XMLOFF_DLLPUBLIC SvXMLExport : public cppu::WeakImplHelper<
     rtl::Reference< XMLPageExport > mxPageExport;
     rtl::Reference< XMLFontAutoStylePool > mxFontAutoStylePool;
     rtl::Reference< xmloff::OFormLayerXMLExport > mxFormExport;
-    XMLEventExport* mpEventExport;
-    XMLImageMapExport* mpImageMapExport;
-    XMLErrors*  mpXMLErrors;
+    std::unique_ptr<XMLEventExport> mpEventExport;
+    std::unique_ptr<XMLImageMapExport> mpImageMapExport;
+    std::unique_ptr<XMLErrors>  mpXMLErrors;
 
     const enum ::xmloff::token::XMLTokenEnum meClass;
     SAL_DLLPRIVATE void InitCtor_();
@@ -420,7 +420,7 @@ public:
     {
         mxNumberFormatsSupplier = _xNumberFormatSupplier;
         if ( mxNumberFormatsSupplier.is() && mxHandler.is() )
-            mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
+            mpNumExport.reset( new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier) );
     }
 
     // get export helper for text
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 796390f2b1e1..d06eb49da770 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -258,7 +258,7 @@ public:
 
     /// stack of backed up namespace maps
     /// long: depth at which namespace map has been backed up into the stack
-    ::std::stack< ::std::pair< SvXMLNamespaceMap *, long > > mNamespaceMaps;
+    ::std::stack< ::std::pair< std::unique_ptr<SvXMLNamespaceMap>, long > > mNamespaceMaps;
     /// counts depth (number of open elements/start tags)
     long mDepth;
 
@@ -480,7 +480,7 @@ SvXMLExport::SvXMLExport(
     InitCtor_();
 
     if (mxNumberFormatsSupplier.is())
-        mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
+        mpNumExport.reset( new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier) );
 }
 
 SvXMLExport::SvXMLExport(
@@ -519,15 +519,15 @@ SvXMLExport::SvXMLExport(
     InitCtor_();
 
     if (mxNumberFormatsSupplier.is())
-        mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
+        mpNumExport.reset( new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier) );
 }
 
 SvXMLExport::~SvXMLExport()
 {
-    delete mpXMLErrors;
-    delete mpImageMapExport;
-    delete mpEventExport;
-    delete mpNamespaceMap;
+    mpXMLErrors.reset();
+    mpImageMapExport.reset();
+    mpEventExport.reset();
+    mpNamespaceMap.reset();
     if (mpProgressBarHelper || mpNumExport)
     {
         if (mxExportInfo.is())
@@ -561,8 +561,8 @@ SvXMLExport::~SvXMLExport()
                 }
             }
         }
-        delete mpProgressBarHelper;
-        delete mpNumExport;
+        mpProgressBarHelper.reset();
+        mpNumExport.reset();
     }
 
     if (mxEventListener.is() && mxModel.is())
@@ -585,7 +585,7 @@ void SAL_CALL SvXMLExport::setSourceDocument( const uno::Reference< lang::XCompo
     {
         mxNumberFormatsSupplier.set(mxModel, css::uno::UNO_QUERY);
         if(mxNumberFormatsSupplier.is() && mxHandler.is())
-            mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
+            mpNumExport.reset( new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier) );
     }
     if (mxExportInfo.is())
     {
@@ -692,7 +692,7 @@ void SAL_CALL SvXMLExport::initialize( const uno::Sequence< uno::Any >& aArgumen
             *pAny >>= mxExtHandler;
 
             if (mxNumberFormatsSupplier.is() && mpNumExport == nullptr)
-                mpNumExport = new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier);
+                mpNumExport.reset( new SvXMLNumFmtExport(*this, mxNumberFormatsSupplier) );
         }
 
         // property set to transport data across
@@ -908,9 +908,10 @@ SvXMLExport::EnsureNamespace(OUString const & i_rNamespace)
             || (mpImpl->mNamespaceMaps.top().second != mpImpl->mDepth))
         {
             // top was created for lower depth... need a new namespace map!
+            auto pNew = new SvXMLNamespaceMap( *mpNamespaceMap );
             mpImpl->mNamespaceMaps.push(
-                ::std::make_pair(mpNamespaceMap, mpImpl->mDepth) );
-            mpNamespaceMap = new SvXMLNamespaceMap( *mpNamespaceMap );
+                ::std::make_pair(std::move(mpNamespaceMap), mpImpl->mDepth) );
+            mpNamespaceMap.reset( pNew );
         }
 
         // add the namespace to the map and as attribute
@@ -1452,7 +1453,7 @@ ErrCode SvXMLExport::exportDoc( enum ::xmloff::token::XMLTokenEnum eClass )
 
 void SvXMLExport::ResetNamespaceMap()
 {
-    delete mpNamespaceMap;    mpNamespaceMap = new SvXMLNamespaceMap;
+    mpNamespaceMap.reset( new SvXMLNamespaceMap );
 }
 
 OUString const & SvXMLExport::GetSourceShellID() const
@@ -1974,7 +1975,7 @@ ProgressBarHelper*  SvXMLExport::GetProgressBarHelper()
 {
     if (!mpProgressBarHelper)
     {
-        mpProgressBarHelper = new ProgressBarHelper(mxStatusIndicator, true);
+        mpProgressBarHelper.reset( new ProgressBarHelper(mxStatusIndicator, true) );
 
         if (mxExportInfo.is())
         {
@@ -2015,7 +2016,7 @@ ProgressBarHelper*  SvXMLExport::GetProgressBarHelper()
             }
         }
     }
-    return mpProgressBarHelper;
+    return mpProgressBarHelper.get();
 }
 
 XMLEventExport& SvXMLExport::GetEventExport()
@@ -2023,7 +2024,7 @@ XMLEventExport& SvXMLExport::GetEventExport()
     if( nullptr == mpEventExport)
     {
         // create EventExport on demand
-        mpEventExport = new XMLEventExport(*this);
+        mpEventExport.reset( new XMLEventExport(*this) );
 
         // and register standard handlers + names
         mpEventExport->AddHandler("StarBasic", new XMLStarBasicExportHandler());
@@ -2039,7 +2040,7 @@ XMLImageMapExport& SvXMLExport::GetImageMapExport()
     // image map export, create on-demand
     if( nullptr == mpImageMapExport )
     {
-        mpImageMapExport = new XMLImageMapExport(*this);
+        mpImageMapExport.reset( new XMLImageMapExport(*this) );
     }
 
     return *mpImageMapExport;
@@ -2238,8 +2239,7 @@ void SvXMLExport::EndElement(const OUString& rName,
     if (!mpImpl->mNamespaceMaps.empty() &&
         (mpImpl->mNamespaceMaps.top().second == mpImpl->mDepth))
     {
-        delete mpNamespaceMap;
-        mpNamespaceMap = mpImpl->mNamespaceMaps.top().first;
+        mpNamespaceMap = std::move(mpImpl->mNamespaceMaps.top().first);
         mpImpl->mNamespaceMaps.pop();
     }
     SAL_WARN_IF(!mpImpl->mNamespaceMaps.empty() &&
@@ -2302,7 +2302,7 @@ void SvXMLExport::SetError(
 
     // create error list on demand
     if ( mpXMLErrors == nullptr )
-        mpXMLErrors = new XMLErrors();
+        mpXMLErrors.reset( new XMLErrors() );
 
     // save error information
     mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage, rLocator );


More information about the Libreoffice-commits mailing list