merged tag ooo/OOO330_m14
[LibreOffice.git] / offapi / com / sun / star / util / XCloseable.idl
blob56fb5429d18f545ae4dd01aa1a3a3187c33652eb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef __com_sun_star_util_XClosable_idl__
28 #define __com_sun_star_util_XClosable_idl__
30 #ifndef __com_sun_star_uno_XInterface_idl__
31 #include <com/sun/star/uno/XInterface.idl>
32 #endif
34 #ifndef __com_sun_star_util_XCloseBroadcaster_idl__
35 #include <com/sun/star/util/XCloseBroadcaster.idl>
36 #endif
38 //=============================================================================
40 module com { module sun { module star { module util {
42 //=============================================================================
43 /** makes it possible to release any objects in a ordered manner by using
44 a two-step mechanism
46 <p>
47 If an object should be terminated, it can be:<br>
48 <ul>
49 <li>disposed (if it supports <member scope="com::sun::star::lang">XComponent::dispose()</member>)</li>
50 <li>closed (if it supports <member>XCloseable::close()</member>)</li>
51 </ul>
52 First version gives the object no chance to disagree with that (e.g. if a
53 process is still running and can't be cancelled realy). Last version
54 provides this possibility, but can't guarantee real termination of called object.
55 It depends from the environment of an object, if one or both mechanism are neccessary.
56 </p>
58 <p>
59 Base interface <type>XCloseBroadcaster</type> makes it possible that any listener
60 which is interrested on life time of listened object ...
61 <ul>
62 <li>can get a notification about closing of it</li>
63 <li>or can have a veto to break that.</li>
64 </ul>
65 </p>
67 @see com::sun::star::lang::XComponent::dispose()
68 @see XCloseBroadcaster
69 @see XCloseListener
71 published interface XCloseable: XCloseBroadcaster
73 //-------------------------------------------------------------------------
74 /** try to close the object
76 <p>
77 Must definitly be called before <member scope="com::sun::star::lang">XComponent::dispose()</member>.
78 But nobody can guarentee real closing of called object - because it can disagree with that if any
79 still running processes can't be cancelled yet. It's not allowed to block this call till internal
80 operations will be finished here. They must be cancelled or call must return imediatly by throwing
81 the <type>CloseVetoException</type>. Otherwise (if nothing exist to disagree) it must return normaly.
82 </p>
84 <p>
85 Before any internal processes will be cancelled, all registered <type>XCloseListener</type>
86 must be notified. Any of them can disagree with a <type>CloseVetoException</type> too.
87 It's forbidden to catch this exception inside the called close() method because the caller must
88 get this information!
89 </p>
91 <p>
92 If somewhere disagree with a CloseVetoException it will not clear who has to close the object again
93 after still running processes was finished. The parameter <var>DeliverOwnership</var> regulate that.
94 If it is set to <FALSE/> the caller of the method close() will be the owner of this object in every case.
95 Then it's not allowed to call close() from any other place (may a registered XCloseListener).
96 If it is set to <TRUE/> the caller gives up his ownership. If a XCloseListener throw the veto exception
97 he will be the new owner of the closing object. This information is passed to the listener by a parameter of
98 his notification method <member>XCloseListener::queryClosing()</member>. After his operations was finished
99 he MUST try to close it again. If the closing object itselfs disagree by an exception and the parameter
100 <var>DeliverOwnership</var> was set to <TRUE/> the object will be his own owner with all consequences of that.
101 <br><strong>Note:</strong><br>
102 There is no way to get the ownership back if it was delivered!
103 </p>
106 If this method was already called on an object it should return without any reaction. Normaly it's possible to throw
107 a <type scope="com::sun::star::lang">DisposedException</type> for already disposed or closed objects
108 (which represent a <type scope="com::sun::star::uno">RuntimeException</type> and can be thrown by every interface call),
109 but it shouldn't be used here. The veto exception should be the only way to indicates the result.
110 </p>
112 @param DeliverOwnership
113 <TRUE/> delegates the ownership of ths closing object to any one which throw the CloseVetoException.
114 This new owner has to close the closing object again if his still running processes will be finished.
115 <br>
116 <FALSE/> let the ownership at the original one which called the close() method. He must react for possible
117 CloseVetoExceptions and try it again at a later time. This can be usefull for a generic UI handling.
119 @throws CloseVetoException
120 indicates that the closing object himself or any of his currently registered listener disagree with this close() request.
122 @see XCloseListener
123 @see CloseVetoException
124 @see com::sun::star::lang::XComponent::dispose()
125 @see com::sun::star::lang::DisposedException
127 void close( [in] boolean DeliverOwnership )
128 raises( CloseVetoException );
131 //=============================================================================
133 }; }; }; };
135 #endif