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 SD_ACCESSIBILITY_ACCESSIBLE_DOCUMENT_VIEW_BASE_HXX
21 #define SD_ACCESSIBILITY_ACCESSIBLE_DOCUMENT_VIEW_BASE_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>
44 namespace accessibility
{
47 /** Base class for the various document views of the Draw and
50 <p>The different view modes of the Draw and Impress applications
51 are made accessible by derived classes. When the view mode is
52 changed than the object representing the document view is
53 disposed and replaced by a new instance of the then appropriate
56 <p>This base class also manages an optionally active accessible OLE
57 object. If you overwrite the <member>getAccessibleChildCount</member>
58 and <member>getAccessibleChild</member> methods then make sure to first
59 call the corresponding method of this class and adapt your child count
60 and indices accordingly. Only one active OLE object is allowed at a
61 time. This class does not listen for disposing calls at the moment
62 because it does not use the accessible OLE object directly and trusts on
63 getting informed through VCL window events.</p>
65 <p>This class implements three kinds of listeners:
66 <ol><li>The property change listener is not used directly but exists as
67 convenience for derived classes. May be moved to those classes
69 <li>As window listener it waits for changes of the window geometry and
70 forwards those as view forwarder changes.</li>
71 <li>As focus listener it keeps track of the focus to give this class and
72 derived classes the oportunity to set and remove the focus to/from
77 class AccessibleDocumentViewBase
78 : public AccessibleContextBase
,
79 public AccessibleComponentBase
,
80 public AccessibleSelectionBase
,
81 public IAccessibleViewForwarderListener
,
82 public ::com::sun::star::beans::XPropertyChangeListener
,
83 public ::com::sun::star::awt::XWindowListener
,
84 public ::com::sun::star::awt::XFocusListener
87 //===== internal ========================================================
89 /** Create a new object. Note that the caller has to call the
90 Init method directly after this constructor has finished.
92 The window whose content is to be made accessible.
94 The view shell associated with the given window.
96 The controller from which to get the model.
98 The accessible parent of the new object. Note that this parent does
99 not necessarily correspond with the parent of the given window.
101 AccessibleDocumentViewBase (
102 ::sd::Window
* pSdWindow
,
103 ::sd::ViewShell
* pViewShell
,
104 const ::com::sun::star::uno::Reference
<
105 ::com::sun::star::frame::XController
>& rxController
,
106 const ::com::sun::star::uno::Reference
<
107 ::com::sun::star::accessibility::XAccessible
>& rxParent
);
109 virtual ~AccessibleDocumentViewBase (void);
111 /** Initialize a new object. Call this method directly after creating a
112 new object. It finished the initialization begun in the constructor
113 but which needs a fully created object.
115 virtual void Init (void);
117 /** Define callback for listening to window child events of VCL.
118 Listen for creation or destruction of OLE objects.
120 DECL_LINK (WindowChildEventListener
, VclSimpleEvent
*);
122 //===== IAccessibleViewForwarderListener ================================
124 /** A view forwarder change is signalled for instance when any of the
125 window events is received. Thus, instead of overloading the four
126 windowResized... methods it will be sufficient in most cases just to
127 overload this method.
129 virtual void ViewForwarderChanged (ChangeType aChangeType
,
130 const IAccessibleViewForwarder
* pViewForwarder
);
132 //===== XAccessibleContext ==============================================
134 virtual ::com::sun::star::uno::Reference
<
135 ::com::sun::star::accessibility::XAccessible
> SAL_CALL
136 getAccessibleParent (void)
137 throw (::com::sun::star::uno::RuntimeException
);
139 /** This implementation returns either 1 or 0 depending on whether there
140 is an active accessible OLE object or not.
142 virtual sal_Int32 SAL_CALL
143 getAccessibleChildCount (void)
144 throw (::com::sun::star::uno::RuntimeException
);
146 /** This implementation either returns the active accessible OLE object
147 if it exists and the given index is 0 or throws an exception.
149 virtual ::com::sun::star::uno::Reference
<
150 ::com::sun::star::accessibility::XAccessible
> SAL_CALL
151 getAccessibleChild (sal_Int32 nIndex
)
152 throw (::com::sun::star::uno::RuntimeException
,
153 ::com::sun::star::lang::IndexOutOfBoundsException
);
156 //===== XAccessibleComponent ============================================
158 virtual ::com::sun::star::uno::Reference
<
159 ::com::sun::star::accessibility::XAccessible
> SAL_CALL
160 getAccessibleAtPoint (const ::com::sun::star::awt::Point
& aPoint
)
161 throw (::com::sun::star::uno::RuntimeException
);
163 virtual ::com::sun::star::awt::Rectangle SAL_CALL
getBounds (void)
164 throw (::com::sun::star::uno::RuntimeException
);
166 virtual ::com::sun::star::awt::Point SAL_CALL
getLocation (void)
167 throw (::com::sun::star::uno::RuntimeException
);
169 virtual ::com::sun::star::awt::Point SAL_CALL
getLocationOnScreen (void)
170 throw (::com::sun::star::uno::RuntimeException
);
172 virtual ::com::sun::star::awt::Size SAL_CALL
getSize (void)
173 throw (::com::sun::star::uno::RuntimeException
);
176 //===== XInterface ======================================================
178 virtual com::sun::star::uno::Any SAL_CALL
179 queryInterface (const com::sun::star::uno::Type
& rType
)
180 throw (::com::sun::star::uno::RuntimeException
);
182 virtual void SAL_CALL
186 virtual void SAL_CALL
191 //===== XServiceInfo ====================================================
193 /** Returns an identifier for the implementation of this object.
195 virtual OUString SAL_CALL
196 getImplementationName (void)
197 throw (::com::sun::star::uno::RuntimeException
);
199 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
200 getSupportedServiceNames (void)
201 throw (::com::sun::star::uno::RuntimeException
);
204 //===== XTypeProvider ===================================================
206 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
208 throw (::com::sun::star::uno::RuntimeException
);
211 //===== lang::XEventListener ============================================
213 virtual void SAL_CALL
214 disposing (const ::com::sun::star::lang::EventObject
& rEventObject
)
215 throw (::com::sun::star::uno::RuntimeException
);
218 //===== XPropertyChangeListener =========================================
220 virtual void SAL_CALL
221 propertyChange (const ::com::sun::star::beans::PropertyChangeEvent
& rEventObject
)
222 throw (::com::sun::star::uno::RuntimeException
);
225 //===== XWindowListener =================================================
227 virtual void SAL_CALL
228 windowResized (const ::com::sun::star::awt::WindowEvent
& e
)
229 throw (::com::sun::star::uno::RuntimeException
);
231 virtual void SAL_CALL
232 windowMoved (const ::com::sun::star::awt::WindowEvent
& e
)
233 throw (::com::sun::star::uno::RuntimeException
);
235 virtual void SAL_CALL
236 windowShown (const ::com::sun::star::lang::EventObject
& e
)
237 throw (::com::sun::star::uno::RuntimeException
);
239 virtual void SAL_CALL
240 windowHidden (const ::com::sun::star::lang::EventObject
& e
)
241 throw (::com::sun::star::uno::RuntimeException
);
243 //===== XFocusListener =================================================
245 virtual void SAL_CALL
focusGained (const ::com::sun::star::awt::FocusEvent
& e
)
246 throw (::com::sun::star::uno::RuntimeException
);
247 virtual void SAL_CALL
focusLost (const ::com::sun::star::awt::FocusEvent
& e
)
248 throw (::com::sun::star::uno::RuntimeException
);
252 // return the member maMutex;
253 virtual ::osl::Mutex
&
256 // return ourself as context in default case
257 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
>
258 implGetAccessibleContext()
259 throw ( ::com::sun::star::uno::RuntimeException
);
261 // return sal_False in default case
263 implIsSelected( sal_Int32 nAccessibleChildIndex
)
264 throw (::com::sun::star::uno::RuntimeException
);
266 // return nothing in default case
268 implSelect( sal_Int32 nAccessibleChildIndex
, sal_Bool bSelect
)
269 throw (::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
272 /// The core window that is made accessible.
273 ::sd::Window
* mpWindow
;
275 /// The API window that is made accessible.
276 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
>
279 /// The controller of the window in which this view is displayed.
280 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XController
>
283 /// Model of the document.
284 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>
287 // Bundle of information that is passed down the shape tree.
288 AccessibleShapeTreeInfo maShapeTreeInfo
;
290 /// The view forwarder passed to the children manager.
291 AccessibleViewForwarder maViewForwarder
;
293 /** Accessible OLE object. Set or removed by the
294 <member>SetAccessibleOLEObject</member> method.
296 ::com::sun::star::uno::Reference
<
297 ::com::sun::star::accessibility::XAccessible
>
298 mxAccessibleOLEObject
;
302 // This method is called from the component helper base class while
304 virtual void SAL_CALL
disposing (void);
306 /** Create a name string. The current name is not modified and,
307 therefore, no events are send. This method is usually called once
308 by the <member>getAccessibleName</member> method of the base class.
313 CreateAccessibleName ()
314 throw (::com::sun::star::uno::RuntimeException
);
316 /** Create a description string. The current description is not
317 modified and, therefore, no events are send. This method is usually
318 called once by the <member>getAccessibleDescription</member> method
321 A description string.
324 CreateAccessibleDescription ()
325 throw (::com::sun::star::uno::RuntimeException
);
327 /** This method is called when (after) the frame containing this
328 document has been activated. Can be used to send FOCUSED state
329 changes for the currently selected element.
331 Note: Currently used as a substitute for FocusGained. Should be
332 renamed in the future.
334 virtual void Activated (void);
336 /** This method is called when (before or after?) the frame containing
337 this document has been deactivated. Can be used to send FOCUSED
338 state changes for the currently selected element.
340 Note: Currently used as a substitute for FocusLost. Should be
341 renamed in the future.
343 virtual void Deactivated (void);
345 /** Set or remove the currently active accessible OLE object.
347 If this is a valid reference then a child event is send that
348 informs the listeners of a new child. If there has already been
349 an active accessible OLE object then this is removed first and
350 appropriate events are send.
352 If this is an empty reference then the currently active
353 accessible OLE object (if there is one) is removed.
355 virtual void SetAccessibleOLEObject (
356 const ::com::sun::star::uno::Reference
<
357 ::com::sun::star::accessibility::XAccessible
>& xOLEObject
);
359 virtual void impl_dispose (void);
362 } // end of namespace accessibility
366 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */