1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23#ifndef __com_sun_star_util_XClosable_idl__ 24#define __com_sun_star_util_XClosable_idl__ 25 26#ifndef __com_sun_star_uno_XInterface_idl__ 27#include <com/sun/star/uno/XInterface.idl> 28#endif 29 30#ifndef __com_sun_star_util_XCloseBroadcaster_idl__ 31#include <com/sun/star/util/XCloseBroadcaster.idl> 32#endif 33 34//============================================================================= 35 36module com { module sun { module star { module util { 37 38//============================================================================= 39/** makes it possible to release any objects in a ordered manner by using 40 a two-step mechanism 41 42 <p> 43 If an object should be terminated, it can be:<br> 44 <ul> 45 <li>disposed (if it supports <member scope="com::sun::star::lang">XComponent::dispose()</member>)</li> 46 <li>closed (if it supports <member>XCloseable::close()</member>)</li> 47 </ul> 48 First version gives the object no chance to disagree with that (e.g. if a 49 process is still running and can't be really canceled). Last version 50 provides this possibility, but can't guarantee real termination of called object. 51 It depends from the environment of an object, if one or both mechanism are necessary. 52 </p> 53 54 <p> 55 Base interface <type>XCloseBroadcaster</type> makes it possible that any listener 56 which is interested on life time of listened object... 57 <ul> 58 <li>can get a notification about closing of it</li> 59 <li>or can have a veto to break that.</li> 60 </ul> 61 </p> 62 63 @see com::sun::star::lang::XComponent::dispose() 64 @see XCloseBroadcaster 65 @see XCloseListener 66 */ 67published interface XCloseable: XCloseBroadcaster 68{ 69 //------------------------------------------------------------------------- 70 /** try to close the object 71 72 <p> 73 Must definitely be called before <member scope="com::sun::star::lang">XComponent::dispose()</member>. 74 But nobody can guarantee real closing of called object - because it can disagree with that if any 75 still running processes can't be canceled yet. It's not allowed to block this call till internal 76 operations will be finished here. They must be canceled or call must return immediately by throwing 77 the <type>CloseVetoException</type>. Otherwise (if nothing exist to disagree) it must return normally. 78 </p> 79 80 <p> 81 Before any internal processes will be canceled, all registered <type>XCloseListener</type> 82 must be notified. Any of them can disagree with a <type>CloseVetoException</type> too. 83 It's forbidden to catch this exception inside the called close() method because the caller must 84 get this information! 85 </p> 86 87 <p> 88 If somewhere disagree with a CloseVetoException it will not clear who has to close the object again 89 after still running processes was finished. The parameter <var>DeliverOwnership</var> regulate that. 90 If it is set to <FALSE/> the caller of the method close() will be the owner of this object in every case. 91 Then it's not allowed to call close() from any other place (may a registered XCloseListener). 92 If it is set to <TRUE/> the caller gives up his ownership. If a XCloseListener throw the veto exception 93 he will be the new owner of the closing object. This information is passed to the listener by a parameter of 94 his notification method <member>XCloseListener::queryClosing()</member>. After his operations was finished 95 he MUST try to close it again. If the closing object itself disagrees by an exception and the parameter 96 <var>DeliverOwnership</var> was set to <TRUE/> the object will be his own owner with all consequences of that. 97 <br><strong>Note:</strong><br> 98 There is no way to get the ownership back if it was delivered! 99 </p> 100 101 <p> 102 If this method was already called on an object it should return without any reaction. Normally it's possible to throw 103 a <type scope="com::sun::star::lang">DisposedException</type> for already disposed or closed objects 104 (which represent a <type scope="com::sun::star::uno">RuntimeException</type> and can be thrown by every interface call), 105 but it shouldn't be used here. The veto exception should be the only way to indicates the result. 106 </p> 107 108 @param DeliverOwnership 109 <TRUE/> delegates the ownership of this closing object to any one which throw the CloseVetoException. 110 This new owner has to close the closing object again if his still running processes will be finished. 111 <br> 112 <FALSE/> let the ownership at the original one which called the close() method. He must react for possible 113 CloseVetoExceptions and try it again at a later time. This can be useful for a generic UI handling. 114 115 @throws CloseVetoException 116 indicates that the closing object himself or any of his currently registered listener disagree with this close() request. 117 118 @see XCloseListener 119 @see CloseVetoException 120 @see com::sun::star::lang::XComponent::dispose() 121 @see com::sun::star::lang::DisposedException 122 */ 123 void close( [in] boolean DeliverOwnership ) 124 raises( CloseVetoException ); 125}; 126 127//============================================================================= 128 129}; }; }; }; 130 131#endif 132