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 : #ifndef INCLUDED_SD_SOURCE_UI_INC_ACCESSIBLEDOCUMENTVIEWBASE_HXX
21 : #define INCLUDED_SD_SOURCE_UI_INC_ACCESSIBLEDOCUMENTVIEWBASE_HXX
22 :
23 : #include <editeng/AccessibleContextBase.hxx>
24 : #include <editeng/AccessibleComponentBase.hxx>
25 : #include <editeng/AccessibleSelectionBase.hxx>
26 : #include "AccessibleViewForwarder.hxx"
27 : #include "AccessiblePageShape.hxx"
28 : #include <svx/ChildrenManager.hxx>
29 : #include <com/sun/star/frame/XModel.hpp>
30 : #include <com/sun/star/awt/XWindowListener.hpp>
31 : #include <com/sun/star/awt/XFocusListener.hpp>
32 : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
33 : #include <com/sun/star/accessibility/XAccessible.hpp>
34 : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
35 : #include <tools/link.hxx>
36 :
37 : #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
38 : #include "DrawViewShell.hxx"
39 : #include "sdpage.hxx"
40 : #include "drawdoc.hxx"
41 : #include "FrameView.hxx"
42 : #include "PresentationViewShell.hxx"
43 : #include <editeng/outlobj.hxx>
44 : #include <com/sun/star/accessibility/XAccessibleGetAccFlowTo.hpp>
45 : class SdViewShell;
46 : namespace sd {
47 : class ViewShell;
48 : class Window;
49 : }
50 :
51 : class VclSimpleEvent;
52 :
53 : namespace accessibility {
54 :
55 : /** Base class for the various document views of the Draw and
56 : Impress applications.
57 :
58 : <p>The different view modes of the Draw and Impress applications
59 : are made accessible by derived classes. When the view mode is
60 : changed than the object representing the document view is
61 : disposed and replaced by a new instance of the then appropriate
62 : derived class.</p>
63 :
64 : <p>This base class also manages an optionally active accessible OLE
65 : object. If you overwrite the <member>getAccessibleChildCount</member>
66 : and <member>getAccessibleChild</member> methods then make sure to first
67 : call the corresponding method of this class and adapt your child count
68 : and indices accordingly. Only one active OLE object is allowed at a
69 : time. This class does not listen for disposing calls at the moment
70 : because it does not use the accessible OLE object directly and trusts on
71 : getting informed through VCL window events.</p>
72 :
73 : <p>This class implements three kinds of listeners:
74 : <ol><li>The property change listener is not used directly but exists as
75 : convenience for derived classes. May be moved to those classes
76 : instead.</li>
77 : <li>As window listener it waits for changes of the window geometry and
78 : forwards those as view forwarder changes.</li>
79 : <li>As focus listener it keeps track of the focus to give this class and
80 : derived classes the opportunity to set and remove the focus to/from
81 : shapes.</li>
82 : </ol>
83 : </p>
84 : */
85 : class AccessibleDocumentViewBase
86 : : public AccessibleContextBase,
87 : public AccessibleComponentBase,
88 : public AccessibleSelectionBase,
89 : public IAccessibleViewForwarderListener,
90 : public ::com::sun::star::beans::XPropertyChangeListener,
91 : public ::com::sun::star::awt::XWindowListener,
92 : public ::com::sun::star::awt::XFocusListener
93 : ,public ::com::sun::star::accessibility::XAccessibleExtendedAttributes
94 : ,public com::sun::star::accessibility::XAccessibleGetAccFlowTo
95 : {
96 : public:
97 : //===== internal ========================================================
98 :
99 : /** Create a new object. Note that the caller has to call the
100 : Init method directly after this constructor has finished.
101 : @param pSdWindow
102 : The window whose content is to be made accessible.
103 : @param pViewShell
104 : The view shell associated with the given window.
105 : @param rxController
106 : The controller from which to get the model.
107 : @param rxParent
108 : The accessible parent of the new object. Note that this parent does
109 : not necessarily correspond with the parent of the given window.
110 : */
111 : AccessibleDocumentViewBase (
112 : ::sd::Window* pSdWindow,
113 : ::sd::ViewShell* pViewShell,
114 : const ::com::sun::star::uno::Reference<
115 : ::com::sun::star::frame::XController>& rxController,
116 : const ::com::sun::star::uno::Reference<
117 : ::com::sun::star::accessibility::XAccessible>& rxParent);
118 :
119 : virtual ~AccessibleDocumentViewBase (void);
120 :
121 : /** Initialize a new object. Call this method directly after creating a
122 : new object. It finished the initialization begun in the constructor
123 : but which needs a fully created object.
124 : */
125 : virtual void Init (void);
126 :
127 : /** Define callback for listening to window child events of VCL.
128 : Listen for creation or destruction of OLE objects.
129 : */
130 : DECL_LINK (WindowChildEventListener, VclSimpleEvent*);
131 :
132 : //===== IAccessibleViewForwarderListener ================================
133 :
134 : /** A view forwarder change is signalled for instance when any of the
135 : window events is received. Thus, instead of overloading the four
136 : windowResized... methods it will be sufficient in most cases just to
137 : overload this method.
138 : */
139 : virtual void ViewForwarderChanged (ChangeType aChangeType,
140 : const IAccessibleViewForwarder* pViewForwarder) SAL_OVERRIDE;
141 :
142 : //===== XAccessibleContext ==============================================
143 :
144 : virtual ::com::sun::star::uno::Reference<
145 : ::com::sun::star::accessibility::XAccessible> SAL_CALL
146 : getAccessibleParent (void)
147 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 :
149 : /** This implementation returns either 1 or 0 depending on whether there
150 : is an active accessible OLE object or not.
151 : */
152 : virtual sal_Int32 SAL_CALL
153 : getAccessibleChildCount (void)
154 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
155 :
156 : /** This implementation either returns the active accessible OLE object
157 : if it exists and the given index is 0 or throws an exception.
158 : */
159 : virtual ::com::sun::star::uno::Reference<
160 : ::com::sun::star::accessibility::XAccessible> SAL_CALL
161 : getAccessibleChild (sal_Int32 nIndex)
162 : throw (::com::sun::star::uno::RuntimeException,
163 : ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
164 :
165 : //===== XAccessibleComponent ============================================
166 :
167 : virtual ::com::sun::star::uno::Reference<
168 : ::com::sun::star::accessibility::XAccessible > SAL_CALL
169 : getAccessibleAtPoint (const ::com::sun::star::awt::Point& aPoint)
170 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
171 :
172 : virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void)
173 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 :
175 : virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void)
176 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 :
178 : virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void)
179 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 :
181 : virtual ::com::sun::star::awt::Size SAL_CALL getSize (void)
182 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
183 :
184 : //===== XInterface ======================================================
185 :
186 : virtual com::sun::star::uno::Any SAL_CALL
187 : queryInterface (const com::sun::star::uno::Type & rType)
188 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 :
190 : virtual void SAL_CALL
191 : acquire (void)
192 : throw () SAL_OVERRIDE;
193 :
194 : virtual void SAL_CALL
195 : release (void)
196 : throw () SAL_OVERRIDE;
197 :
198 : //===== XServiceInfo ====================================================
199 :
200 : /** Returns an identifier for the implementation of this object.
201 : */
202 : virtual OUString SAL_CALL
203 : getImplementationName (void)
204 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
205 :
206 : virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL
207 : getSupportedServiceNames (void)
208 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
209 :
210 : //===== XTypeProvider ===================================================
211 :
212 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL
213 : getTypes (void)
214 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
215 :
216 : //===== lang::XEventListener ============================================
217 :
218 : virtual void SAL_CALL
219 : disposing (const ::com::sun::star::lang::EventObject& rEventObject)
220 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
221 :
222 : //===== XPropertyChangeListener =========================================
223 :
224 : virtual void SAL_CALL
225 : propertyChange (const ::com::sun::star::beans::PropertyChangeEvent& rEventObject)
226 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
227 :
228 : //===== XWindowListener =================================================
229 :
230 : virtual void SAL_CALL
231 : windowResized (const ::com::sun::star::awt::WindowEvent& e)
232 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
233 :
234 : virtual void SAL_CALL
235 : windowMoved (const ::com::sun::star::awt::WindowEvent& e)
236 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
237 :
238 : virtual void SAL_CALL
239 : windowShown (const ::com::sun::star::lang::EventObject& e)
240 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
241 :
242 : virtual void SAL_CALL
243 : windowHidden (const ::com::sun::star::lang::EventObject& e)
244 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
245 :
246 : //===== XFocusListener =================================================
247 :
248 : virtual void SAL_CALL focusGained (const ::com::sun::star::awt::FocusEvent& e)
249 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
250 : virtual void SAL_CALL focusLost (const ::com::sun::star::awt::FocusEvent& e)
251 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
252 : //----------------------------xAttribute----------------------------
253 : virtual com::sun::star::uno::Any SAL_CALL getExtendedAttributes()
254 : throw (::com::sun::star::lang::IndexOutOfBoundsException,
255 : ::com::sun::star::uno::RuntimeException,
256 : std::exception) SAL_OVERRIDE;
257 : ::sd::ViewShell* mpViewShell;
258 : private:
259 :
260 : // return the member maMutex;
261 : virtual ::osl::Mutex&
262 : implGetMutex() SAL_OVERRIDE;
263 :
264 : // return ourself as context in default case
265 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
266 : implGetAccessibleContext()
267 : throw ( ::com::sun::star::uno::RuntimeException ) SAL_OVERRIDE;
268 :
269 : // return sal_False in default case
270 : virtual bool
271 : implIsSelected( sal_Int32 nAccessibleChildIndex )
272 : throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
273 :
274 : // return nothing in default case
275 : virtual void
276 : implSelect( sal_Int32 nAccessibleChildIndex, bool bSelect )
277 : throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
278 :
279 : protected:
280 : /// The core window that is made accessible.
281 : ::sd::Window* mpWindow;
282 :
283 : /// The API window that is made accessible.
284 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>
285 : mxWindow;
286 :
287 : /// The controller of the window in which this view is displayed.
288 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>
289 : mxController;
290 :
291 : /// Model of the document.
292 : ::com::sun::star::uno::Reference < ::com::sun::star::frame::XModel>
293 : mxModel;
294 :
295 : // Bundle of information that is passed down the shape tree.
296 : AccessibleShapeTreeInfo maShapeTreeInfo;
297 :
298 : /// The view forwarder passed to the children manager.
299 : AccessibleViewForwarder maViewForwarder;
300 :
301 : /** Accessible OLE object. Set or removed by the
302 : <member>SetAccessibleOLEObject</member> method.
303 : */
304 : ::com::sun::star::uno::Reference <
305 : ::com::sun::star::accessibility::XAccessible>
306 : mxAccessibleOLEObject;
307 :
308 : Link maWindowLink;
309 :
310 : // This method is called from the component helper base class while
311 : // disposing.
312 : virtual void SAL_CALL disposing (void) SAL_OVERRIDE;
313 :
314 : /** Create a name string. The current name is not modified and,
315 : therefore, no events are send. This method is usually called once
316 : by the <member>getAccessibleName</member> method of the base class.
317 : @return
318 : A name string.
319 : */
320 : virtual OUString
321 : CreateAccessibleName ()
322 : throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
323 :
324 : /** Create a description string. The current description is not
325 : modified and, therefore, no events are send. This method is usually
326 : called once by the <member>getAccessibleDescription</member> method
327 : of the base class.
328 : @return
329 : A description string.
330 : */
331 : virtual OUString
332 : CreateAccessibleDescription ()
333 : throw (::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
334 :
335 : /** This method is called when (after) the frame containing this
336 : document has been activated. Can be used to send FOCUSED state
337 : changes for the currently selected element.
338 :
339 : Note: Currently used as a substitute for FocusGained. Should be
340 : renamed in the future.
341 : */
342 : virtual void Activated (void);
343 :
344 : /** This method is called when (before or after?) the frame containing
345 : this document has been deactivated. Can be used to send FOCUSED
346 : state changes for the currently selected element.
347 :
348 : Note: Currently used as a substitute for FocusLost. Should be
349 : renamed in the future.
350 : */
351 : virtual void Deactivated (void);
352 :
353 : /** Set or remove the currently active accessible OLE object.
354 : @param xOLEObject
355 : If this is a valid reference then a child event is send that
356 : informs the listeners of a new child. If there has already been
357 : an active accessible OLE object then this is removed first and
358 : appropriate events are send.
359 :
360 : If this is an empty reference then the currently active
361 : accessible OLE object (if there is one) is removed.
362 : */
363 : virtual void SetAccessibleOLEObject (
364 : const ::com::sun::star::uno::Reference <
365 : ::com::sun::star::accessibility::XAccessible>& xOLEObject);
366 : //===== XAccessibleGetAccFromXShape ============================================
367 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
368 : SAL_CALL getAccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType)
369 : throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
370 :
371 : public:
372 0 : virtual void SwitchViewActivated (void) { Activated(); }
373 : virtual sal_Int32 SAL_CALL getForeground( )
374 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
375 :
376 : virtual sal_Int32 SAL_CALL getBackground( )
377 : throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
378 : virtual void impl_dispose (void);
379 : };
380 :
381 : } // end of namespace accessibility
382 :
383 : #endif
384 :
385 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|