FAouzi Abderrahman wrote:

>       // I search the equivalent to this line : (remark this line is not
> operational) 
>       fDocument.OnClose := CloseDocument // CloseDocument is a procedure
> will be called when I close the document

OK, so you want to get a notification when the document is closed?

In general there are three kinds of notifications that can handle this:

(1) Listening for document events

You can get a notification *before* the dialog asking for saving the
document (if necessary) will appear and another notification immediately
before the closing will happen. In both cases the document is still
complete and you can do anything with it you like to do. But you can't
intercept the closing procedure, it's only a passive notification.
So this way of notification is useful if you don't want to intercept but
still want to do something with the document when it is going to be closed.

(2) Listening for disposal of the document

When the document is closed successfully and before it can be removed
from memory it sends a notification to all interested listeners that it
is going to die and that all listeners must release their references to
it. At that time you can't use any API of the document anymore, you will
always produce a runtime exception when doing so.
So this notification is useful when you just want to know that a
document will vanish but don't need to intercept the closing procedure
and don't need to do anything with the closing document.

(3) Listening for close events

OOo documents can be closed by calling their close() method. Here
listeners can prevent the closing by throwing a suitable exception. This
notification gives you the full control over the document, but are are
not allowed to use any GUI elements in your listener.
Unfortunately you can't do that because you are using the Automation
Bridge that does not support exceptions. We are planning to offer a
workaround for this in OOo2.0. Then you can install a "locking" service
that prevents locking of a document as long as you tell it to do so.

I hope that this gives you some hints about the direction you can go.

Best regards,

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