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