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 .
21 #ifndef _SC_ACCESSIBLECONTEXTBASE_HXX
22 #define _SC_ACCESSIBLECONTEXTBASE_HXX
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>
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>
49 This base class provides an implementation of the
50 <code>AccessibleContext</code> service.
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
;
61 typedef cppu::ImplHelper1
<
62 ::com::sun::star::accessibility::XAccessibleEventListener
63 > ScAccessibleContextBaseImplEvent
;
65 class ScAccessibleContextBase
66 : public comphelper::OBaseMutex
,
67 public ScAccessibleContextBaseWeakImpl
,
68 public ScAccessibleContextBaseImplEvent
,
72 //===== internal ========================================================
73 ScAccessibleContextBase(
74 const ::com::sun::star::uno::Reference
<
75 ::com::sun::star::accessibility::XAccessible
>& rxParent
,
76 const sal_Int16 aRole
);
79 virtual void SAL_CALL
disposing();
81 virtual ~ScAccessibleContextBase(void);
83 ///===== SfxListener =====================================================
85 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
87 ///===== XInterface =====================================================
89 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(
90 ::com::sun::star::uno::Type
const & rType
)
91 throw (::com::sun::star::uno::RuntimeException
);
93 virtual void SAL_CALL
acquire() throw ();
95 virtual void SAL_CALL
release() throw ();
97 ///===== XAccessible =====================================================
99 /// Return the XAccessibleContext.
100 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
101 getAccessibleContext(void) throw (::com::sun::star::uno::RuntimeException
);
103 ///===== XAccessibleComponent ============================================
105 virtual sal_Bool SAL_CALL
containsPoint(
106 const ::com::sun::star::awt::Point
& rPoint
)
107 throw (::com::sun::star::uno::RuntimeException
);
109 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
110 SAL_CALL
getAccessibleAtPoint(
111 const ::com::sun::star::awt::Point
& rPoint
)
112 throw (::com::sun::star::uno::RuntimeException
);
114 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds( )
115 throw (::com::sun::star::uno::RuntimeException
);
117 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation( )
118 throw (::com::sun::star::uno::RuntimeException
);
120 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen( )
121 throw (::com::sun::star::uno::RuntimeException
);
123 virtual ::com::sun::star::awt::Size SAL_CALL
getSize( )
124 throw (::com::sun::star::uno::RuntimeException
);
126 virtual sal_Bool SAL_CALL
isShowing( )
127 throw (::com::sun::star::uno::RuntimeException
);
129 virtual sal_Bool SAL_CALL
isVisible( )
130 throw (::com::sun::star::uno::RuntimeException
);
132 virtual void SAL_CALL
grabFocus( )
133 throw (::com::sun::star::uno::RuntimeException
);
135 virtual sal_Int32 SAL_CALL
getForeground( )
136 throw (::com::sun::star::uno::RuntimeException
);
138 virtual sal_Int32 SAL_CALL
getBackground( )
139 throw (::com::sun::star::uno::RuntimeException
);
141 ///===== XAccessibleContext ==============================================
143 /// Return the number of currently visible children.
144 virtual sal_Int32 SAL_CALL
145 getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException
);
147 /// Return the specified child or NULL if index is invalid.
148 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
149 getAccessibleChild(sal_Int32 nIndex
)
150 throw (::com::sun::star::uno::RuntimeException
,
151 ::com::sun::star::lang::IndexOutOfBoundsException
);
153 /// Return a reference to the parent.
154 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
155 getAccessibleParent(void)
156 throw (::com::sun::star::uno::RuntimeException
);
158 /// Return this objects index among the parents children.
159 virtual sal_Int32 SAL_CALL
160 getAccessibleIndexInParent(void)
161 throw (::com::sun::star::uno::RuntimeException
);
163 /// Return this object's role.
164 virtual sal_Int16 SAL_CALL
165 getAccessibleRole(void)
166 throw (::com::sun::star::uno::RuntimeException
);
168 /// Return this object's description.
169 virtual OUString SAL_CALL
170 getAccessibleDescription(void)
171 throw (::com::sun::star::uno::RuntimeException
);
173 /// Return the object's current name.
174 virtual OUString SAL_CALL
175 getAccessibleName(void)
176 throw (::com::sun::star::uno::RuntimeException
);
178 /// Return NULL to indicate that an empty relation set.
179 virtual ::com::sun::star::uno::Reference
<
180 ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
181 getAccessibleRelationSet(void)
182 throw (::com::sun::star::uno::RuntimeException
);
184 /// Return the set of current states.
185 virtual ::com::sun::star::uno::Reference
<
186 ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
187 getAccessibleStateSet(void)
188 throw (::com::sun::star::uno::RuntimeException
);
190 /** Return the parents locale or throw exception if this object has no
193 virtual ::com::sun::star::lang::Locale SAL_CALL
195 throw (::com::sun::star::uno::RuntimeException
,
196 ::com::sun::star::accessibility::IllegalAccessibleComponentStateException
);
198 ///===== XAccessibleEventBroadcaster =====================================
200 /** Add listener that is informed of future changes of name,
201 description and so on events.
203 virtual void SAL_CALL
204 addAccessibleEventListener(
205 const ::com::sun::star::uno::Reference
<
206 ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
)
207 throw (com::sun::star::uno::RuntimeException
);
209 // Remove an existing event listener.
210 virtual void SAL_CALL
211 removeAccessibleEventListener(
212 const ::com::sun::star::uno::Reference
<
213 ::com::sun::star::accessibility::XAccessibleEventListener
>& xListener
)
214 throw (com::sun::star::uno::RuntimeException
);
216 ///===== XAccessibleEventListener ========================================
218 virtual void SAL_CALL
219 disposing( const ::com::sun::star::lang::EventObject
& Source
)
220 throw (::com::sun::star::uno::RuntimeException
);
222 virtual void SAL_CALL
224 const ::com::sun::star::accessibility::AccessibleEventObject
& aEvent
)
225 throw (::com::sun::star::uno::RuntimeException
);
227 ///===== XServiceInfo ====================================================
229 /** Returns an identifier for the implementation of this object.
231 virtual OUString SAL_CALL
232 getImplementationName(void)
233 throw (::com::sun::star::uno::RuntimeException
);
235 /** Return whether the specified service is supported by this class.
237 virtual sal_Bool SAL_CALL
238 supportsService(const OUString
& sServiceName
)
239 throw (::com::sun::star::uno::RuntimeException
);
241 /** Returns a list of all supported services. In this case that is just
242 the AccessibleContext and Accessible service.
244 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
245 getSupportedServiceNames(void)
246 throw (::com::sun::star::uno::RuntimeException
);
248 ///===== XTypeProvider ===================================================
250 /// returns the possible types
251 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
253 throw (::com::sun::star::uno::RuntimeException
);
255 /** Returns a implementation id.
257 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
258 getImplementationId(void)
259 throw (::com::sun::star::uno::RuntimeException
);
262 /// Return this object's description.
263 virtual OUString SAL_CALL
264 createAccessibleDescription(void)
265 throw (::com::sun::star::uno::RuntimeException
);
267 /// Return the object's current name.
268 virtual OUString SAL_CALL
269 createAccessibleName(void)
270 throw (::com::sun::star::uno::RuntimeException
);
272 /// Return the object's current bounding box relative to the desktop.
273 virtual Rectangle
GetBoundingBoxOnScreen(void) const
274 throw (::com::sun::star::uno::RuntimeException
);
276 /// Return the object's current bounding box relative to the parent object.
277 virtual Rectangle
GetBoundingBox(void) const
278 throw (::com::sun::star::uno::RuntimeException
);
281 /// Calls all Listener to tell they the change.
283 CommitChange(const com::sun::star::accessibility::AccessibleEventObject
& rEvent
) const;
285 /// change the name and call the listener to tell they the change
290 /// Calls all FocusListener to tell they that the focus is gained.
291 void CommitFocusGained() const;
293 /// Calls all FocusListener to tell they that the focus is lost.
294 void CommitFocusLost() const;
296 sal_Bool
IsDefunc() const { return rBHelper
.bDisposed
; }
298 virtual void IsObjectValid() const
299 throw (::com::sun::star::lang::DisposedException
);
301 /// Use this method to set initial Name without notification
302 void SetName(const OUString
& rName
) { msName
= rName
; }
303 /// Use this method to set initial Description without notification
304 void SetDescription(const OUString
& rDesc
) { msDescription
= rDesc
; }
306 /// Reference to the parent object.
307 ::com::sun::star::uno::Reference
<
308 ::com::sun::star::accessibility::XAccessible
> mxParent
;
311 /** Description of this object. This is not a constant because it can
312 be set from the outside. Furthermore, it changes according the the
313 draw page's display mode.
315 OUString msDescription
;
317 /** Name of this object. It changes according the draw page's
322 /// client id in the AccessibleEventNotifier queue
323 sal_uInt32 mnClientId
;
325 /** This is the role of this object.
333 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */