ooodev.adapter.util.close_listener module
- class ooodev.adapter.util.close_listener.CloseListener(trigger_args=None, subscriber=None)[source]
Bases:
AdapterBase
,XCloseListener
Makes it possible to receive events when an object is called for closing
Such close events are broadcasted by a XCloseBroadcaster if somewhere tries to close it by calling XCloseable.close(). Listener can:
If an event com.sun.star.lang.XEventListener.disposing() occurred, nobody called XCloseable.close() on listened object before. Then it’s not allowed to break this request - it must be accepted!
See also
- Parameters:
args (Any) –
kwargs (Any) –
- Return type:
Any
- __init__(trigger_args=None, subscriber=None)[source]
Constructor
- Parameters:
trigger_args (GenericArgs, Optional) – Args that are passed to events when they are triggered.
subscriber (XCloseBroadcaster, optional) – An UNO object that implements the
XCloseBroadcaster
interface. If passed in then this listener instance is automatically added to it.
- Return type:
None
- disposing(Source)[source]
Gets invoked when the broadcaster is about to be disposed.
All listeners and all other objects, which reference the broadcaster should release the reference to the source. No method should be invoked anymore on this object ( including
XComponent.removeEventListener()
).This method is called for every listener registration of derived listener interfaced, not only for registrations at
XComponent
.- Return type:
None
- Parameters:
Source (com.sun.star.lang.EventObject) –
- notifyClosing(Source)[source]
Is invoked when the listened object is closed really.
Now the listened object is closed really. Listener has to accept that; should deregister itself and release all references to it. It’s not allowed nor possible to disagree with that by throwing any exception.
If the event
com.sun.star.lang.XEventListener.disposing()
occurred before it must be accepted too. There exist no chance for a disagreement any more.- Return type:
None
- Parameters:
Source (com.sun.star.lang.EventObject) –
- queryClosing(Source, GetsOwnership)[source]
Is invoked when somewhere tries to close listened object
Is called before
XCloseListener.notifyClosing()
. Listener has the chance to break that by throwing a CloseVetoException. This exception must be passed to the original caller ofXCloseable.close()
without any interaction.The parameter
gets_ownership
regulate who has to try to close the listened object again, if this listener disagree with the request by throwing the exception. If it’s set toFalse
the original caller ofXCloseable.close()
will be the owner in every case. It’s not allowed to callclose()
from this listener then. If it’s set toTrue
this listener will be the new owner if he throw the exception, otherwise not! If his still running processes will be finished he must callclose()
on listened object again then.If this listener doesn’t disagree with th close request it depends from his internal implementation if he deregister itself at the listened object. But normally this must be done in
XCloseListener.notifyClosing()
.- Parameters:
event (EventObject) – Describes the source of the event (must be the listened object)
gets_ownership (bool) –
True
pass the ownership to this listener, if he throw the veto exception (otherwise this parameter must be ignored!)False
forbids to grab the ownership for the listened close object and call close() on that any time.Source (com.sun.star.lang.EventObject) –
GetsOwnership (bool) –
- Raises:
CloseVetoException –
CloseVetoException
- Return type:
None
Note
This implementation raises a
queryClosing
event in the event system. The event data is aKeyValArgs
instance with the following properties:key=gets_ownership
,value=gets_ownership
andevent_data=event
.- Return type:
None
- Parameters:
Source (com.sun.star.lang.EventObject) –
GetsOwnership (bool) –