Alexander Peters wrote:
> Hello! 
> Did someone know about any changes for the "DocCloseListener_"? In the
> latest Snapshot 1.9.122 comes the Listener to late. 
> 
> My situation: i use the "DocCloseListener_"-Listener for a question when
> the user close the document. If the user click yes the event saves the
> document. This runs in older releases of the BETA really good. But know
> the document is already disposed when the Listener is trigged and an
> exception is comming, when i try to save. 
> 
> Is there an other Close Listener-Event?
> 
> Here my Listerer Code:
> Sub StartCloseListening()
>       oEventListener  = CreateUnoListener( "DocCloseListener_",
> "com.sun.star.lang.XEventListener" )
>       ThisComponent.addEventListener( oEventListener  )
> End Sub
> 
> Sub StopCloseListening()
>       If Not IsNull( oEventListener ) Then
>               ThisComponent.removeEventListener( oEventListener )
>       EndIf
> End Sub
> 
> Sub DocCloseListener_disposing( oEvent )
>       AutoClose() <-- in older versions, the document wasnt disposed
> on this position.
> End Sub

The document *never* is or was disposed when this call happened, but it
is not usable anymore (that's an important difference!). It was also
never intended nor guaranteed that in the "disposing" call you can do
anything useful with the document. I have no idea why it seemed to work
in older versions, I even can't believe it.

But anyway, if you want to place a query dialog before a document is
*closed* you must register as a document event listener and watch for
the "OnPrepareUnload" Event.

Ciao,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project Lead
Please reply to the list only, [EMAIL PROTECTED] is a spam sink.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to