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_SC_SOURCE_UI_INC_ACCESSIBLECONTEXTBASE_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECONTEXTBASE_HXX
23 #include <com/sun/star/accessibility/XAccessible.hpp>
24 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
25 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
26 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
27 #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
28 #include <com/sun/star/lang/DisposedException.hpp>
29 #include <com/sun/star/uno/Reference.hxx>
30 #include <cppuhelper/weak.hxx>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/lang/XTypeProvider.hpp>
33 #include <com/sun/star/lang/XServiceName.hpp>
34 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
35 #include <osl/mutex.hxx>
36 #include <cppuhelper/interfacecontainer.h>
38 #include <svl/lstner.hxx>
39 #include <cppuhelper/compbase5.hxx>
40 #include <cppuhelper/implbase1.hxx>
41 #include <comphelper/servicehelper.hxx>
42 #include <comphelper/broadcasthelper.hxx>
47 This base class provides an implementation of the
48 <code>AccessibleContext</code> service.
51 typedef cppu::WeakAggComponentImplHelper5
<
52 ::com::sun::star::accessibility::XAccessible
,
53 ::com::sun::star::accessibility::XAccessibleComponent
,
54 ::com::sun::star::accessibility::XAccessibleContext
,
55 ::com::sun::star::accessibility::XAccessibleEventBroadcaster
,
56 ::com::sun::star::lang::XServiceInfo
57 > ScAccessibleContextBaseWeakImpl
;
59 typedef cppu::ImplHelper1
<
60 ::com::sun::star::accessibility::XAccessibleEventListener
61 > ScAccessibleContextBaseImplEvent
;
63 class ScAccessibleContextBase
64 : public comphelper::OBaseMutex
,
65 public ScAccessibleContextBaseWeakImpl
,
66 public ScAccessibleContextBaseImplEvent
,
70 //===== internal ========================================================
71 ScAccessibleContextBase(
72 const ::com::sun::star::uno::Reference
<
73 ::com::sun::star::accessibility::XAccessible
>& rxParent
,
74 const sal_Int16 aRole
);
77 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
79 virtual ~ScAccessibleContextBase();
82 bool SAL_CALL
isShowing( )
83 throw (::com::sun::star::uno::RuntimeException
);
85 virtual bool SAL_CALL
isVisible()
86 throw (::com::sun::star::uno::RuntimeException
, std::exception
);
88 ///===== SfxListener =====================================================
90 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
92 ///===== XInterface =====================================================
94 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(
95 ::com::sun::star::uno::Type
const & rType
)
96 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 virtual void SAL_CALL
acquire() throw () SAL_OVERRIDE
;
100 virtual void SAL_CALL
release() throw () SAL_OVERRIDE
;
102 ///===== XAccessible =====================================================
104 /// Return the XAccessibleContext.
105 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
106 getAccessibleContext() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
108 ///===== XAccessibleComponent ============================================
110 virtual sal_Bool SAL_CALL
containsPoint(
111 const ::com::sun::star::awt::Point
& rPoint
)
112 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
114 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
115 SAL_CALL
getAccessibleAtPoint(
116 const ::com::sun::star::awt::Point
& rPoint
)
117 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
119 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds( )
120 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
122 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation( )
123 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
125 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen( )
126 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
128 virtual ::com::sun::star::awt::Size SAL_CALL
getSize( )
129 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
131 virtual void SAL_CALL
grabFocus( )
132 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
134 virtual sal_Int32 SAL_CALL
getForeground( )
135 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
137 virtual sal_Int32 SAL_CALL
getBackground( )
138 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
140 ///===== XAccessibleContext ==============================================
142 /// Return the number of currently visible children.
143 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
144 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
146 /// Return the specified child or NULL if index is invalid.
147 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
148 getAccessibleChild(sal_Int32 nIndex
)
149 throw (::com::sun::star::uno::RuntimeException
,
150 ::com::sun::star::lang::IndexOutOfBoundsException
,
151 std::exception
) SAL_OVERRIDE
;
153 /// Return a reference to the parent.
154 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
155 getAccessibleParent()
156 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
158 /// Return this objects index among the parents children.
159 virtual sal_Int32 SAL_CALL
160 getAccessibleIndexInParent()
161 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
163 /// Return this object's role.
164 virtual sal_Int16 SAL_CALL
166 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
168 /// Return this object's description.
169 virtual OUString SAL_CALL
170 getAccessibleDescription()
171 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
173 /// Return the object's current name.
174 virtual OUString SAL_CALL
176 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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()
182 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
184 /// Return the set of current states.
185 virtual ::com::sun::star::uno::Reference
<
186 ::com::sun::star::accessibility::XAccessibleStateSet
> SAL_CALL
187 getAccessibleStateSet()
188 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
216 ///===== XAccessibleEventListener ========================================
218 virtual void SAL_CALL
219 disposing( const ::com::sun::star::lang::EventObject
& Source
)
220 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
222 virtual void SAL_CALL
224 const ::com::sun::star::accessibility::AccessibleEventObject
& aEvent
)
225 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
227 ///===== XServiceInfo ====================================================
229 /** Returns an identifier for the implementation of this object.
231 virtual OUString SAL_CALL
232 getImplementationName()
233 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
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()
246 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
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
, std::exception
) SAL_OVERRIDE
;
255 /** Returns a implementation id.
257 virtual ::com::sun::star::uno::Sequence
<sal_Int8
> SAL_CALL
258 getImplementationId()
259 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
262 /// Return this object's description.
263 virtual OUString SAL_CALL
264 createAccessibleDescription()
265 throw (::com::sun::star::uno::RuntimeException
);
267 /// Return the object's current name.
268 virtual OUString SAL_CALL
269 createAccessibleName()
270 throw (::com::sun::star::uno::RuntimeException
,
273 /// Return the object's current bounding box relative to the desktop.
274 virtual Rectangle
GetBoundingBoxOnScreen() const
275 throw (::com::sun::star::uno::RuntimeException
, std::exception
);
277 /// Return the object's current bounding box relative to the parent object.
278 virtual Rectangle
GetBoundingBox() const
279 throw (::com::sun::star::uno::RuntimeException
, std::exception
);
282 /// Calls all Listener to tell they the change.
284 CommitChange(const com::sun::star::accessibility::AccessibleEventObject
& rEvent
) const;
287 /// Calls all FocusListener to tell they that the focus is gained.
288 void CommitFocusGained() const;
290 /// Calls all FocusListener to tell they that the focus is lost.
291 void CommitFocusLost() const;
293 bool IsDefunc() const { return rBHelper
.bDisposed
; }
295 void IsObjectValid() const
296 throw (::com::sun::star::lang::DisposedException
);
298 /// Use this method to set initial Name without notification
299 void SetName(const OUString
& rName
) { msName
= rName
; }
300 /// Use this method to set initial Description without notification
301 void SetDescription(const OUString
& rDesc
) { msDescription
= rDesc
; }
303 /// Reference to the parent object.
304 ::com::sun::star::uno::Reference
<
305 ::com::sun::star::accessibility::XAccessible
> mxParent
;
308 /** Description of this object. This is not a constant because it can
309 be set from the outside. Furthermore, it changes according to the
310 draw page's display mode.
312 OUString msDescription
;
314 /** Name of this object. It changes according the draw page's
319 /// client id in the AccessibleEventNotifier queue
320 sal_uInt32 mnClientId
;
322 /** This is the role of this object.
329 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */