summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-17 11:08:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-31 07:46:14 +0100
commita8c1083553ee4c0d85bacef4ea4cdef0de8927d3 (patch)
tree6cb42c165d1f958743e7dc03fc7a5540a530ed33 /xmloff
parent96a47c604df8187ab5c68d9941d71e8f07acce6d (diff)
loplugin:useuniqueptr in SvXMLExport
Change-Id: I8ce26b7cddeb74fd86f60896c84bf3574ccbc9bc Reviewed-on: https://gerrit.libreoffice.org/48421 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlexp.cxx42
1 files changed, 21 insertions, 21 deletions
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 );