1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleDocumentViewBase.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_ACCESSIBILITY_ACCESSIBLE_DOCUMENT_VIEW_BASE_HXX
32 #define SD_ACCESSIBILITY_ACCESSIBLE_DOCUMENT_VIEW_BASE_HXX
34 #include <svx/AccessibleContextBase.hxx>
35 #include <svx/AccessibleComponentBase.hxx>
36 #include <svx/AccessibleSelectionBase.hxx>
37 #include "AccessibleViewForwarder.hxx"
38 #include "AccessiblePageShape.hxx"
39 #include <svx/ChildrenManager.hxx>
40 #include <com/sun/star/frame/XModel.hpp>
41 #include <com/sun/star/awt/XWindowListener.hpp>
42 #include <com/sun/star/awt/XFocusListener.hpp>
43 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
44 #include <com/sun/star/accessibility/XAccessible.hpp>
45 #include <tools/link.hxx>
54 namespace accessibility
{
57 /** Base class for the various document views of the Draw and
60 <p>The different view modes of the Draw and Impress applications
61 are made accessible by derived classes. When the view mode is
62 changed than the object representing the document view is
63 disposed and replaced by a new instance of the then appropriate
66 <p>This base class also manages an optionally active accessible OLE
67 object. If you overwrite the <member>getAccessibleChildCount</member>
68 and <member>getAccessibleChild</member> methods then make sure to first
69 call the corresponding method of this class and adapt your child count
70 and indices accordingly. Only one active OLE object is allowed at a
71 time. This class does not listen for disposing calls at the moment
72 because it does not use the accessible OLE object directly and trusts on
73 getting informed through VCL window events.</p>
75 <p>This class implements three kinds of listeners:
76 <ol><li>The property change listener is not used directly but exists as
77 convenience for derived classes. May be moved to those classes
79 <li>As window listener it waits for changes of the window geometry and
80 forwards those as view forwarder changes.</li>
81 <li>As focus listener it keeps track of the focus to give this class and
82 derived classes the oportunity to set and remove the focus to/from
87 class AccessibleDocumentViewBase
88 : public AccessibleContextBase
,
89 public AccessibleComponentBase
,
90 public AccessibleSelectionBase
,
91 public IAccessibleViewForwarderListener
,
92 public ::com::sun::star::beans::XPropertyChangeListener
,
93 public ::com::sun::star::awt::XWindowListener
,
94 public ::com::sun::star::awt::XFocusListener
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 (void);
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.
125 virtual void Init (void);
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 recieved. Thus, instead of overloading the four
136 windowResized... methods it will be sufficient in most cases just to
137 overload this method.
139 virtual void ViewForwarderChanged (ChangeType aChangeType
,
140 const IAccessibleViewForwarder
* pViewForwarder
);
142 //===== XAccessibleContext ==============================================
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
);
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 (void)
154 throw (::com::sun::star::uno::RuntimeException
);
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
);
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
);
172 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds (void)
173 throw (::com::sun::star::uno::RuntimeException
);
175 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation (void)
176 throw (::com::sun::star::uno::RuntimeException
);
178 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen (void)
179 throw (::com::sun::star::uno::RuntimeException
);
181 virtual ::com::sun::star::awt::Size SAL_CALL
getSize (void)
182 throw (::com::sun::star::uno::RuntimeException
);
185 //===== XInterface ======================================================
187 virtual com::sun::star::uno::Any SAL_CALL
188 queryInterface (const com::sun::star::uno::Type
& rType
)
189 throw (::com::sun::star::uno::RuntimeException
);
191 virtual void SAL_CALL
195 virtual void SAL_CALL
200 //===== XServiceInfo ====================================================
202 /** Returns an identifier for the implementation of this object.
204 virtual ::rtl::OUString SAL_CALL
205 getImplementationName (void)
206 throw (::com::sun::star::uno::RuntimeException
);
208 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
209 getSupportedServiceNames (void)
210 throw (::com::sun::star::uno::RuntimeException
);
213 //===== XTypeProvider ===================================================
215 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
217 throw (::com::sun::star::uno::RuntimeException
);
220 //===== lang::XEventListener ============================================
222 virtual void SAL_CALL
223 disposing (const ::com::sun::star::lang::EventObject
& rEventObject
)
224 throw (::com::sun::star::uno::RuntimeException
);
227 //===== XPropertyChangeListener =========================================
229 virtual void SAL_CALL
230 propertyChange (const ::com::sun::star::beans::PropertyChangeEvent
& rEventObject
)
231 throw (::com::sun::star::uno::RuntimeException
);
234 //===== XWindowListener =================================================
236 virtual void SAL_CALL
237 windowResized (const ::com::sun::star::awt::WindowEvent
& e
)
238 throw (::com::sun::star::uno::RuntimeException
);
240 virtual void SAL_CALL
241 windowMoved (const ::com::sun::star::awt::WindowEvent
& e
)
242 throw (::com::sun::star::uno::RuntimeException
);
244 virtual void SAL_CALL
245 windowShown (const ::com::sun::star::lang::EventObject
& e
)
246 throw (::com::sun::star::uno::RuntimeException
);
248 virtual void SAL_CALL
249 windowHidden (const ::com::sun::star::lang::EventObject
& e
)
250 throw (::com::sun::star::uno::RuntimeException
);
252 //===== XFocusListener =================================================
254 virtual void SAL_CALL
focusGained (const ::com::sun::star::awt::FocusEvent
& e
)
255 throw (::com::sun::star::uno::RuntimeException
);
256 virtual void SAL_CALL
focusLost (const ::com::sun::star::awt::FocusEvent
& e
)
257 throw (::com::sun::star::uno::RuntimeException
);
261 // return the member maMutex;
262 virtual ::osl::Mutex
&
265 // return ourself as context in default case
266 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
>
267 implGetAccessibleContext()
268 throw ( ::com::sun::star::uno::RuntimeException
);
270 // return sal_False in default case
272 implIsSelected( sal_Int32 nAccessibleChildIndex
)
273 throw (::com::sun::star::uno::RuntimeException
);
275 // return nothing in default case
277 implSelect( sal_Int32 nAccessibleChildIndex
, sal_Bool bSelect
)
278 throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
281 /// The core window that is made accessible.
282 ::sd::Window
* mpWindow
;
284 /// The API window that is made accessible.
285 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
288 /// The controller of the window in which this view is displayed.
289 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>
292 /// Model of the document.
293 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>
296 // Bundle of information that is passed down the shape tree.
297 AccessibleShapeTreeInfo maShapeTreeInfo
;
299 /// The view forwarder passed to the children manager.
300 AccessibleViewForwarder maViewForwarder
;
302 /** Accessible OLE object. Set or removed by the
303 <member>SetAccessibleOLEObject</member> method.
305 ::com::sun::star::uno::Reference
<
306 ::com::sun::star::accessibility::XAccessible
>
307 mxAccessibleOLEObject
;
311 // This method is called from the component helper base class while
313 virtual void SAL_CALL
disposing (void);
315 /** Create a name string. The current name is not modified and,
316 therefore, no events are send. This method is usually called once
317 by the <member>getAccessibleName</member> method of the base class.
321 virtual ::rtl::OUString
322 CreateAccessibleName ()
323 throw (::com::sun::star::uno::RuntimeException
);
325 /** Create a description string. The current description is not
326 modified and, therefore, no events are send. This method is usually
327 called once by the <member>getAccessibleDescription</member> method
330 A description string.
332 virtual ::rtl::OUString
333 CreateAccessibleDescription ()
334 throw (::com::sun::star::uno::RuntimeException
);
336 /** This method is called when (after) the frame containing this
337 document has been activated. Can be used to send FOCUSED state
338 changes for the currently selected element.
340 Note: Currently used as a substitute for FocusGained. Should be
341 renamed in the future.
343 virtual void Activated (void);
345 /** This method is called when (before or after?) the frame containing
346 this document has been deactivated. Can be used to send FOCUSED
347 state changes for the currently selected element.
349 Note: Currently used as a substitute for FocusLost. Should be
350 renamed in the future.
352 virtual void Deactivated (void);
354 /** Set or remove the currently active accessible OLE object.
356 If this is a valid reference then a child event is send that
357 informs the listeners of a new child. If there has already been
358 an active accessible OLE object then this is removed first and
359 appropriate events are send.
361 If this is an empty reference then the currently active
362 accessible OLE object (if there is one) is removed.
364 virtual void SetAccessibleOLEObject (
365 const ::com::sun::star::uno::Reference
<
366 ::com::sun::star::accessibility::XAccessible
>& xOLEObject
);
368 virtual void impl_dispose (void);
371 } // end of namespace accessibility