1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10f6e50924SAndrew Rist * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f6e50924SAndrew Rist * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19f6e50924SAndrew Rist * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "ChildrenManagerImpl.hxx" 28cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx> 29cdf0e10cSrcweir #include <svx/AccessibleShapeInfo.hxx> 30cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBLE_ACCESSIBLESTATETYPE_HPP_ 31cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #include <com/sun/star/view/XSelectionSupplier.hpp> 34cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 35cdf0e10cSrcweir #include <comphelper/uno3.hxx> 36cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <rtl/ustring.hxx> 39cdf0e10cSrcweir #include <tools/debug.hxx> 409b8096d0SSteve Yin #ifndef _SVX_ACCESSIBILITY_SVX_SHAPE_TYPES_HXX 419b8096d0SSteve Yin #include <svx/SvxShapeTypes.hxx> 429b8096d0SSteve Yin #endif 439b8096d0SSteve Yin #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 449b8096d0SSteve Yin #include <toolkit/unohlp.hxx> 459b8096d0SSteve Yin #endif 46cdf0e10cSrcweir 479b8096d0SSteve Yin #ifndef _SV_WINDOW_HXX 489b8096d0SSteve Yin #include <vcl/window.hxx> 499b8096d0SSteve Yin #endif 50cdf0e10cSrcweir using namespace ::com::sun::star; 51cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 52cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 53cdf0e10cSrcweir 54cdf0e10cSrcweir 55cdf0e10cSrcweir namespace accessibility { 56cdf0e10cSrcweir 57cdf0e10cSrcweir namespace 58cdf0e10cSrcweir { 59cdf0e10cSrcweir void adjustIndexInParentOfShapes(ChildDescriptorListType& _rList) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir ChildDescriptorListType::iterator aEnd = _rList.end(); 62cdf0e10cSrcweir sal_Int32 i=0; 63cdf0e10cSrcweir for ( ChildDescriptorListType::iterator aIter = _rList.begin(); aIter != aEnd; ++aIter,++i) 64cdf0e10cSrcweir aIter->setIndexAtAccessibleShape(i); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir //===== AccessibleChildrenManager =========================================== 69cdf0e10cSrcweir 70cdf0e10cSrcweir ChildrenManagerImpl::ChildrenManagerImpl ( 71cdf0e10cSrcweir const uno::Reference<XAccessible>& rxParent, 72cdf0e10cSrcweir const uno::Reference<drawing::XShapes>& rxShapeList, 73cdf0e10cSrcweir const AccessibleShapeTreeInfo& rShapeTreeInfo, 74cdf0e10cSrcweir AccessibleContextBase& rContext) 75cdf0e10cSrcweir : ::cppu::WeakComponentImplHelper2< 76cdf0e10cSrcweir ::com::sun::star::document::XEventListener, 77cdf0e10cSrcweir ::com::sun::star::view::XSelectionChangeListener>(maMutex), 78cdf0e10cSrcweir mxShapeList (rxShapeList), 79cdf0e10cSrcweir mxParent (rxParent), 80cdf0e10cSrcweir maShapeTreeInfo (rShapeTreeInfo), 81cdf0e10cSrcweir mrContext (rContext), 82cdf0e10cSrcweir mnNewNameIndex(1), 83cdf0e10cSrcweir mpFocusedShape(NULL) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir } 86cdf0e10cSrcweir 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir 90cdf0e10cSrcweir ChildrenManagerImpl::~ChildrenManagerImpl (void) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose, 93cdf0e10cSrcweir "~AccessibleDrawDocumentView: object has not been disposed"); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir 97cdf0e10cSrcweir 98cdf0e10cSrcweir 99cdf0e10cSrcweir void ChildrenManagerImpl::Init (void) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir // Register as view::XSelectionChangeListener. 102cdf0e10cSrcweir Reference<frame::XController> xController(maShapeTreeInfo.GetController()); 103cdf0e10cSrcweir Reference<view::XSelectionSupplier> xSelectionSupplier ( 104cdf0e10cSrcweir xController, uno::UNO_QUERY); 105cdf0e10cSrcweir if (xSelectionSupplier.is()) 106cdf0e10cSrcweir { 107cdf0e10cSrcweir xController->addEventListener( 108cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 109cdf0e10cSrcweir 110cdf0e10cSrcweir xSelectionSupplier->addSelectionChangeListener ( 111cdf0e10cSrcweir static_cast<view::XSelectionChangeListener*>(this)); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir // Register at model as document::XEventListener. 115cdf0e10cSrcweir if (maShapeTreeInfo.GetModelBroadcaster().is()) 116cdf0e10cSrcweir maShapeTreeInfo.GetModelBroadcaster()->addEventListener ( 117cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir 121cdf0e10cSrcweir 122cdf0e10cSrcweir 123cdf0e10cSrcweir long ChildrenManagerImpl::GetChildCount (void) const throw () 124cdf0e10cSrcweir { 125cdf0e10cSrcweir return maVisibleChildren.size(); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir 1299b8096d0SSteve Yin ::com::sun::star::uno::Reference< 1309b8096d0SSteve Yin ::com::sun::star::drawing::XShape> ChildrenManagerImpl::GetChildShape(long nIndex) 1319b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException) 1329b8096d0SSteve Yin { 1339b8096d0SSteve Yin uno::Reference<XAccessible> xAcc = GetChild(nIndex); 1349b8096d0SSteve Yin ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end(); 1359b8096d0SSteve Yin for (I = maVisibleChildren.begin(); I != aEnd; ++I) 1369b8096d0SSteve Yin { 1379b8096d0SSteve Yin if (I->mxAccessibleShape == xAcc) 1389b8096d0SSteve Yin return I->mxShape; 1399b8096d0SSteve Yin } 1409b8096d0SSteve Yin return uno::Reference< drawing::XShape > (); 1419b8096d0SSteve Yin } 142cdf0e10cSrcweir 143cdf0e10cSrcweir /** Return the requested accessible child object. Create it if it is not 144cdf0e10cSrcweir yet in the cache. 145cdf0e10cSrcweir */ 146cdf0e10cSrcweir uno::Reference<XAccessible> 147cdf0e10cSrcweir ChildrenManagerImpl::GetChild (long nIndex) 148cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 149cdf0e10cSrcweir ::com::sun::star::lang::IndexOutOfBoundsException) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir // Check wether the given index is valid. 152cdf0e10cSrcweir if (nIndex < 0 || (unsigned long)nIndex >= maVisibleChildren.size()) 153cdf0e10cSrcweir throw lang::IndexOutOfBoundsException ( 15424c56ab9SHerbert Dürr ::rtl::OUString::createFromAscii( "no accessible child with index ") 15524c56ab9SHerbert Dürr + ::rtl::OUString::valueOf( nIndex, 10), 156cdf0e10cSrcweir mxParent); 157cdf0e10cSrcweir 158cdf0e10cSrcweir return GetChild (maVisibleChildren[nIndex],nIndex); 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir 162cdf0e10cSrcweir 163cdf0e10cSrcweir 164cdf0e10cSrcweir /** Return the requested accessible child object. Create it if it is not 165cdf0e10cSrcweir yet in the cache. 166cdf0e10cSrcweir */ 167cdf0e10cSrcweir uno::Reference<XAccessible> 168cdf0e10cSrcweir ChildrenManagerImpl::GetChild (ChildDescriptor& rChildDescriptor,sal_Int32 _nIndex) 169cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 170cdf0e10cSrcweir { 171cdf0e10cSrcweir if ( ! rChildDescriptor.mxAccessibleShape.is()) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 174cdf0e10cSrcweir // Make sure that the requested accessible object has not been 175cdf0e10cSrcweir // created while locking the global mutex. 176cdf0e10cSrcweir if ( ! rChildDescriptor.mxAccessibleShape.is()) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir AccessibleShapeInfo aShapeInfo( 179cdf0e10cSrcweir rChildDescriptor.mxShape, 180cdf0e10cSrcweir mxParent, 181cdf0e10cSrcweir this, 182cdf0e10cSrcweir mnNewNameIndex++); 183cdf0e10cSrcweir // Create accessible object that corresponds to the descriptor's 184cdf0e10cSrcweir // shape. 185cdf0e10cSrcweir AccessibleShape* pShape = 186cdf0e10cSrcweir ShapeTypeHandler::Instance().CreateAccessibleObject ( 187cdf0e10cSrcweir aShapeInfo, 188cdf0e10cSrcweir maShapeTreeInfo); 189cdf0e10cSrcweir rChildDescriptor.mxAccessibleShape = uno::Reference<XAccessible> ( 190cdf0e10cSrcweir static_cast<uno::XWeak*>(pShape), 191cdf0e10cSrcweir uno::UNO_QUERY); 192cdf0e10cSrcweir // Now that there is a reference to the new accessible shape we 193cdf0e10cSrcweir // can safely call its Init() method. 194cdf0e10cSrcweir if ( pShape != NULL ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir pShape->Init(); 197cdf0e10cSrcweir pShape->setIndexInParent(_nIndex); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir } 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir return rChildDescriptor.mxAccessibleShape; 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir 206cdf0e10cSrcweir 207cdf0e10cSrcweir 208cdf0e10cSrcweir uno::Reference<XAccessible> 209cdf0e10cSrcweir ChildrenManagerImpl::GetChild (const uno::Reference<drawing::XShape>& xShape) 210cdf0e10cSrcweir throw (uno::RuntimeException) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end(); 213cdf0e10cSrcweir for (I = maVisibleChildren.begin(); I != aEnd; ++I) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir if ( I->mxShape.get() == xShape.get() ) 216cdf0e10cSrcweir return I->mxAccessibleShape; 217cdf0e10cSrcweir } 218cdf0e10cSrcweir return uno::Reference<XAccessible> (); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir 222cdf0e10cSrcweir 223cdf0e10cSrcweir 224cdf0e10cSrcweir /** Find all shapes among the specified shapes that lie fully or partially 225cdf0e10cSrcweir inside the visible area. Put those shapes into the cleared cache. The 226cdf0e10cSrcweir corresponding accessible objects will be created on demand. 227cdf0e10cSrcweir 228cdf0e10cSrcweir At the moment, first all accessible objects are removed from the cache 229cdf0e10cSrcweir and the appropriate listeners are informed of this. Next, the list is 230cdf0e10cSrcweir created again. This should be optimized in the future to not remove and 231cdf0e10cSrcweir create objects that will be in the list before and after the update 232cdf0e10cSrcweir method. 233cdf0e10cSrcweir */ 234cdf0e10cSrcweir void ChildrenManagerImpl::Update (bool bCreateNewObjectsOnDemand) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir if (maShapeTreeInfo.GetViewForwarder() == NULL) 237cdf0e10cSrcweir return; 238cdf0e10cSrcweir Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea(); 239cdf0e10cSrcweir 240cdf0e10cSrcweir // 1. Create a local list of visible shapes. 241cdf0e10cSrcweir ChildDescriptorListType aChildList; 242cdf0e10cSrcweir CreateListOfVisibleShapes (aChildList); 243cdf0e10cSrcweir 244cdf0e10cSrcweir // 2. Merge the information that is already known about the visible 245cdf0e10cSrcweir // shapes from the current list into the new list. 246cdf0e10cSrcweir MergeAccessibilityInformation (aChildList); 247cdf0e10cSrcweir 248cdf0e10cSrcweir // 3. Replace the current list of visible shapes with the new one. Do 249cdf0e10cSrcweir // the same with the visible area. 250cdf0e10cSrcweir { 251cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 252cdf0e10cSrcweir adjustIndexInParentOfShapes(aChildList); 253cdf0e10cSrcweir 254cdf0e10cSrcweir // Use swap to copy the contents of the new list in constant time. 255cdf0e10cSrcweir maVisibleChildren.swap (aChildList); 256cdf0e10cSrcweir 257cdf0e10cSrcweir // aChildList now contains all the old children, while maVisibleChildren 258cdf0e10cSrcweir // contains all the current children 259cdf0e10cSrcweir 260cdf0e10cSrcweir // 4. Find all shapes in the old list that are not in the current list, 261cdf0e10cSrcweir // send appropriate events and remove the accessible shape. 262cdf0e10cSrcweir // 263cdf0e10cSrcweir // Do this *after* we have set our new list of children, because 264cdf0e10cSrcweir // removing a child may cause 265cdf0e10cSrcweir // 266cdf0e10cSrcweir // ChildDescriptor::disposeAccessibleObject --> 267cdf0e10cSrcweir // AccessibleContextBase::CommitChange --> 268cdf0e10cSrcweir // AtkListener::notifyEvent -> 269cdf0e10cSrcweir // AtkListener::handleChildRemoved -> 270cdf0e10cSrcweir // AtkListener::updateChildList 271cdf0e10cSrcweir // AccessibleDrawDocumentView::getAccessibleChildCount -> 272cdf0e10cSrcweir // ChildrenManagerImpl::GetChildCount -> 273cdf0e10cSrcweir // maVisibleChildren.size() 274cdf0e10cSrcweir // 275cdf0e10cSrcweir // to be fired, and so the operations will take place on 276cdf0e10cSrcweir // the list we are trying to replace 277cdf0e10cSrcweir // 278cdf0e10cSrcweir RemoveNonVisibleChildren (maVisibleChildren, aChildList); 279cdf0e10cSrcweir 280cdf0e10cSrcweir aChildList.clear(); 281cdf0e10cSrcweir 282cdf0e10cSrcweir maVisibleArea = aVisibleArea; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir // 5. If the visible area has changed then send events that signal a 286cdf0e10cSrcweir // change of their bounding boxes for all shapes that are members of 287cdf0e10cSrcweir // both the current and the new list of visible shapes. 288cdf0e10cSrcweir if (maVisibleArea != aVisibleArea) 289cdf0e10cSrcweir SendVisibleAreaEvents (maVisibleChildren); 290cdf0e10cSrcweir 291cdf0e10cSrcweir // 6. If children have to be created immediately and not on demand then 292cdf0e10cSrcweir // create the missing accessible objects now. 293cdf0e10cSrcweir if ( ! bCreateNewObjectsOnDemand) 294cdf0e10cSrcweir CreateAccessibilityObjects (maVisibleChildren); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir 298cdf0e10cSrcweir 299cdf0e10cSrcweir 300cdf0e10cSrcweir void ChildrenManagerImpl::CreateListOfVisibleShapes ( 301cdf0e10cSrcweir ChildDescriptorListType& raDescriptorList) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 304cdf0e10cSrcweir 305cdf0e10cSrcweir OSL_ASSERT (maShapeTreeInfo.GetViewForwarder() != NULL); 306cdf0e10cSrcweir 307cdf0e10cSrcweir Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea(); 308cdf0e10cSrcweir 309*86e1cf34SPedro Giffuni // Add the visible shapes for which the accessible objects already exist. 310cdf0e10cSrcweir AccessibleShapeList::iterator I,aEnd = maAccessibleShapes.end(); 311cdf0e10cSrcweir for (I=maAccessibleShapes.begin(); I != aEnd; ++I) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir if (I->is()) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xComponent ( 316cdf0e10cSrcweir (*I)->getAccessibleContext(), uno::UNO_QUERY); 317cdf0e10cSrcweir if (xComponent.is()) 318cdf0e10cSrcweir { 319cdf0e10cSrcweir // The bounding box of the object already is clipped to the 320cdf0e10cSrcweir // visible area. The object is therefore visible if the 321cdf0e10cSrcweir // bounding box has non-zero extensions. 322cdf0e10cSrcweir awt::Rectangle aPixelBBox (xComponent->getBounds()); 323cdf0e10cSrcweir if ((aPixelBBox.Width > 0) && (aPixelBBox.Height > 0)) 324cdf0e10cSrcweir raDescriptorList.push_back (ChildDescriptor (*I)); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir } 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir // Add the visible shapes for which only the XShapes exist. 330cdf0e10cSrcweir uno::Reference<container::XIndexAccess> xShapeAccess (mxShapeList, uno::UNO_QUERY); 331cdf0e10cSrcweir if (xShapeAccess.is()) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir sal_Int32 nShapeCount = xShapeAccess->getCount(); 334cdf0e10cSrcweir raDescriptorList.reserve( nShapeCount ); 335cdf0e10cSrcweir awt::Point aPos; 336cdf0e10cSrcweir awt::Size aSize; 337cdf0e10cSrcweir Rectangle aBoundingBox; 338cdf0e10cSrcweir uno::Reference<drawing::XShape> xShape; 339cdf0e10cSrcweir for (sal_Int32 i=0; i<nShapeCount; ++i) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir xShapeAccess->getByIndex(i) >>= xShape; 342cdf0e10cSrcweir aPos = xShape->getPosition(); 343cdf0e10cSrcweir aSize = xShape->getSize(); 344cdf0e10cSrcweir 345cdf0e10cSrcweir aBoundingBox.nLeft = aPos.X; 346cdf0e10cSrcweir aBoundingBox.nTop = aPos.Y; 347cdf0e10cSrcweir aBoundingBox.nRight = aPos.X + aSize.Width; 348cdf0e10cSrcweir aBoundingBox.nBottom = aPos.Y + aSize.Height; 349cdf0e10cSrcweir 350cdf0e10cSrcweir // Insert shape if it is visible, i.e. its bounding box overlaps 351cdf0e10cSrcweir // the visible area. 352cdf0e10cSrcweir if ( aBoundingBox.IsOver (aVisibleArea) ) 353cdf0e10cSrcweir raDescriptorList.push_back (ChildDescriptor (xShape)); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir } 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir 359cdf0e10cSrcweir 360cdf0e10cSrcweir 361cdf0e10cSrcweir void ChildrenManagerImpl::RemoveNonVisibleChildren ( 362cdf0e10cSrcweir const ChildDescriptorListType& rNewChildList, 363cdf0e10cSrcweir ChildDescriptorListType& rOldChildList) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir // Iterate over list of formerly visible children and remove those that 366cdf0e10cSrcweir // are not visible anymore, i.e. member of the new list of visible 367cdf0e10cSrcweir // children. 368cdf0e10cSrcweir ChildDescriptorListType::iterator I, aEnd = rOldChildList.end(); 369cdf0e10cSrcweir for (I=rOldChildList.begin(); I != aEnd; ++I) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir if (::std::find(rNewChildList.begin(), rNewChildList.end(), *I) == rNewChildList.end()) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir // The child is disposed when there is a UNO shape from which 374cdf0e10cSrcweir // the accessible shape can be created when the shape becomes 375cdf0e10cSrcweir // visible again. When there is no such UNO shape then simply 376cdf0e10cSrcweir // reset the descriptor but keep the accessibility object. 377cdf0e10cSrcweir if (I->mxShape.is()) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir UnregisterAsDisposeListener (I->mxShape); 380cdf0e10cSrcweir I->disposeAccessibleObject (mrContext); 381cdf0e10cSrcweir } 382cdf0e10cSrcweir else 383cdf0e10cSrcweir { 384cdf0e10cSrcweir AccessibleShape* pAccessibleShape = I->GetAccessibleShape(); 385cdf0e10cSrcweir pAccessibleShape->ResetState (AccessibleStateType::VISIBLE); 386cdf0e10cSrcweir I->mxAccessibleShape = NULL; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir } 389cdf0e10cSrcweir } 390cdf0e10cSrcweir } 391cdf0e10cSrcweir 392cdf0e10cSrcweir 393cdf0e10cSrcweir 394cdf0e10cSrcweir 395cdf0e10cSrcweir void ChildrenManagerImpl::MergeAccessibilityInformation ( 396cdf0e10cSrcweir ChildDescriptorListType& raNewChildList) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir ChildDescriptorListType::iterator aOldChildDescriptor; 399cdf0e10cSrcweir ChildDescriptorListType::iterator I, aEnd = raNewChildList.end(); 400cdf0e10cSrcweir for (I=raNewChildList.begin(); I != aEnd; ++I) 401cdf0e10cSrcweir { 402cdf0e10cSrcweir aOldChildDescriptor = ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(), *I); 403cdf0e10cSrcweir 404cdf0e10cSrcweir // Copy accessible shape if that exists in the old descriptor. 405cdf0e10cSrcweir bool bRegistrationIsNecessary = true; 406cdf0e10cSrcweir if (aOldChildDescriptor != maVisibleChildren.end()) 407cdf0e10cSrcweir if (aOldChildDescriptor->mxAccessibleShape.is()) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir I->mxAccessibleShape = aOldChildDescriptor->mxAccessibleShape; 410cdf0e10cSrcweir I->mbCreateEventPending = false; 411cdf0e10cSrcweir bRegistrationIsNecessary = false; 412cdf0e10cSrcweir } 413cdf0e10cSrcweir if (bRegistrationIsNecessary) 414cdf0e10cSrcweir RegisterAsDisposeListener (I->mxShape); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir 419cdf0e10cSrcweir 420cdf0e10cSrcweir 421cdf0e10cSrcweir void ChildrenManagerImpl::SendVisibleAreaEvents ( 422cdf0e10cSrcweir ChildDescriptorListType& raNewChildList) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir ChildDescriptorListType::iterator I,aEnd = raNewChildList.end(); 425cdf0e10cSrcweir for (I=raNewChildList.begin(); I != aEnd; ++I) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir // Tell shape of changed visible area. To do this, fake a 428cdf0e10cSrcweir // change of the view forwarder. (Actually we usually get here 429cdf0e10cSrcweir // as a result of a change of the view forwarder). 430cdf0e10cSrcweir AccessibleShape* pShape = I->GetAccessibleShape (); 431cdf0e10cSrcweir if (pShape != NULL) 432cdf0e10cSrcweir pShape->ViewForwarderChanged ( 433cdf0e10cSrcweir IAccessibleViewForwarderListener::VISIBLE_AREA, 434cdf0e10cSrcweir maShapeTreeInfo.GetViewForwarder()); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir 439cdf0e10cSrcweir 440cdf0e10cSrcweir 441cdf0e10cSrcweir void ChildrenManagerImpl::CreateAccessibilityObjects ( 442cdf0e10cSrcweir ChildDescriptorListType& raNewChildList) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir ChildDescriptorListType::iterator I, aEnd = raNewChildList.end(); 445cdf0e10cSrcweir sal_Int32 nPos = 0; 446cdf0e10cSrcweir for ( I = raNewChildList.begin(); I != aEnd; ++I,++nPos) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir // Create the associated accessible object when the flag says so and 449cdf0e10cSrcweir // it does not yet exist. 450cdf0e10cSrcweir if ( ! I->mxAccessibleShape.is() ) 451cdf0e10cSrcweir GetChild (*I,nPos); 452cdf0e10cSrcweir if (I->mxAccessibleShape.is() && I->mbCreateEventPending) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir I->mbCreateEventPending = false; 455cdf0e10cSrcweir mrContext.CommitChange ( 456cdf0e10cSrcweir AccessibleEventId::CHILD, 457cdf0e10cSrcweir uno::makeAny(I->mxAccessibleShape), 458cdf0e10cSrcweir uno::Any()); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir } 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir 464cdf0e10cSrcweir 465cdf0e10cSrcweir 466cdf0e10cSrcweir void ChildrenManagerImpl::AddShape (const Reference<drawing::XShape>& rxShape) 467cdf0e10cSrcweir { 468cdf0e10cSrcweir if (rxShape.is()) 469cdf0e10cSrcweir { 470cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard (maMutex); 471cdf0e10cSrcweir 472cdf0e10cSrcweir // Test visibility of the shape. 473cdf0e10cSrcweir Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea(); 474cdf0e10cSrcweir awt::Point aPos = rxShape->getPosition(); 475cdf0e10cSrcweir awt::Size aSize = rxShape->getSize(); 476cdf0e10cSrcweir 477cdf0e10cSrcweir Rectangle aBoundingBox ( 478cdf0e10cSrcweir aPos.X, 479cdf0e10cSrcweir aPos.Y, 480cdf0e10cSrcweir aPos.X + aSize.Width, 481cdf0e10cSrcweir aPos.Y + aSize.Height); 482cdf0e10cSrcweir 483cdf0e10cSrcweir // Add the shape only when it belongs to the list of shapes stored 484cdf0e10cSrcweir // in mxShapeList (which is either a page or a group shape). 485cdf0e10cSrcweir Reference<container::XChild> xChild (rxShape, uno::UNO_QUERY); 486cdf0e10cSrcweir if (xChild.is()) 487cdf0e10cSrcweir { 488cdf0e10cSrcweir Reference<drawing::XShapes> xParent (xChild->getParent(), uno::UNO_QUERY); 489cdf0e10cSrcweir if (xParent == mxShapeList) 490cdf0e10cSrcweir if (aBoundingBox.IsOver (aVisibleArea)) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir // Add shape to list of visible shapes. 493cdf0e10cSrcweir maVisibleChildren.push_back (ChildDescriptor (rxShape)); 494cdf0e10cSrcweir 495cdf0e10cSrcweir // Create accessibility object. 496cdf0e10cSrcweir ChildDescriptor& rDescriptor = maVisibleChildren.back(); 497cdf0e10cSrcweir GetChild (rDescriptor, maVisibleChildren.size()-1); 498cdf0e10cSrcweir 499cdf0e10cSrcweir // Inform listeners about new child. 500cdf0e10cSrcweir uno::Any aNewShape; 501cdf0e10cSrcweir aNewShape <<= rDescriptor.mxAccessibleShape; 502cdf0e10cSrcweir aGuard.clear(); 503cdf0e10cSrcweir mrContext.CommitChange ( 504cdf0e10cSrcweir AccessibleEventId::CHILD, 505cdf0e10cSrcweir aNewShape, 506cdf0e10cSrcweir uno::Any()); 507cdf0e10cSrcweir RegisterAsDisposeListener (rDescriptor.mxShape); 508cdf0e10cSrcweir } 509cdf0e10cSrcweir } 510cdf0e10cSrcweir } 511cdf0e10cSrcweir } 512cdf0e10cSrcweir 513cdf0e10cSrcweir 514cdf0e10cSrcweir 515cdf0e10cSrcweir 516cdf0e10cSrcweir void ChildrenManagerImpl::RemoveShape (const Reference<drawing::XShape>& rxShape) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir if (rxShape.is()) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir ::osl::ClearableMutexGuard aGuard (maMutex); 521cdf0e10cSrcweir 522cdf0e10cSrcweir // Search shape in list of visible children. 523cdf0e10cSrcweir ChildDescriptorListType::iterator I ( 524cdf0e10cSrcweir ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(), 525cdf0e10cSrcweir ChildDescriptor (rxShape))); 526cdf0e10cSrcweir if (I != maVisibleChildren.end()) 527cdf0e10cSrcweir { 528cdf0e10cSrcweir // Remove descriptor from that list. 529cdf0e10cSrcweir Reference<XAccessible> xAccessibleShape (I->mxAccessibleShape); 530cdf0e10cSrcweir 531cdf0e10cSrcweir UnregisterAsDisposeListener (I->mxShape); 532cdf0e10cSrcweir // Dispose the accessible object. 533cdf0e10cSrcweir I->disposeAccessibleObject (mrContext); 534cdf0e10cSrcweir 535cdf0e10cSrcweir // Now we can safely remove the child descriptor and thus 536cdf0e10cSrcweir // invalidate the iterator. 537cdf0e10cSrcweir maVisibleChildren.erase (I); 538cdf0e10cSrcweir 539cdf0e10cSrcweir adjustIndexInParentOfShapes(maVisibleChildren); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir } 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir 545cdf0e10cSrcweir 546cdf0e10cSrcweir 547cdf0e10cSrcweir void ChildrenManagerImpl::SetShapeList (const ::com::sun::star::uno::Reference< 548cdf0e10cSrcweir ::com::sun::star::drawing::XShapes>& xShapeList) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir mxShapeList = xShapeList; 551cdf0e10cSrcweir } 552cdf0e10cSrcweir 553cdf0e10cSrcweir 554cdf0e10cSrcweir 555cdf0e10cSrcweir 556cdf0e10cSrcweir void ChildrenManagerImpl::AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape) 557cdf0e10cSrcweir { 558cdf0e10cSrcweir if (pShape.get() != NULL) 559cdf0e10cSrcweir maAccessibleShapes.push_back (pShape.release()); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir 563cdf0e10cSrcweir 564cdf0e10cSrcweir 565cdf0e10cSrcweir void ChildrenManagerImpl::ClearAccessibleShapeList (void) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir // Copy the list of (visible) shapes to local lists and clear the 568cdf0e10cSrcweir // originals. 569cdf0e10cSrcweir ChildDescriptorListType aLocalVisibleChildren; 570cdf0e10cSrcweir aLocalVisibleChildren.swap(maVisibleChildren); 571cdf0e10cSrcweir AccessibleShapeList aLocalAccessibleShapes; 572cdf0e10cSrcweir aLocalAccessibleShapes.swap(maAccessibleShapes); 573cdf0e10cSrcweir 574cdf0e10cSrcweir // Tell the listeners that all children are gone. 575cdf0e10cSrcweir mrContext.CommitChange ( 576cdf0e10cSrcweir AccessibleEventId::INVALIDATE_ALL_CHILDREN, 577cdf0e10cSrcweir uno::Any(), 578cdf0e10cSrcweir uno::Any()); 579cdf0e10cSrcweir 580cdf0e10cSrcweir // There are no accessible shapes left so the index assigned to new 581cdf0e10cSrcweir // accessible shapes can be reset. 582cdf0e10cSrcweir mnNewNameIndex = 1; 583cdf0e10cSrcweir 584cdf0e10cSrcweir // Now the objects in the local lists can be safely disposed without 585cdf0e10cSrcweir // having problems with callers that want to update their child lists. 586cdf0e10cSrcweir 587cdf0e10cSrcweir // Clear the list of visible accessible objects. Objects not created on 588cdf0e10cSrcweir // demand for XShapes are treated below. 589cdf0e10cSrcweir ChildDescriptorListType::iterator I,aEnd = aLocalVisibleChildren.end(); 590cdf0e10cSrcweir for (I=aLocalVisibleChildren.begin(); I != aEnd; ++I) 591cdf0e10cSrcweir if ( I->mxAccessibleShape.is() && I->mxShape.is() ) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir ::comphelper::disposeComponent(I->mxAccessibleShape); 594cdf0e10cSrcweir I->mxAccessibleShape = NULL; 595cdf0e10cSrcweir } 596cdf0e10cSrcweir 597cdf0e10cSrcweir // Dispose all objects in the accessible shape list. 598cdf0e10cSrcweir AccessibleShapeList::iterator J,aEnd2 = aLocalAccessibleShapes.end(); 599cdf0e10cSrcweir for (J=aLocalAccessibleShapes.begin(); J != aEnd2; ++J) 600cdf0e10cSrcweir if (J->is()) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir // Dispose the object. 603cdf0e10cSrcweir ::comphelper::disposeComponent(*J); 604cdf0e10cSrcweir *J = NULL; 605cdf0e10cSrcweir } 606cdf0e10cSrcweir } 607cdf0e10cSrcweir 608cdf0e10cSrcweir 609cdf0e10cSrcweir 610cdf0e10cSrcweir 611cdf0e10cSrcweir /** If the broadcasters change at which this object is registered then 612cdf0e10cSrcweir unregister at old and register at new broadcasters. 613cdf0e10cSrcweir */ 614cdf0e10cSrcweir void ChildrenManagerImpl::SetInfo (const AccessibleShapeTreeInfo& rShapeTreeInfo) 615cdf0e10cSrcweir { 616cdf0e10cSrcweir // Remember the current broadcasters and exchange the shape tree info. 617cdf0e10cSrcweir Reference<document::XEventBroadcaster> xCurrentBroadcaster; 618cdf0e10cSrcweir Reference<frame::XController> xCurrentController; 619cdf0e10cSrcweir Reference<view::XSelectionSupplier> xCurrentSelectionSupplier; 620cdf0e10cSrcweir { 621cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 622cdf0e10cSrcweir xCurrentBroadcaster = maShapeTreeInfo.GetModelBroadcaster(); 623cdf0e10cSrcweir xCurrentController = maShapeTreeInfo.GetController(); 624cdf0e10cSrcweir xCurrentSelectionSupplier = Reference<view::XSelectionSupplier> ( 625cdf0e10cSrcweir xCurrentController, uno::UNO_QUERY); 626cdf0e10cSrcweir maShapeTreeInfo = rShapeTreeInfo; 627cdf0e10cSrcweir } 628cdf0e10cSrcweir 629cdf0e10cSrcweir // Move registration to new model. 630cdf0e10cSrcweir if (maShapeTreeInfo.GetModelBroadcaster() != xCurrentBroadcaster) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir // Register at new broadcaster. 633cdf0e10cSrcweir if (maShapeTreeInfo.GetModelBroadcaster().is()) 634cdf0e10cSrcweir maShapeTreeInfo.GetModelBroadcaster()->addEventListener ( 635cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 636cdf0e10cSrcweir 637cdf0e10cSrcweir // Unregister at old broadcaster. 638cdf0e10cSrcweir if (xCurrentBroadcaster.is()) 639cdf0e10cSrcweir xCurrentBroadcaster->removeEventListener ( 640cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 641cdf0e10cSrcweir } 642cdf0e10cSrcweir 643cdf0e10cSrcweir // Move registration to new selection supplier. 644cdf0e10cSrcweir Reference<frame::XController> xNewController(maShapeTreeInfo.GetController()); 645cdf0e10cSrcweir Reference<view::XSelectionSupplier> xNewSelectionSupplier ( 646cdf0e10cSrcweir xNewController, uno::UNO_QUERY); 647cdf0e10cSrcweir if (xNewSelectionSupplier != xCurrentSelectionSupplier) 648cdf0e10cSrcweir { 649cdf0e10cSrcweir // Register at new broadcaster. 650cdf0e10cSrcweir if (xNewSelectionSupplier.is()) 651cdf0e10cSrcweir { 652cdf0e10cSrcweir xNewController->addEventListener( 653cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 654cdf0e10cSrcweir 655cdf0e10cSrcweir xNewSelectionSupplier->addSelectionChangeListener ( 656cdf0e10cSrcweir static_cast<view::XSelectionChangeListener*>(this)); 657cdf0e10cSrcweir } 658cdf0e10cSrcweir 659cdf0e10cSrcweir // Unregister at old broadcaster. 660cdf0e10cSrcweir if (xCurrentSelectionSupplier.is()) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir xCurrentSelectionSupplier->removeSelectionChangeListener ( 663cdf0e10cSrcweir static_cast<view::XSelectionChangeListener*>(this)); 664cdf0e10cSrcweir 665cdf0e10cSrcweir xCurrentController->removeEventListener( 666cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 667cdf0e10cSrcweir } 668cdf0e10cSrcweir } 669cdf0e10cSrcweir } 670cdf0e10cSrcweir 671cdf0e10cSrcweir 672cdf0e10cSrcweir 673cdf0e10cSrcweir 674cdf0e10cSrcweir //===== lang::XEventListener ================================================ 675cdf0e10cSrcweir 676cdf0e10cSrcweir void SAL_CALL 677cdf0e10cSrcweir ChildrenManagerImpl::disposing (const lang::EventObject& rEventObject) 678cdf0e10cSrcweir throw (uno::RuntimeException) 679cdf0e10cSrcweir { 680cdf0e10cSrcweir if (rEventObject.Source == maShapeTreeInfo.GetModelBroadcaster() 681cdf0e10cSrcweir || rEventObject.Source == maShapeTreeInfo.GetController()) 682cdf0e10cSrcweir { 683cdf0e10cSrcweir impl_dispose(); 684cdf0e10cSrcweir } 685cdf0e10cSrcweir 686cdf0e10cSrcweir // Handle disposing UNO shapes. 687cdf0e10cSrcweir else 688cdf0e10cSrcweir { 689cdf0e10cSrcweir Reference<drawing::XShape> xShape (rEventObject.Source, uno::UNO_QUERY); 690cdf0e10cSrcweir 691cdf0e10cSrcweir // Find the descriptor for the given shape. 692cdf0e10cSrcweir ChildDescriptorListType::iterator I ( 693cdf0e10cSrcweir ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(), 694cdf0e10cSrcweir ChildDescriptor (xShape))); 695cdf0e10cSrcweir if (I != maVisibleChildren.end()) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir // Clear the descriptor. 698cdf0e10cSrcweir I->disposeAccessibleObject (mrContext); 699cdf0e10cSrcweir I->mxShape = NULL; 700cdf0e10cSrcweir } 701cdf0e10cSrcweir } 702cdf0e10cSrcweir } 703cdf0e10cSrcweir 704cdf0e10cSrcweir 705cdf0e10cSrcweir 706cdf0e10cSrcweir 707cdf0e10cSrcweir //===== document::XEventListener ============================================ 708cdf0e10cSrcweir 709cdf0e10cSrcweir /** Listen for new and removed shapes. 710cdf0e10cSrcweir */ 711cdf0e10cSrcweir void SAL_CALL 712cdf0e10cSrcweir ChildrenManagerImpl::notifyEvent ( 713cdf0e10cSrcweir const document::EventObject& rEventObject) 714cdf0e10cSrcweir throw (uno::RuntimeException) 715cdf0e10cSrcweir { 716cdf0e10cSrcweir static const ::rtl::OUString sShapeInserted ( 717cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("ShapeInserted")); 718cdf0e10cSrcweir static const ::rtl::OUString sShapeRemoved ( 719cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("ShapeRemoved")); 720cdf0e10cSrcweir 721cdf0e10cSrcweir 722cdf0e10cSrcweir if (rEventObject.EventName.equals (sShapeInserted)) 723cdf0e10cSrcweir AddShape (Reference<drawing::XShape>(rEventObject.Source, uno::UNO_QUERY)); 724cdf0e10cSrcweir else if (rEventObject.EventName.equals (sShapeRemoved)) 725cdf0e10cSrcweir RemoveShape (Reference<drawing::XShape>(rEventObject.Source, uno::UNO_QUERY)); 726cdf0e10cSrcweir // else ignore unknown event. 727cdf0e10cSrcweir } 728cdf0e10cSrcweir 729cdf0e10cSrcweir 730cdf0e10cSrcweir 731cdf0e10cSrcweir 732cdf0e10cSrcweir //===== view::XSelectionChangeListener ====================================== 733cdf0e10cSrcweir 734cdf0e10cSrcweir void SAL_CALL 735cdf0e10cSrcweir ChildrenManagerImpl::selectionChanged (const lang::EventObject& /*rEvent*/) 736cdf0e10cSrcweir throw (uno::RuntimeException) 737cdf0e10cSrcweir { 738cdf0e10cSrcweir UpdateSelection (); 739cdf0e10cSrcweir } 740cdf0e10cSrcweir 741cdf0e10cSrcweir 742cdf0e10cSrcweir 743cdf0e10cSrcweir 744cdf0e10cSrcweir void ChildrenManagerImpl::impl_dispose (void) 745cdf0e10cSrcweir { 746cdf0e10cSrcweir Reference<frame::XController> xController(maShapeTreeInfo.GetController()); 747cdf0e10cSrcweir // Remove from broadcasters. 748cdf0e10cSrcweir try 749cdf0e10cSrcweir { 750cdf0e10cSrcweir Reference<view::XSelectionSupplier> xSelectionSupplier ( 751cdf0e10cSrcweir xController, uno::UNO_QUERY); 752cdf0e10cSrcweir if (xSelectionSupplier.is()) 753cdf0e10cSrcweir { 754cdf0e10cSrcweir xSelectionSupplier->removeSelectionChangeListener ( 755cdf0e10cSrcweir static_cast<view::XSelectionChangeListener*>(this)); 756cdf0e10cSrcweir } 757cdf0e10cSrcweir } 758cdf0e10cSrcweir catch( uno::RuntimeException&) 759cdf0e10cSrcweir {} 760cdf0e10cSrcweir 761cdf0e10cSrcweir try 762cdf0e10cSrcweir { 763cdf0e10cSrcweir if (xController.is()) 764cdf0e10cSrcweir xController->removeEventListener( 765cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 766cdf0e10cSrcweir } 767cdf0e10cSrcweir catch( uno::RuntimeException&) 768cdf0e10cSrcweir {} 769cdf0e10cSrcweir 770cdf0e10cSrcweir maShapeTreeInfo.SetController (NULL); 771cdf0e10cSrcweir 772cdf0e10cSrcweir try 773cdf0e10cSrcweir { 774cdf0e10cSrcweir // Remove from broadcaster. 775cdf0e10cSrcweir if (maShapeTreeInfo.GetModelBroadcaster().is()) 776cdf0e10cSrcweir maShapeTreeInfo.GetModelBroadcaster()->removeEventListener ( 777cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 778cdf0e10cSrcweir maShapeTreeInfo.SetModelBroadcaster (NULL); 779cdf0e10cSrcweir } 780cdf0e10cSrcweir catch( uno::RuntimeException& ) 781cdf0e10cSrcweir {} 782cdf0e10cSrcweir 783cdf0e10cSrcweir ClearAccessibleShapeList (); 784cdf0e10cSrcweir SetShapeList (NULL); 785cdf0e10cSrcweir } 786cdf0e10cSrcweir 787cdf0e10cSrcweir 788cdf0e10cSrcweir 789cdf0e10cSrcweir void SAL_CALL ChildrenManagerImpl::disposing (void) 790cdf0e10cSrcweir { 791cdf0e10cSrcweir impl_dispose(); 792cdf0e10cSrcweir } 793cdf0e10cSrcweir 794cdf0e10cSrcweir 795cdf0e10cSrcweir 796cdf0e10cSrcweir 797cdf0e10cSrcweir // This method is experimental. Use with care. 798cdf0e10cSrcweir long int ChildrenManagerImpl::GetChildIndex (const ::com::sun::star::uno::Reference< 799cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& xChild) const 800cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 801cdf0e10cSrcweir { 802cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 803cdf0e10cSrcweir sal_Int32 nCount = maVisibleChildren.size(); 804cdf0e10cSrcweir for (sal_Int32 i=0; i < nCount; ++i) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir // Is this equality comparison valid? 807cdf0e10cSrcweir if (maVisibleChildren[i].mxAccessibleShape == xChild) 808cdf0e10cSrcweir return i; 809cdf0e10cSrcweir } 810cdf0e10cSrcweir 811cdf0e10cSrcweir return -1; 812cdf0e10cSrcweir } 813cdf0e10cSrcweir 814cdf0e10cSrcweir 815cdf0e10cSrcweir 816cdf0e10cSrcweir 817cdf0e10cSrcweir //===== IAccessibleViewForwarderListener ==================================== 818cdf0e10cSrcweir 819cdf0e10cSrcweir void ChildrenManagerImpl::ViewForwarderChanged (ChangeType aChangeType, 820cdf0e10cSrcweir const IAccessibleViewForwarder* pViewForwarder) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir if (aChangeType == IAccessibleViewForwarderListener::VISIBLE_AREA) 823cdf0e10cSrcweir Update (false); 824cdf0e10cSrcweir else 825cdf0e10cSrcweir { 826cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 827cdf0e10cSrcweir ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end(); 828cdf0e10cSrcweir for (I=maVisibleChildren.begin(); I != aEnd; ++I) 829cdf0e10cSrcweir { 830cdf0e10cSrcweir AccessibleShape* pShape = I->GetAccessibleShape(); 831cdf0e10cSrcweir if (pShape != NULL) 832cdf0e10cSrcweir pShape->ViewForwarderChanged (aChangeType, pViewForwarder); 833cdf0e10cSrcweir } 834cdf0e10cSrcweir } 835cdf0e10cSrcweir } 836cdf0e10cSrcweir 837cdf0e10cSrcweir 838cdf0e10cSrcweir 839cdf0e10cSrcweir 840cdf0e10cSrcweir //===== IAccessibleParent =================================================== 841cdf0e10cSrcweir 842cdf0e10cSrcweir sal_Bool ChildrenManagerImpl::ReplaceChild ( 843cdf0e10cSrcweir AccessibleShape* pCurrentChild, 844cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape, 845cdf0e10cSrcweir const long _nIndex, 846cdf0e10cSrcweir const AccessibleShapeTreeInfo& _rShapeTreeInfo) 847cdf0e10cSrcweir throw (uno::RuntimeException) 848cdf0e10cSrcweir { 849cdf0e10cSrcweir AccessibleShapeInfo aShapeInfo( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex ); 850cdf0e10cSrcweir // create the new child 851cdf0e10cSrcweir AccessibleShape* pNewChild = ShapeTypeHandler::Instance().CreateAccessibleObject ( 852cdf0e10cSrcweir aShapeInfo, 853cdf0e10cSrcweir _rShapeTreeInfo 854cdf0e10cSrcweir ); 855cdf0e10cSrcweir Reference< XAccessible > xNewChild( pNewChild ); // keep this alive (do this before calling Init!) 856cdf0e10cSrcweir if ( pNewChild ) 857cdf0e10cSrcweir pNewChild->Init(); 858cdf0e10cSrcweir 859cdf0e10cSrcweir sal_Bool bResult = sal_False; 860cdf0e10cSrcweir 861cdf0e10cSrcweir // Iterate over the visible children. If one of them has an already 862cdf0e10cSrcweir // created accessible object that matches pCurrentChild then replace 863cdf0e10cSrcweir // it. Otherwise the child to replace is either not in the list or has 864cdf0e10cSrcweir // not ye been created (and is therefore not in the list, too) and a 865cdf0e10cSrcweir // replacement is not necessary. 866cdf0e10cSrcweir ChildDescriptorListType::iterator I,aEnd = maVisibleChildren.end(); 867cdf0e10cSrcweir for (I=maVisibleChildren.begin(); I != aEnd; ++I) 868cdf0e10cSrcweir { 869cdf0e10cSrcweir if (I->GetAccessibleShape() == pCurrentChild) 870cdf0e10cSrcweir { 871cdf0e10cSrcweir // Dispose the current child and send an event about its deletion. 872cdf0e10cSrcweir pCurrentChild->dispose(); 873cdf0e10cSrcweir mrContext.CommitChange ( 874cdf0e10cSrcweir AccessibleEventId::CHILD, 875cdf0e10cSrcweir uno::Any(), 876cdf0e10cSrcweir uno::makeAny (I->mxAccessibleShape)); 877cdf0e10cSrcweir 878*86e1cf34SPedro Giffuni // Replace with replacement and send an event about existence 879cdf0e10cSrcweir // of the new child. 880cdf0e10cSrcweir I->mxAccessibleShape = pNewChild; 881cdf0e10cSrcweir mrContext.CommitChange ( 882cdf0e10cSrcweir AccessibleEventId::CHILD, 883cdf0e10cSrcweir uno::makeAny (I->mxAccessibleShape), 884cdf0e10cSrcweir uno::Any()); 885cdf0e10cSrcweir bResult = sal_True; 886cdf0e10cSrcweir break; 887cdf0e10cSrcweir } 888cdf0e10cSrcweir } 889cdf0e10cSrcweir 890cdf0e10cSrcweir // When not found among the visible children we have to search the list 891cdf0e10cSrcweir // of accessible shapes. This is not yet implemented. 892cdf0e10cSrcweir 893cdf0e10cSrcweir return bResult; 894cdf0e10cSrcweir } 8959b8096d0SSteve Yin // Add the impl method for IAccessibleParent interface 8969b8096d0SSteve Yin AccessibleControlShape * ChildrenManagerImpl::GetAccControlShapeFromModel(::com::sun::star::beans::XPropertySet* pSet) throw (::com::sun::star::uno::RuntimeException) 8979b8096d0SSteve Yin { 8989b8096d0SSteve Yin sal_Int32 count = GetChildCount(); 8999b8096d0SSteve Yin for (sal_Int32 index=0;index<count;index++) 9009b8096d0SSteve Yin { 9019b8096d0SSteve Yin AccessibleShape* pAccShape = maVisibleChildren[index].GetAccessibleShape(); 9029b8096d0SSteve Yin if (pAccShape && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == DRAWING_CONTROL) 9039b8096d0SSteve Yin { 9049b8096d0SSteve Yin ::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape); 9059b8096d0SSteve Yin if (pCtlAccShape && pCtlAccShape->GetControlModel() == pSet) 9069b8096d0SSteve Yin return pCtlAccShape; 9079b8096d0SSteve Yin } 9089b8096d0SSteve Yin } 9099b8096d0SSteve Yin return NULL; 9109b8096d0SSteve Yin } 9119b8096d0SSteve Yin uno::Reference<XAccessible> 9129b8096d0SSteve Yin ChildrenManagerImpl::GetAccessibleCaption (const uno::Reference<drawing::XShape>& xShape) 9139b8096d0SSteve Yin throw (uno::RuntimeException) 9149b8096d0SSteve Yin { 9159b8096d0SSteve Yin ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end(); 9169b8096d0SSteve Yin for (I = maVisibleChildren.begin(); I != aEnd; ++I) 9179b8096d0SSteve Yin { 9189b8096d0SSteve Yin if ( I->mxShape.get() == xShape.get() ) 9199b8096d0SSteve Yin return I->mxAccessibleShape; 9209b8096d0SSteve Yin } 9219b8096d0SSteve Yin return uno::Reference<XAccessible> (); 9229b8096d0SSteve Yin } 923cdf0e10cSrcweir 924cdf0e10cSrcweir /** Update the <const>SELECTED</const> and the <const>FOCUSED</const> state 925cdf0e10cSrcweir of all visible children. Maybe this should be changed to all children. 926cdf0e10cSrcweir 927cdf0e10cSrcweir Iterate over all descriptors of visible accessible shapes and look them 928cdf0e10cSrcweir up in the selection. 929cdf0e10cSrcweir 930cdf0e10cSrcweir If there is no valid controller then all shapes are deselected and 931cdf0e10cSrcweir unfocused. If the controller's frame is not active then all shapes are 932cdf0e10cSrcweir unfocused. 933cdf0e10cSrcweir */ 934cdf0e10cSrcweir void ChildrenManagerImpl::UpdateSelection (void) 935cdf0e10cSrcweir { 936cdf0e10cSrcweir Reference<frame::XController> xController(maShapeTreeInfo.GetController()); 937cdf0e10cSrcweir Reference<view::XSelectionSupplier> xSelectionSupplier ( 938cdf0e10cSrcweir xController, uno::UNO_QUERY); 939cdf0e10cSrcweir 940cdf0e10cSrcweir // Try to cast the selection both to a multi selection and to a single 941cdf0e10cSrcweir // selection. 942cdf0e10cSrcweir Reference<container::XIndexAccess> xSelectedShapeAccess; 943cdf0e10cSrcweir Reference<drawing::XShape> xSelectedShape; 944cdf0e10cSrcweir if (xSelectionSupplier.is()) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir xSelectedShapeAccess = Reference<container::XIndexAccess> ( 947cdf0e10cSrcweir xSelectionSupplier->getSelection(), uno::UNO_QUERY); 948cdf0e10cSrcweir xSelectedShape = Reference<drawing::XShape> ( 949cdf0e10cSrcweir xSelectionSupplier->getSelection(), uno::UNO_QUERY); 950cdf0e10cSrcweir } 951cdf0e10cSrcweir 952cdf0e10cSrcweir // Remember the current and new focused shape. 953cdf0e10cSrcweir AccessibleShape* pCurrentlyFocusedShape = NULL; 954cdf0e10cSrcweir AccessibleShape* pNewFocusedShape = NULL; 9559b8096d0SSteve Yin typedef std::pair< AccessibleShape* , sal_Bool > PAIR_SHAPE;//sal_Bool Selected,UnSelected. 9569b8096d0SSteve Yin typedef std::vector< PAIR_SHAPE > VEC_SHAPE; 9579b8096d0SSteve Yin VEC_SHAPE vecSelect; 9589b8096d0SSteve Yin int nAddSelect=0; 9599b8096d0SSteve Yin int nRemoveSelect=0; 9609b8096d0SSteve Yin sal_Bool bHasSelectedShape=sal_False; 961cdf0e10cSrcweir ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end(); 962cdf0e10cSrcweir for (I=maVisibleChildren.begin(); I != aEnd; ++I) 963cdf0e10cSrcweir { 964cdf0e10cSrcweir AccessibleShape* pAccessibleShape = I->GetAccessibleShape(); 965cdf0e10cSrcweir if (I->mxAccessibleShape.is() && I->mxShape.is() && pAccessibleShape!=NULL) 966cdf0e10cSrcweir { 9679b8096d0SSteve Yin short nRole = pAccessibleShape->getAccessibleRole(); 9689b8096d0SSteve Yin bool bDrawShape = ( 9699b8096d0SSteve Yin nRole == AccessibleRole::GRAPHIC || 9709b8096d0SSteve Yin nRole == AccessibleRole::EMBEDDED_OBJECT || 9719b8096d0SSteve Yin nRole == AccessibleRole::SHAPE || 9729b8096d0SSteve Yin nRole == AccessibleRole::IMAGE_MAP || 9739b8096d0SSteve Yin nRole == AccessibleRole::TABLE_CELL || 9749b8096d0SSteve Yin nRole == AccessibleRole::TABLE ); 975cdf0e10cSrcweir bool bShapeIsSelected = false; 976cdf0e10cSrcweir 977cdf0e10cSrcweir // Look up the shape in the (single or multi-) selection. 978cdf0e10cSrcweir if (xSelectedShape.is()) 979cdf0e10cSrcweir { 980cdf0e10cSrcweir if (I->mxShape == xSelectedShape) 981cdf0e10cSrcweir { 982cdf0e10cSrcweir bShapeIsSelected = true; 983cdf0e10cSrcweir pNewFocusedShape = pAccessibleShape; 984cdf0e10cSrcweir } 985cdf0e10cSrcweir } 986cdf0e10cSrcweir else if (xSelectedShapeAccess.is()) 987cdf0e10cSrcweir { 988cdf0e10cSrcweir sal_Int32 nCount=xSelectedShapeAccess->getCount(); 989cdf0e10cSrcweir for (sal_Int32 i=0; i<nCount&&!bShapeIsSelected; i++) 990cdf0e10cSrcweir if (xSelectedShapeAccess->getByIndex(i) == I->mxShape) 991cdf0e10cSrcweir { 992cdf0e10cSrcweir bShapeIsSelected = true; 993cdf0e10cSrcweir // In a multi-selection no shape has the focus. 994cdf0e10cSrcweir if (nCount == 1) 995cdf0e10cSrcweir pNewFocusedShape = pAccessibleShape; 996cdf0e10cSrcweir } 997cdf0e10cSrcweir } 998cdf0e10cSrcweir 999cdf0e10cSrcweir // Set or reset the SELECTED state. 1000cdf0e10cSrcweir if (bShapeIsSelected) 10019b8096d0SSteve Yin { 10029b8096d0SSteve Yin if (pAccessibleShape->SetState (AccessibleStateType::SELECTED)) 10039b8096d0SSteve Yin { 10049b8096d0SSteve Yin if (bDrawShape) 10059b8096d0SSteve Yin { 10069b8096d0SSteve Yin vecSelect.push_back(std::make_pair(pAccessibleShape,sal_True)); 10079b8096d0SSteve Yin ++nAddSelect; 10089b8096d0SSteve Yin } 10099b8096d0SSteve Yin } 10109b8096d0SSteve Yin else 10119b8096d0SSteve Yin {//Selected not change,has selected shape before 10129b8096d0SSteve Yin bHasSelectedShape=sal_True; 10139b8096d0SSteve Yin } 10149b8096d0SSteve Yin } 1015cdf0e10cSrcweir else 10169b8096d0SSteve Yin { 10179b8096d0SSteve Yin if(pAccessibleShape->ResetState (AccessibleStateType::SELECTED)) 10189b8096d0SSteve Yin { 10199b8096d0SSteve Yin if(bDrawShape) 10209b8096d0SSteve Yin { 10219b8096d0SSteve Yin vecSelect.push_back(std::make_pair(pAccessibleShape,sal_False)); 10229b8096d0SSteve Yin ++nRemoveSelect; 10239b8096d0SSteve Yin } 10249b8096d0SSteve Yin } 10259b8096d0SSteve Yin } 1026cdf0e10cSrcweir // Does the shape have the current selection? 1027cdf0e10cSrcweir if (pAccessibleShape->GetState (AccessibleStateType::FOCUSED)) 1028cdf0e10cSrcweir pCurrentlyFocusedShape = pAccessibleShape; 1029cdf0e10cSrcweir } 1030cdf0e10cSrcweir } 10319b8096d0SSteve Yin /* 1032cdf0e10cSrcweir // Check if the frame we are in is currently active. If not then make 1033cdf0e10cSrcweir // sure to not send a FOCUSED state change. 1034cdf0e10cSrcweir if (xController.is()) 1035cdf0e10cSrcweir { 1036cdf0e10cSrcweir Reference<frame::XFrame> xFrame (xController->getFrame()); 1037cdf0e10cSrcweir if (xFrame.is()) 1038cdf0e10cSrcweir if ( ! xFrame->isActive()) 1039cdf0e10cSrcweir pNewFocusedShape = NULL; 1040cdf0e10cSrcweir } 10419b8096d0SSteve Yin */ 10429b8096d0SSteve Yin Window *pParentWidow = maShapeTreeInfo.GetWindow(); 10439b8096d0SSteve Yin bool bShapeActive= false; 10440deba7fbSSteve Yin // For table cell, the table's parent must be checked to make sure it has focus. 10459b8096d0SSteve Yin Window *pPWindow = pParentWidow->GetParent(); 10469b8096d0SSteve Yin if (pParentWidow && ( pParentWidow->HasFocus() || (pPWindow && pPWindow->HasFocus()))) 10479b8096d0SSteve Yin { 10489b8096d0SSteve Yin bShapeActive =true; 10499b8096d0SSteve Yin } 1050cdf0e10cSrcweir // Move focus from current to newly focused shape. 1051cdf0e10cSrcweir if (pCurrentlyFocusedShape != pNewFocusedShape) 1052cdf0e10cSrcweir { 1053cdf0e10cSrcweir if (pCurrentlyFocusedShape != NULL) 1054cdf0e10cSrcweir pCurrentlyFocusedShape->ResetState (AccessibleStateType::FOCUSED); 10559b8096d0SSteve Yin if (pNewFocusedShape != NULL && bShapeActive) 1056cdf0e10cSrcweir pNewFocusedShape->SetState (AccessibleStateType::FOCUSED); 10579b8096d0SSteve Yin } 10589b8096d0SSteve Yin 10599b8096d0SSteve Yin if (nAddSelect >= 10 )//fire selection within 10609b8096d0SSteve Yin { 10619b8096d0SSteve Yin mrContext.CommitChange(AccessibleEventId::SELECTION_CHANGED_WITHIN,uno::Any(),uno::Any()); 10629b8096d0SSteve Yin nAddSelect =0 ;//not fire selection event 10639b8096d0SSteve Yin } 10649b8096d0SSteve Yin //VEC_SHAPE::iterator vi = vecSelect.begin(); 10659b8096d0SSteve Yin //for (; vi != vecSelect.end() ;++vi) 10669b8096d0SSteve Yin VEC_SHAPE::reverse_iterator vi = vecSelect.rbegin(); 10679b8096d0SSteve Yin for (; vi != vecSelect.rend() ;++vi) 10689b8096d0SSteve Yin 10699b8096d0SSteve Yin { 10709b8096d0SSteve Yin PAIR_SHAPE &pairShape= *vi; 10719b8096d0SSteve Yin Reference< XAccessible > xShape(pairShape.first); 10729b8096d0SSteve Yin uno::Any anyShape; 10739b8096d0SSteve Yin anyShape <<= xShape; 10749b8096d0SSteve Yin 10759b8096d0SSteve Yin if (pairShape.second)//Selection add 10769b8096d0SSteve Yin { 10779b8096d0SSteve Yin if (bHasSelectedShape) 10789b8096d0SSteve Yin { 10799b8096d0SSteve Yin if ( nAddSelect > 0 ) 10809b8096d0SSteve Yin { 10819b8096d0SSteve Yin mrContext.CommitChange(AccessibleEventId::SELECTION_CHANGED_ADD,anyShape,uno::Any()); 10829b8096d0SSteve Yin } 10839b8096d0SSteve Yin } 10849b8096d0SSteve Yin else 10859b8096d0SSteve Yin { 10869b8096d0SSteve Yin //if has not selected shape ,first selected shape is fire selection event; 10879b8096d0SSteve Yin if (nAddSelect > 0 ) 10889b8096d0SSteve Yin { 10899b8096d0SSteve Yin mrContext.CommitChange(AccessibleEventId::SELECTION_CHANGED,anyShape,uno::Any()); 10909b8096d0SSteve Yin } 10919b8096d0SSteve Yin if (nAddSelect > 1 )//check other selected shape fire selection add event 10929b8096d0SSteve Yin { 10939b8096d0SSteve Yin bHasSelectedShape=sal_True; 10949b8096d0SSteve Yin } 10959b8096d0SSteve Yin } 10969b8096d0SSteve Yin } 10979b8096d0SSteve Yin else //selection remove 10989b8096d0SSteve Yin { 10999b8096d0SSteve Yin mrContext.CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE,anyShape,uno::Any()); 11009b8096d0SSteve Yin } 11019b8096d0SSteve Yin } 1102cdf0e10cSrcweir 1103cdf0e10cSrcweir // Remember whether there is a shape that now has the focus. 1104cdf0e10cSrcweir mpFocusedShape = pNewFocusedShape; 1105cdf0e10cSrcweir } 1106cdf0e10cSrcweir 1107cdf0e10cSrcweir 1108cdf0e10cSrcweir 1109cdf0e10cSrcweir 1110cdf0e10cSrcweir bool ChildrenManagerImpl::HasFocus (void) 1111cdf0e10cSrcweir { 1112cdf0e10cSrcweir return mpFocusedShape != NULL; 1113cdf0e10cSrcweir } 1114cdf0e10cSrcweir 1115cdf0e10cSrcweir 1116cdf0e10cSrcweir 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir void ChildrenManagerImpl::RemoveFocus (void) 1119cdf0e10cSrcweir { 1120cdf0e10cSrcweir if (mpFocusedShape != NULL) 1121cdf0e10cSrcweir { 1122cdf0e10cSrcweir mpFocusedShape->ResetState (AccessibleStateType::FOCUSED); 1123cdf0e10cSrcweir mpFocusedShape = NULL; 1124cdf0e10cSrcweir } 1125cdf0e10cSrcweir } 1126cdf0e10cSrcweir 1127cdf0e10cSrcweir 1128cdf0e10cSrcweir 1129cdf0e10cSrcweir void ChildrenManagerImpl::RegisterAsDisposeListener ( 1130cdf0e10cSrcweir const Reference<drawing::XShape>& xShape) 1131cdf0e10cSrcweir { 1132cdf0e10cSrcweir Reference<lang::XComponent> xComponent (xShape, uno::UNO_QUERY); 1133cdf0e10cSrcweir if (xComponent.is()) 1134cdf0e10cSrcweir xComponent->addEventListener ( 1135cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 1136cdf0e10cSrcweir } 1137cdf0e10cSrcweir 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir void ChildrenManagerImpl::UnregisterAsDisposeListener ( 1142cdf0e10cSrcweir const Reference<drawing::XShape>& xShape) 1143cdf0e10cSrcweir { 1144cdf0e10cSrcweir Reference<lang::XComponent> xComponent (xShape, uno::UNO_QUERY); 1145cdf0e10cSrcweir if (xComponent.is()) 1146cdf0e10cSrcweir xComponent->removeEventListener ( 1147cdf0e10cSrcweir static_cast<document::XEventListener*>(this)); 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir 1152cdf0e10cSrcweir 1153cdf0e10cSrcweir //===== AccessibleChildDescriptor =========================================== 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir ChildDescriptor::ChildDescriptor (const Reference<drawing::XShape>& xShape) 1156cdf0e10cSrcweir : mxShape (xShape), 1157cdf0e10cSrcweir mxAccessibleShape (NULL), 1158cdf0e10cSrcweir mbCreateEventPending (true) 1159cdf0e10cSrcweir { 1160cdf0e10cSrcweir // Empty. 1161cdf0e10cSrcweir } 1162cdf0e10cSrcweir 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir 1166cdf0e10cSrcweir ChildDescriptor::ChildDescriptor (const Reference<XAccessible>& rxAccessibleShape) 1167cdf0e10cSrcweir : mxShape (NULL), 1168cdf0e10cSrcweir mxAccessibleShape (rxAccessibleShape), 1169cdf0e10cSrcweir mbCreateEventPending (true) 1170cdf0e10cSrcweir { 1171cdf0e10cSrcweir // Make sure that the accessible object has the <const>VISIBLE</const> 1172cdf0e10cSrcweir // state set. 1173cdf0e10cSrcweir AccessibleShape* pAccessibleShape = GetAccessibleShape(); 1174cdf0e10cSrcweir pAccessibleShape->SetState (AccessibleStateType::VISIBLE); 1175cdf0e10cSrcweir } 1176cdf0e10cSrcweir 1177cdf0e10cSrcweir 1178cdf0e10cSrcweir 1179cdf0e10cSrcweir 1180cdf0e10cSrcweir ChildDescriptor::~ChildDescriptor (void) 1181cdf0e10cSrcweir { 1182cdf0e10cSrcweir } 1183cdf0e10cSrcweir 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir AccessibleShape* ChildDescriptor::GetAccessibleShape (void) const 1188cdf0e10cSrcweir { 1189cdf0e10cSrcweir return static_cast<AccessibleShape*> (mxAccessibleShape.get()); 1190cdf0e10cSrcweir } 1191cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1192cdf0e10cSrcweir void ChildDescriptor::setIndexAtAccessibleShape(sal_Int32 _nIndex) 1193cdf0e10cSrcweir { 1194cdf0e10cSrcweir AccessibleShape* pShape = GetAccessibleShape(); 1195cdf0e10cSrcweir if ( pShape ) 1196cdf0e10cSrcweir pShape->setIndexInParent(_nIndex); 1197cdf0e10cSrcweir } 1198cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1199cdf0e10cSrcweir 1200cdf0e10cSrcweir 1201cdf0e10cSrcweir 1202cdf0e10cSrcweir 1203cdf0e10cSrcweir void ChildDescriptor::disposeAccessibleObject (AccessibleContextBase& rParent) 1204cdf0e10cSrcweir { 1205cdf0e10cSrcweir if (mxAccessibleShape.is()) 1206cdf0e10cSrcweir { 1207cdf0e10cSrcweir // Send event that the shape has been removed. 1208cdf0e10cSrcweir uno::Any aOldValue; 1209cdf0e10cSrcweir aOldValue <<= mxAccessibleShape; 1210cdf0e10cSrcweir rParent.CommitChange ( 1211cdf0e10cSrcweir AccessibleEventId::CHILD, 1212cdf0e10cSrcweir uno::Any(), 1213cdf0e10cSrcweir aOldValue); 1214cdf0e10cSrcweir 1215cdf0e10cSrcweir // Dispose and remove the object. 1216cdf0e10cSrcweir Reference<lang::XComponent> xComponent (mxAccessibleShape, uno::UNO_QUERY); 1217cdf0e10cSrcweir if (xComponent.is()) 1218cdf0e10cSrcweir xComponent->dispose (); 1219cdf0e10cSrcweir 1220cdf0e10cSrcweir mxAccessibleShape = NULL; 1221cdf0e10cSrcweir } 1222cdf0e10cSrcweir } 1223cdf0e10cSrcweir 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir } // end of namespace accessibility 1226cdf0e10cSrcweir 1227