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_XCloseListener_idl__
24#define __com_sun_star_util_XCloseListener_idl__
25
26#ifndef __com_sun_star_util_CloseVetoException_idl__
27#include <com/sun/star/util/CloseVetoException.idl>
28#endif
29
30#ifndef __com_sun_star_lang_XEventListener_idl__
31#include <com/sun/star/lang/XEventListener.idl>
32#endif
33
34#ifndef __com_sun_star_lang_EventObject_idl__
35#include <com/sun/star/lang/EventObject.idl>
36#endif
37
38//=============================================================================
39
40 module com {  module sun {  module star {  module util {
41
42//=============================================================================
43/** makes it possible to receive events when an object
44    is called for closing
45
46    <p>
47    Such close events are broadcasted by a <type>XCloseBroadcaster</type>
48    if somewhere tries to close it by calling <member>XCloseable::close()</member>.
49    Listener can:
50    <ul>
51        <li>break that by throwing <type>CloseVetoException</type></li>
52        <li>or accept that by deregister himself at this broadcaster.</li>
53    </ul>
54    </p>
55
56    <p>
57    If an event <method scope="com::sun::star::lang">XEventListener::disposing</method>
58    occured, nobody called <method>XCloseable::close</method> on listened object before.
59    Then it's not allowed to break this request - it must be accepted!
60    </p>
61
62    @see XCloseable
63    @see XCloseBroadcaster
64 */
65published interface XCloseListener: com::sun::star::lang::XEventListener
66{
67	//-------------------------------------------------------------------------
68    /** is called when somewhere tries to close listened object
69
70        <p>
71        Is called before <member>XCloseListener::notifyClosing()</member>.
72        Listener has the chance to break that by throwing a <type>CloseVetoException</type>.
73        This exception must be passed to the original caller of <member>XCloseable::close()</member>
74        without any interaction.
75        </p>
76
77        <p>
78        The parameter <var>GetsOwnership</var> regulate who has to try to close the listened object
79        again, if this listener disagree with the request by throwing the exception.
80        If it's set to <FALSE/> the original caller of <member>XCloseable::close()</member>
81        will be the owner in every case. It's not allowed to call close() from this listener then.
82        If it's set to <TRUE/> this listener will be the new owner if he throw the exception,
83        otherwise not! If his still running processes will be finished he must call close() on
84        listened object again then.
85        </p>
86
87        <p>
88        If this listener doesn't disagree with th close request it depends from his internal
89        implementation if he deregister himself at the listened object.
90        But normaly this must be done in <member>XCloseListener::notifyClosing()</member>.
91        </p>
92
93        @param Source
94            describes the source of the event (must be the listened object)
95
96        @param GetsOwnership
97            <TRUE/> pass the ownership to this listener, if he throw the veto exception
98            (otherwise this parameter must be ignored!)
99            <br>
100            <FALSE/> forbids to grab the ownership for the listened close object and call
101            close() on that any time.
102
103        @throws CloseVetoException
104            if listener disagree with the close request on listened object he must throw this exception
105	 */
106    void queryClosing(
107        [in] com::sun::star::lang::EventObject Source,
108        [in] boolean GetsOwnership )
109            raises( CloseVetoException );
110
111	//-------------------------------------------------------------------------
112    /** is called when the listened object is closed realy
113
114        <p>
115        Now the listened object is closed realy. Listener has to accept that;
116        should deregister himself and relaese all references to it.
117        It's not allowed nor possible to disagree with that by throwing any exception.
118        </p>
119
120        <p>
121        If the event <member scope="com::sun::star::lang">XEventListener::disposing()</member> occured before
122        it must be accepted too. There exist no chance for a disagreement any more.
123        </p>
124
125        @param Source
126            describes the source of the event (must be the listened object)
127	 */
128    void notifyClosing( [in] com::sun::star::lang::EventObject Source );
129};
130
131//=============================================================================
132
133}; }; }; };
134
135#endif
136