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