https://bugs.documentfoundation.org/show_bug.cgi?id=117280

--- Comment #18 from Mike Kaganski <mikekagan...@hotmail.com> ---
FTR: The solution implemented in the abovementioned commits is to pass
com.sun.star.view.PrintableState [1] value in the
com.sun.star.document.DocumentEvent struct's Supplement, passed as event
handler's argument. So the event handler could look like this:


> Sub OnPrintHandler(e)
>   If (e.Supplement = com.sun.star.view.PrintableState.JOB_STARTED) Then
>     MsgBox("JOB_STARTED")
>   ElseIf (e.Supplement = com.sun.star.view.PrintableState.JOB_COMPLETED) Then
>     MsgBox("JOB_COMPLETED")
>   ElseIf (e.Supplement = com.sun.star.view.PrintableState.JOB_SPOOLED) Then
>     MsgBox("JOB_SPOOLED")
>   ElseIf (e.Supplement = com.sun.star.view.PrintableState.JOB_ABORTED) Then
>     MsgBox("JOB_ABORTED")
>   ElseIf (e.Supplement = com.sun.star.view.PrintableState.JOB_FAILED) Then
>     MsgBox("JOB_FAILED")
>   ElseIf (e.Supplement = 
> com.sun.star.view.PrintableState.JOB_SPOOLING_FAILED) Then
>     MsgBox("JOB_SPOOLING_FAILED")
>   Else
>     MsgBox(e.Supplement)
  EndIf
End Sub

Julien has removed one likely unnecessary notification, so the event is
generated twice instead of three times, as was noticed in comment 3. The two
other invocations are legitimate, and typically reflect JOB_STARTED then
JOB_SPOOLED, or JOB_STARTED then JOB_ABORTED. The handler should handle the
kind of event that it needs, based on the PrintableState, as shown above.

Interesting, if this is an API change. Also, it likely needs documentation.
Also, it might be possible in the future to re-consider what is put into
Supplement field, so user code should be prepared that Supplement may be empty
(as prior to the change), or numeric (as now), or maybe something else (a
struct?).

[1]
https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1view.html#ad9b0afaffefc166344fd9575516b6626

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to