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_SD_SOURCE_UI_INC_ACCESSIBLEDOCUMENTVIEWBASE_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_ACCESSIBLEDOCUMENTVIEWBASE_HXX
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>
37 #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
38 #include "DrawViewShell.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>
53 namespace accessibility
{
55 /** Base class for the various document views of the Draw and
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
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>
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
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
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
97 //===== internal ========================================================
99 /** Create a new object. Note that the caller has to call the
100 Init method directly after this constructor has finished.
102 The window whose content is to be made accessible.
104 The view shell associated with the given window.
106 The controller from which to get the model.
108 The accessible parent of the new object. Note that this parent does
109 not necessarily correspond with the parent of the given window.
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
);
119 virtual ~AccessibleDocumentViewBase();
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.
127 /** Define callback for listening to window child events of VCL.
128 Listen for creation or destruction of OLE objects.
130 DECL_LINK (WindowChildEventListener
, VclSimpleEvent
*);
132 //===== IAccessibleViewForwarderListener ================================
134 /** A view forwarder change is signalled for instance when any of the
135 window events is received. Thus, instead of overriding the four
136 windowResized... methods it will be sufficient in most cases just to
137 override this method.
139 virtual void ViewForwarderChanged (ChangeType aChangeType
,
140 const IAccessibleViewForwarder
* pViewForwarder
) SAL_OVERRIDE
;
142 //===== XAccessibleContext ==============================================
144 virtual ::com::sun::star::uno::Reference
<
145 ::com::sun::star::accessibility::XAccessible
> SAL_CALL
146 getAccessibleParent()
147 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
149 /** This implementation returns either 1 or 0 depending on whether there
150 is an active accessible OLE object or not.
152 virtual sal_Int32 SAL_CALL
153 getAccessibleChildCount()
154 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
156 /** This implementation either returns the active accessible OLE object
157 if it exists and the given index is 0 or throws an exception.
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
;
165 //===== XAccessibleComponent ============================================
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
;
172 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds()
173 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
175 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation()
176 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
178 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen()
179 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
181 virtual ::com::sun::star::awt::Size SAL_CALL
getSize()
182 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
184 //===== XInterface ======================================================
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
;
190 virtual void SAL_CALL
192 throw () SAL_OVERRIDE
;
194 virtual void SAL_CALL
196 throw () SAL_OVERRIDE
;
198 //===== XServiceInfo ====================================================
200 /** Returns an identifier for the implementation of this object.
202 virtual OUString SAL_CALL
203 getImplementationName()
204 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
206 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
207 getSupportedServiceNames()
208 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
210 //===== XTypeProvider ===================================================
212 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
214 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
216 //===== lang::XEventListener ============================================
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
;
222 //===== XPropertyChangeListener =========================================
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
;
228 //===== XWindowListener =================================================
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
;
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
;
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
;
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
;
246 //===== XFocusListener =================================================
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
;
260 // return the member maMutex;
261 virtual ::osl::Mutex
&
262 implGetMutex() SAL_OVERRIDE
;
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
;
269 // return sal_False in default case
271 implIsSelected( sal_Int32 nAccessibleChildIndex
)
272 throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
274 // return nothing in default case
276 implSelect( sal_Int32 nAccessibleChildIndex
, bool bSelect
)
277 throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
280 /// The core window that is made accessible.
281 VclPtr
< ::sd::Window
> mpWindow
;
283 /// The API window that is made accessible.
284 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
287 /// The controller of the window in which this view is displayed.
288 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>
291 /// Model of the document.
292 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>
295 // Bundle of information that is passed down the shape tree.
296 AccessibleShapeTreeInfo maShapeTreeInfo
;
298 /// The view forwarder passed to the children manager.
299 AccessibleViewForwarder maViewForwarder
;
301 /** Accessible OLE object. Set or removed by the
302 <member>SetAccessibleOLEObject</member> method.
304 ::com::sun::star::uno::Reference
<
305 ::com::sun::star::accessibility::XAccessible
>
306 mxAccessibleOLEObject
;
310 // This method is called from the component helper base class while
312 virtual void SAL_CALL
disposing() SAL_OVERRIDE
;
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.
321 CreateAccessibleName ()
322 throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
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
329 A description string.
332 CreateAccessibleDescription ()
333 throw (::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
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.
339 Note: Currently used as a substitute for FocusGained. Should be
340 renamed in the future.
342 virtual void Activated();
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.
348 Note: Currently used as a substitute for FocusLost. Should be
349 renamed in the future.
351 virtual void Deactivated();
353 /** Set or remove the currently active accessible OLE object.
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.
360 If this is an empty reference then the currently active
361 accessible OLE object (if there is one) is removed.
363 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
;
372 void SwitchViewActivated() { Activated(); }
373 virtual sal_Int32 SAL_CALL
getForeground( )
374 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
376 virtual sal_Int32 SAL_CALL
getBackground( )
377 throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
378 virtual void impl_dispose();
381 } // end of namespace accessibility
385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */