diff options
author | Noel Grandin <noel@peralex.com> | 2015-11-17 09:43:45 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-11-17 10:59:48 +0200 |
commit | edc264d1da7d4240c27c9f98efab09e84d78fff3 (patch) | |
tree | 1b5c5904b5f965660c045c5c7e16fd70c96b5c34 | |
parent | 85d7a76aba066553b8ecf385f295b1630d50ab8a (diff) |
use unique_ptr for pImpl in unotools/
Change-Id: I4128ca0d4ff18f6e0c3c9f8ecad13b69c38c3157
-rw-r--r-- | include/unotools/eventlisteneradapter.hxx | 6 | ||||
-rw-r--r-- | include/unotools/misccfg.hxx | 4 | ||||
-rw-r--r-- | include/unotools/searchopt.hxx | 3 | ||||
-rw-r--r-- | unotools/source/config/misccfg.cxx | 34 | ||||
-rw-r--r-- | unotools/source/config/searchopt.cxx | 3 | ||||
-rw-r--r-- | unotools/source/misc/eventlisteneradapter.cxx | 2 |
6 files changed, 24 insertions, 28 deletions
diff --git a/include/unotools/eventlisteneradapter.hxx b/include/unotools/eventlisteneradapter.hxx index 78408ed2b46b..74f608922ba4 100644 --- a/include/unotools/eventlisteneradapter.hxx +++ b/include/unotools/eventlisteneradapter.hxx @@ -16,11 +16,13 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <unotools/unotoolsdllapi.h> #ifndef INCLUDED_UNOTOOLS_EVENTLISTENERADAPTER_HXX #define INCLUDED_UNOTOOLS_EVENTLISTENERADAPTER_HXX + +#include <unotools/unotoolsdllapi.h> #include <com/sun/star/lang/XComponent.hpp> +#include <memory> namespace utl { @@ -40,7 +42,7 @@ namespace utl const OEventListenerAdapter& operator=( const OEventListenerAdapter& _rSource ) = delete; protected: - OEventListenerAdapterImpl* m_pImpl; + std::unique_ptr<OEventListenerAdapterImpl> m_pImpl; protected: OEventListenerAdapter(); diff --git a/include/unotools/misccfg.hxx b/include/unotools/misccfg.hxx index eca80c4617aa..9aebe796b4e8 100644 --- a/include/unotools/misccfg.hxx +++ b/include/unotools/misccfg.hxx @@ -24,12 +24,8 @@ namespace utl { - class SfxMiscCfg; - class UNOTOOLS_DLLPUBLIC MiscCfg : public detail::Options { - SfxMiscCfg* pImpl; - public: MiscCfg( ); virtual ~MiscCfg( ); diff --git a/include/unotools/searchopt.hxx b/include/unotools/searchopt.hxx index c560ae98e429..5accfba2a2db 100644 --- a/include/unotools/searchopt.hxx +++ b/include/unotools/searchopt.hxx @@ -21,12 +21,13 @@ #define INCLUDED_UNOTOOLS_SEARCHOPT_HXX #include <unotools/unotoolsdllapi.h> +#include <memory> class SvtSearchOptions_Impl; class UNOTOOLS_DLLPUBLIC SvtSearchOptions { - SvtSearchOptions_Impl *pImpl; + std::unique_ptr<SvtSearchOptions_Impl> pImpl; SvtSearchOptions( const SvtSearchOptions & ) = delete; SvtSearchOptions & operator = ( const SvtSearchOptions & ) = delete; diff --git a/unotools/source/config/misccfg.cxx b/unotools/source/config/misccfg.cxx index faf8fd7f9e80..527b8eb3e86c 100644 --- a/unotools/source/config/misccfg.cxx +++ b/unotools/source/config/misccfg.cxx @@ -32,8 +32,9 @@ using namespace com::sun::star::uno; namespace utl { +class SfxMiscCfg; -static SfxMiscCfg* pOptions = nullptr; +static SfxMiscCfg* g_pOptions = nullptr; static sal_Int32 nRefCount = 0; class SfxMiscCfg : public utl::ConfigItem @@ -186,69 +187,68 @@ MiscCfg::MiscCfg( ) { // Global access, must be guarded (multithreading) ::osl::MutexGuard aGuard( LocalSingleton::get() ); - if ( !pOptions ) + if ( !g_pOptions ) { - pOptions = new SfxMiscCfg; + g_pOptions = new SfxMiscCfg; ItemHolder1::holdConfigItem(E_MISCCFG); } ++nRefCount; - pImpl = pOptions; - pImpl->AddListener(this); + g_pOptions->AddListener(this); } MiscCfg::~MiscCfg( ) { // Global access, must be guarded (multithreading) ::osl::MutexGuard aGuard( LocalSingleton::get() ); - pImpl->RemoveListener(this); + g_pOptions->RemoveListener(this); if ( !--nRefCount ) { - if ( pOptions->IsModified() ) - pOptions->Commit(); - DELETEZ( pOptions ); + if ( g_pOptions->IsModified() ) + g_pOptions->Commit(); + DELETEZ( g_pOptions ); } } bool MiscCfg::IsNotFoundWarning() const { - return pImpl->IsNotFoundWarning(); + return g_pOptions->IsNotFoundWarning(); } void MiscCfg::SetNotFoundWarning( bool bSet) { - pImpl->SetNotFoundWarning( bSet ); + g_pOptions->SetNotFoundWarning( bSet ); } bool MiscCfg::IsPaperSizeWarning() const { - return pImpl->IsPaperSizeWarning(); + return g_pOptions->IsPaperSizeWarning(); } void MiscCfg::SetPaperSizeWarning(bool bSet) { - pImpl->SetPaperSizeWarning( bSet ); + g_pOptions->SetPaperSizeWarning( bSet ); } bool MiscCfg::IsPaperOrientationWarning() const { - return pImpl->IsPaperOrientationWarning(); + return g_pOptions->IsPaperOrientationWarning(); } void MiscCfg::SetPaperOrientationWarning( bool bSet) { - pImpl->SetPaperOrientationWarning( bSet ); + g_pOptions->SetPaperOrientationWarning( bSet ); } sal_Int32 MiscCfg::GetYear2000() const { - return pImpl->GetYear2000(); + return g_pOptions->GetYear2000(); } void MiscCfg::SetYear2000( sal_Int32 nSet ) { - pImpl->SetYear2000( nSet ); + g_pOptions->SetYear2000( nSet ); } } diff --git a/unotools/source/config/searchopt.cxx b/unotools/source/config/searchopt.cxx index b1bec8b9a846..5f8cda2be5b9 100644 --- a/unotools/source/config/searchopt.cxx +++ b/unotools/source/config/searchopt.cxx @@ -240,13 +240,12 @@ bool SvtSearchOptions_Impl::Save() } SvtSearchOptions::SvtSearchOptions() + : pImpl( new SvtSearchOptions_Impl ) { - pImpl = new SvtSearchOptions_Impl; } SvtSearchOptions::~SvtSearchOptions() { - delete pImpl; } void SvtSearchOptions::Commit() diff --git a/unotools/source/misc/eventlisteneradapter.cxx b/unotools/source/misc/eventlisteneradapter.cxx index c8f726b24ed3..ef825eab2ad3 100644 --- a/unotools/source/misc/eventlisteneradapter.cxx +++ b/unotools/source/misc/eventlisteneradapter.cxx @@ -105,8 +105,6 @@ namespace utl OEventListenerAdapter::~OEventListenerAdapter() { stopAllComponentListening( ); - delete m_pImpl; - m_pImpl = nullptr; } void OEventListenerAdapter::stopComponentListening( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComp ) |