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