Page 1 of 1

Cancel event propagation in an XEventListener

PostPosted: Wed Oct 26, 2011 11:12 am
by bcris
Is there any possibility to cancel the event propagation in an XEventListener ?

I have a class, DocumentEventListener, implementing the XEventListener interface which is added as a listener with the following code:

Code: Select all   Expand viewCollapse view
Object globalEventBroadcaster = m_xContext.getServiceManager().createInstanceWithContext("com.sun.star.frame.GlobalEventBroadcaster", m_xContext);
         
XEventBroadcaster xEVBC = (XEventBroadcaster) UnoRuntime.queryInterface(XEventBroadcaster.class, globalEventBroadcaster);

xEVBC.addEventListener(new DocumentEventListener(m_xContext));


In this class I intercept the OnPrepareViewClosing event and call a project specific closing functionality, where at some point a project specific question message appears asking if the document should be saved (it has the buttons: yes, no, cancel).

If the user chooses to save the document, the project specific saving functionality is processed, that includes setting the modified flag to false and than the DocumentEventListener functionality is finished, the event is further propagated and Open Office closes the document.

If however, the user chooses to cancel the closing than the project specific handling is finished, the modified flag is not set to false, the event is further propagated and the Open Office specific question message about saving the document appears. Is there any possibility to cancel the event propagation from within the DocumentEventListener class ?

Thanks in advance !