1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef __com_sun_star_lang_XComponent_idl__
20 #define __com_sun_star_lang_XComponent_idl__
22 #include
<com
/sun
/star
/uno
/XInterface.idl
>
25 module com
{ module sun
{ module star
{ module lang
{
27 published
interface XEventListener
;
29 /** allows to exclicitly free resources and break cyclic references.
31 <p>Actually the real lifetime of an UNO object is controlled by
32 references kept on interfaces of this object. But there are two
33 distinct meanings in keeping a reference to an interface:
34 1st to own the object and 2nd to know the object.
36 <p>You are only allowed to keep references of interfaces
37 to UNO objects if you are by definition the owner of that object or
38 your reference is very temporary or you have registered an
39 EventListener at that object and release the reference when
40 "disposing" is called.</p>
42 published
interface XComponent
: com
::sun
::star
::uno
::XInterface
44 /** The owner of an object calls this method to explicitly free all
45 resources kept by this object and thus break cyclic references.
47 <p>Only the owner of this object is allowed to call this method.
48 The object should release all resources and references in the
49 easiest possible manner ( for instance no serialization should
53 The object must notify all registered listeners using the method
54 XEventListener::disposing(). All notfied objects
55 should release there references to this object without
56 calling XComponent::removeEventListener()
57 (the disposed object will release the listeners eitherway).
60 <p>After this method has been called, the object should behave as passive
61 as possible, thus it should ignore all calls
62 in case it can comply with its specification (for instance addEventListener()).
63 Often the object can't fulfill its specification anymore,
64 in this case it must throw the DisposedException
65 (which is derived from com::sun::star::uno::RuntimeException)
66 when it gets called.</p>
68 <p>For some objects no real owner can be identified, thus it can be
69 disposed from multiple reference holders. In this case
70 the object should be able to cope with multiple dispose()-calls (which
71 are inevitable in a multithreaded environment).
75 /** adds an event listener to the object.
77 <p>The broadcaster fires the disposing method of this listener
78 if the XComponent::dispose() method is called.</p>
80 <p>It is suggested to allow multiple registration of the same listener,
81 thus for each time a listener is added, it has to be removed.</p>
83 <p>If this XComponent is already disposed when
84 XComponent::addEventListener() is called, the call will not fail
85 with a DisposedException, but the caller will be notified via the
86 XEventListener::disposing()
87 callback. This callback can occur synchronously within the
88 addEventListener() call.</p>
90 @see XComponent::removeEventListener
92 void addEventListener
( [in] XEventListener xListener
);
94 /** removes an event listener from the listener list.
96 <p>It is a "noop" if the specified listener is not registered.</p>
98 <p>It is suggested to allow multiple registration of the same listener,
99 thus for each time a listener is added, it has to be removed.
101 <p>If this XComponent is already disposed when
102 XComponent::removeEventListener() is called, the call will not
103 fail with a DisposedException,
104 but will rather be ignored silently.</p>
106 @see XComponent::addEventListener
108 void removeEventListener
( [in] XEventListener aListener
);
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */