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 _SVX_ACCESSIBILITY_ACCESSIBLE_SHAPE_HXX
22 : : #define _SVX_ACCESSIBILITY_ACCESSIBLE_SHAPE_HXX
23 : :
24 : : #include <editeng/AccessibleContextBase.hxx>
25 : : #include <editeng/AccessibleComponentBase.hxx>
26 : : #include <svx/IAccessibleViewForwarderListener.hxx>
27 : : #include <com/sun/star/document/XEventListener.hpp>
28 : : #include <com/sun/star/accessibility/XAccessible.hpp>
29 : : #include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
30 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 : : #include <com/sun/star/drawing/XShape.hpp>
32 : : #include <com/sun/star/lang/XEventListener.hpp>
33 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
34 : : #include <svx/AccessibleTextHelper.hxx>
35 : : #include "svx/svxdllapi.h"
36 : : #include "ChildrenManager.hxx"
37 : :
38 : : class SdrObject;
39 : :
40 : : namespace accessibility {
41 : :
42 : : class AccessibleShapeInfo;
43 : : class AccessibleShapeTreeInfo;
44 : : class IAccessibleParent;
45 : :
46 : : /** This base class provides a base implementation for all shapes. For more
47 : : detailed documentation about the methods refer to the descriptions of
48 : : the implemented interfaces. These are, among others,
49 : : <type>XAccessible</type>, <type>XAccessibleContext</type>,
50 : : <type>XAccessibleComponent</type> and
51 : : <type>XAccessibleExtendedComponent</type>.
52 : :
53 : : <p>The children of a shape can stem from two sources which, in case of
54 : : SVX and SD shapes, are mutually exclusive. This implementation,
55 : : however, handles both simultaniously to cope with future extensions or
56 : : shapes from other projects.
57 : : <ul>
58 : : <li>If this shape is a group shape, i.e. a
59 : : <type>SvxShapeGroup</type> or a <type>Svx3DSceneObject</type>, it
60 : : can have nested shapes.</li>
61 : : <li>If this shape is a descendant from <type>SvxShapeText</type>
62 : : then the text paragraphs are its children.</li>
63 : : </ul>
64 : : </p>
65 : :
66 : : <p>Accessible shapes do not listen for disposing() calls of the UNO
67 : : shapes they make accessible. This is the task of their owner, usually a
68 : : container, who can then call dispose() at the accessible object.</p>
69 : : */
70 : : class SVX_DLLPUBLIC AccessibleShape
71 : : : public AccessibleContextBase,
72 : : public AccessibleComponentBase,
73 : : public IAccessibleViewForwarderListener,
74 : : public ::com::sun::star::document::XEventListener,
75 : : public ::com::sun::star::lang::XUnoTunnel
76 : : {
77 : : public:
78 : : //===== internal ========================================================
79 : :
80 : : /** Create a new accessible object that makes the given shape accessible.
81 : : @param rShapeInfo
82 : : This object contains all information specific to the new
83 : : accessible shape. That are e.g. the shape to be made accessible
84 : : and the accessible object that will become the parent of the new
85 : : object.
86 : : @param rShapeTreeInfo
87 : : Bundel of information passed to this shape and all of its desendants.
88 : : @attention
89 : : Always call the <member>init</member> method after creating a
90 : : new accessible shape. This is one way to overcome the potential
91 : : problem of registering the new object with e.g. event
92 : : broadcasters. That would delete the new object if a broadcaster
93 : : would not keep a strong reference to the new object.
94 : : */
95 : : AccessibleShape (
96 : : const AccessibleShapeInfo& rShapeInfo,
97 : : const AccessibleShapeTreeInfo& rShapeTreeInfo);
98 : :
99 : : /** The destructor releases its children manager and text engine if
100 : : still existent. These are responsible to send appropriate events.
101 : : */
102 : : virtual ~AccessibleShape (void);
103 : :
104 : : /** Initialize a new shape. See the documentation of the constructor
105 : : for the reason of this method's existence.
106 : : */
107 : : virtual void Init (void);
108 : :
109 : : /** Compare two accessible shapes using object identity
110 : : @param rShape
111 : : This is the second operand.
112 : : @return
113 : : Returns true if both shapes are the same object.
114 : : */
115 : : virtual bool operator== (const AccessibleShape& rShape);
116 : :
117 : : /** Set the specified state. If the state is <const>FOCUSED</const>
118 : : then, additionally to the inherited functionality, the focus
119 : : listeners registered with the <type>XAccessibleComponent</type>
120 : : interface are called (if that state really changes).
121 : :
122 : : @param aState
123 : : The state to turn on.
124 : :
125 : : @return
126 : : The returned flag indicates whether the specified state has been
127 : : changed (<TRUE/>), i.e. it has formerly not been set.
128 : : */
129 : : virtual sal_Bool SetState (sal_Int16 aState);
130 : :
131 : : /** Reset the specified state. If the state is <const>FOCUSED</const>
132 : : then, additionally to the inherited functionality, the focus
133 : : listeners registered with the <type>XAccessibleComponent</type>
134 : : interface are called (if that state really changes).
135 : :
136 : : @param aState
137 : : The state to turn off.
138 : :
139 : : @return
140 : : The returned flag indicates whether the specified state has been
141 : : changed (<TRUE/>), i.e. it has formerly been set.
142 : : */
143 : : virtual sal_Bool ResetState (sal_Int16 aState);
144 : :
145 : : /** Return the state of the specified state. Take the
146 : : <const>FOCUSED</const> state from the accessible edit engine.
147 : :
148 : : @param aState
149 : : The state for which to return its value.
150 : : @return
151 : : A value of <TRUE/> indicates that the state is set. A <FALSE/>
152 : : value indicates an unset state or the inability to access the
153 : : entity that manages the state set.
154 : :
155 : : */
156 : : sal_Bool GetState (sal_Int16 aState);
157 : :
158 : :
159 : : //===== XAccessibleContext ==============================================
160 : :
161 : : /// Return the number of currently visible children.
162 : : virtual sal_Int32 SAL_CALL
163 : : getAccessibleChildCount (void)
164 : : throw (::com::sun::star::uno::RuntimeException);
165 : :
166 : : /** Return the specified child.
167 : : @param nIndex
168 : : Index of the requested child.
169 : : @return
170 : : Reference of the requested child which is the accessible object
171 : : of a visible shape.
172 : : @raises IndexOutOfBoundsException
173 : : Throws an exception if the index is not valid.
174 : : */
175 : : virtual ::com::sun::star::uno::Reference<
176 : : ::com::sun::star::accessibility::XAccessible> SAL_CALL
177 : : getAccessibleChild (sal_Int32 nIndex)
178 : : throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
179 : :
180 : :
181 : : /// Return the set of current states.
182 : : virtual ::com::sun::star::uno::Reference<
183 : : ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
184 : : getAccessibleStateSet (void)
185 : : throw (::com::sun::star::uno::RuntimeException);
186 : :
187 : : /// Return this objects index among the parents children.
188 : : virtual sal_Int32 SAL_CALL
189 : : getAccessibleIndexInParent (void)
190 : : throw (::com::sun::star::uno::RuntimeException);
191 : :
192 : : //===== XAccessibleComponent ============================================
193 : :
194 : : virtual ::com::sun::star::uno::Reference<
195 : : ::com::sun::star::accessibility::XAccessible > SAL_CALL
196 : : getAccessibleAtPoint (const ::com::sun::star::awt::Point& aPoint)
197 : : throw (::com::sun::star::uno::RuntimeException);
198 : :
199 : : virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void)
200 : : throw (::com::sun::star::uno::RuntimeException);
201 : :
202 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void)
203 : : throw (::com::sun::star::uno::RuntimeException);
204 : :
205 : : virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void)
206 : : throw (::com::sun::star::uno::RuntimeException);
207 : :
208 : : virtual ::com::sun::star::awt::Size SAL_CALL getSize (void)
209 : : throw (::com::sun::star::uno::RuntimeException);
210 : :
211 : : virtual sal_Int32 SAL_CALL getForeground (void)
212 : : throw (::com::sun::star::uno::RuntimeException);
213 : :
214 : : virtual sal_Int32 SAL_CALL getBackground (void)
215 : : throw (::com::sun::star::uno::RuntimeException);
216 : :
217 : :
218 : :
219 : : //===== XComponent ========================================================
220 : :
221 : : using WeakComponentImplHelperBase::addEventListener;
222 : : using WeakComponentImplHelperBase::removeEventListener;
223 : :
224 : : //===== XAccessibleEventBroadcaster =====================================
225 : :
226 : : /** This call is forwarded to a) the base class and b) to the
227 : : accessible edit engine if it is present.
228 : :
229 : : @param rxListener
230 : : This listener is informed about accessibility events.
231 : : */
232 : : virtual void SAL_CALL
233 : : addEventListener (
234 : : const ::com::sun::star::uno::Reference<
235 : : ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener)
236 : : throw (::com::sun::star::uno::RuntimeException);
237 : :
238 : : /** This call is forwarded to a) the base class and b) to the
239 : : accessible edit engine if it is present.
240 : :
241 : : @param rxListener
242 : : This listener will not be informed about accessibility events
243 : : anymore.
244 : : */
245 : : virtual void SAL_CALL
246 : : removeEventListener (
247 : : const ::com::sun::star::uno::Reference<
248 : : ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener)
249 : : throw (::com::sun::star::uno::RuntimeException);
250 : :
251 : :
252 : : //===== XInterface ======================================================
253 : :
254 : : virtual com::sun::star::uno::Any SAL_CALL
255 : : queryInterface (const com::sun::star::uno::Type & rType)
256 : : throw (::com::sun::star::uno::RuntimeException);
257 : :
258 : : virtual void SAL_CALL
259 : : acquire (void)
260 : : throw ();
261 : :
262 : : virtual void SAL_CALL
263 : : release (void)
264 : : throw ();
265 : :
266 : :
267 : : //===== XServiceInfo ====================================================
268 : :
269 : : /** Returns an identifier for the implementation of this object.
270 : : */
271 : : virtual ::rtl::OUString SAL_CALL
272 : : getImplementationName (void)
273 : : throw (::com::sun::star::uno::RuntimeException);
274 : :
275 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
276 : : getSupportedServiceNames (void)
277 : : throw (::com::sun::star::uno::RuntimeException);
278 : :
279 : : //===== XTypeProvider ===================================================
280 : :
281 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
282 : : getTypes (void)
283 : : throw (::com::sun::star::uno::RuntimeException);
284 : :
285 : : //===== IAccessibleViewForwarderListener ================================
286 : : virtual void ViewForwarderChanged (ChangeType aChangeType,
287 : : const IAccessibleViewForwarder* pViewForwarder);
288 : :
289 : : //===== lang::XEventListener ============================================
290 : :
291 : : /** Listen for disposing events of the model. The accessible shape
292 : : remains functional when this happens.
293 : : */
294 : : virtual void SAL_CALL
295 : : disposing (const ::com::sun::star::lang::EventObject& Source)
296 : : throw (::com::sun::star::uno::RuntimeException);
297 : :
298 : : //===== document::XEventListener ========================================
299 : :
300 : : virtual void SAL_CALL
301 : : notifyEvent (const ::com::sun::star::document::EventObject& rEventObject)
302 : : throw (::com::sun::star::uno::RuntimeException);
303 : :
304 : :
305 : : //===== XUnoTunnel ========================================================
306 : :
307 : : static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelImplementationId() throw();
308 : : static AccessibleShape* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIFace ) throw();
309 : : sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& _rIdentifier ) throw(::com::sun::star::uno::RuntimeException);
310 : :
311 : : //===== Misc ========================================================
312 : :
313 : : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
314 : : GetXShape();
315 : :
316 : : /** set the index _nIndex at the accessible shape
317 : : @param _nIndex
318 : : The new index in parent.
319 : : */
320 : 48 : inline void setIndexInParent(sal_Int32 _nIndex) { m_nIndexInParent = _nIndex; }
321 : :
322 : : protected:
323 : : /// Children manager. May be empty if there are no children.
324 : : ChildrenManager* mpChildrenManager;
325 : :
326 : : /// Reference to the actual shape.
327 : : ::com::sun::star::uno::Reference<
328 : : ::com::sun::star::drawing::XShape> mxShape;
329 : :
330 : : /** Bundle of information passed to all shapes in a document tree.
331 : : */
332 : : AccessibleShapeTreeInfo maShapeTreeInfo;
333 : :
334 : : /** Index that is appended to the object's name to disambiguate between
335 : : different names with the otherwise same name.
336 : : */
337 : : long mnIndex;
338 : :
339 : : /** the index in parent.
340 : : */
341 : : sal_Int32 m_nIndexInParent;
342 : :
343 : : /** The accessible text engine. May be NULL if it can not be created.
344 : : */
345 : : AccessibleTextHelper* mpText;
346 : :
347 : : /** This object can be used to modify the child list of our parent.
348 : : */
349 : : IAccessibleParent* mpParent;
350 : :
351 : : /** This object can be removed when we have an extra interface to ask if the shape is selected
352 : : */
353 : : SdrObject* m_pShape;
354 : :
355 : : /** This method is called from the component helper base class while
356 : : disposing.
357 : : */
358 : : virtual void SAL_CALL disposing (void);
359 : :
360 : : /** Create a base name string that contains the accessible name.
361 : : */
362 : : virtual ::rtl::OUString
363 : : CreateAccessibleBaseName (void)
364 : : throw (::com::sun::star::uno::RuntimeException);
365 : :
366 : : /** Create a unique name string that contains the accessible name. The
367 : : name consists of the base name and the index.
368 : : */
369 : : virtual ::rtl::OUString
370 : : CreateAccessibleName (void)
371 : : throw (::com::sun::star::uno::RuntimeException);
372 : :
373 : : /// Create a description string that contains the accessible description.
374 : : virtual ::rtl::OUString
375 : : CreateAccessibleDescription (void)
376 : : throw (::com::sun::star::uno::RuntimeException);
377 : :
378 : : /** Update the <const>OPAQUE</const> and <const>SELECTED</const> state.
379 : : */
380 : : virtual void UpdateStates (void);
381 : :
382 : : private:
383 : : /** Don't use the default constructor. Use the public constructor that
384 : : takes the original shape and the parent as arguments instead.
385 : : */
386 : : SVX_DLLPRIVATE explicit AccessibleShape (void);
387 : : /// Don't use the copy constructor. Is there any use for it?
388 : : SVX_DLLPRIVATE explicit AccessibleShape (const AccessibleShape&);
389 : : /// Don't use the assignment operator. Do we need this?
390 : : SVX_DLLPRIVATE AccessibleShape& operator= (const AccessibleShape&);
391 : :
392 : : /** Call this method when the title, name, or description of the mxShape
393 : : member (may) have been changed.
394 : : This method adapts the name and description members of the
395 : : AccessibleContextBase base class.
396 : : */
397 : : void UpdateNameAndDescription (void);
398 : : };
399 : :
400 : : } // end of namespace accessibility
401 : :
402 : : #endif
403 : :
404 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|