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 oportunity 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 recieved. 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 throw (::com::sun::star::uno::RuntimeException); 153 154 /** This implementation returns either 1 or 0 depending on whether there 155 is an active accessible OLE object or not. 156 */ 157 virtual sal_Int32 SAL_CALL 158 getAccessibleChildCount (void) 159 throw (::com::sun::star::uno::RuntimeException); 160 161 /** This implementation either returns the active accessible OLE object 162 if it exists and the given index is 0 or throws an exception. 163 */ 164 virtual ::com::sun::star::uno::Reference< 165 ::com::sun::star::accessibility::XAccessible> SAL_CALL 166 getAccessibleChild (sal_Int32 nIndex) 167 throw (::com::sun::star::uno::RuntimeException, 168 ::com::sun::star::lang::IndexOutOfBoundsException); 169 170 171 //===== XAccessibleComponent ============================================ 172 173 virtual ::com::sun::star::uno::Reference< 174 ::com::sun::star::accessibility::XAccessible > SAL_CALL 175 getAccessibleAtPoint (const ::com::sun::star::awt::Point& aPoint) 176 throw (::com::sun::star::uno::RuntimeException); 177 178 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void) 179 throw (::com::sun::star::uno::RuntimeException); 180 181 virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void) 182 throw (::com::sun::star::uno::RuntimeException); 183 184 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void) 185 throw (::com::sun::star::uno::RuntimeException); 186 187 virtual ::com::sun::star::awt::Size SAL_CALL getSize (void) 188 throw (::com::sun::star::uno::RuntimeException); 189 190 191 //===== XInterface ====================================================== 192 193 virtual com::sun::star::uno::Any SAL_CALL 194 queryInterface (const com::sun::star::uno::Type & rType) 195 throw (::com::sun::star::uno::RuntimeException); 196 197 virtual void SAL_CALL 198 acquire (void) 199 throw (); 200 201 virtual void SAL_CALL 202 release (void) 203 throw (); 204 205 206 //===== XServiceInfo ==================================================== 207 208 /** Returns an identifier for the implementation of this object. 209 */ 210 virtual ::rtl::OUString SAL_CALL 211 getImplementationName (void) 212 throw (::com::sun::star::uno::RuntimeException); 213 214 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 215 getSupportedServiceNames (void) 216 throw (::com::sun::star::uno::RuntimeException); 217 218 219 //===== XTypeProvider =================================================== 220 221 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL 222 getTypes (void) 223 throw (::com::sun::star::uno::RuntimeException); 224 225 226 //===== lang::XEventListener ============================================ 227 228 virtual void SAL_CALL 229 disposing (const ::com::sun::star::lang::EventObject& rEventObject) 230 throw (::com::sun::star::uno::RuntimeException); 231 232 233 //===== XPropertyChangeListener ========================================= 234 235 virtual void SAL_CALL 236 propertyChange (const ::com::sun::star::beans::PropertyChangeEvent& rEventObject) 237 throw (::com::sun::star::uno::RuntimeException); 238 239 240 //===== XWindowListener ================================================= 241 242 virtual void SAL_CALL 243 windowResized (const ::com::sun::star::awt::WindowEvent& e) 244 throw (::com::sun::star::uno::RuntimeException); 245 246 virtual void SAL_CALL 247 windowMoved (const ::com::sun::star::awt::WindowEvent& e) 248 throw (::com::sun::star::uno::RuntimeException); 249 250 virtual void SAL_CALL 251 windowShown (const ::com::sun::star::lang::EventObject& e) 252 throw (::com::sun::star::uno::RuntimeException); 253 254 virtual void SAL_CALL 255 windowHidden (const ::com::sun::star::lang::EventObject& e) 256 throw (::com::sun::star::uno::RuntimeException); 257 258 //===== XFocusListener ================================================= 259 260 virtual void SAL_CALL focusGained (const ::com::sun::star::awt::FocusEvent& e) 261 throw (::com::sun::star::uno::RuntimeException); 262 virtual void SAL_CALL focusLost (const ::com::sun::star::awt::FocusEvent& e) 263 throw (::com::sun::star::uno::RuntimeException); 264 //----------------------------xAttribute---------------------------- 265 virtual com::sun::star::uno::Any SAL_CALL getExtendedAttributes() 266 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 267 ::sd::ViewShell* mpViewShell; 268 private: 269 270 // return the member maMutex; 271 virtual ::osl::Mutex& 272 implGetMutex(); 273 274 // return ourself as context in default case 275 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > 276 implGetAccessibleContext() 277 throw ( ::com::sun::star::uno::RuntimeException ); 278 279 // return sal_False in default case 280 virtual sal_Bool 281 implIsSelected( sal_Int32 nAccessibleChildIndex ) 282 throw (::com::sun::star::uno::RuntimeException); 283 284 // return nothing in default case 285 virtual void 286 implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) 287 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 288 289 protected: 290 /// The core window that is made accessible. 291 ::sd::Window* mpWindow; 292 293 /// The API window that is made accessible. 294 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> 295 mxWindow; 296 297 /// The controller of the window in which this view is displayed. 298 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController> 299 mxController; 300 301 /// Model of the document. 302 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XModel> 303 mxModel; 304 305 // Bundle of information that is passed down the shape tree. 306 AccessibleShapeTreeInfo maShapeTreeInfo; 307 308 /// The view forwarder passed to the children manager. 309 AccessibleViewForwarder maViewForwarder; 310 311 /** Accessible OLE object. Set or removed by the 312 <member>SetAccessibleOLEObject</member> method. 313 */ 314 ::com::sun::star::uno::Reference < 315 ::com::sun::star::accessibility::XAccessible> 316 mxAccessibleOLEObject; 317 318 Link maWindowLink; 319 320 // This method is called from the component helper base class while 321 // disposing. 322 virtual void SAL_CALL disposing (void); 323 324 /** Create a name string. The current name is not modified and, 325 therefore, no events are send. This method is usually called once 326 by the <member>getAccessibleName</member> method of the base class. 327 @return 328 A name string. 329 */ 330 virtual ::rtl::OUString 331 CreateAccessibleName () 332 throw (::com::sun::star::uno::RuntimeException); 333 334 /** Create a description string. The current description is not 335 modified and, therefore, no events are send. This method is usually 336 called once by the <member>getAccessibleDescription</member> method 337 of the base class. 338 @return 339 A description string. 340 */ 341 virtual ::rtl::OUString 342 CreateAccessibleDescription () 343 throw (::com::sun::star::uno::RuntimeException); 344 345 /** This method is called when (after) the frame containing this 346 document has been activated. Can be used to send FOCUSED state 347 changes for the currently selected element. 348 349 Note: Currently used as a substitute for FocusGained. Should be 350 renamed in the future. 351 */ 352 virtual void Activated (void); 353 354 /** This method is called when (before or after?) the frame containing 355 this document has been deactivated. Can be used to send FOCUSED 356 state changes for the currently selected element. 357 358 Note: Currently used as a substitute for FocusLost. Should be 359 renamed in the future. 360 */ 361 virtual void Deactivated (void); 362 363 /** Set or remove the currently active accessible OLE object. 364 @param xOLEObject 365 If this is a valid reference then a child event is send that 366 informs the listeners of a new child. If there has already been 367 an active accessible OLE object then this is removed first and 368 appropriate events are send. 369 370 If this is an empty reference then the currently active 371 accessible OLE object (if there is one) is removed. 372 */ 373 virtual void SetAccessibleOLEObject ( 374 const ::com::sun::star::uno::Reference < 375 ::com::sun::star::accessibility::XAccessible>& xOLEObject); 376 //===== XAccessibleGetAccFromXShape ============================================ 377 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > 378 SAL_CALL get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType) 379 throw ( ::com::sun::star::uno::RuntimeException ); 380 381 public: 382 virtual void SwitchViewActivated (void) { Activated(); } 383 virtual sal_Int32 SAL_CALL getForeground( ) 384 throw (::com::sun::star::uno::RuntimeException); 385 386 virtual sal_Int32 SAL_CALL getBackground( ) 387 throw (::com::sun::star::uno::RuntimeException); 388 virtual void impl_dispose (void); 389 }; 390 391 } // end of namespace accessibility 392 393 #endif 394