Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : :
21 : : #ifndef _SC_ACCESSIBLECONTEXTBASE_HXX
22 : : #define _SC_ACCESSIBLECONTEXTBASE_HXX
23 : :
24 : : #include <com/sun/star/accessibility/XAccessible.hpp>
25 : : #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
26 : : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
27 : : #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
28 : : #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
29 : : #include <com/sun/star/lang/DisposedException.hpp>
30 : : #include <com/sun/star/uno/Reference.hxx>
31 : : #include <cppuhelper/weak.hxx>
32 : : #include <com/sun/star/lang/XServiceInfo.hpp>
33 : : #include <com/sun/star/lang/XTypeProvider.hpp>
34 : : #include <com/sun/star/lang/XServiceName.hpp>
35 : : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
36 : : #include <osl/mutex.hxx>
37 : : #include <cppuhelper/interfacecontainer.h>
38 : :
39 : :
40 : : #include <svl/lstner.hxx>
41 : : #include <cppuhelper/compbase5.hxx>
42 : : #include <cppuhelper/implbase1.hxx>
43 : : #include <comphelper/servicehelper.hxx>
44 : : #include <comphelper/broadcasthelper.hxx>
45 : :
46 : : class Rectangle;
47 : :
48 : : /** @descr
49 : : This base class provides an implementation of the
50 : : <code>AccessibleContext</code> service.
51 : : */
52 : :
53 : : typedef cppu::WeakAggComponentImplHelper5<
54 : : ::com::sun::star::accessibility::XAccessible,
55 : : ::com::sun::star::accessibility::XAccessibleComponent,
56 : : ::com::sun::star::accessibility::XAccessibleContext,
57 : : ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
58 : : ::com::sun::star::lang::XServiceInfo
59 : : > ScAccessibleContextBaseWeakImpl;
60 : :
61 : : typedef cppu::ImplHelper1<
62 : : ::com::sun::star::accessibility::XAccessibleEventListener
63 : : > ScAccessibleContextBaseImplEvent;
64 : :
65 : : class ScAccessibleContextBase
66 : : : public comphelper::OBaseMutex,
67 : : public ScAccessibleContextBaseWeakImpl,
68 : : public ScAccessibleContextBaseImplEvent,
69 : : public SfxListener
70 : : {
71 : : public:
72 : : //===== internal ========================================================
73 : : ScAccessibleContextBase(
74 : : const ::com::sun::star::uno::Reference<
75 : : ::com::sun::star::accessibility::XAccessible>& rxParent,
76 : : const sal_Int16 aRole);
77 : :
78 : : virtual void Init();
79 : : virtual void SAL_CALL disposing();
80 : : protected:
81 : : virtual ~ScAccessibleContextBase(void);
82 : : public:
83 : : using WeakAggComponentImplHelperBase::addEventListener;
84 : : using WeakAggComponentImplHelperBase::removeEventListener;
85 : :
86 : : ///===== SfxListener =====================================================
87 : :
88 : : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
89 : :
90 : : ///===== XInterface =====================================================
91 : :
92 : : virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
93 : : ::com::sun::star::uno::Type const & rType )
94 : : throw (::com::sun::star::uno::RuntimeException);
95 : :
96 : : virtual void SAL_CALL acquire() throw ();
97 : :
98 : : virtual void SAL_CALL release() throw ();
99 : :
100 : : ///===== XAccessible =====================================================
101 : :
102 : : /// Return the XAccessibleContext.
103 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
104 : : getAccessibleContext(void) throw (::com::sun::star::uno::RuntimeException);
105 : :
106 : : ///===== XAccessibleComponent ============================================
107 : :
108 : : virtual sal_Bool SAL_CALL containsPoint(
109 : : const ::com::sun::star::awt::Point& rPoint )
110 : : throw (::com::sun::star::uno::RuntimeException);
111 : :
112 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
113 : : SAL_CALL getAccessibleAtPoint(
114 : : const ::com::sun::star::awt::Point& rPoint )
115 : : throw (::com::sun::star::uno::RuntimeException);
116 : :
117 : : virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( )
118 : : throw (::com::sun::star::uno::RuntimeException);
119 : :
120 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocation( )
121 : : throw (::com::sun::star::uno::RuntimeException);
122 : :
123 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( )
124 : : throw (::com::sun::star::uno::RuntimeException);
125 : :
126 : : virtual ::com::sun::star::awt::Size SAL_CALL getSize( )
127 : : throw (::com::sun::star::uno::RuntimeException);
128 : :
129 : : virtual sal_Bool SAL_CALL isShowing( )
130 : : throw (::com::sun::star::uno::RuntimeException);
131 : :
132 : : virtual sal_Bool SAL_CALL isVisible( )
133 : : throw (::com::sun::star::uno::RuntimeException);
134 : :
135 : : virtual void SAL_CALL grabFocus( )
136 : : throw (::com::sun::star::uno::RuntimeException);
137 : :
138 : : virtual sal_Int32 SAL_CALL getForeground( )
139 : : throw (::com::sun::star::uno::RuntimeException);
140 : :
141 : : virtual sal_Int32 SAL_CALL getBackground( )
142 : : throw (::com::sun::star::uno::RuntimeException);
143 : :
144 : : ///===== XAccessibleContext ==============================================
145 : :
146 : : /// Return the number of currently visible children.
147 : : virtual sal_Int32 SAL_CALL
148 : : getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException);
149 : :
150 : : /// Return the specified child or NULL if index is invalid.
151 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
152 : : getAccessibleChild(sal_Int32 nIndex)
153 : : throw (::com::sun::star::uno::RuntimeException,
154 : : ::com::sun::star::lang::IndexOutOfBoundsException);
155 : :
156 : : /// Return a reference to the parent.
157 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
158 : : getAccessibleParent(void)
159 : : throw (::com::sun::star::uno::RuntimeException);
160 : :
161 : : /// Return this objects index among the parents children.
162 : : virtual sal_Int32 SAL_CALL
163 : : getAccessibleIndexInParent(void)
164 : : throw (::com::sun::star::uno::RuntimeException);
165 : :
166 : : /// Return this object's role.
167 : : virtual sal_Int16 SAL_CALL
168 : : getAccessibleRole(void)
169 : : throw (::com::sun::star::uno::RuntimeException);
170 : :
171 : : /// Return this object's description.
172 : : virtual ::rtl::OUString SAL_CALL
173 : : getAccessibleDescription(void)
174 : : throw (::com::sun::star::uno::RuntimeException);
175 : :
176 : : /// Return the object's current name.
177 : : virtual ::rtl::OUString SAL_CALL
178 : : getAccessibleName(void)
179 : : throw (::com::sun::star::uno::RuntimeException);
180 : :
181 : : /// Return NULL to indicate that an empty relation set.
182 : : virtual ::com::sun::star::uno::Reference<
183 : : ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
184 : : getAccessibleRelationSet(void)
185 : : throw (::com::sun::star::uno::RuntimeException);
186 : :
187 : : /// Return the set of current states.
188 : : virtual ::com::sun::star::uno::Reference<
189 : : ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
190 : : getAccessibleStateSet(void)
191 : : throw (::com::sun::star::uno::RuntimeException);
192 : :
193 : : /** Return the parents locale or throw exception if this object has no
194 : : parent yet/anymore.
195 : : */
196 : : virtual ::com::sun::star::lang::Locale SAL_CALL
197 : : getLocale(void)
198 : : throw (::com::sun::star::uno::RuntimeException,
199 : : ::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
200 : :
201 : : ///===== XAccessibleEventBroadcaster =====================================
202 : :
203 : : /** Add listener that is informed of future changes of name,
204 : : description and so on events.
205 : : */
206 : : virtual void SAL_CALL
207 : : addEventListener(
208 : : const ::com::sun::star::uno::Reference<
209 : : ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
210 : : throw (com::sun::star::uno::RuntimeException);
211 : :
212 : : // Remove an existing event listener.
213 : : virtual void SAL_CALL
214 : : removeEventListener(
215 : : const ::com::sun::star::uno::Reference<
216 : : ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
217 : : throw (com::sun::star::uno::RuntimeException);
218 : :
219 : : ///===== XAccessibleEventListener ========================================
220 : :
221 : : virtual void SAL_CALL
222 : : disposing( const ::com::sun::star::lang::EventObject& Source )
223 : : throw (::com::sun::star::uno::RuntimeException);
224 : :
225 : : virtual void SAL_CALL
226 : : notifyEvent(
227 : : const ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
228 : : throw (::com::sun::star::uno::RuntimeException);
229 : :
230 : : ///===== XServiceInfo ====================================================
231 : :
232 : : /** Returns an identifier for the implementation of this object.
233 : : */
234 : : virtual ::rtl::OUString SAL_CALL
235 : : getImplementationName(void)
236 : : throw (::com::sun::star::uno::RuntimeException);
237 : :
238 : : /** Return whether the specified service is supported by this class.
239 : : */
240 : : virtual sal_Bool SAL_CALL
241 : : supportsService(const ::rtl::OUString& sServiceName)
242 : : throw (::com::sun::star::uno::RuntimeException);
243 : :
244 : : /** Returns a list of all supported services. In this case that is just
245 : : the AccessibleContext and Accessible service.
246 : : */
247 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
248 : : getSupportedServiceNames(void)
249 : : throw (::com::sun::star::uno::RuntimeException);
250 : :
251 : : ///===== XTypeProvider ===================================================
252 : :
253 : : /// returns the possible types
254 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
255 : : getTypes()
256 : : throw (::com::sun::star::uno::RuntimeException);
257 : :
258 : : /** Returns a implementation id.
259 : : */
260 : : virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
261 : : getImplementationId(void)
262 : : throw (::com::sun::star::uno::RuntimeException);
263 : :
264 : : protected:
265 : : /// Return this object's description.
266 : : virtual ::rtl::OUString SAL_CALL
267 : : createAccessibleDescription(void)
268 : : throw (::com::sun::star::uno::RuntimeException);
269 : :
270 : : /// Return the object's current name.
271 : : virtual ::rtl::OUString SAL_CALL
272 : : createAccessibleName(void)
273 : : throw (::com::sun::star::uno::RuntimeException);
274 : :
275 : : /// Return the object's current bounding box relative to the desktop.
276 : : virtual Rectangle GetBoundingBoxOnScreen(void) const
277 : : throw (::com::sun::star::uno::RuntimeException);
278 : :
279 : : /// Return the object's current bounding box relative to the parent object.
280 : : virtual Rectangle GetBoundingBox(void) const
281 : : throw (::com::sun::star::uno::RuntimeException);
282 : :
283 : : public:
284 : : /// Calls all Listener to tell they the change.
285 : : void
286 : : CommitChange(const com::sun::star::accessibility::AccessibleEventObject& rEvent) const;
287 : :
288 : : /// change the name and call the listener to tell they the change
289 : : void
290 : : ChangeName();
291 : :
292 : : protected:
293 : : /// Calls all FocusListener to tell they that the focus is gained.
294 : : void CommitFocusGained() const;
295 : :
296 : : /// Calls all FocusListener to tell they that the focus is lost.
297 : : void CommitFocusLost() const;
298 : :
299 : 788 : sal_Bool IsDefunc() const { return rBHelper.bDisposed; }
300 : :
301 : : virtual void IsObjectValid() const
302 : : throw (::com::sun::star::lang::DisposedException);
303 : :
304 : : /// Use this method to set initial Name without notification
305 : 0 : void SetName(const rtl::OUString& rName) { msName = rName; }
306 : : /// Use this method to set initial Description without notification
307 : 0 : void SetDescription(const rtl::OUString& rDesc) { msDescription = rDesc; }
308 : :
309 : : /// Reference to the parent object.
310 : : ::com::sun::star::uno::Reference<
311 : : ::com::sun::star::accessibility::XAccessible> mxParent;
312 : :
313 : : private:
314 : : /** Description of this object. This is not a constant because it can
315 : : be set from the outside. Furthermore, it changes according the the
316 : : draw page's display mode.
317 : : */
318 : : ::rtl::OUString msDescription;
319 : :
320 : : /** Name of this object. It changes according the the draw page's
321 : : display mode.
322 : : */
323 : : ::rtl::OUString msName;
324 : :
325 : : /// client id in the AccessibleEventNotifier queue
326 : : sal_uInt32 mnClientId;
327 : :
328 : : /** This is the role of this object.
329 : : */
330 : : sal_Int16 maRole;
331 : : };
332 : :
333 : :
334 : : #endif
335 : :
336 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|