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