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