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