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

use unique_ptr for pImpl in unotools/

Change-Id: I4128ca0d4ff18f6e0c3c9f8ecad13b69c38c3157
üst 85d7a76a
...@@ -16,11 +16,13 @@ ...@@ -16,11 +16,13 @@
* except in compliance with the License. You may obtain a copy of * except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <unotools/unotoolsdllapi.h>
#ifndef INCLUDED_UNOTOOLS_EVENTLISTENERADAPTER_HXX #ifndef INCLUDED_UNOTOOLS_EVENTLISTENERADAPTER_HXX
#define INCLUDED_UNOTOOLS_EVENTLISTENERADAPTER_HXX #define INCLUDED_UNOTOOLS_EVENTLISTENERADAPTER_HXX
#include <unotools/unotoolsdllapi.h>
#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XComponent.hpp>
#include <memory>
namespace utl namespace utl
{ {
...@@ -40,7 +42,7 @@ namespace utl ...@@ -40,7 +42,7 @@ namespace utl
const OEventListenerAdapter& operator=( const OEventListenerAdapter& _rSource ) = delete; const OEventListenerAdapter& operator=( const OEventListenerAdapter& _rSource ) = delete;
protected: protected:
OEventListenerAdapterImpl* m_pImpl; std::unique_ptr<OEventListenerAdapterImpl> m_pImpl;
protected: protected:
OEventListenerAdapter(); OEventListenerAdapter();
......
...@@ -24,12 +24,8 @@ ...@@ -24,12 +24,8 @@
namespace utl namespace utl
{ {
class SfxMiscCfg;
class UNOTOOLS_DLLPUBLIC MiscCfg : public detail::Options class UNOTOOLS_DLLPUBLIC MiscCfg : public detail::Options
{ {
SfxMiscCfg* pImpl;
public: public:
MiscCfg( ); MiscCfg( );
virtual ~MiscCfg( ); virtual ~MiscCfg( );
......
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
#define INCLUDED_UNOTOOLS_SEARCHOPT_HXX #define INCLUDED_UNOTOOLS_SEARCHOPT_HXX
#include <unotools/unotoolsdllapi.h> #include <unotools/unotoolsdllapi.h>
#include <memory>
class SvtSearchOptions_Impl; class SvtSearchOptions_Impl;
class UNOTOOLS_DLLPUBLIC SvtSearchOptions class UNOTOOLS_DLLPUBLIC SvtSearchOptions
{ {
SvtSearchOptions_Impl *pImpl; std::unique_ptr<SvtSearchOptions_Impl> pImpl;
SvtSearchOptions( const SvtSearchOptions & ) = delete; SvtSearchOptions( const SvtSearchOptions & ) = delete;
SvtSearchOptions & operator = ( const SvtSearchOptions & ) = delete; SvtSearchOptions & operator = ( const SvtSearchOptions & ) = delete;
......
...@@ -32,8 +32,9 @@ using namespace com::sun::star::uno; ...@@ -32,8 +32,9 @@ using namespace com::sun::star::uno;
namespace utl namespace utl
{ {
class SfxMiscCfg;
static SfxMiscCfg* pOptions = nullptr; static SfxMiscCfg* g_pOptions = nullptr;
static sal_Int32 nRefCount = 0; static sal_Int32 nRefCount = 0;
class SfxMiscCfg : public utl::ConfigItem class SfxMiscCfg : public utl::ConfigItem
...@@ -186,69 +187,68 @@ MiscCfg::MiscCfg( ) ...@@ -186,69 +187,68 @@ MiscCfg::MiscCfg( )
{ {
// Global access, must be guarded (multithreading) // Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( LocalSingleton::get() ); ::osl::MutexGuard aGuard( LocalSingleton::get() );
if ( !pOptions ) if ( !g_pOptions )
{ {
pOptions = new SfxMiscCfg; g_pOptions = new SfxMiscCfg;
ItemHolder1::holdConfigItem(E_MISCCFG); ItemHolder1::holdConfigItem(E_MISCCFG);
} }
++nRefCount; ++nRefCount;
pImpl = pOptions; g_pOptions->AddListener(this);
pImpl->AddListener(this);
} }
MiscCfg::~MiscCfg( ) MiscCfg::~MiscCfg( )
{ {
// Global access, must be guarded (multithreading) // Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( LocalSingleton::get() ); ::osl::MutexGuard aGuard( LocalSingleton::get() );
pImpl->RemoveListener(this); g_pOptions->RemoveListener(this);
if ( !--nRefCount ) if ( !--nRefCount )
{ {
if ( pOptions->IsModified() ) if ( g_pOptions->IsModified() )
pOptions->Commit(); g_pOptions->Commit();
DELETEZ( pOptions ); DELETEZ( g_pOptions );
} }
} }
bool MiscCfg::IsNotFoundWarning() const bool MiscCfg::IsNotFoundWarning() const
{ {
return pImpl->IsNotFoundWarning(); return g_pOptions->IsNotFoundWarning();
} }
void MiscCfg::SetNotFoundWarning( bool bSet) void MiscCfg::SetNotFoundWarning( bool bSet)
{ {
pImpl->SetNotFoundWarning( bSet ); g_pOptions->SetNotFoundWarning( bSet );
} }
bool MiscCfg::IsPaperSizeWarning() const bool MiscCfg::IsPaperSizeWarning() const
{ {
return pImpl->IsPaperSizeWarning(); return g_pOptions->IsPaperSizeWarning();
} }
void MiscCfg::SetPaperSizeWarning(bool bSet) void MiscCfg::SetPaperSizeWarning(bool bSet)
{ {
pImpl->SetPaperSizeWarning( bSet ); g_pOptions->SetPaperSizeWarning( bSet );
} }
bool MiscCfg::IsPaperOrientationWarning() const bool MiscCfg::IsPaperOrientationWarning() const
{ {
return pImpl->IsPaperOrientationWarning(); return g_pOptions->IsPaperOrientationWarning();
} }
void MiscCfg::SetPaperOrientationWarning( bool bSet) void MiscCfg::SetPaperOrientationWarning( bool bSet)
{ {
pImpl->SetPaperOrientationWarning( bSet ); g_pOptions->SetPaperOrientationWarning( bSet );
} }
sal_Int32 MiscCfg::GetYear2000() const sal_Int32 MiscCfg::GetYear2000() const
{ {
return pImpl->GetYear2000(); return g_pOptions->GetYear2000();
} }
void MiscCfg::SetYear2000( sal_Int32 nSet ) void MiscCfg::SetYear2000( sal_Int32 nSet )
{ {
pImpl->SetYear2000( nSet ); g_pOptions->SetYear2000( nSet );
} }
} }
......
...@@ -240,13 +240,12 @@ bool SvtSearchOptions_Impl::Save() ...@@ -240,13 +240,12 @@ bool SvtSearchOptions_Impl::Save()
} }
SvtSearchOptions::SvtSearchOptions() SvtSearchOptions::SvtSearchOptions()
: pImpl( new SvtSearchOptions_Impl )
{ {
pImpl = new SvtSearchOptions_Impl;
} }
SvtSearchOptions::~SvtSearchOptions() SvtSearchOptions::~SvtSearchOptions()
{ {
delete pImpl;
} }
void SvtSearchOptions::Commit() void SvtSearchOptions::Commit()
......
...@@ -105,8 +105,6 @@ namespace utl ...@@ -105,8 +105,6 @@ namespace utl
OEventListenerAdapter::~OEventListenerAdapter() OEventListenerAdapter::~OEventListenerAdapter()
{ {
stopAllComponentListening( ); stopAllComponentListening( );
delete m_pImpl;
m_pImpl = nullptr;
} }
void OEventListenerAdapter::stopComponentListening( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComp ) void OEventListenerAdapter::stopComponentListening( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComp )
......
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