22#include <com/sun/star/util/CloseVetoException.hpp>
23#include <com/sun/star/util/XCloseable.hpp>
32 using ::com::sun::star::uno::Reference;
33 using ::com::sun::star::uno::XInterface;
34 using ::com::sun::star::uno::UNO_QUERY;
35 using ::com::sun::star::uno::Exception;
36 using ::com::sun::star::util::XCloseable;
37 using ::com::sun::star::util::XCloseListener;
38 using ::com::sun::star::util::CloseVetoException;
39 using ::com::sun::star::lang::EventObject;
43 typedef ::cppu::WeakImplHelper < XCloseListener
51 explicit CloseListener_Impl(
bool const bHasOwnership)
57 virtual void SAL_CALL queryClosing(
const EventObject&
Source,
sal_Bool GetsOwnership )
override;
58 virtual void SAL_CALL notifyClosing(
const EventObject&
Source )
override;
61 virtual void SAL_CALL disposing(
const EventObject&
Source)
override;
66 virtual ~CloseListener_Impl()
override
76 void SAL_CALL CloseListener_Impl::queryClosing(
const EventObject&,
sal_Bool i_deliverOwnership )
81 throw CloseVetoException();
84 void SAL_CALL CloseListener_Impl::notifyClosing(
const EventObject& ) {}
86 void SAL_CALL CloseListener_Impl::disposing(
const EventObject& ) {}
101 void lcl_init(
CloseVeto_Data& i_data,
const Reference< XInterface >& i_closeable,
102 bool const hasOwnership)
104 i_data.
xCloseable.set( i_closeable, UNO_QUERY );
107 i_data.
pListener =
new CloseListener_Impl(hasOwnership);
111 void lcl_deinit( CloseVeto_Data
const & i_data )
113 if ( !i_data.xCloseable.is() )
116 i_data.xCloseable->removeCloseListener( i_data.pListener );
117 if ( i_data.pListener->hasOwnership() )
121 i_data.xCloseable->close(
true );
123 catch(
const CloseVetoException& ) { }
124 catch(
const Exception& )
134 bool const hasOwnership)
137 lcl_init(*
m_xData, i_closeable, hasOwnership);
CloseVeto(const css::uno::Reference< css::uno::XInterface > &i_closeable, bool bHasOwnership=false)
std::unique_ptr< CloseVeto_Data > m_xData
#define DBG_UNHANDLED_EXCEPTION(...)
#define ENSURE_OR_RETURN_VOID(c, m)
::cppu::WeakImplHelper< XCloseListener > CloseListener_Base
::rtl::Reference< CloseListener_Impl > pListener
Reference< XCloseable > xCloseable