Kaydet (Commit) cc813c94 authored tarafından Xisco Fauli's avatar Xisco Fauli Kaydeden (comit) Noel Grandin

tdf#89329: use unique_ptr for pImpl in unoctitm

Change-Id: I580c6c9999b35137ae883a84898b9d03fd7cb056
Reviewed-on: https://gerrit.libreoffice.org/25899Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst d2e0d10d
...@@ -73,7 +73,7 @@ class SfxDispatchController_Impl; ...@@ -73,7 +73,7 @@ class SfxDispatchController_Impl;
class SfxOfficeDispatch : public ::cppu::ImplInheritanceHelper1< SfxStatusDispatcher, css::lang::XUnoTunnel > class SfxOfficeDispatch : public ::cppu::ImplInheritanceHelper1< SfxStatusDispatcher, css::lang::XUnoTunnel >
{ {
friend class SfxDispatchController_Impl; friend class SfxDispatchController_Impl;
SfxDispatchController_Impl* pControllerItem; std::unique_ptr<SfxDispatchController_Impl> pImpl;
public: public:
SfxOfficeDispatch( SfxBindings& rBind, SfxOfficeDispatch( SfxBindings& rBind,
SfxDispatcher* pDispat, SfxDispatcher* pDispat,
......
...@@ -161,24 +161,24 @@ sal_Int64 SAL_CALL SfxOfficeDispatch::getSomething( const css::uno::Sequence< sa ...@@ -161,24 +161,24 @@ sal_Int64 SAL_CALL SfxOfficeDispatch::getSomething( const css::uno::Sequence< sa
} }
SfxOfficeDispatch::SfxOfficeDispatch( SfxBindings& rBindings, SfxDispatcher* pDispat, const SfxSlot* pSlot, const css::util::URL& rURL ) SfxOfficeDispatch::SfxOfficeDispatch( SfxBindings& rBindings, SfxDispatcher* pDispat, const SfxSlot* pSlot, const css::util::URL& rURL )
: pImpl( new SfxDispatchController_Impl( this, &rBindings, pDispat, pSlot, rURL ))
{ {
// this object is an adapter that shows a css::frame::XDispatch-Interface to the outside and uses a SfxControllerItem to monitor a state // pImpl is an adapter that shows a css::frame::XDispatch-Interface to the outside and uses a SfxControllerItem to monitor a state
pControllerItem = new SfxDispatchController_Impl( this, &rBindings, pDispat, pSlot, rURL );
} }
SfxOfficeDispatch::SfxOfficeDispatch( SfxDispatcher* pDispat, const SfxSlot* pSlot, const css::util::URL& rURL ) SfxOfficeDispatch::SfxOfficeDispatch( SfxDispatcher* pDispat, const SfxSlot* pSlot, const css::util::URL& rURL )
: pImpl( new SfxDispatchController_Impl( this, nullptr, pDispat, pSlot, rURL ))
{ {
// this object is an adapter that shows a css::frame::XDispatch-Interface to the outside and uses a SfxControllerItem to monitor a state // pImpl is an adapter that shows a css::frame::XDispatch-Interface to the outside and uses a SfxControllerItem to monitor a state
pControllerItem = new SfxDispatchController_Impl( this, nullptr, pDispat, pSlot, rURL );
} }
SfxOfficeDispatch::~SfxOfficeDispatch() SfxOfficeDispatch::~SfxOfficeDispatch()
{ {
if ( pControllerItem ) if ( pImpl )
{ {
// when dispatch object is released, destroy its connection to this object and destroy it // when dispatch object is released, destroy its connection to this object and destroy it
pControllerItem->UnBindController(); pImpl->UnBindController();
delete pControllerItem;
} }
} }
...@@ -194,7 +194,7 @@ const css::uno::Sequence< sal_Int8 >& SfxOfficeDispatch::impl_getStaticIdentifie ...@@ -194,7 +194,7 @@ const css::uno::Sequence< sal_Int8 >& SfxOfficeDispatch::impl_getStaticIdentifie
void SAL_CALL SfxOfficeDispatch::dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) throw ( css::uno::RuntimeException, std::exception ) void SAL_CALL SfxOfficeDispatch::dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) throw ( css::uno::RuntimeException, std::exception )
{ {
// ControllerItem is the Impl class // ControllerItem is the Impl class
if ( pControllerItem ) if ( pImpl )
{ {
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
// The JavaContext contains an interaction handler which is used when // The JavaContext contains an interaction handler which is used when
...@@ -206,7 +206,7 @@ void SAL_CALL SfxOfficeDispatch::dispatch( const css::util::URL& aURL, const css ...@@ -206,7 +206,7 @@ void SAL_CALL SfxOfficeDispatch::dispatch( const css::util::URL& aURL, const css
css::uno::ContextLayer layer( css::uno::ContextLayer layer(
new svt::JavaContext( css::uno::getCurrentContext() ) ); new svt::JavaContext( css::uno::getCurrentContext() ) );
#endif #endif
pControllerItem->dispatch( aURL, aArgs, css::uno::Reference < css::frame::XDispatchResultListener >() ); pImpl->dispatch( aURL, aArgs, css::uno::Reference < css::frame::XDispatchResultListener >() );
} }
} }
...@@ -215,41 +215,41 @@ void SAL_CALL SfxOfficeDispatch::dispatchWithNotification( const css::util::URL& ...@@ -215,41 +215,41 @@ void SAL_CALL SfxOfficeDispatch::dispatchWithNotification( const css::util::URL&
const css::uno::Reference< css::frame::XDispatchResultListener >& rListener ) throw( css::uno::RuntimeException, std::exception ) const css::uno::Reference< css::frame::XDispatchResultListener >& rListener ) throw( css::uno::RuntimeException, std::exception )
{ {
// ControllerItem is the Impl class // ControllerItem is the Impl class
if ( pControllerItem ) if ( pImpl )
{ {
#if HAVE_FEATURE_JAVA #if HAVE_FEATURE_JAVA
// see comment for SfxOfficeDispatch::dispatch // see comment for SfxOfficeDispatch::dispatch
css::uno::ContextLayer layer( new svt::JavaContext( css::uno::getCurrentContext() ) ); css::uno::ContextLayer layer( new svt::JavaContext( css::uno::getCurrentContext() ) );
#endif #endif
pControllerItem->dispatch( aURL, aArgs, rListener ); pImpl->dispatch( aURL, aArgs, rListener );
} }
} }
void SAL_CALL SfxOfficeDispatch::addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & aListener, const css::util::URL& aURL) throw ( css::uno::RuntimeException, std::exception ) void SAL_CALL SfxOfficeDispatch::addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & aListener, const css::util::URL& aURL) throw ( css::uno::RuntimeException, std::exception )
{ {
GetListeners().addInterface( aURL.Complete, aListener ); GetListeners().addInterface( aURL.Complete, aListener );
if ( pControllerItem ) if ( pImpl )
{ {
// ControllerItem is the Impl class // ControllerItem is the Impl class
pControllerItem->addStatusListener( aListener, aURL ); pImpl->addStatusListener( aListener, aURL );
} }
} }
SfxDispatcher* SfxOfficeDispatch::GetDispatcher_Impl() SfxDispatcher* SfxOfficeDispatch::GetDispatcher_Impl()
{ {
return pControllerItem->GetDispatcher(); return pImpl->GetDispatcher();
} }
void SfxOfficeDispatch::SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame) void SfxOfficeDispatch::SetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame)
{ {
if ( pControllerItem ) if ( pImpl )
pControllerItem->SetFrame( xFrame ); pImpl->SetFrame( xFrame );
} }
void SfxOfficeDispatch::SetMasterUnoCommand( bool bSet ) void SfxOfficeDispatch::SetMasterUnoCommand( bool bSet )
{ {
if ( pControllerItem ) if ( pImpl )
pControllerItem->setMasterSlaveCommand( bSet ); pImpl->setMasterSlaveCommand( bSet );
} }
// Determine if URL contains a master/slave command which must be handled a little bit different // Determine if URL contains a master/slave command which must be handled a little bit different
...@@ -315,7 +315,7 @@ SfxDispatchController_Impl::~SfxDispatchController_Impl() ...@@ -315,7 +315,7 @@ SfxDispatchController_Impl::~SfxDispatchController_Impl()
if ( pDispatch ) if ( pDispatch )
{ {
// disconnect // disconnect
pDispatch->pControllerItem = nullptr; pDispatch->pImpl = nullptr;
// force all listeners to release the dispatch object // force all listeners to release the dispatch object
css::lang::EventObject aObject; css::lang::EventObject aObject;
......
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