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 @@
* 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();
......
......@@ -24,12 +24,8 @@
namespace utl
{
class SfxMiscCfg;
class UNOTOOLS_DLLPUBLIC MiscCfg : public detail::Options
{
SfxMiscCfg* pImpl;
public:
MiscCfg( );
virtual ~MiscCfg( );
......
......@@ -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;
......
......@@ -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 );
}
}
......
......@@ -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()
......
......@@ -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 )
......
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