23#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
34 using ::com::sun::star::document::XDocumentEventBroadcaster;
35 using ::com::sun::star::document::XDocumentEventListener;
36 using ::com::sun::star::document::DocumentEvent;
37 using ::com::sun::star::uno::XComponentContext;
38 using ::com::sun::star::uno::Reference;
39 using ::com::sun::star::uno::UNO_QUERY_THROW;
40 using ::com::sun::star::uno::Exception;
41 using ::com::sun::star::frame::XModel;
42 using ::com::sun::star::frame::theGlobalEventBroadcaster;
43 using ::com::sun::star::uno::UNO_QUERY;
70 virtual ~Impl ()
override;
76 virtual void SAL_CALL
disposing(
const css::lang::EventObject& Event )
override;
79 virtual void disposing(std::unique_lock<std::mutex>&)
override;
97 m_pListener(&rListener),
109 if ( !impl_isDisposed_nothrow(aGuard) )
118 std::unique_lock aGuard(
m_aMutex );
120 OSL_PRECOND( !impl_isDisposed_nothrow(aGuard),
"DocumentEventNotifier::Impl::notifyEvent: disposed, but still getting events?" );
121 if ( impl_isDisposed_nothrow(aGuard) )
125 OSL_ENSURE( xDocument.is(),
"DocumentEventNotifier::Impl::notifyEvent: illegal source document!" );
126 if ( !xDocument.is() )
131 const char* pEventName;
134 static EventEntry
const aEvents[] = {
146 for (EventEntry
const &
aEvent : aEvents)
148 if ( !_rEvent.EventName.equalsAscii(
aEvent.pEventName ) )
157 std::unique_lock aGuard2(
m_aMutex );
159 if ( impl_isDisposed_nothrow(aGuard2) )
172 std::unique_lock aGuard(
m_aMutex );
174 if ( !impl_isDisposed_nothrow(aGuard) )
175 impl_dispose_nothrow(aGuard);
180 impl_listenerAction_nothrow( rGuard, RemoveListener );
181 impl_dispose_nothrow(rGuard);
186 m_pListener =
nullptr;
196 xBroadcaster.set(
m_xModel, UNO_QUERY_THROW );
201 xBroadcaster = theGlobalEventBroadcaster::get(aContext);
205 ( _eAction == RegisterListener ) ? &XDocumentEventBroadcaster::addDocumentEventListener : &XDocumentEventBroadcaster::removeDocumentEventListener;
208 (xBroadcaster.get()->*listenerAction)(
this );
virtual void onDocumentSaveAs(const ScriptDocument &_rDocument)=0
virtual void onDocumentSave(const ScriptDocument &_rDocument)=0
virtual void onDocumentTitleChanged(const ScriptDocument &_rDocument)=0
virtual void onDocumentSaveDone(const ScriptDocument &_rDocument)=0
virtual void onDocumentModeChanged(const ScriptDocument &_rDocument)=0
virtual void onDocumentCreated(const ScriptDocument &_rDocument)=0
virtual void onDocumentClosed(const ScriptDocument &_rDocument)=0
virtual void onDocumentSaveAsDone(const ScriptDocument &_rDocument)=0
virtual void onDocumentOpened(const ScriptDocument &_rDocument)=0
virtual ~DocumentEventListener()
impl class for DocumentEventNotifier
DocumentEventListener * m_pListener
void impl_dispose_nothrow(std::unique_lock< std::mutex > &rGuard)
disposes the instance
void impl_listenerAction_nothrow(std::unique_lock< std::mutex > &rGuard, ListenerAction _eAction)
registers or revokes the instance as listener at the global event broadcaster
Impl & operator=(const Impl &)=delete
virtual void SAL_CALL disposing(const css::lang::EventObject &Event) override
Reference< XModel > m_xModel
virtual void SAL_CALL documentEventOccured(const DocumentEvent &Event) override
bool impl_isDisposed_nothrow(std::unique_lock< std::mutex > &) const
determines whether the instance is already disposed
Impl(const Impl &)=delete
rtl::Reference< Impl > m_pImpl
DocumentEventNotifier(DocumentEventListener &)
create a notifier instance which notifies about events of all documents in the whole application
encapsulates a document which contains Basic scripts and dialogs
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< frame::XModel > m_xModel
::comphelper::WeakComponentImplHelper< XDocumentEventListener > DocumentEventNotifier_Impl_Base
Reference< XComponentContext > getProcessComponentContext()