Kaydet (Commit) e5404aef authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in svl

Change-Id: I89aa05b3c59ca3ad680d35899400957a399ccf0e
Reviewed-on: https://gerrit.libreoffice.org/47795Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 37464a0f
...@@ -36,11 +36,6 @@ OFSInputStreamContainer::OFSInputStreamContainer( const uno::Reference< io::XInp ...@@ -36,11 +36,6 @@ OFSInputStreamContainer::OFSInputStreamContainer( const uno::Reference< io::XInp
OFSInputStreamContainer::~OFSInputStreamContainer() OFSInputStreamContainer::~OFSInputStreamContainer()
{ {
if ( m_pListenersContainer )
{
delete m_pListenersContainer;
m_pListenersContainer = nullptr;
}
} }
uno::Sequence< uno::Type > SAL_CALL OFSInputStreamContainer::getTypes() uno::Sequence< uno::Type > SAL_CALL OFSInputStreamContainer::getTypes()
...@@ -267,7 +262,7 @@ void SAL_CALL OFSInputStreamContainer::addEventListener( const uno::Reference< l ...@@ -267,7 +262,7 @@ void SAL_CALL OFSInputStreamContainer::addEventListener( const uno::Reference< l
throw lang::DisposedException(); throw lang::DisposedException();
if ( !m_pListenersContainer ) if ( !m_pListenersContainer )
m_pListenersContainer = new ::comphelper::OInterfaceContainerHelper2( m_aMutex ); m_pListenersContainer.reset( new ::comphelper::OInterfaceContainerHelper2( m_aMutex ) );
m_pListenersContainer->addInterface( xListener ); m_pListenersContainer->addInterface( xListener );
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <comphelper/interfacecontainer2.hxx> #include <comphelper/interfacecontainer2.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <memory>
class OFSInputStreamContainer : public cppu::WeakImplHelper < css::io::XInputStream class OFSInputStreamContainer : public cppu::WeakImplHelper < css::io::XInputStream
,css::embed::XExtendedStorageStream > ,css::embed::XExtendedStorageStream >
...@@ -43,7 +44,7 @@ class OFSInputStreamContainer : public cppu::WeakImplHelper < css::io::XInputStr ...@@ -43,7 +44,7 @@ class OFSInputStreamContainer : public cppu::WeakImplHelper < css::io::XInputStr
bool m_bDisposed; bool m_bDisposed;
::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list of listeners std::unique_ptr<::comphelper::OInterfaceContainerHelper2> m_pListenersContainer; // list of listeners
public: public:
explicit OFSInputStreamContainer( const css::uno::Reference < css::io::XInputStream >& xStream ); explicit OFSInputStreamContainer( const css::uno::Reference < css::io::XInputStream >& xStream );
......
...@@ -56,11 +56,6 @@ OFSStreamContainer::OFSStreamContainer( const uno::Reference < io::XStream >& xS ...@@ -56,11 +56,6 @@ OFSStreamContainer::OFSStreamContainer( const uno::Reference < io::XStream >& xS
OFSStreamContainer::~OFSStreamContainer() OFSStreamContainer::~OFSStreamContainer()
{ {
if ( m_pListenersContainer )
{
delete m_pListenersContainer;
m_pListenersContainer = nullptr;
}
} }
// XInterface // XInterface
...@@ -259,7 +254,7 @@ void SAL_CALL OFSStreamContainer::addEventListener( const uno::Reference< lang:: ...@@ -259,7 +254,7 @@ void SAL_CALL OFSStreamContainer::addEventListener( const uno::Reference< lang::
throw lang::DisposedException(); throw lang::DisposedException();
if ( !m_pListenersContainer ) if ( !m_pListenersContainer )
m_pListenersContainer = new ::comphelper::OInterfaceContainerHelper2( m_aMutex ); m_pListenersContainer.reset(new ::comphelper::OInterfaceContainerHelper2( m_aMutex ));
m_pListenersContainer->addInterface( xListener ); m_pListenersContainer->addInterface( xListener );
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <cppuhelper/typeprovider.hxx> #include <cppuhelper/typeprovider.hxx>
#include <comphelper/interfacecontainer2.hxx> #include <comphelper/interfacecontainer2.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <memory>
class OFSStreamContainer : public cppu::OWeakObject, class OFSStreamContainer : public cppu::OWeakObject,
public css::lang::XTypeProvider, public css::lang::XTypeProvider,
...@@ -56,7 +57,7 @@ class OFSStreamContainer : public cppu::OWeakObject, ...@@ -56,7 +57,7 @@ class OFSStreamContainer : public cppu::OWeakObject,
bool m_bInputClosed; bool m_bInputClosed;
bool m_bOutputClosed; bool m_bOutputClosed;
::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list of listeners std::unique_ptr<::comphelper::OInterfaceContainerHelper2> m_pListenersContainer; // list of listeners
::cppu::OTypeCollection* m_pTypeCollection; ::cppu::OTypeCollection* m_pTypeCollection;
public: public:
......
...@@ -46,11 +46,6 @@ SvNumberFormatsSupplierServiceObject::SvNumberFormatsSupplierServiceObject(const ...@@ -46,11 +46,6 @@ SvNumberFormatsSupplierServiceObject::SvNumberFormatsSupplierServiceObject(const
SvNumberFormatsSupplierServiceObject::~SvNumberFormatsSupplierServiceObject() SvNumberFormatsSupplierServiceObject::~SvNumberFormatsSupplierServiceObject()
{ {
if (m_pOwnFormatter)
{
delete m_pOwnFormatter;
m_pOwnFormatter = nullptr;
}
} }
Any SAL_CALL SvNumberFormatsSupplierServiceObject::queryAggregation( const Type& _rType ) Any SAL_CALL SvNumberFormatsSupplierServiceObject::queryAggregation( const Type& _rType )
...@@ -76,9 +71,8 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence< ...@@ -76,9 +71,8 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence<
// you should use XMultiServiceFactory::createInstanceWithArguments to avoid that // you should use XMultiServiceFactory::createInstanceWithArguments to avoid that
if (m_pOwnFormatter) if (m_pOwnFormatter)
{ // !!! this is only a emergency handling, normally this should not occur !!! { // !!! this is only a emergency handling, normally this should not occur !!!
delete m_pOwnFormatter; m_pOwnFormatter.reset();
m_pOwnFormatter = nullptr; SetNumberFormatter(m_pOwnFormatter.get());
SetNumberFormatter(m_pOwnFormatter);
} }
Type aExpectedArgType = ::cppu::UnoType<css::lang::Locale>::get(); Type aExpectedArgType = ::cppu::UnoType<css::lang::Locale>::get();
...@@ -102,9 +96,9 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence< ...@@ -102,9 +96,9 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence<
#endif #endif
} }
m_pOwnFormatter = new SvNumberFormatter( m_xORB, eNewFormatterLanguage); m_pOwnFormatter.reset( new SvNumberFormatter( m_xORB, eNewFormatterLanguage) );
m_pOwnFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL ); m_pOwnFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL );
SetNumberFormatter(m_pOwnFormatter); SetNumberFormatter(m_pOwnFormatter.get());
} }
OUString SAL_CALL SvNumberFormatsSupplierServiceObject::getImplementationName( ) OUString SAL_CALL SvNumberFormatsSupplierServiceObject::getImplementationName( )
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <svl/zforlist.hxx> #include <svl/zforlist.hxx>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <memory>
/** /**
* SvNumberFormatsSupplierServiceObject - a number formats supplier which * SvNumberFormatsSupplierServiceObject - a number formats supplier which
...@@ -37,7 +38,7 @@ class SvNumberFormatsSupplierServiceObject final ...@@ -37,7 +38,7 @@ class SvNumberFormatsSupplierServiceObject final
,public css::lang::XInitialization ,public css::lang::XInitialization
,public css::lang::XServiceInfo ,public css::lang::XServiceInfo
{ {
SvNumberFormatter* m_pOwnFormatter; std::unique_ptr<SvNumberFormatter> m_pOwnFormatter;
css::uno::Reference< css::uno::XComponentContext > m_xORB; css::uno::Reference< css::uno::XComponentContext > m_xORB;
void implEnsureFormatter(); void implEnsureFormatter();
......
...@@ -377,7 +377,7 @@ PasswordContainer::PasswordContainer( const Reference<XMultiServiceFactory>& xSe ...@@ -377,7 +377,7 @@ PasswordContainer::PasswordContainer( const Reference<XMultiServiceFactory>& xSe
mComponent.set( xServiceFactory, UNO_QUERY ); mComponent.set( xServiceFactory, UNO_QUERY );
mComponent->addEventListener( this ); mComponent->addEventListener( this );
m_pStorageFile = new StorageItem( this, "Office.Common/Passwords" ); m_pStorageFile.reset( new StorageItem( this, "Office.Common/Passwords" ) );
if( m_pStorageFile->useStorage() ) if( m_pStorageFile->useStorage() )
m_aContainer = m_pStorageFile->getInfo(); m_aContainer = m_pStorageFile->getInfo();
} }
...@@ -387,11 +387,7 @@ PasswordContainer::~PasswordContainer() ...@@ -387,11 +387,7 @@ PasswordContainer::~PasswordContainer()
{ {
::osl::MutexGuard aGuard( mMutex ); ::osl::MutexGuard aGuard( mMutex );
if( m_pStorageFile ) m_pStorageFile.reset();
{
delete m_pStorageFile;
m_pStorageFile = nullptr;
}
if( mComponent.is() ) if( mComponent.is() )
{ {
...@@ -404,11 +400,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& ) ...@@ -404,11 +400,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& )
{ {
::osl::MutexGuard aGuard( mMutex ); ::osl::MutexGuard aGuard( mMutex );
if( m_pStorageFile ) m_pStorageFile.reset();
{
delete m_pStorageFile;
m_pStorageFile = nullptr;
}
if( mComponent.is() ) if( mComponent.is() )
{ {
......
...@@ -212,7 +212,7 @@ class PasswordContainer : public ::cppu::WeakImplHelper< ...@@ -212,7 +212,7 @@ class PasswordContainer : public ::cppu::WeakImplHelper<
{ {
private: private:
PassMap m_aContainer; PassMap m_aContainer;
StorageItem* m_pStorageFile; std::unique_ptr<StorageItem> m_pStorageFile;
::osl::Mutex mMutex; ::osl::Mutex mMutex;
OUString m_aMasterPasswd; // master password is set when the string is not empty OUString m_aMasterPasswd; // master password is set when the string is not empty
css::uno::Reference< css::lang::XComponent > mComponent; css::uno::Reference< css::lang::XComponent > mComponent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment