ooodev.adapter.form.submission.submission_veto_listener module

class ooodev.adapter.form.submission.submission_veto_listener.SubmissionVetoListener(trigger_args=None, subscriber=None)[source]

Bases: AdapterBase, XSubmissionVetoListener

Is implement by components which want to observe (and probably veto) the submission of data.

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 (XSubmission, optional) – An UNO object that implements the com.sun.star.form.XSubmission interface. If passed in then this listener instance is automatically added to it.

Return type:

None

disposing(event)[source]

Gets called 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.

Parameters:

event (EventObject) – Event data for the event.

Return type:

None

submitting(event)[source]

Is invoked when a component, at which the listener has been registered, is about to submit its data.

If event is canceled and the cancel args are not handled then a VetoException will be raised.

Parameters:

event (EventObject) – Event data for the event.

Raises:

com.sun.star.util.VetoExceptionVetoException

Return type:

None

Note

When submitting event is invoked it will contain a CancelEventArgs instance as the trigger event. When the event is triggered the CancelEventArgs.cancel can be set to True to cancel the submission. Also if canceled the CancelEventArgs.handled can be set to True to indicate that the submission should be performed. The CancelEventArgs.event_data will contain the original com.sun.star.lang.EventObject that triggered the update.

Also the CancelEventArgs can set a message value that will be used as the message for the VetoException.

If the event.set("skip_veto_exception", True) is set then the VetoException will not be raised. This is probably not a good idea but it is there if you need it.

The following example shows how to use the CancelEventArgs to cancel the submission of data.

def on_submitting(src: Any, event: CancelEventArgs) -> None:
    if not validate_data():
        event.cancel = True
        event.set("message", "Canceling due to data validation fail.")