use rtl::Reference in DocumentHolder

instead of manual acquire/release

Change-Id: Id795dca5ff9e392fa2649f4721a73ce3ffd6de2c
This commit is contained in:
Noel Grandin
2017-01-20 13:37:37 +02:00
parent 4f5b22b93a
commit 2bbf21aade
2 changed files with 10 additions and 12 deletions

View File

@@ -149,7 +149,6 @@ static void InsertMenu_Impl( const uno::Reference< container::XIndexContainer >&
DocumentHolder::DocumentHolder( const uno::Reference< uno::XComponentContext >& xContext,
OCommonEmbeddedObject* pEmbObj )
: m_pEmbedObj( pEmbObj ),
m_pInterceptor( nullptr ),
m_xContext( xContext ),
m_bReadOnly( false ),
m_bWaitForClose( false ),
@@ -200,10 +199,10 @@ DocumentHolder::~DocumentHolder()
} catch( const uno::Exception& ) {}
}
if ( m_pInterceptor )
if ( m_xInterceptor.is() )
{
m_pInterceptor->DisconnectDocHolder();
m_pInterceptor->release();
m_xInterceptor->DisconnectDocHolder();
m_xInterceptor.clear();
}
if ( !m_bDesktopTerminated )
@@ -837,17 +836,15 @@ uno::Reference< frame::XFrame > const & DocumentHolder::GetDocFrame()
uno::Reference< frame::XDispatchProviderInterception > xInterception( m_xFrame, uno::UNO_QUERY );
if ( xInterception.is() )
{
if ( m_pInterceptor )
if ( m_xInterceptor.is() )
{
m_pInterceptor->DisconnectDocHolder();
m_pInterceptor->release();
m_pInterceptor = nullptr;
m_xInterceptor->DisconnectDocHolder();
m_xInterceptor.clear();
}
m_pInterceptor = new Interceptor( this );
m_pInterceptor->acquire();
m_xInterceptor = new Interceptor( this );
xInterception->registerDispatchProviderInterceptor( m_pInterceptor );
xInterception->registerDispatchProviderInterceptor( m_xInterceptor.get() );
// register interceptor from outside
if ( m_xOutplaceInterceptor.is() )

View File

@@ -36,6 +36,7 @@
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/implbase.hxx>
#include <rtl/ref.hxx>
class OCommonEmbeddedObject;
class Interceptor;
@@ -53,7 +54,7 @@ private:
OCommonEmbeddedObject* m_pEmbedObj;
Interceptor* m_pInterceptor;
rtl::Reference<Interceptor> m_xInterceptor;
css::uno::Reference< css::frame::XDispatchProviderInterceptor > m_xOutplaceInterceptor;
css::uno::Reference< css::uno::XComponentContext > m_xContext;