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_lang_XComponent_idl__
28 #define __com_sun_star_lang_XComponent_idl__
30 #ifndef __com_sun_star_uno_XInterface_idl__
31 #include
<com
/sun
/star
/uno
/XInterface.idl
>
34 //=============================================================================
36 module com
{ module sun
{ module star
{ module lang
{
38 published
interface XEventListener
;
40 //=============================================================================
42 // DocMerge from xml: interface com::sun::star::lang::XComponent
43 /** allows to exclicitly free resources and break cyclic references.
45 <p>Actually the real lifetime of an UNO object is controlled by
46 references kept on interfaces of this object. But there are two
47 distinct meanings in keeping a reference to an interface:
48 1st to own the object and 2nd to know the object.
50 <p>You are only allowed to keep references of interfaces
51 to UNO objects if you are by definition the owner of that object or
52 your reference is very temporary or you have registered an
53 EventListener at that object and release the reference when
54 "disposing" is called.</p>
56 published
interface XComponent
: com
::sun
::star
::uno
::XInterface
58 //-------------------------------------------------------------------------
60 // DocMerge from xml: method com::sun::star::lang::XComponent::dispose
61 /** The owner of an object calls this method to explicitly free all
62 resources kept by this object and thus break cyclic references.
64 <p>Only the owner of this object is allowed to call this method.
65 The object should release all resources and references in the
66 easiest possible manner ( for instance no serialization should
70 The object must notify all registered listeners using the method
71 <member>XEventListener::disposing</member>. All notfied objects
72 should release there references to this object without
73 calling <member>XComponent::removeEventListener</member>
74 (the disposed object will release the listeners eitherway).
77 <p>After this method has been called, the object should behave as passive
78 as possible, thus it should ignore all calls
79 in case it can comply with its specification (for instance addEventListener()).
80 Often the object can't fulfill its specification anymore,
81 in this case it must throw the <type>DisposedException</type>
82 (which is derived from <type scope="com::sun::star::uno">RuntimeException</type>)
83 when it gets called.</p>
85 <p>For some objects no real owner can be identified, thus it can be
86 disposed from multiple reference holders. In this case
87 the object should be able to cope with multiple dispose()-calls (which
88 are inevitable in a multithreaded environment).
92 //-------------------------------------------------------------------------
94 // DocMerge from xml: method com::sun::star::lang::XComponent::addEventListener
95 /** adds an event listener to the object.
97 <p>The broadcaster fires the disposing method of this listener
98 if the <member>XComponent::dispose</member> method is called.</p>
100 <p>It is suggested to allow multiple registration of the same listener,
101 thus for each time a listener is added, it has to be removed.</p>
103 <p>If this <type scope="com::sun::star::lang">XComponent</type> is
104 already disposed when <member scope="com::sun::star::lang">
105 XComponent::addEventListener</member> is called, the call will not fail
106 with a <type scope="com::sun::star::lang">DisposedException</type>, but
107 the caller will be notified via the
108 <member scope="com::sun::star::lang">XEventListener::disposing</member>
109 callback. This callback can occur synchronously within the
110 <member scope="com::sun::star::lang">XComponent::addEventListener
113 @see XComponent::removeEventListener
115 void addEventListener
( [in] XEventListener xListener
);
117 //-------------------------------------------------------------------------
119 // DocMerge from xml: method com::sun::star::lang::XComponent::removeEventListener
120 /** removes an event listener from the listener list.
122 <p>It is a "noop" if the specified listener is not registered.</p>
124 <p>It is suggested to allow multiple registration of the same listener,
125 thus for each time a listener is added, it has to be removed.
127 <p>If this <type scope="com::sun::star::lang">XComponent</type> is
128 already disposed when <member scope="com::sun::star::lang">
129 XComponent::removeEventListener</member> is called, the call will not
130 fail with a <type scope="com::sun::star::lang">DisposedException</type>,
131 but will rather be ignored silently.</p>
133 @see XComponent::addEventListener
135 void removeEventListener
( [in] XEventListener aListener
);
139 //=============================================================================