bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / inc / AccessibleDocumentViewBase.hxx
blobee2acf119ce48fb81c904706a3bbe4c4e3354787
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <svx/AccessibleShapeTreeInfo.hxx>
28 #include <svx/IAccessibleViewForwarderListener.hxx>
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 <tools/link.hxx>
35 #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
36 #include <com/sun/star/accessibility/XAccessibleGetAccFlowTo.hpp>
38 #include "Window.hxx"
40 namespace com { namespace sun { namespace star { namespace accessibility { class XAccessible; } } } }
41 namespace com { namespace sun { namespace star { namespace frame { class XModel; } } } }
42 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
44 class VclWindowEvent;
46 namespace sd {
47 class ViewShell;
50 namespace accessibility {
52 /** Base class for the various document views of the Draw and
53 Impress applications.
55 <p>The different view modes of the Draw and Impress applications
56 are made accessible by derived classes. When the view mode is
57 changed then the object representing the document view is
58 disposed and replaced by a new instance of the then appropriate
59 derived class.</p>
61 <p>This base class also manages an optionally active accessible OLE
62 object. If you overwrite the <member>getAccessibleChildCount</member>
63 and <member>getAccessibleChild</member> methods then make sure to first
64 call the corresponding method of this class and adapt your child count
65 and indices accordingly. Only one active OLE object is allowed at a
66 time. This class does not listen for disposing calls at the moment
67 because it does not use the accessible OLE object directly and trusts on
68 getting informed through VCL window events.</p>
70 <p>This class implements three kinds of listeners:
71 <ol><li>The property change listener is not used directly but exists as
72 convenience for derived classes. May be moved to those classes
73 instead.</li>
74 <li>As window listener it waits for changes of the window geometry and
75 forwards those as view forwarder changes.</li>
76 <li>As focus listener it keeps track of the focus to give this class and
77 derived classes the opportunity to set and remove the focus to/from
78 shapes.</li>
79 </ol>
80 </p>
82 class AccessibleDocumentViewBase
83 : public AccessibleContextBase,
84 public AccessibleComponentBase,
85 public AccessibleSelectionBase,
86 public IAccessibleViewForwarderListener,
87 public css::beans::XPropertyChangeListener,
88 public css::awt::XWindowListener,
89 public css::awt::XFocusListener,
90 public css::accessibility::XAccessibleExtendedAttributes,
91 public css::accessibility::XAccessibleGetAccFlowTo
93 public:
94 //===== internal ========================================================
96 /** Create a new object. Note that the caller has to call the
97 Init method directly after this constructor has finished.
98 @param pSdWindow
99 The window whose content is to be made accessible.
100 @param pViewShell
101 The view shell associated with the given window.
102 @param rxController
103 The controller from which to get the model.
104 @param rxParent
105 The accessible parent of the new object. Note that this parent does
106 not necessarily correspond with the parent of the given window.
108 AccessibleDocumentViewBase (
109 ::sd::Window* pSdWindow,
110 ::sd::ViewShell* pViewShell,
111 const css::uno::Reference<css::frame::XController>& rxController,
112 const css::uno::Reference<css::accessibility::XAccessible>& rxParent);
114 virtual ~AccessibleDocumentViewBase() override;
116 /** Initialize a new object. Call this method directly after creating a
117 new object. It finished the initialization begun in the constructor
118 but which needs a fully created object.
120 virtual void Init();
122 /** Define callback for listening to window child events of VCL.
123 Listen for creation or destruction of OLE objects.
125 DECL_LINK( WindowChildEventListener, VclWindowEvent&, void );
127 //===== IAccessibleViewForwarderListener ================================
129 /** A view forwarder change is signalled for instance when any of the
130 window events is received. Thus, instead of overriding the four
131 windowResized... methods it will be sufficient in most cases just to
132 override this method.
134 virtual void ViewForwarderChanged() override;
136 //===== XAccessibleContext ==============================================
138 virtual css::uno::Reference<css::accessibility::XAccessible> SAL_CALL
139 getAccessibleParent() override;
141 /** This implementation returns either 1 or 0 depending on whether there
142 is an active accessible OLE object or not.
144 virtual sal_Int32 SAL_CALL
145 getAccessibleChildCount() override;
147 /** This implementation either returns the active accessible OLE object
148 if it exists and the given index is 0 or throws an exception.
150 virtual css::uno::Reference<css::accessibility::XAccessible> SAL_CALL
151 getAccessibleChild (sal_Int32 nIndex) override;
153 //===== XAccessibleComponent ============================================
155 virtual css::uno::Reference<css::accessibility::XAccessible > SAL_CALL
156 getAccessibleAtPoint (const css::awt::Point& aPoint) override;
158 virtual css::awt::Rectangle SAL_CALL getBounds() override;
160 virtual css::awt::Point SAL_CALL getLocation() override;
162 virtual css::awt::Point SAL_CALL getLocationOnScreen() override;
164 virtual css::awt::Size SAL_CALL getSize() override;
166 //===== XInterface ======================================================
168 virtual css::uno::Any SAL_CALL
169 queryInterface (const css::uno::Type & rType) override;
171 virtual void SAL_CALL
172 acquire()
173 throw () override;
175 virtual void SAL_CALL
176 release()
177 throw () override;
179 //===== XServiceInfo ====================================================
181 /** Returns an identifier for the implementation of this object.
183 virtual OUString SAL_CALL
184 getImplementationName() override;
186 virtual css::uno::Sequence< OUString> SAL_CALL
187 getSupportedServiceNames() override;
189 //===== XTypeProvider ===================================================
191 virtual css::uno::Sequence< css::uno::Type> SAL_CALL
192 getTypes() override;
194 //===== lang::XEventListener ============================================
196 virtual void SAL_CALL
197 disposing (const css::lang::EventObject& rEventObject) override;
199 //===== XPropertyChangeListener =========================================
201 virtual void SAL_CALL
202 propertyChange (const css::beans::PropertyChangeEvent& rEventObject) override;
204 //===== XWindowListener =================================================
206 virtual void SAL_CALL
207 windowResized (const css::awt::WindowEvent& e) override;
209 virtual void SAL_CALL
210 windowMoved (const css::awt::WindowEvent& e) override;
212 virtual void SAL_CALL
213 windowShown (const css::lang::EventObject& e) override;
215 virtual void SAL_CALL
216 windowHidden (const css::lang::EventObject& e) override;
218 //===== XFocusListener =================================================
220 virtual void SAL_CALL focusGained (const css::awt::FocusEvent& e) override;
221 virtual void SAL_CALL focusLost (const css::awt::FocusEvent& e) override;
222 //----------------------------xAttribute----------------------------
223 virtual css::uno::Any SAL_CALL getExtendedAttributes() override;
224 ::sd::ViewShell* mpViewShell;
225 private:
227 // return the member maMutex;
228 virtual ::osl::Mutex&
229 implGetMutex() override;
231 // return ourself as context in default case
232 virtual css::uno::Reference< css::accessibility::XAccessibleContext >
233 implGetAccessibleContext() override;
235 // return sal_False in default case
236 virtual bool
237 implIsSelected( sal_Int32 nAccessibleChildIndex ) override;
239 // return nothing in default case
240 virtual void
241 implSelect( sal_Int32 nAccessibleChildIndex, bool bSelect ) override;
243 protected:
244 /// The core window that is made accessible.
245 VclPtr< ::sd::Window> mpWindow;
247 /// The API window that is made accessible.
248 css::uno::Reference< css::awt::XWindow>
249 mxWindow;
251 /// The controller of the window in which this view is displayed.
252 css::uno::Reference< css::frame::XController>
253 mxController;
255 /// Model of the document.
256 css::uno::Reference < css::frame::XModel>
257 mxModel;
259 // Bundle of information that is passed down the shape tree.
260 AccessibleShapeTreeInfo maShapeTreeInfo;
262 /// The view forwarder passed to the children manager.
263 AccessibleViewForwarder maViewForwarder;
265 /** Accessible OLE object. Set or removed by the
266 <member>SetAccessibleOLEObject</member> method.
268 css::uno::Reference< css::accessibility::XAccessible>
269 mxAccessibleOLEObject;
271 Link<VclWindowEvent&,void> maWindowLink;
273 // This method is called from the component helper base class while
274 // disposing.
275 virtual void SAL_CALL disposing() override;
277 /** Create a name string. The current name is not modified and,
278 therefore, no events are send. This method is usually called once
279 by the <member>getAccessibleName</member> method of the base class.
280 @return
281 A name string.
283 virtual OUString
284 CreateAccessibleName () override;
286 /** This method is called when (after) the frame containing this
287 document has been activated. Can be used to send FOCUSED state
288 changes for the currently selected element.
290 Note: Currently used as a substitute for FocusGained. Should be
291 renamed in the future.
293 virtual void Activated();
295 /** This method is called when (before or after?) the frame containing
296 this document has been deactivated. Can be used to send FOCUSED
297 state changes for the currently selected element.
299 Note: Currently used as a substitute for FocusLost. Should be
300 renamed in the future.
302 virtual void Deactivated();
304 /** Set or remove the currently active accessible OLE object.
305 @param xOLEObject
306 If this is a valid reference then a child event is send that
307 informs the listeners of a new child. If there has already been
308 an active accessible OLE object then this is removed first and
309 appropriate events are send.
311 If this is an empty reference then the currently active
312 accessible OLE object (if there is one) is removed.
314 void SetAccessibleOLEObject (
315 const css::uno::Reference<css::accessibility::XAccessible>& xOLEObject);
316 //===== XAccessibleGetAccFromXShape ============================================
317 css::uno::Sequence< css::uno::Any >
318 SAL_CALL getAccFlowTo(const css::uno::Any& rAny, sal_Int32 nType) override;
320 public:
321 void SwitchViewActivated() { Activated(); }
322 virtual sal_Int32 SAL_CALL getForeground( ) override;
324 virtual sal_Int32 SAL_CALL getBackground( ) override;
325 virtual void impl_dispose();
328 } // end of namespace accessibility
330 #endif
332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */