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