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 .
20 #ifndef INCLUDED_COMPHELPER_ACCESSIBLEEVENTNOTIFIER_HXX
21 #define INCLUDED_COMPHELPER_ACCESSIBLEEVENTNOTIFIER_HXX
23 #include <comphelper/comphelperdllapi.h>
25 namespace com::sun::star::uno
{ class XInterface
; }
26 namespace com::sun::star::uno
{ template <class interface_type
> class Reference
; }
27 namespace com::sun::star::accessibility
{ class XAccessibleEventListener
; }
28 namespace com::sun::star::accessibility
{ struct AccessibleEventObject
; }
30 namespace comphelper
{
32 class COMPHELPER_DLLPUBLIC AccessibleEventNotifier
35 typedef sal_uInt32 TClientId
;
38 AccessibleEventNotifier() = delete;
39 ~AccessibleEventNotifier() = delete;
40 AccessibleEventNotifier( const AccessibleEventNotifier
& ) = delete;
41 AccessibleEventNotifier
& operator=( const AccessibleEventNotifier
& ) = delete;
43 /** registers a client of this class, means a broadcaster of AccessibleEvents
45 <p>No precaution is taken to care for disposal of this component. When the component
46 dies, it <b>must</b> call <member>revokeClient</member> or <member>revokeClientNotifyDisposing</member>
47 explicitly itself.</p>
49 static TClientId
registerClient();
51 /** revokes a broadcaster of AccessibleEvents
53 <p>Note that no disposing event is fired when you use this method, the client is simply revoked.
54 You can for instance revoke a client if the last listener for it is revoked, but the client
55 itself is not disposed.<br/>
56 When the client is disposed, you should prefer <member>revokeClientNotifyDisposing</member></p>
58 <p>Any possibly pending events for this client are removed from the queue.</p>
60 @seealso revokeClientNotifyDisposing
62 static void revokeClient( const TClientId _nClient
);
64 /** revokes a client, with additionally notifying a disposing event to all listeners registered for
67 <p>Any other possibly pending events for this client are removed from the queue</p>
70 the id of the client which should be revoked
72 the source to be notified together with the <member scope="com.sun.star.lang">XComponent::disposing</member>
75 static void revokeClientNotifyDisposing(
76 const TClientId _nClient
,
77 const css::uno::Reference
< css::uno::XInterface
>& _rxEventSource
);
79 /** registers a listener for the given client
82 the id of the client for which a listener should be registered
84 the number of event listeners currently registered for this client
86 static sal_Int32
addEventListener(
87 const TClientId _nClient
,
88 const css::uno::Reference
< css::accessibility::XAccessibleEventListener
>& _rxListener
);
90 /** revokes a listener for the given client
93 the id of the client for which a listener should be revoked
95 the number of event listeners currently registered for this client
97 static sal_Int32
removeEventListener(
98 const TClientId _nClient
,
99 const css::uno::Reference
< css::accessibility::XAccessibleEventListener
>& _rxListener
);
101 /** adds an event, which is to be broadcasted, to the queue
104 the id of the client which needs to broadcast the event
106 static void addEvent(
107 const TClientId _nClient
,
108 const css::accessibility::AccessibleEventObject
& _rEvent
);
110 // to be called at application shutdown to clear the static map, so we don't get crashes on shutdown
111 static void shutdown();
115 } // namespace comphelper
117 #endif // INCLUDED_COMPHELPER_ACCESSIBLEEVENTNOTIFIER_HXX
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */