diff options
-rw-r--r-- | editeng/source/items/xmlcnitm.cxx | 3 | ||||
-rw-r--r-- | include/xmloff/unoatrcn.hxx | 11 | ||||
-rw-r--r-- | xmloff/source/core/unoatrcn.cxx | 14 |
3 files changed, 13 insertions, 15 deletions
diff --git a/editeng/source/items/xmlcnitm.cxx b/editeng/source/items/xmlcnitm.cxx index c1e397fe06d8..520b3b1fea0e 100644 --- a/editeng/source/items/xmlcnitm.cxx +++ b/editeng/source/items/xmlcnitm.cxx @@ -20,6 +20,7 @@ #include <com/sun/star/xml/AttributeData.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <o3tl/any.hxx> +#include <o3tl/make_unique.hxx> #include <xmloff/xmlcnimp.hxx> #include <xmloff/unoatrcn.hxx> #include <editeng/xmlcnitm.hxx> @@ -73,7 +74,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.get() ) ); + new SvUnoAttributeContainer( o3tl::make_unique<SvXMLAttrContainerData>( *pImpl.get() ) ); rVal <<= xContainer; return true; diff --git a/include/xmloff/unoatrcn.hxx b/include/xmloff/unoatrcn.hxx index 1f81e9171321..7ba70ad7ae25 100644 --- a/include/xmloff/unoatrcn.hxx +++ b/include/xmloff/unoatrcn.hxx @@ -21,6 +21,9 @@ #define INCLUDED_XMLOFF_UNOATRCN_HXX #include <sal/config.h> + +#include <memory> + #include <xmloff/dllapi.h> #include <sal/types.h> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -41,16 +44,14 @@ class XMLOFF_DLLPUBLIC SvUnoAttributeContainer: css::container::XNameContainer > { private: - SvXMLAttrContainerData* mpContainer; + std::unique_ptr<SvXMLAttrContainerData> mpContainer; SAL_DLLPRIVATE sal_uInt16 getIndexByName(const OUString& aName ) const; public: - SvUnoAttributeContainer( SvXMLAttrContainerData* pContainer = nullptr ); - virtual ~SvUnoAttributeContainer(); - - SvXMLAttrContainerData* GetContainerImpl() const { return mpContainer; } + SvUnoAttributeContainer( std::unique_ptr<SvXMLAttrContainerData> pContainer = nullptr ); + SvXMLAttrContainerData* GetContainerImpl() const { return mpContainer.get(); } static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw(); virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) throw(css::uno::RuntimeException, std::exception) override; diff --git a/xmloff/source/core/unoatrcn.cxx b/xmloff/source/core/unoatrcn.cxx index 1fae778f1f90..fec3e48fa4ae 100644 --- a/xmloff/source/core/unoatrcn.cxx +++ b/xmloff/source/core/unoatrcn.cxx @@ -20,6 +20,7 @@ #include <string.h> #include <com/sun/star/xml/AttributeData.hpp> #include <o3tl/any.hxx> +#include <o3tl/make_unique.hxx> #include <rtl/ustrbuf.hxx> #include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> @@ -38,16 +39,11 @@ uno::Reference< uno::XInterface > SvUnoAttributeContainer_CreateInstance() return *(new SvUnoAttributeContainer); } -SvUnoAttributeContainer::SvUnoAttributeContainer( SvXMLAttrContainerData* pContainer) -: mpContainer( pContainer ) +SvUnoAttributeContainer::SvUnoAttributeContainer( std::unique_ptr<SvXMLAttrContainerData> pContainer) +: mpContainer( std::move( pContainer ) ) { - if( mpContainer == nullptr ) - mpContainer = new SvXMLAttrContainerData; -} - -SvUnoAttributeContainer::~SvUnoAttributeContainer() -{ - delete mpContainer; + if( !mpContainer ) + mpContainer = o3tl::make_unique<SvXMLAttrContainerData>(); } // container::XElementAccess |