1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleContextBase.hxx,v $
10 * $Revision: 1.23.32.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _SC_ACCESSIBLECONTEXTBASE_HXX
33 #define _SC_ACCESSIBLECONTEXTBASE_HXX
35 #include <com/sun/star/accessibility/XAccessible.hpp>
36 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
37 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
38 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
39 #ifndef _COM_SUN_STAR_ACCESSIBILITY_IllegalAccessibleComponentStateException_HPP_
40 #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
42 #include <com/sun/star/lang/DisposedException.hpp>
43 #include <com/sun/star/uno/Reference.hxx>
44 #include <cppuhelper/weak.hxx>
45 #include <com/sun/star/lang/XServiceInfo.hpp>
46 #include <com/sun/star/lang/XTypeProvider.hpp>
47 #include <com/sun/star/lang/XServiceName.hpp>
48 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
49 #include <vos/mutex.hxx>
50 #include <cppuhelper/interfacecontainer.h>
53 #include <svtools/lstner.hxx>
54 #include <cppuhelper/compbase5.hxx>
55 #include <cppuhelper/implbase1.hxx>
56 #include <comphelper/servicehelper.hxx>
57 #include <comphelper/broadcasthelper.hxx>
62 This base class provides an implementation of the
63 <code>AccessibleContext</code> service.
66 typedef cppu::WeakAggComponentImplHelper5
<
67 ::com::sun::star::accessibility::XAccessible
,
68 ::com::sun::star::accessibility::XAccessibleComponent
,
69 ::com::sun::star::accessibility::XAccessibleContext
,
70 ::com::sun::star::accessibility::XAccessibleEventBroadcaster
,
71 ::com::sun::star::lang::XServiceInfo
72 > ScAccessibleContextBaseWeakImpl
;
74 typedef cppu::ImplHelper1
<
75 ::com::sun::star::accessibility::XAccessibleEventListener
76 > ScAccessibleContextBaseImplEvent
;
78 class ScAccessibleContextBase
79 : public comphelper::OBaseMutex
,
80 public ScAccessibleContextBaseWeakImpl
,
81 public ScAccessibleContextBaseImplEvent
,
85 //===== internal ========================================================
86 ScAccessibleContextBase(
87 const ::com::sun::star::uno::Reference
<
88 ::com::sun::star::accessibility::XAccessible
>& rxParent
,
89 const sal_Int16 aRole
);
92 virtual void SAL_CALL
disposing();
94 virtual ~ScAccessibleContextBase(void);
96 using WeakAggComponentImplHelperBase::addEventListener
;
97 using WeakAggComponentImplHelperBase::removeEventListener
;
99 ///===== SfxListener =====================================================
101 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
103 ///===== XInterface =====================================================
105 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(
106 ::com::sun::star::uno::Type
const & rType
)
107 throw (::com::sun::star::uno::RuntimeException
);
109 virtual void SAL_CALL
acquire() throw ();
111 virtual void SAL_CALL
release() throw ();
113 ///===== XAccessible =====================================================
115 /// Return the XAccessibleContext.
116 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
117 getAccessibleContext(void) throw (::com::sun::star::uno::RuntimeException
);
119 ///===== XAccessibleComponent ============================================
121 virtual sal_Bool SAL_CALL
containsPoint(
122 const ::com::sun::star::awt::Point
& rPoint
)
123 throw (::com::sun::star::uno::RuntimeException
);
125 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
126 SAL_CALL
getAccessibleAtPoint(
127 const ::com::sun::star::awt::Point
& rPoint
)
128 throw (::com::sun::star::uno::RuntimeException
);
130 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds( )
131 throw (::com::sun::star::uno::RuntimeException
);
133 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation( )
134 throw (::com::sun::star::uno::RuntimeException
);
136 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen( )
137 throw (::com::sun::star::uno::RuntimeException
);
139 virtual ::com::sun::star::awt::Size SAL_CALL
getSize( )
140 throw (::com::sun::star::uno::RuntimeException
);
142 virtual sal_Bool SAL_CALL
isShowing( )
143 throw (::com::sun::star::uno::RuntimeException
);
145 virtual sal_Bool SAL_CALL
isVisible( )
146 throw (::com::sun::star::uno::RuntimeException
);
148 virtual void SAL_CALL
grabFocus( )
149 throw (::com::sun::star::uno::RuntimeException
);
151 virtual sal_Int32 SAL_CALL
getForeground( )
152 throw (::com::sun::star::uno::RuntimeException
);
154 virtual sal_Int32 SAL_CALL
getBackground( )
155 throw (::com::sun::star::uno::RuntimeException
);
157 ///===== XAccessibleContext ==============================================
159 /// Return the number of currently visible children.
160 virtual sal_Int32 SAL_CALL
161 getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException
);
163 /// Return the specified child or NULL if index is invalid.
164 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
165 getAccessibleChild(sal_Int32 nIndex
)
166 throw (::com::sun::star::uno::RuntimeException
,
167 ::com::sun::star::lang::IndexOutOfBoundsException
);
169 /// Return a reference to the parent.
170 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
171 getAccessibleParent(void)
172 throw (::com::sun::star::uno::RuntimeException
);
174 /// Return this objects index among the parents children.
175 virtual sal_Int32 SAL_CALL
176 getAccessibleIndexInParent(void)
177 throw (::com::sun::star::uno::RuntimeException
);
179 /// Return this object's role.
180 virtual sal_Int16 SAL_CALL
181 getAccessibleRole(void)
182 throw (::com::sun::star::uno::RuntimeException
);
184 /// Return this object's description.
185 virtual ::rtl::OUString SAL_CALL
186 getAccessibleDescription(void)
187 throw (::com::sun::star::uno::RuntimeException
);
189 /// Return the object's current name.
190 virtual ::rtl::OUString SAL_CALL
191 getAccessibleName(void)
192 throw (::com::sun::star::uno::RuntimeException
);
194 /// Return NULL to indicate that an empty relation set.
195 virtual ::com::sun::star::uno::Reference
<
196 ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
197 getAccessibleRelationSet(void)
198 throw (::com::sun::star::uno::RuntimeException
);
200 /// Return the set of current states.
201 virtual ::com::sun::star::uno::Reference
<
202 ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
203 getAccessibleStateSet(void)
204 throw (::com::sun::star::uno::RuntimeException
);
206 /** Return the parents locale or throw exception if this object has no
209 virtual ::com::sun::star::lang::Locale SAL_CALL
211 throw (::com::sun::star::uno::RuntimeException
,
212 ::com::sun::star::accessibility::IllegalAccessibleComponentStateException
);
214 ///===== XAccessibleEventBroadcaster =====================================
216 /** Add listener that is informed of future changes of name,
217 description and so on events.
219 virtual void SAL_CALL
221 const ::com::sun::star::uno::Reference
<
222 ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
)
223 throw (com::sun::star::uno::RuntimeException
);
225 // Remove an existing event listener.
226 virtual void SAL_CALL
228 const ::com::sun::star::uno::Reference
<
229 ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
)
230 throw (com::sun::star::uno::RuntimeException
);
232 ///===== XAccessibleEventListener ========================================
234 virtual void SAL_CALL
235 disposing( const ::com::sun::star::lang::EventObject
& Source
)
236 throw (::com::sun::star::uno::RuntimeException
);
238 virtual void SAL_CALL
240 const ::com::sun::star::accessibility::AccessibleEventObject
& aEvent
)
241 throw (::com::sun::star::uno::RuntimeException
);
243 ///===== XServiceInfo ====================================================
245 /** Returns an identifier for the implementation of this object.
247 virtual ::rtl::OUString SAL_CALL
248 getImplementationName(void)
249 throw (::com::sun::star::uno::RuntimeException
);
251 /** Return whether the specified service is supported by this class.
253 virtual sal_Bool SAL_CALL
254 supportsService(const ::rtl::OUString
& sServiceName
)
255 throw (::com::sun::star::uno::RuntimeException
);
257 /** Returns a list of all supported services. In this case that is just
258 the AccessibleContext and Accessible service.
260 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
261 getSupportedServiceNames(void)
262 throw (::com::sun::star::uno::RuntimeException
);
264 ///===== XTypeProvider ===================================================
266 /// returns the possible types
267 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
269 throw (::com::sun::star::uno::RuntimeException
);
271 /** Returns a implementation id.
273 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
274 getImplementationId(void)
275 throw (::com::sun::star::uno::RuntimeException
);
278 /// Return this object's description.
279 virtual ::rtl::OUString SAL_CALL
280 createAccessibleDescription(void)
281 throw (::com::sun::star::uno::RuntimeException
);
283 /// Return the object's current name.
284 virtual ::rtl::OUString SAL_CALL
285 createAccessibleName(void)
286 throw (::com::sun::star::uno::RuntimeException
);
288 /// Return the object's current bounding box relative to the desktop.
289 virtual Rectangle
GetBoundingBoxOnScreen(void) const
290 throw (::com::sun::star::uno::RuntimeException
);
292 /// Return the object's current bounding box relative to the parent object.
293 virtual Rectangle
GetBoundingBox(void) const
294 throw (::com::sun::star::uno::RuntimeException
);
297 /// Calls all Listener to tell they the change.
299 CommitChange(const com::sun::star::accessibility::AccessibleEventObject
& rEvent
) const;
301 /// change the name and call the listener to tell they the change
306 /// Calls all FocusListener to tell they that the focus is gained.
307 void CommitFocusGained() const;
309 /// Calls all FocusListener to tell they that the focus is lost.
310 void CommitFocusLost() const;
312 sal_Bool
IsDefunc() const { return rBHelper
.bDisposed
; }
314 virtual void IsObjectValid() const
315 throw (::com::sun::star::lang::DisposedException
);
317 /// Use this method to set initial Name without notification
318 void SetName(const rtl::OUString
& rName
) { msName
= rName
; }
319 /// Use this method to set initial Description without notification
320 void SetDescription(const rtl::OUString
& rDesc
) { msDescription
= rDesc
; }
322 void SetRole(sal_Int16 nRole
);
324 /// Reference to the parent object.
325 ::com::sun::star::uno::Reference
<
326 ::com::sun::star::accessibility::XAccessible
> mxParent
;
329 /** Description of this object. This is not a constant because it can
330 be set from the outside. Furthermore, it changes according the the
331 draw page's display mode.
333 ::rtl::OUString msDescription
;
335 /** Name of this object. It changes according the the draw page's
338 ::rtl::OUString msName
;
340 /// client id in the AccessibleEventNotifier queue
341 sal_uInt32 mnClientId
;
343 /** This is the role of this object.