Language:

The Free and Open Productivity Suite
Apache OpenOffice 4.1.4 released

Developer's Guide

API

SDK

Tips 'n' Tricks

Miscellaneous


:: com :: sun :: star :: util ::

interface XCloseable
Base Interfaces
XCloseableXCloseBroadcaster

XCloseBroadcaster
(referenced interface's summary:)
broadcasts each tried closing of an object to all interest listener
Description
makes it possible to release any objects in a ordered manner by using a two-step mechanism

If an object should be terminated, it can be:

First version gives the object no chance to disagree with that (e.g. if a process is still running and can't be cancelled realy). Last version provides this possibility, but can't guarantee real termination of called object. It depends from the environment of an object, if one or both mechanism are neccessary.

Base interface XCloseBroadcaster makes it possible that any listener which is interrested on life time of listened object ...

  • can get a notification about closing of it
  • or can have a veto to break that.

See also
::com::sun::star::lang::XComponent::dispose(), XCloseBroadcaster, XCloseListener
Developers Guide
OfficeDev - Closing Documents

Methods' Summary
close try to close the object  
Methods' Details
close
void
close( [in] boolean  DeliverOwnership )
raises( CloseVetoException );

Description
try to close the object

Must definitly be called before ::com::sun::star::lang::XComponent::dispose(). But nobody can guarentee real closing of called object - because it can disagree with that if any still running processes can't be cancelled yet. It's not allowed to block this call till internal operations will be finished here. They must be cancelled or call must return imediatly by throwing the CloseVetoException. Otherwise (if nothing exist to disagree) it must return normaly.

Before any internal processes will be cancelled, all registered XCloseListener must be notified. Any of them can disagree with a CloseVetoException too. It's forbidden to catch this exception inside the called close() method because the caller must get this information!

If somewhere disagree with a CloseVetoException it will not clear who has to close the object again after still running processes was finished. The parameter DeliverOwnership regulate that. If it is set to false the caller of the method close() will be the owner of this object in every case. Then it's not allowed to call close() from any other place (may a registered XCloseListener). If it is set to true the caller gives up his ownership. If a XCloseListener throw the veto exception he will be the new owner of the closing object. This information is passed to the listener by a parameter of his notification method XCloseListener::queryClosing(). After his operations was finished he MUST try to close it again. If the closing object itselfs disagree by an exception and the parameter DeliverOwnership was set to true the object will be his own owner with all consequences of that.
Note:
There is no way to get the ownership back if it was delivered!

If this method was already called on an object it should return without any reaction. Normaly it's possible to throw a ::com::sun::star::lang::DisposedException for already disposed or closed objects (which represent a ::com::sun::star::uno::RuntimeException and can be thrown by every interface call), but it shouldn't be used here. The veto exception should be the only way to indicates the result.

Parameter DeliverOwnership
true delegates the ownership of ths closing object to any one which throw the CloseVetoException. This new owner has to close the closing object again if his still running processes will be finished.
false let the ownership at the original one which called the close() method. He must react for possible CloseVetoExceptions and try it again at a later time. This can be usefull for a generic UI handling.
Throws
CloseVetoException indicates that the closing object himself or any of his currently registered listener disagree with this close() request.
See also
XCloseListener, CloseVetoException, ::com::sun::star::lang::XComponent::dispose(), ::com::sun::star::lang::DisposedException
Top of Page

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache and the Apache feather logo are trademarks of The Apache Software Foundation. OpenOffice, OpenOffice.org and the seagull logo are registered trademarks of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.