13334a7e6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 33334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 43334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 53334a7e6SAndrew Rist * distributed with this work for additional information 63334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 73334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 83334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 93334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 113334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 133334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 143334a7e6SAndrew Rist * software distributed under the License is distributed on an 153334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 163334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 173334a7e6SAndrew Rist * specific language governing permissions and limitations 183334a7e6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 203334a7e6SAndrew Rist *************************************************************/ 213334a7e6SAndrew Rist 223334a7e6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SVX_ACCESSIBILITY_CHILDREN_MANAGER_IMPL_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <svx/IAccessibleViewForwarderListener.hxx> 27cdf0e10cSrcweir #include <svx/IAccessibleParent.hxx> 28cdf0e10cSrcweir #include <svx/AccessibleShapeTreeInfo.hxx> 29cdf0e10cSrcweir #include <editeng/AccessibleContextBase.hxx> 30cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 31cdf0e10cSrcweir #include <vos/mutex.hxx> 32cdf0e10cSrcweir #include <vector> 33cdf0e10cSrcweir #include <memory> 34cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp> 35cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp> 36cdf0e10cSrcweir #include <com/sun/star/document/XEventListener.hpp> 37cdf0e10cSrcweir #include <com/sun/star/view/XSelectionChangeListener.hpp> 38cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir using namespace ::com::sun::star; 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace accessibility { 43cdf0e10cSrcweir 44cdf0e10cSrcweir class AccessibleShape; 45cdf0e10cSrcweir 46cdf0e10cSrcweir class ChildDescriptor; // See below for declaration. 47cdf0e10cSrcweir typedef ::std::vector<ChildDescriptor> ChildDescriptorListType; 48cdf0e10cSrcweir 49cdf0e10cSrcweir // Re-using MutexOwner class defined in AccessibleContextBase.hxx 50cdf0e10cSrcweir 51cdf0e10cSrcweir /** This class contains the actual implementation of the children manager. 52cdf0e10cSrcweir 53cdf0e10cSrcweir <p>It maintains a set of visible accessible shapes in 54cdf0e10cSrcweir <member>maVisibleChildren</member>. The objects in this list stem from 55cdf0e10cSrcweir two sources. The first is a list of UNO shapes like the list of shapes 56cdf0e10cSrcweir in a draw page. A reference to this list is held in 57cdf0e10cSrcweir <member>maShapeList</member>. Accessible objects for these shapes are 58cdf0e10cSrcweir created on demand. The list can be replaced by calls to the 59cdf0e10cSrcweir <member>SetShapeList</member> method. The second source is a list of 60cdf0e10cSrcweir already accessible objects. It can be modified by calls to the 61cdf0e10cSrcweir <member>AddAccessibleShape</member> and 62cdf0e10cSrcweir <member>ClearAccessibleShapeList</member> methods.</p> 63cdf0e10cSrcweir 64cdf0e10cSrcweir <p>Each call of the <member>Update</member> method leads to a 65cdf0e10cSrcweir re-calculation of the visible shapes which then can be queried with the 66cdf0e10cSrcweir <member>GetChildCount</member> and <member>GetChild</member> methods. 67cdf0e10cSrcweir Events are send informing all listeners about the removed shapes which are 68cdf0e10cSrcweir not visible anymore and about the added shapes.</p> 69cdf0e10cSrcweir 70cdf0e10cSrcweir <p> The visible area which is used to determine the visibility of the 71cdf0e10cSrcweir shapes is taken from the view forwarder. Thus, to signal a change of 72cdf0e10cSrcweir the visible area call <member>ViewForwarderChanged</member>.</p> 73cdf0e10cSrcweir 74cdf0e10cSrcweir <p>The children manager adds itself as disposing() listener at every UNO 75cdf0e10cSrcweir shape it creates an accessible object for so that when the UNO shape 76cdf0e10cSrcweir passes away it can dispose() the associated accessible object.</p> 77cdf0e10cSrcweir 78cdf0e10cSrcweir @see ChildrenManager 79cdf0e10cSrcweir */ 80cdf0e10cSrcweir class ChildrenManagerImpl 81cdf0e10cSrcweir : public MutexOwner, 82cdf0e10cSrcweir public cppu::WeakComponentImplHelper2< 83cdf0e10cSrcweir ::com::sun::star::document::XEventListener, 84cdf0e10cSrcweir ::com::sun::star::view::XSelectionChangeListener>, 85cdf0e10cSrcweir public IAccessibleViewForwarderListener, 86cdf0e10cSrcweir public IAccessibleParent 87cdf0e10cSrcweir { 88cdf0e10cSrcweir public: 89cdf0e10cSrcweir /** Create a children manager, which manages the children of the given 90cdf0e10cSrcweir parent. The parent is used for creating accessible objects. The 91cdf0e10cSrcweir list of shapes for which to create those objects is not derived from 92cdf0e10cSrcweir the parent and has to be provided seperately by calling one of the 93cdf0e10cSrcweir update methods. 94cdf0e10cSrcweir @param rxParent 95cdf0e10cSrcweir The parent of the accessible objects which will be created 96cdf0e10cSrcweir on demand at some point of time in the future. 97cdf0e10cSrcweir @param rxShapeList 98cdf0e10cSrcweir List of UNO shapes to manage. 99cdf0e10cSrcweir @param rShapeTreeInfo 100cdf0e10cSrcweir Bundel of information passed down the shape tree. 101cdf0e10cSrcweir @param rContext 102cdf0e10cSrcweir An accessible context object that is called for fireing events 103cdf0e10cSrcweir for new and deleted children, i.e. that holds a list of 104cdf0e10cSrcweir listeners to be informed. 105cdf0e10cSrcweir */ 106cdf0e10cSrcweir ChildrenManagerImpl (const ::com::sun::star::uno::Reference< 107cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent, 108cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 109cdf0e10cSrcweir ::com::sun::star::drawing::XShapes>& rxShapeList, 110cdf0e10cSrcweir const AccessibleShapeTreeInfo& rShapeTreeInfo, 111cdf0e10cSrcweir AccessibleContextBase& rContext); 112cdf0e10cSrcweir 113cdf0e10cSrcweir /** If there still are managed children these are disposed and 114cdf0e10cSrcweir released. 115cdf0e10cSrcweir */ 116cdf0e10cSrcweir ~ChildrenManagerImpl (void); 117cdf0e10cSrcweir 118cdf0e10cSrcweir /** Do that part of the initialization that you can not or should not do 119cdf0e10cSrcweir in the constructor like registering at broadcasters. 120cdf0e10cSrcweir */ 121cdf0e10cSrcweir void Init (void); 122cdf0e10cSrcweir 123cdf0e10cSrcweir /** Return the number of currently visible accessible children. 124cdf0e10cSrcweir @return 125cdf0e10cSrcweir If there are no children a 0 is returned. 126cdf0e10cSrcweir */ 127cdf0e10cSrcweir long GetChildCount (void) const throw (); 128cdf0e10cSrcweir 129*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 130*9b8096d0SSteve Yin ::com::sun::star::uno::Reference< 131*9b8096d0SSteve Yin ::com::sun::star::drawing::XShape> GetChildShape(long nIndex) 132*9b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException); 133*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 134cdf0e10cSrcweir /** Return the requested accessible child or throw and 135cdf0e10cSrcweir IndexOutOfBoundsException if the given index is invalid. 136cdf0e10cSrcweir @param nIndex 137cdf0e10cSrcweir Index of the requested child. Call getChildCount for obtaining 138cdf0e10cSrcweir the number of children. 139cdf0e10cSrcweir @return 140cdf0e10cSrcweir In case of a valid index this method returns a reference to the 141cdf0e10cSrcweir requested accessible child. This reference is empty if it has 142cdf0e10cSrcweir not been possible to create the accessible object of the 143cdf0e10cSrcweir corresponding shape. 144cdf0e10cSrcweir @raises 145cdf0e10cSrcweir Throws an IndexOutOfBoundsException if the index is not valid. 146cdf0e10cSrcweir */ 147cdf0e10cSrcweir ::com::sun::star::uno::Reference< 148cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> 149cdf0e10cSrcweir GetChild (long nIndex) 150cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 151cdf0e10cSrcweir ::com::sun::star::lang::IndexOutOfBoundsException); 152cdf0e10cSrcweir 153cdf0e10cSrcweir /** Return the requested accessible child. 154cdf0e10cSrcweir @param aChildDescriptor 155cdf0e10cSrcweir This object contains references to the original shape and its 156cdf0e10cSrcweir associated accessible object. 157cdf0e10cSrcweir @param _nIndex 158cdf0e10cSrcweir The index which will be used in getAccessibleIndexInParent of the accessible shape. 159cdf0e10cSrcweir @return 160cdf0e10cSrcweir Returns a reference to the requested accessible child. This 161cdf0e10cSrcweir reference is empty if it has not been possible to create the 162cdf0e10cSrcweir accessible object of the corresponding shape. 163cdf0e10cSrcweir */ 164cdf0e10cSrcweir ::com::sun::star::uno::Reference< 165cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> 166cdf0e10cSrcweir GetChild (ChildDescriptor& aChildDescriptor,sal_Int32 _nIndex) 167cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 168cdf0e10cSrcweir 169cdf0e10cSrcweir /** Return the requested accessible child given a shape. This method 170cdf0e10cSrcweir searches the list of descriptors for the one that holds the 171cdf0e10cSrcweir association of the given shape to the requested accessible object 172cdf0e10cSrcweir and returns that. If no such descriptor is found that is 173cdf0e10cSrcweir interpreted so that the specified shape is not visible at the moment. 174cdf0e10cSrcweir @param xShape 175cdf0e10cSrcweir The shape for which to return the associated accessible object. 176cdf0e10cSrcweir @return 177cdf0e10cSrcweir Returns a reference to the requested accessible child. The 178cdf0e10cSrcweir reference is empty if there is no shape descriptor that 179cdf0e10cSrcweir associates the shape with an accessible object. 180cdf0e10cSrcweir */ 181cdf0e10cSrcweir ::com::sun::star::uno::Reference< 182cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> 183cdf0e10cSrcweir GetChild (const ::com::sun::star::uno::Reference< 184cdf0e10cSrcweir ::com::sun::star::drawing::XShape>& xShape) 185cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 186cdf0e10cSrcweir 187cdf0e10cSrcweir /** Update the child manager. Take care of a modified set of children 188cdf0e10cSrcweir and modified visible area. This method can optimize the update 189cdf0e10cSrcweir process with respect seperate updates of a modified children list 190cdf0e10cSrcweir and visible area. 191cdf0e10cSrcweir @param bCreateNewObjectsOnDemand 192cdf0e10cSrcweir If </true> then accessible objects associated with the visible 193cdf0e10cSrcweir shapes are created only when asked for. No event is sent on 194cdf0e10cSrcweir creation. If </false> then the accessible objects are created 195cdf0e10cSrcweir before this method returns and events are sent to inform the 196cdf0e10cSrcweir listeners of the new object. 197cdf0e10cSrcweir */ 198cdf0e10cSrcweir void Update (bool bCreateNewObjectsOnDemand = true); 199cdf0e10cSrcweir 200cdf0e10cSrcweir /** Set the list of UNO shapes to the given list. This removes the old 201cdf0e10cSrcweir list and does not add to it. The list of accessible shapes that is 202cdf0e10cSrcweir build up by calls to <member>AddAccessibleShape</member> is not 203cdf0e10cSrcweir modified. Neither is the list of visible children. Accessible 204cdf0e10cSrcweir objects are created on demand. 205cdf0e10cSrcweir @param xShapeList 206cdf0e10cSrcweir The list of UNO shapes that replaces the old list. 207cdf0e10cSrcweir */ 208cdf0e10cSrcweir void SetShapeList (const ::com::sun::star::uno::Reference< 209cdf0e10cSrcweir ::com::sun::star::drawing::XShapes>& xShapeList); 210cdf0e10cSrcweir 211cdf0e10cSrcweir /** Add a accessible shape. This does not modify the list of UNO shapes 212cdf0e10cSrcweir or the list of visible shapes. Accessible shapes are, at the 213cdf0e10cSrcweir moment, not tested against the visible area but are always appended 214cdf0e10cSrcweir to the list of visible children. 215cdf0e10cSrcweir @param pShape 216cdf0e10cSrcweir The new shape that is added to the list of accessible shapes. 217cdf0e10cSrcweir */ 218cdf0e10cSrcweir void AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape); 219cdf0e10cSrcweir 220cdf0e10cSrcweir /** Clear the lists of accessible shapes and that of visible accessible 221cdf0e10cSrcweir shapes. The list of UNO shapes is not modified. 222cdf0e10cSrcweir */ 223cdf0e10cSrcweir void ClearAccessibleShapeList (void); 224cdf0e10cSrcweir 225cdf0e10cSrcweir /** Set a new event shape tree info. Call this method to inform the 226cdf0e10cSrcweir children manager of a change of the info bundle. 227cdf0e10cSrcweir @param rShapeTreeInfo 228cdf0e10cSrcweir The new info that replaces the current one. 229cdf0e10cSrcweir */ 230cdf0e10cSrcweir void SetInfo (const AccessibleShapeTreeInfo& rShapeTreeInfo); 231cdf0e10cSrcweir 232cdf0e10cSrcweir /** Update the SELECTED and FOCUSED states of all visible children 233cdf0e10cSrcweir according to the given selection. This includes setting 234cdf0e10cSrcweir <em>and</em> resetting the states. 235cdf0e10cSrcweir */ 236cdf0e10cSrcweir void UpdateSelection (void); 237cdf0e10cSrcweir 238cdf0e10cSrcweir /** Return whether one of the shapes managed by this object has 239cdf0e10cSrcweir currently the focus. 240cdf0e10cSrcweir @return 241cdf0e10cSrcweir Returns <true/> when there is a shape that has the focus and 242cdf0e10cSrcweir <false/> when there is no such shape. 243cdf0e10cSrcweir */ 244cdf0e10cSrcweir bool HasFocus (void); 245cdf0e10cSrcweir 246cdf0e10cSrcweir /** When there is a shape that currently has the focus, 247cdf0e10cSrcweir i.e. <member>HasFocus()</member> returns <true/> then remove the 248cdf0e10cSrcweir focus from that shape. Otherwise nothing changes. 249cdf0e10cSrcweir */ 250cdf0e10cSrcweir void RemoveFocus (void); 251cdf0e10cSrcweir 252cdf0e10cSrcweir //===== lang::XEventListener ============================================ 253cdf0e10cSrcweir 254cdf0e10cSrcweir virtual void SAL_CALL 255cdf0e10cSrcweir disposing (const ::com::sun::star::lang::EventObject& rEventObject) 256cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 257cdf0e10cSrcweir 258cdf0e10cSrcweir 259cdf0e10cSrcweir //===== document::XEventListener ======================================== 260cdf0e10cSrcweir 261cdf0e10cSrcweir virtual void SAL_CALL 262cdf0e10cSrcweir notifyEvent (const ::com::sun::star::document::EventObject& rEventObject) 263cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 264cdf0e10cSrcweir 265cdf0e10cSrcweir 266cdf0e10cSrcweir //===== view::XSelectionChangeListener ================================== 267cdf0e10cSrcweir 268cdf0e10cSrcweir virtual void SAL_CALL 269cdf0e10cSrcweir selectionChanged (const ::com::sun::star::lang::EventObject& rEvent) 270cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 271cdf0e10cSrcweir 272cdf0e10cSrcweir 273cdf0e10cSrcweir //===== IAccessibleViewForwarderListener ================================ 274cdf0e10cSrcweir 275cdf0e10cSrcweir /** Informs this children manager and its children about a change of one 276cdf0e10cSrcweir (or more) aspect of the view forwarder. 277cdf0e10cSrcweir @param aChangeType 278cdf0e10cSrcweir A change type of <const>VISIBLE_AREA</const> leads to a call to 279cdf0e10cSrcweir the <member>Update</memeber> which creates accessible objects of 280cdf0e10cSrcweir new shapes immediately. Other change types are passed to the 281cdf0e10cSrcweir visible accessible children without calling 282cdf0e10cSrcweir <member>Update</memeber>. 283cdf0e10cSrcweir @param pViewForwarder 284cdf0e10cSrcweir The modified view forwarder. Use this one from now on. 285cdf0e10cSrcweir */ 286cdf0e10cSrcweir virtual void ViewForwarderChanged (ChangeType aChangeType, 287cdf0e10cSrcweir const IAccessibleViewForwarder* pViewForwarder); 288cdf0e10cSrcweir 289cdf0e10cSrcweir //===== IAccessibleParent =============================================== 290cdf0e10cSrcweir 291cdf0e10cSrcweir /** Replace the specified child with a replacement. 292cdf0e10cSrcweir @param pCurrentChild 293cdf0e10cSrcweir This child is to be replaced. 294cdf0e10cSrcweir @param pReplacement 295cdf0e10cSrcweir The replacement for the current child. 296cdf0e10cSrcweir @return 297cdf0e10cSrcweir The returned value indicates wether the replacement has been 298cdf0e10cSrcweir finished successfully. 299cdf0e10cSrcweir */ 300cdf0e10cSrcweir virtual sal_Bool ReplaceChild ( 301cdf0e10cSrcweir AccessibleShape* pCurrentChild, 302cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape, 303cdf0e10cSrcweir const long _nIndex, 304cdf0e10cSrcweir const AccessibleShapeTreeInfo& _rShapeTreeInfo 305cdf0e10cSrcweir ) throw (::com::sun::star::uno::RuntimeException); 306*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 307*9b8096d0SSteve Yin // Add the impl method for IAccessibleParent interface 308*9b8096d0SSteve Yin virtual AccessibleControlShape* GetAccControlShapeFromModel 309*9b8096d0SSteve Yin (::com::sun::star::beans::XPropertySet* pSet) 310*9b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException); 311*9b8096d0SSteve Yin virtual ::com::sun::star::uno::Reference< 312*9b8096d0SSteve Yin ::com::sun::star::accessibility::XAccessible> 313*9b8096d0SSteve Yin GetAccessibleCaption (const ::com::sun::star::uno::Reference< 314*9b8096d0SSteve Yin ::com::sun::star::drawing::XShape>& xShape) 315*9b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException); 316*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 317cdf0e10cSrcweir protected: 318cdf0e10cSrcweir /** This list holds the descriptors of all currently visible shapes and 319cdf0e10cSrcweir associated accessible object. 320cdf0e10cSrcweir 321cdf0e10cSrcweir <p>With the descriptors it maintains a mapping of shapes to 322cdf0e10cSrcweir accessible objects. It acts as a cache in that accessible objects 323cdf0e10cSrcweir are only created on demand and released with every update (where the 324cdf0e10cSrcweir latter may be optimized by the update methods).<p> 325cdf0e10cSrcweir 326cdf0e10cSrcweir <p>The list is realized as a vector because it remains unchanged 327cdf0e10cSrcweir between updates (i.e. complete rebuilds of the list) and allows a 328cdf0e10cSrcweir fast (constant time) access to its elements for given indices.</p> 329cdf0e10cSrcweir */ 330cdf0e10cSrcweir ChildDescriptorListType maVisibleChildren; 331cdf0e10cSrcweir 332cdf0e10cSrcweir /** The original list of UNO shapes. The visible shapes are inserted 333cdf0e10cSrcweir into the list of visible children 334cdf0e10cSrcweir <member>maVisibleChildren</member>. 335cdf0e10cSrcweir */ 336cdf0e10cSrcweir ::com::sun::star::uno::Reference< 337cdf0e10cSrcweir ::com::sun::star::drawing::XShapes> mxShapeList; 338cdf0e10cSrcweir 339cdf0e10cSrcweir /** This list of additional accessible shapes that can or shall not be 340cdf0e10cSrcweir created by the shape factory. 341cdf0e10cSrcweir */ 342cdf0e10cSrcweir typedef std::vector< ::com::sun::star::uno::Reference< 343cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> > AccessibleShapeList; 344cdf0e10cSrcweir AccessibleShapeList maAccessibleShapes; 345cdf0e10cSrcweir 346cdf0e10cSrcweir /** Rectangle that describes the visible area in which a shape has to lie 347cdf0e10cSrcweir at least partly, to be accessible through this class. Used to 348cdf0e10cSrcweir detect changes of the visible area after changes of the view forwarder. 349cdf0e10cSrcweir */ 350cdf0e10cSrcweir Rectangle maVisibleArea; 351cdf0e10cSrcweir 352cdf0e10cSrcweir /** The parent of the shapes. It is used for creating accessible 353cdf0e10cSrcweir objects for given shapes. 354cdf0e10cSrcweir */ 355cdf0e10cSrcweir ::com::sun::star::uno::Reference< 356cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> mxParent; 357cdf0e10cSrcweir 358cdf0e10cSrcweir /** Bundel of information passed down the shape tree. 359cdf0e10cSrcweir */ 360cdf0e10cSrcweir AccessibleShapeTreeInfo maShapeTreeInfo; 361cdf0e10cSrcweir 362cdf0e10cSrcweir /** Reference to an accessible context object that is used to inform its 363cdf0e10cSrcweir listeners of new and remved children. 364cdf0e10cSrcweir */ 365cdf0e10cSrcweir AccessibleContextBase& mrContext; 366cdf0e10cSrcweir 367cdf0e10cSrcweir /** This method is called from the component helper base class while 368cdf0e10cSrcweir disposing. 369cdf0e10cSrcweir */ 370cdf0e10cSrcweir virtual void SAL_CALL disposing (void); 371cdf0e10cSrcweir 372cdf0e10cSrcweir /** Experimental: Get the index of the specified accessible object with 373cdf0e10cSrcweir respect to the list of children maintained by this object. 374cdf0e10cSrcweir 375cdf0e10cSrcweir @return 376cdf0e10cSrcweir Return the index of the given child or -1 to indicate that the 377cdf0e10cSrcweir child is unknown. 378cdf0e10cSrcweir */ 379cdf0e10cSrcweir long GetChildIndex (const ::com::sun::star::uno::Reference< 380cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& xChild) const 381cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 382cdf0e10cSrcweir 383cdf0e10cSrcweir void impl_dispose (void); 384cdf0e10cSrcweir 385cdf0e10cSrcweir private: 386cdf0e10cSrcweir /** Names of new accessible objects are disambiguated with this index. 387cdf0e10cSrcweir It gets increased every time a new object is created and (at the 388cdf0e10cSrcweir moment) never reset. 389cdf0e10cSrcweir */ 390cdf0e10cSrcweir sal_Int32 mnNewNameIndex; 391cdf0e10cSrcweir 392cdf0e10cSrcweir // Don't use the copy constructor or the assignment operator. They are 393cdf0e10cSrcweir // not implemented (and are not intended to be). 394cdf0e10cSrcweir ChildrenManagerImpl (const ChildrenManagerImpl&); 395cdf0e10cSrcweir ChildrenManagerImpl& operator= (const ChildrenManagerImpl&); 396cdf0e10cSrcweir 397cdf0e10cSrcweir /** This member points to the currently focused shape. It is NULL when 398cdf0e10cSrcweir there is no focused shape. 399cdf0e10cSrcweir */ 400cdf0e10cSrcweir AccessibleShape* mpFocusedShape; 401cdf0e10cSrcweir 402cdf0e10cSrcweir /** Three helper functions for the <member>Update</member> method. 403cdf0e10cSrcweir */ 404cdf0e10cSrcweir 405cdf0e10cSrcweir /** Create a list of visible shapes from the list of UNO shapes 406cdf0e10cSrcweir <member>maShapeList</member> and the list of accessible objects. 407cdf0e10cSrcweir @param raChildList 408cdf0e10cSrcweir For every visible shape from the two sources mentioned above one 409cdf0e10cSrcweir descriptor is added to this list. 410cdf0e10cSrcweir */ 411cdf0e10cSrcweir void CreateListOfVisibleShapes (ChildDescriptorListType& raChildList); 412cdf0e10cSrcweir 413cdf0e10cSrcweir /** From the old list of (former) visible shapes remove those that 414cdf0e10cSrcweir are not member of the new list. Send appropriate events for every 415cdf0e10cSrcweir such shape. 416cdf0e10cSrcweir @param raNewChildList 417cdf0e10cSrcweir The new list of visible children against which the old one 418cdf0e10cSrcweir is compared. 419cdf0e10cSrcweir @param raOldChildList 420cdf0e10cSrcweir The old list of visible children against which the new one 421cdf0e10cSrcweir is compared. 422cdf0e10cSrcweir */ 423cdf0e10cSrcweir void RemoveNonVisibleChildren ( 424cdf0e10cSrcweir const ChildDescriptorListType& raNewChildList, 425cdf0e10cSrcweir ChildDescriptorListType& raOldChildList); 426cdf0e10cSrcweir 427cdf0e10cSrcweir /** Merge the information that is already known about the visible shapes 428cdf0e10cSrcweir from the current list into the new list. 429cdf0e10cSrcweir @param raChildList 430cdf0e10cSrcweir Information is merged from the current list of visible children 431cdf0e10cSrcweir to this list. 432cdf0e10cSrcweir */ 433cdf0e10cSrcweir void MergeAccessibilityInformation (ChildDescriptorListType& raChildList); 434cdf0e10cSrcweir 435cdf0e10cSrcweir /** If the visible area has changed then send events that signal a 436cdf0e10cSrcweir change of their bounding boxes for all shapes that are members of 437cdf0e10cSrcweir both the current and the new list of visible shapes. 438cdf0e10cSrcweir @param raChildList 439cdf0e10cSrcweir Events are sent to all entries of this list that already contain 440cdf0e10cSrcweir an accessible object. 441cdf0e10cSrcweir */ 442cdf0e10cSrcweir void SendVisibleAreaEvents (ChildDescriptorListType& raChildList); 443cdf0e10cSrcweir 444cdf0e10cSrcweir /** If children have to be created immediately and not on demand the 445cdf0e10cSrcweir create the missing accessible objects now. 446cdf0e10cSrcweir @param raDescriptorList 447cdf0e10cSrcweir Create an accessible object for every member of this list where 448cdf0e10cSrcweir that obejct does not already exist. 449cdf0e10cSrcweir */ 450cdf0e10cSrcweir void CreateAccessibilityObjects (ChildDescriptorListType& raChildList); 451cdf0e10cSrcweir 452cdf0e10cSrcweir /** Add a single shape. Update all relevant data structures 453cdf0e10cSrcweir accordingly. Use this method instead of <member>Update()</member> 454cdf0e10cSrcweir when only a single shape has been added. 455cdf0e10cSrcweir */ 456cdf0e10cSrcweir void AddShape (const ::com::sun::star::uno::Reference< 457cdf0e10cSrcweir ::com::sun::star::drawing::XShape>& xShape); 458cdf0e10cSrcweir 459cdf0e10cSrcweir /** Remove a single shape. Update all relevant data structures 460cdf0e10cSrcweir accordingly. Use this method instead of <member>Update()</member> 461cdf0e10cSrcweir when only a single shape has been removed. 462cdf0e10cSrcweir */ 463cdf0e10cSrcweir void RemoveShape (const ::com::sun::star::uno::Reference< 464cdf0e10cSrcweir ::com::sun::star::drawing::XShape>& xShape); 465cdf0e10cSrcweir 466cdf0e10cSrcweir /** Add the children manager as dispose listener at the given shape so 467cdf0e10cSrcweir that the associated accessible object can be disposed when the shape 468cdf0e10cSrcweir is disposed. 469cdf0e10cSrcweir @param xShape 470cdf0e10cSrcweir Register at this shape as dispose listener. 471cdf0e10cSrcweir */ 472cdf0e10cSrcweir void RegisterAsDisposeListener (const ::com::sun::star::uno::Reference< 473cdf0e10cSrcweir ::com::sun::star::drawing::XShape>& xShape); 474cdf0e10cSrcweir 475cdf0e10cSrcweir /** Remove the children manager as dispose listener at the given shape 476cdf0e10cSrcweir @param xShape 477cdf0e10cSrcweir Unregister at this shape as dispose listener. 478cdf0e10cSrcweir */ 479cdf0e10cSrcweir void UnregisterAsDisposeListener (const ::com::sun::star::uno::Reference< 480cdf0e10cSrcweir ::com::sun::star::drawing::XShape>& xShape); 481cdf0e10cSrcweir }; 482cdf0e10cSrcweir 483cdf0e10cSrcweir 484cdf0e10cSrcweir 485cdf0e10cSrcweir 486cdf0e10cSrcweir /** A child descriptor holds a reference to a UNO shape and the 487cdf0e10cSrcweir corresponding accessible object. There are two use cases: 488cdf0e10cSrcweir <ol><li>The accessible object is only created on demand and is then 489cdf0e10cSrcweir initially empty.</li> 490cdf0e10cSrcweir <li>There is no UNO shape. The accessible object is given as argument 491cdf0e10cSrcweir to the constructor.</li> 492cdf0e10cSrcweir </ol> 493cdf0e10cSrcweir In both cases the child descriptor assumes ownership over the accessible 494cdf0e10cSrcweir object. 495cdf0e10cSrcweir */ 496cdf0e10cSrcweir class ChildDescriptor 497cdf0e10cSrcweir { 498cdf0e10cSrcweir public: 499cdf0e10cSrcweir /** Reference to a (partially) visible shape. 500cdf0e10cSrcweir */ 501cdf0e10cSrcweir ::com::sun::star::uno::Reference< 502cdf0e10cSrcweir ::com::sun::star::drawing::XShape> mxShape; 503cdf0e10cSrcweir 504cdf0e10cSrcweir /** The corresponding accessible object. This reference is initially 505cdf0e10cSrcweir empty and only replaced by a reference to a new object when that is 506cdf0e10cSrcweir requested from the outside. 507cdf0e10cSrcweir */ 508cdf0e10cSrcweir ::com::sun::star::uno::Reference< 509cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> mxAccessibleShape; 510cdf0e10cSrcweir 511cdf0e10cSrcweir /** Return a pointer to the implementation object of the accessible 512cdf0e10cSrcweir shape of this descriptor. 513cdf0e10cSrcweir @return 514cdf0e10cSrcweir The result is NULL if either the UNO reference to the accessible 515cdf0e10cSrcweir shape is empty or it can not be transformed into a pointer to 516cdf0e10cSrcweir the desired class. 517cdf0e10cSrcweir */ 518cdf0e10cSrcweir AccessibleShape* GetAccessibleShape (void) const; 519cdf0e10cSrcweir 520cdf0e10cSrcweir /** set the index _nIndex at the accessible shape 521cdf0e10cSrcweir @param _nIndex 522cdf0e10cSrcweir The new index in parent. 523cdf0e10cSrcweir */ 524cdf0e10cSrcweir void setIndexAtAccessibleShape(sal_Int32 _nIndex); 525cdf0e10cSrcweir 526cdf0e10cSrcweir /** This flag is set during the visibility calculation and indicates 527cdf0e10cSrcweir that at one time in this process an event is sent that informs the 528cdf0e10cSrcweir listners of the creation of a new accessible object. This flags is 529cdf0e10cSrcweir not reset afterwards. Don't use it unless you know exactly what you 530cdf0e10cSrcweir are doing. 531cdf0e10cSrcweir */ 532cdf0e10cSrcweir bool mbCreateEventPending; 533cdf0e10cSrcweir 534cdf0e10cSrcweir /** Create a new descriptor for the specified shape with empty reference 535cdf0e10cSrcweir to accessible object. 536cdf0e10cSrcweir */ 537cdf0e10cSrcweir explicit ChildDescriptor (const ::com::sun::star::uno::Reference< 538cdf0e10cSrcweir ::com::sun::star::drawing::XShape>& xShape); 539cdf0e10cSrcweir 540cdf0e10cSrcweir /** Create a new descriptor for the specified shape with empty reference 541cdf0e10cSrcweir to the original shape. 542cdf0e10cSrcweir */ 543cdf0e10cSrcweir explicit ChildDescriptor (const ::com::sun::star::uno::Reference< 544cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxAccessibleShape); 545cdf0e10cSrcweir 546cdf0e10cSrcweir ~ChildDescriptor (void); 547cdf0e10cSrcweir 548cdf0e10cSrcweir /** Dispose the accessible object of this descriptor. If that object 549cdf0e10cSrcweir does not exist then do nothing. 550cdf0e10cSrcweir @param rParent 551cdf0e10cSrcweir The parent of the accessible object to dispose. A child event 552cdf0e10cSrcweir is sent in its name. 553cdf0e10cSrcweir */ 554cdf0e10cSrcweir void disposeAccessibleObject (AccessibleContextBase& rParent); 555cdf0e10cSrcweir 556cdf0e10cSrcweir /** Compare two child descriptors. Take into account that a child 557cdf0e10cSrcweir descriptor may be based on a UNO shape or, already, on an accessible 558cdf0e10cSrcweir shape. 559cdf0e10cSrcweir */ 560cdf0e10cSrcweir inline bool operator == (const ChildDescriptor& aDescriptor) const 561cdf0e10cSrcweir { 562cdf0e10cSrcweir return ( 563cdf0e10cSrcweir this == &aDescriptor || 564cdf0e10cSrcweir ( 565cdf0e10cSrcweir (mxShape.get() == aDescriptor.mxShape.get() ) && 566cdf0e10cSrcweir (mxShape.is() || mxAccessibleShape.get() == aDescriptor.mxAccessibleShape.get()) 567cdf0e10cSrcweir ) 568cdf0e10cSrcweir ); 569cdf0e10cSrcweir } 570cdf0e10cSrcweir 571cdf0e10cSrcweir /** The ordering defined by this operator is only used in order to be able 572cdf0e10cSrcweir to put child descriptors in some STL containers. The ordering itself is 573cdf0e10cSrcweir not so important, its 'features' are not used. 574cdf0e10cSrcweir */ 575cdf0e10cSrcweir inline bool operator < (const ChildDescriptor& aDescriptor) const 576cdf0e10cSrcweir { 577cdf0e10cSrcweir return (mxShape.get() < aDescriptor.mxShape.get()); 578cdf0e10cSrcweir } 579cdf0e10cSrcweir 580cdf0e10cSrcweir }; 581cdf0e10cSrcweir 582cdf0e10cSrcweir 583cdf0e10cSrcweir 584cdf0e10cSrcweir } // end of namespace accessibility 585cdf0e10cSrcweir 586cdf0e10cSrcweir #endif 587cdf0e10cSrcweir 588