From 90df5ee10727719aa1407ed4d1f06d7a790d6871 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 16 Jan 2017 14:16:55 +0200 Subject: new loplugin: useuniqueptr: jvmfwk..sax Change-Id: I732e2e22c6f953f0982fbc8833453e7c23cf9d49 Reviewed-on: https://gerrit.libreoffice.org/33166 Tested-by: Jenkins Reviewed-by: Noel Grandin --- sax/source/expatwrap/sax_expat.cxx | 16 ++++------------ sax/source/expatwrap/saxwriter.cxx | 11 +++-------- 2 files changed, 7 insertions(+), 20 deletions(-) (limited to 'sax') diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index ba87c6f9e146..9330749185f4 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -105,7 +105,6 @@ class SaxExpatParser public: SaxExpatParser(); - virtual ~SaxExpatParser() override; // css::lang::XInitialization: virtual void SAL_CALL initialize(css::uno::Sequence const& rArguments) @@ -134,9 +133,7 @@ public: // XServiceInfo sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (std::exception) override; private: - - SaxExpatParser_Impl *m_pImpl; - + std::unique_ptr m_pImpl; }; @@ -365,9 +362,9 @@ private: SaxExpatParser::SaxExpatParser( ) { - m_pImpl = new SaxExpatParser_Impl; + m_pImpl.reset( new SaxExpatParser_Impl ); - LocatorImpl *pLoc = new LocatorImpl( m_pImpl ); + LocatorImpl *pLoc = new LocatorImpl( m_pImpl.get() ); m_pImpl->rDocumentLocator.set( pLoc ); // Performance-improvement; handing out the same object with every call of @@ -378,11 +375,6 @@ SaxExpatParser::SaxExpatParser( ) m_pImpl->bRTExceptionWasThrown = false; } -SaxExpatParser::~SaxExpatParser() -{ - delete m_pImpl; -} - // css::lang::XInitialization: void SAL_CALL SaxExpatParser::initialize(css::uno::Sequence< css::uno::Any > const& rArguments) @@ -440,7 +432,7 @@ void SaxExpatParser::parseStream( const InputSource& structSource) } // set all necessary C-Callbacks - XML_SetUserData( entity.pParser , m_pImpl ); + XML_SetUserData( entity.pParser, m_pImpl.get() ); XML_SetElementHandler( entity.pParser , call_callbackStartElement , call_callbackEndElement ); diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx index 9074688260e5..50deb1f04768 100644 --- a/sax/source/expatwrap/saxwriter.cxx +++ b/sax/source/expatwrap/saxwriter.cxx @@ -884,10 +884,6 @@ public: , m_nLevel(0) { } - virtual ~SAXWriter() override - { - delete m_pSaxWriterHelper; - } public: // XActiveDataSource virtual void SAL_CALL setOutputStream(const Reference< XOutputStream > & aStream) @@ -901,8 +897,7 @@ public: // XActiveDataSource else { m_out = aStream; - delete m_pSaxWriterHelper; - m_pSaxWriterHelper = new SaxWriterHelper(m_out); + m_pSaxWriterHelper.reset( new SaxWriterHelper(m_out) ); m_bDocStarted = false; m_nLevel = 0; m_bIsCDATA = false; @@ -965,8 +960,8 @@ public: // XServiceInfo private: sal_Int32 getIndentPrefixLength( sal_Int32 nFirstLineBreakOccurrence ) throw(); - Reference< XOutputStream > m_out; - SaxWriterHelper* m_pSaxWriterHelper; + Reference< XOutputStream > m_out; + std::unique_ptr m_pSaxWriterHelper; // Status information bool m_bDocStarted : 1; -- cgit