21#include <osl/diagnose.h>
24#include <com/sun/star/lang/XComponent.hpp>
25#include <com/sun/star/util/CloseVetoException.hpp>
26#include <com/sun/star/util/XCloseable.hpp>
34 using ::com::sun::star::uno::XInterface;
35 using ::com::sun::star::uno::Reference;
36 using ::com::sun::star::uno::Exception;
37 using ::com::sun::star::uno::UNO_QUERY;
38 using ::com::sun::star::lang::EventObject;
39 using ::com::sun::star::util::XCloseable;
40 using ::com::sun::star::util::XCloseListener;
41 using ::com::sun::star::util::CloseVetoException;
46 :m_xComponent( _rxComponent, UNO_QUERY )
48 DBG_ASSERT( m_xComponent.is() || !_rxComponent.is(),
"DisposableComponent::DisposableComponent: should be an XComponent!" );
51 DisposableComponent::~DisposableComponent()
53 if ( m_xComponent.is() )
57 m_xComponent->dispose();
67 typedef ::cppu::WeakImplHelper < XCloseListener
84 void nf_closeComponent();
90 virtual void SAL_CALL queryClosing(
const EventObject& Source,
sal_Bool GetsOwnership )
override;
91 virtual void SAL_CALL notifyClosing(
const EventObject& Source )
override;
94 virtual void SAL_CALL disposing(
const css::lang::EventObject& Source )
override;
104 void impl_nf_switchListening(
bool _bListen );
107 CloseableComponentImpl::CloseableComponentImpl(
const Reference< XInterface >& _rxComponent )
108 :m_xCloseable( _rxComponent, UNO_QUERY )
110 DBG_ASSERT(
m_xCloseable.is() || !_rxComponent.is(),
"CloseableComponentImpl::CloseableComponentImpl: component is not an XCloseable!" );
133 catch(
const CloseVetoException& ) { }
136 TOOLS_WARN_EXCEPTION(
"unotools",
"CloseableComponentImpl::nf_closeComponent: caught an unexpected exception!" );
166 throw CloseVetoException();
176 OSL_FAIL(
"CloseableComponentImpl::notifyClosing: unreachable!" );
182 OSL_FAIL(
"CloseableComponentImpl::disposing: unreachable!" );
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void impl_nf_switchListening(bool _bListen)
starts or stops being a CloseListener at the component
virtual void SAL_CALL notifyClosing(const EventObject &Source) override
virtual void SAL_CALL queryClosing(const EventObject &Source, sal_Bool GetsOwnership) override
virtual ~CloseableComponentImpl() override
CloseableComponentImpl & operator=(const CloseableComponentImpl &)=delete
void nf_closeComponent()
closes the component
Reference< XCloseable > m_xCloseable
CloseableComponentImpl(const CloseableComponentImpl &)=delete
~CloseableComponent()
destroys resources associated with this instance, and disposes the component
CloseableComponent(const css::uno::Reference< css::uno::XInterface > &_rxComponent)
constructs a ->CloseableComponent instance
::rtl::Reference< CloseableComponentImpl > m_pImpl
Our IMPL class.
DisposableComponent(const css::uno::Reference< css::uno::XInterface > &_rxComponent)
constructs a ->DisposableComponent instance
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
::cppu::WeakImplHelper< XCloseListener > CloseableComponentImpl_Base