LCOV - code coverage report
Current view: top level - svx/source/accessibility - ChildrenManagerImpl.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 463 0.0 %
Date: 2014-04-14 Functions: 0 42 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <sal/config.h>
      21             : 
      22             : #include <cassert>
      23             : 
      24             : #include "ChildrenManagerImpl.hxx"
      25             : #include <svx/ShapeTypeHandler.hxx>
      26             : #include <svx/AccessibleShapeInfo.hxx>
      27             : #include <vcl/svapp.hxx>
      28             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      29             : #include <com/sun/star/view/XSelectionSupplier.hpp>
      30             : #include <com/sun/star/container/XChild.hpp>
      31             : #include <comphelper/uno3.hxx>
      32             : 
      33             : #include <rtl/ustring.hxx>
      34             : #include <tools/debug.hxx>
      35             : #include <svx/SvxShapeTypes.hxx>
      36             : #include <vcl/window.hxx>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::accessibility;
      40             : using ::com::sun::star::uno::Reference;
      41             : 
      42             : namespace accessibility {
      43             : 
      44             : namespace
      45             : {
      46           0 : void adjustIndexInParentOfShapes(ChildDescriptorListType& _rList)
      47             : {
      48           0 :     ChildDescriptorListType::iterator aEnd = _rList.end();
      49           0 :     sal_Int32 i=0;
      50           0 :     for ( ChildDescriptorListType::iterator aIter = _rList.begin(); aIter != aEnd; ++aIter,++i)
      51           0 :         aIter->setIndexAtAccessibleShape(i);
      52           0 : }
      53             : }
      54             : 
      55             : //=====  AccessibleChildrenManager  ===========================================
      56             : 
      57           0 : ChildrenManagerImpl::ChildrenManagerImpl (
      58             :     const uno::Reference<XAccessible>& rxParent,
      59             :     const uno::Reference<drawing::XShapes>& rxShapeList,
      60             :     const AccessibleShapeTreeInfo& rShapeTreeInfo,
      61             :     AccessibleContextBase& rContext)
      62             :     : ::cppu::WeakComponentImplHelper2<
      63             :           ::com::sun::star::document::XEventListener,
      64             :           ::com::sun::star::view::XSelectionChangeListener>(maMutex),
      65             :       mxShapeList (rxShapeList),
      66             :       mxParent (rxParent),
      67             :       maShapeTreeInfo (rShapeTreeInfo),
      68             :       mrContext (rContext),
      69             :       mnNewNameIndex(1),
      70           0 :       mpFocusedShape(NULL)
      71             : {
      72           0 : }
      73             : 
      74             : 
      75             : 
      76             : 
      77           0 : ChildrenManagerImpl::~ChildrenManagerImpl (void)
      78             : {
      79             :     DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose,
      80             :         "~AccessibleDrawDocumentView: object has not been disposed");
      81           0 : }
      82             : 
      83             : 
      84             : 
      85             : 
      86           0 : void ChildrenManagerImpl::Init (void)
      87             : {
      88             :     // Register as view::XSelectionChangeListener.
      89           0 :     Reference<frame::XController> xController(maShapeTreeInfo.GetController());
      90             :     Reference<view::XSelectionSupplier> xSelectionSupplier (
      91           0 :         xController, uno::UNO_QUERY);
      92           0 :     if (xSelectionSupplier.is())
      93             :     {
      94           0 :         xController->addEventListener(
      95           0 :             static_cast<document::XEventListener*>(this));
      96             : 
      97           0 :         xSelectionSupplier->addSelectionChangeListener (
      98           0 :             static_cast<view::XSelectionChangeListener*>(this));
      99             :     }
     100             : 
     101             :     // Register at model as document::XEventListener.
     102           0 :     if (maShapeTreeInfo.GetModelBroadcaster().is())
     103           0 :         maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
     104           0 :             static_cast<document::XEventListener*>(this));
     105           0 : }
     106             : 
     107             : 
     108             : 
     109             : 
     110           0 : long ChildrenManagerImpl::GetChildCount (void) const throw ()
     111             : {
     112           0 :     return maVisibleChildren.size();
     113             : }
     114             : 
     115             : 
     116             : ::com::sun::star::uno::Reference<
     117           0 :         ::com::sun::star::drawing::XShape> ChildrenManagerImpl::GetChildShape(long nIndex)
     118             :     throw (::com::sun::star::uno::RuntimeException,
     119             :            ::com::sun::star::lang::IndexOutOfBoundsException)
     120             : {
     121           0 :     uno::Reference<XAccessible> xAcc = GetChild(nIndex);
     122           0 :     ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end();
     123           0 :     for (I = maVisibleChildren.begin(); I != aEnd; ++I)
     124             :     {
     125           0 :         if (I->mxAccessibleShape == xAcc)
     126           0 :             return I->mxShape;
     127             :     }
     128           0 :     return uno::Reference< drawing::XShape > ();
     129             : }
     130             : 
     131             : /** Return the requested accessible child object.  Create it if it is not
     132             :     yet in the cache.
     133             : */
     134             : uno::Reference<XAccessible>
     135           0 :     ChildrenManagerImpl::GetChild (long nIndex)
     136             :     throw (::com::sun::star::uno::RuntimeException,
     137             :            ::com::sun::star::lang::IndexOutOfBoundsException)
     138             : {
     139             :     // Check whether the given index is valid.
     140           0 :     if (nIndex < 0 || (unsigned long)nIndex >= maVisibleChildren.size())
     141             :         throw lang::IndexOutOfBoundsException (
     142           0 :             "no accessible child with index " + OUString::number(nIndex),
     143           0 :             mxParent);
     144             : 
     145           0 :     return GetChild (maVisibleChildren[nIndex],nIndex);
     146             : }
     147             : 
     148             : 
     149             : 
     150             : 
     151             : /** Return the requested accessible child object.  Create it if it is not
     152             :     yet in the cache.
     153             : */
     154             : uno::Reference<XAccessible>
     155           0 :     ChildrenManagerImpl::GetChild (ChildDescriptor& rChildDescriptor,sal_Int32 _nIndex)
     156             :     throw (::com::sun::star::uno::RuntimeException)
     157             : {
     158           0 :     if ( ! rChildDescriptor.mxAccessibleShape.is())
     159             :     {
     160           0 :         SolarMutexGuard g;
     161             :         // Make sure that the requested accessible object has not been
     162             :         // created while locking the global mutex.
     163           0 :         if ( ! rChildDescriptor.mxAccessibleShape.is())
     164             :         {
     165             :             AccessibleShapeInfo aShapeInfo(
     166             :                         rChildDescriptor.mxShape,
     167             :                         mxParent,
     168             :                         this,
     169           0 :                         mnNewNameIndex++);
     170             :             // Create accessible object that corresponds to the descriptor's
     171             :             // shape.
     172             :             AccessibleShape* pShape =
     173           0 :                 ShapeTypeHandler::Instance().CreateAccessibleObject (
     174             :                     aShapeInfo,
     175           0 :                     maShapeTreeInfo);
     176           0 :             rChildDescriptor.mxAccessibleShape = uno::Reference<XAccessible> (
     177             :                 static_cast<uno::XWeak*>(pShape),
     178           0 :                 uno::UNO_QUERY);
     179             :             // Now that there is a reference to the new accessible shape we
     180             :             // can safely call its Init() method.
     181           0 :             if ( pShape != NULL )
     182             :             {
     183           0 :                 pShape->Init();
     184           0 :                 pShape->setIndexInParent(_nIndex);
     185           0 :             }
     186           0 :         }
     187             :     }
     188             : 
     189           0 :     return rChildDescriptor.mxAccessibleShape;
     190             : }
     191             : 
     192             : 
     193             : 
     194             : 
     195             : uno::Reference<XAccessible>
     196           0 :     ChildrenManagerImpl::GetChild (const uno::Reference<drawing::XShape>& xShape)
     197             :     throw (uno::RuntimeException)
     198             : {
     199           0 :     ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end();
     200           0 :     for (I = maVisibleChildren.begin(); I != aEnd; ++I)
     201             :     {
     202           0 :         if ( I->mxShape.get() == xShape.get() )
     203           0 :             return I->mxAccessibleShape;
     204             :     }
     205           0 :     return uno::Reference<XAccessible> ();
     206             : }
     207             : 
     208             : 
     209             : 
     210             : 
     211             : /** Find all shapes among the specified shapes that lie fully or partially
     212             :     inside the visible area.  Put those shapes into the cleared cache. The
     213             :     corresponding accessible objects will be created on demand.
     214             : 
     215             :     At the moment, first all accessible objects are removed from the cache
     216             :     and the appropriate listeners are informed of this.  Next, the list is
     217             :     created again.  This should be optimized in the future to not remove and
     218             :     create objects that will be in the list before and after the update
     219             :     method.
     220             : */
     221           0 : void ChildrenManagerImpl::Update (bool bCreateNewObjectsOnDemand)
     222             : {
     223           0 :     if (maShapeTreeInfo.GetViewForwarder() == NULL)
     224           0 :         return;
     225           0 :     Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea();
     226             : 
     227             :     // 1. Create a local list of visible shapes.
     228           0 :     ChildDescriptorListType aChildList;
     229           0 :     CreateListOfVisibleShapes (aChildList);
     230             : 
     231             :     // 2. Merge the information that is already known about the visible
     232             :     // shapes from the current list into the new list.
     233           0 :     MergeAccessibilityInformation (aChildList);
     234             : 
     235             :     // 3. Replace the current list of visible shapes with the new one.  Do
     236             :     // the same with the visible area.
     237             :     {
     238           0 :         SolarMutexGuard g;
     239           0 :         adjustIndexInParentOfShapes(aChildList);
     240             : 
     241             :         // Use swap to copy the contents of the new list in constant time.
     242           0 :         maVisibleChildren.swap (aChildList);
     243             : 
     244             :         // aChildList now contains all the old children, while maVisibleChildren
     245             :         // contains all the current children
     246             : 
     247             :         // 4. Find all shapes in the old list that are not in the current list,
     248             :         // send appropriate events and remove the accessible shape.
     249             : 
     250             :         // Do this *after* we have set our new list of children, because
     251             :         // removing a child may cause
     252             : 
     253             :         // ChildDescriptor::disposeAccessibleObject -->
     254             :         // AccessibleContextBase::CommitChange -->
     255             :         // AtkListener::notifyEvent ->
     256             :         // AtkListener::handleChildRemoved ->
     257             :         // AtkListener::updateChildList
     258             :         // AccessibleDrawDocumentView::getAccessibleChildCount ->
     259             :         // ChildrenManagerImpl::GetChildCount ->
     260             :         // maVisibleChildren.size()
     261             : 
     262             :         // to be fired, and so the operations will take place on
     263             :         // the list we are trying to replace
     264             : 
     265           0 :         RemoveNonVisibleChildren (maVisibleChildren, aChildList);
     266             : 
     267           0 :         aChildList.clear();
     268             : 
     269           0 :         maVisibleArea = aVisibleArea;
     270             :     }
     271             : 
     272             :     // 5. If the visible area has changed then send events that signal a
     273             :     // change of their bounding boxes for all shapes that are members of
     274             :     // both the current and the new list of visible shapes.
     275           0 :     if (maVisibleArea != aVisibleArea)
     276           0 :         SendVisibleAreaEvents (maVisibleChildren);
     277             : 
     278             :     // 6. If children have to be created immediately and not on demand then
     279             :     // create the missing accessible objects now.
     280           0 :     if ( ! bCreateNewObjectsOnDemand)
     281           0 :         CreateAccessibilityObjects (maVisibleChildren);
     282             : }
     283             : 
     284             : 
     285             : 
     286             : 
     287           0 : void ChildrenManagerImpl::CreateListOfVisibleShapes (
     288             :     ChildDescriptorListType& raDescriptorList)
     289             : {
     290           0 :     SolarMutexGuard g;
     291             : 
     292             :     OSL_ASSERT (maShapeTreeInfo.GetViewForwarder() != NULL);
     293             : 
     294           0 :     Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea();
     295             : 
     296             :     // Add the visible shapes for which the accessible objects already exist.
     297           0 :     AccessibleShapeList::iterator I,aEnd = maAccessibleShapes.end();
     298           0 :     for (I=maAccessibleShapes.begin(); I != aEnd; ++I)
     299             :     {
     300           0 :         if (I->is())
     301             :         {
     302             :             uno::Reference<XAccessibleComponent> xComponent (
     303           0 :                 (*I)->getAccessibleContext(), uno::UNO_QUERY);
     304           0 :             if (xComponent.is())
     305             :             {
     306             :                 // The bounding box of the object already is clipped to the
     307             :                 // visible area.  The object is therefore visible if the
     308             :                 // bounding box has non-zero extensions.
     309           0 :                 awt::Rectangle aPixelBBox (xComponent->getBounds());
     310           0 :                 if ((aPixelBBox.Width > 0) && (aPixelBBox.Height > 0))
     311           0 :                     raDescriptorList.push_back (ChildDescriptor (*I));
     312           0 :             }
     313             :         }
     314             :     }
     315             : 
     316             :     // Add the visible shapes for which only the XShapes exist.
     317           0 :     uno::Reference<container::XIndexAccess> xShapeAccess (mxShapeList, uno::UNO_QUERY);
     318           0 :     if (xShapeAccess.is())
     319             :     {
     320           0 :         sal_Int32 nShapeCount = xShapeAccess->getCount();
     321           0 :         raDescriptorList.reserve( nShapeCount );
     322           0 :         awt::Point aPos;
     323           0 :         awt::Size aSize;
     324           0 :         Rectangle aBoundingBox;
     325           0 :         uno::Reference<drawing::XShape> xShape;
     326           0 :         for (sal_Int32 i=0; i<nShapeCount; ++i)
     327             :         {
     328           0 :             xShapeAccess->getByIndex(i) >>= xShape;
     329           0 :             aPos = xShape->getPosition();
     330           0 :             aSize = xShape->getSize();
     331             : 
     332           0 :             aBoundingBox.Left() = aPos.X;
     333           0 :             aBoundingBox.Top() = aPos.Y;
     334           0 :             aBoundingBox.Right() = aPos.X + aSize.Width;
     335           0 :             aBoundingBox.Bottom() = aPos.Y + aSize.Height;
     336             : 
     337             :             // Insert shape if it is visible, i.e. its bounding box overlaps
     338             :             // the visible area.
     339           0 :             if ( aBoundingBox.IsOver (aVisibleArea) )
     340           0 :                 raDescriptorList.push_back (ChildDescriptor (xShape));
     341           0 :         }
     342           0 :     }
     343           0 : }
     344             : 
     345             : 
     346             : 
     347             : 
     348           0 : void ChildrenManagerImpl::RemoveNonVisibleChildren (
     349             :     const ChildDescriptorListType& rNewChildList,
     350             :     ChildDescriptorListType& rOldChildList)
     351             : {
     352             :     // Iterate over list of formerly visible children and remove those that
     353             :     // are not visible anymore, i.e. member of the new list of visible
     354             :     // children.
     355           0 :     ChildDescriptorListType::iterator I, aEnd = rOldChildList.end();
     356           0 :     for (I=rOldChildList.begin(); I != aEnd; ++I)
     357             :     {
     358           0 :         if (::std::find(rNewChildList.begin(), rNewChildList.end(), *I) == rNewChildList.end())
     359             :         {
     360             :             // The child is disposed when there is a UNO shape from which
     361             :             // the accessible shape can be created when the shape becomes
     362             :             // visible again.  When there is no such UNO shape then simply
     363             :             // reset the descriptor but keep the accessibility object.
     364           0 :             if (I->mxShape.is())
     365             :             {
     366           0 :                 UnregisterAsDisposeListener (I->mxShape);
     367           0 :                 I->disposeAccessibleObject (mrContext);
     368             :             }
     369             :             else
     370             :             {
     371           0 :                 AccessibleShape* pAccessibleShape = I->GetAccessibleShape();
     372           0 :                 pAccessibleShape->ResetState (AccessibleStateType::VISIBLE);
     373           0 :                 I->mxAccessibleShape = NULL;
     374             :             }
     375             :         }
     376             :     }
     377           0 : }
     378             : 
     379             : 
     380             : 
     381             : 
     382           0 : void ChildrenManagerImpl::MergeAccessibilityInformation (
     383             :     ChildDescriptorListType& raNewChildList)
     384             : {
     385           0 :     ChildDescriptorListType::iterator aOldChildDescriptor;
     386           0 :     ChildDescriptorListType::iterator I, aEnd = raNewChildList.end();
     387           0 :     for (I=raNewChildList.begin(); I != aEnd; ++I)
     388             :     {
     389           0 :         aOldChildDescriptor = ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(), *I);
     390             : 
     391             :         // Copy accessible shape if that exists in the old descriptor.
     392           0 :         bool bRegistrationIsNecessary = true;
     393           0 :         if (aOldChildDescriptor != maVisibleChildren.end())
     394           0 :             if (aOldChildDescriptor->mxAccessibleShape.is())
     395             :             {
     396           0 :                 I->mxAccessibleShape = aOldChildDescriptor->mxAccessibleShape;
     397           0 :                 I->mbCreateEventPending = false;
     398           0 :                 bRegistrationIsNecessary = false;
     399             :             }
     400           0 :         if (bRegistrationIsNecessary)
     401           0 :             RegisterAsDisposeListener (I->mxShape);
     402             :     }
     403           0 : }
     404             : 
     405             : 
     406             : 
     407             : 
     408           0 : void ChildrenManagerImpl::SendVisibleAreaEvents (
     409             :     ChildDescriptorListType& raNewChildList)
     410             : {
     411           0 :     ChildDescriptorListType::iterator I,aEnd = raNewChildList.end();
     412           0 :     for (I=raNewChildList.begin(); I != aEnd; ++I)
     413             :     {
     414             :         // Tell shape of changed visible area.  To do this, fake a
     415             :         // change of the view forwarder.  (Actually we usually get here
     416             :         // as a result of a change of the view forwarder).
     417           0 :         AccessibleShape* pShape = I->GetAccessibleShape ();
     418           0 :         if (pShape != NULL)
     419             :             pShape->ViewForwarderChanged (
     420             :                 IAccessibleViewForwarderListener::VISIBLE_AREA,
     421           0 :                 maShapeTreeInfo.GetViewForwarder());
     422             :     }
     423           0 : }
     424             : 
     425             : 
     426             : 
     427             : 
     428           0 : void ChildrenManagerImpl::CreateAccessibilityObjects (
     429             :     ChildDescriptorListType& raNewChildList)
     430             : {
     431           0 :     ChildDescriptorListType::iterator I, aEnd = raNewChildList.end();
     432           0 :     sal_Int32 nPos = 0;
     433           0 :     for ( I = raNewChildList.begin(); I != aEnd; ++I,++nPos)
     434             :     {
     435             :         // Create the associated accessible object when the flag says so and
     436             :         // it does not yet exist.
     437           0 :         if ( ! I->mxAccessibleShape.is() )
     438           0 :             GetChild (*I,nPos);
     439           0 :         if (I->mxAccessibleShape.is() && I->mbCreateEventPending)
     440             :         {
     441           0 :             I->mbCreateEventPending = false;
     442             :             mrContext.CommitChange (
     443             :                 AccessibleEventId::CHILD,
     444           0 :                 uno::makeAny(I->mxAccessibleShape),
     445           0 :                 uno::Any());
     446             :         }
     447             :     }
     448           0 : }
     449             : 
     450             : 
     451             : 
     452             : 
     453           0 : void ChildrenManagerImpl::AddShape (const Reference<drawing::XShape>& rxShape)
     454             : {
     455           0 :     if (rxShape.is())
     456             :     {
     457           0 :         SolarMutexClearableGuard aGuard;
     458             : 
     459             :         // Test visibility of the shape.
     460           0 :         Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea();
     461           0 :         awt::Point aPos = rxShape->getPosition();
     462           0 :         awt::Size aSize = rxShape->getSize();
     463             : 
     464             :         Rectangle aBoundingBox (
     465             :             aPos.X,
     466             :             aPos.Y,
     467             :             aPos.X + aSize.Width,
     468           0 :             aPos.Y + aSize.Height);
     469             : 
     470             :         // Add the shape only when it belongs to the list of shapes stored
     471             :         // in mxShapeList (which is either a page or a group shape).
     472           0 :         Reference<container::XChild> xChild (rxShape, uno::UNO_QUERY);
     473           0 :         if (xChild.is())
     474             :         {
     475           0 :             Reference<drawing::XShapes> xParent (xChild->getParent(), uno::UNO_QUERY);
     476           0 :             if (xParent == mxShapeList)
     477           0 :                 if (aBoundingBox.IsOver (aVisibleArea))
     478             :                 {
     479             :                     // Add shape to list of visible shapes.
     480           0 :                     maVisibleChildren.push_back (ChildDescriptor (rxShape));
     481             : 
     482             :                     // Create accessibility object.
     483           0 :                     ChildDescriptor& rDescriptor = maVisibleChildren.back();
     484           0 :                     GetChild (rDescriptor, maVisibleChildren.size()-1);
     485             : 
     486             :                     // Inform listeners about new child.
     487           0 :                     uno::Any aNewShape;
     488           0 :                     aNewShape <<= rDescriptor.mxAccessibleShape;
     489           0 :                     aGuard.clear();
     490             :                     mrContext.CommitChange (
     491             :                         AccessibleEventId::CHILD,
     492             :                         aNewShape,
     493           0 :                         uno::Any());
     494           0 :                     RegisterAsDisposeListener(rxShape);
     495           0 :                 }
     496           0 :         }
     497             :     }
     498           0 : }
     499             : 
     500             : 
     501             : 
     502             : 
     503           0 : void ChildrenManagerImpl::RemoveShape (const Reference<drawing::XShape>& rxShape)
     504             : {
     505           0 :     if (rxShape.is())
     506             :     {
     507           0 :         SolarMutexGuard g;
     508             : 
     509             :         // Search shape in list of visible children.
     510             :         ChildDescriptorListType::iterator I (
     511             :             ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(),
     512           0 :                 ChildDescriptor (rxShape)));
     513           0 :         if (I != maVisibleChildren.end())
     514             :         {
     515             :             // Remove descriptor from that list.
     516           0 :             Reference<XAccessible> xAccessibleShape (I->mxAccessibleShape);
     517             : 
     518           0 :             UnregisterAsDisposeListener (I->mxShape);
     519             :             // Dispose the accessible object.
     520           0 :             I->disposeAccessibleObject (mrContext);
     521             : 
     522             :             // Now we can safely remove the child descriptor and thus
     523             :             // invalidate the iterator.
     524           0 :             maVisibleChildren.erase (I);
     525             : 
     526           0 :             adjustIndexInParentOfShapes(maVisibleChildren);
     527           0 :         }
     528             :     }
     529           0 : }
     530             : 
     531             : 
     532             : 
     533             : 
     534           0 : void ChildrenManagerImpl::SetShapeList (const ::com::sun::star::uno::Reference<
     535             :     ::com::sun::star::drawing::XShapes>& xShapeList)
     536             : {
     537           0 :     mxShapeList = xShapeList;
     538           0 : }
     539             : 
     540             : 
     541             : 
     542             : 
     543           0 : void ChildrenManagerImpl::AddAccessibleShape (css::uno::Reference<css::accessibility::XAccessible> const & shape)
     544             : {
     545             :     assert(shape.is());
     546           0 :     maAccessibleShapes.push_back (shape);
     547           0 : }
     548             : 
     549             : 
     550             : 
     551             : 
     552           0 : void ChildrenManagerImpl::ClearAccessibleShapeList (void)
     553             : {
     554             :     // Copy the list of (visible) shapes to local lists and clear the
     555             :     // originals.
     556           0 :     ChildDescriptorListType aLocalVisibleChildren;
     557           0 :     aLocalVisibleChildren.swap(maVisibleChildren);
     558           0 :     AccessibleShapeList aLocalAccessibleShapes;
     559           0 :     aLocalAccessibleShapes.swap(maAccessibleShapes);
     560             : 
     561             :     // Tell the listeners that all children are gone.
     562             :     mrContext.CommitChange (
     563             :         AccessibleEventId::INVALIDATE_ALL_CHILDREN,
     564             :         uno::Any(),
     565           0 :         uno::Any());
     566             : 
     567             :     // There are no accessible shapes left so the index assigned to new
     568             :     // accessible shapes can be reset.
     569           0 :     mnNewNameIndex = 1;
     570             : 
     571             :     // Now the objects in the local lists can be safely disposed without
     572             :     // having problems with callers that want to update their child lists.
     573             : 
     574             :     // Clear the list of visible accessible objects.  Objects not created on
     575             :     // demand for XShapes are treated below.
     576           0 :     ChildDescriptorListType::iterator I,aEnd = aLocalVisibleChildren.end();
     577           0 :     for (I=aLocalVisibleChildren.begin(); I != aEnd; ++I)
     578           0 :         if ( I->mxAccessibleShape.is() && I->mxShape.is() )
     579             :         {
     580           0 :             ::comphelper::disposeComponent(I->mxAccessibleShape);
     581           0 :             I->mxAccessibleShape = NULL;
     582             :         }
     583             : 
     584             :     // Dispose all objects in the accessible shape list.
     585           0 :     AccessibleShapeList::iterator J,aEnd2 = aLocalAccessibleShapes.end();
     586           0 :     for (J=aLocalAccessibleShapes.begin(); J != aEnd2; ++J)
     587           0 :         if (J->is())
     588             :         {
     589             :             // Dispose the object.
     590           0 :             ::comphelper::disposeComponent(*J);
     591           0 :             *J = NULL;
     592           0 :         }
     593           0 : }
     594             : 
     595             : 
     596             : 
     597             : 
     598             : /** If the broadcasters change at which this object is registered then
     599             :     unregister at old and register at new broadcasters.
     600             : */
     601           0 : void ChildrenManagerImpl::SetInfo (const AccessibleShapeTreeInfo& rShapeTreeInfo)
     602             : {
     603             :     // Remember the current broadcasters and exchange the shape tree info.
     604           0 :     Reference<document::XEventBroadcaster> xCurrentBroadcaster;
     605           0 :     Reference<frame::XController> xCurrentController;
     606           0 :     Reference<view::XSelectionSupplier> xCurrentSelectionSupplier;
     607             :     {
     608           0 :         SolarMutexGuard g;
     609           0 :         xCurrentBroadcaster = maShapeTreeInfo.GetModelBroadcaster();
     610           0 :         xCurrentController = maShapeTreeInfo.GetController();
     611           0 :         xCurrentSelectionSupplier = Reference<view::XSelectionSupplier> (
     612           0 :             xCurrentController, uno::UNO_QUERY);
     613           0 :         maShapeTreeInfo = rShapeTreeInfo;
     614             :     }
     615             : 
     616             :     // Move registration to new model.
     617           0 :     if (maShapeTreeInfo.GetModelBroadcaster() != xCurrentBroadcaster)
     618             :     {
     619             :         // Register at new broadcaster.
     620           0 :         if (maShapeTreeInfo.GetModelBroadcaster().is())
     621           0 :             maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
     622           0 :                 static_cast<document::XEventListener*>(this));
     623             : 
     624             :         // Unregister at old broadcaster.
     625           0 :         if (xCurrentBroadcaster.is())
     626           0 :             xCurrentBroadcaster->removeEventListener (
     627           0 :                 static_cast<document::XEventListener*>(this));
     628             :     }
     629             : 
     630             :     // Move registration to new selection supplier.
     631           0 :     Reference<frame::XController> xNewController(maShapeTreeInfo.GetController());
     632             :     Reference<view::XSelectionSupplier> xNewSelectionSupplier (
     633           0 :         xNewController, uno::UNO_QUERY);
     634           0 :     if (xNewSelectionSupplier != xCurrentSelectionSupplier)
     635             :     {
     636             :         // Register at new broadcaster.
     637           0 :         if (xNewSelectionSupplier.is())
     638             :         {
     639           0 :             xNewController->addEventListener(
     640           0 :                 static_cast<document::XEventListener*>(this));
     641             : 
     642           0 :             xNewSelectionSupplier->addSelectionChangeListener (
     643           0 :                 static_cast<view::XSelectionChangeListener*>(this));
     644             :         }
     645             : 
     646             :         // Unregister at old broadcaster.
     647           0 :         if (xCurrentSelectionSupplier.is())
     648             :         {
     649           0 :             xCurrentSelectionSupplier->removeSelectionChangeListener (
     650           0 :                 static_cast<view::XSelectionChangeListener*>(this));
     651             : 
     652           0 :             xCurrentController->removeEventListener(
     653           0 :                 static_cast<document::XEventListener*>(this));
     654             :         }
     655           0 :     }
     656           0 : }
     657             : 
     658             : 
     659             : 
     660             : 
     661             : //=====  lang::XEventListener  ================================================
     662             : 
     663             : void SAL_CALL
     664           0 :     ChildrenManagerImpl::disposing (const lang::EventObject& rEventObject)
     665             :     throw (uno::RuntimeException, std::exception)
     666             : {
     667           0 :     if (rEventObject.Source == maShapeTreeInfo.GetModelBroadcaster()
     668           0 :             || rEventObject.Source == maShapeTreeInfo.GetController())
     669             :     {
     670           0 :         impl_dispose();
     671             :     }
     672             : 
     673             :     // Handle disposing UNO shapes.
     674             :     else
     675             :     {
     676           0 :         Reference<drawing::XShape> xShape (rEventObject.Source, uno::UNO_QUERY);
     677             : 
     678             :         // Find the descriptor for the given shape.
     679             :         ChildDescriptorListType::iterator I (
     680             :             ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(),
     681           0 :                 ChildDescriptor (xShape)));
     682           0 :         if (I != maVisibleChildren.end())
     683             :         {
     684             :             // Clear the descriptor.
     685           0 :             I->disposeAccessibleObject (mrContext);
     686           0 :             I->mxShape = NULL;
     687           0 :         }
     688             :     }
     689           0 : }
     690             : 
     691             : 
     692             : 
     693             : 
     694             : //=====  document::XEventListener  ============================================
     695             : 
     696             : /** Listen for new and removed shapes.
     697             : */
     698             : void SAL_CALL
     699           0 :     ChildrenManagerImpl::notifyEvent (
     700             :         const document::EventObject& rEventObject)
     701             :     throw (uno::RuntimeException, std::exception)
     702             : {
     703           0 :     static const OUString sShapeInserted ("ShapeInserted");
     704           0 :     static const OUString sShapeRemoved ("ShapeRemoved");
     705             : 
     706             : 
     707           0 :     if (rEventObject.EventName == sShapeInserted)
     708           0 :         AddShape (Reference<drawing::XShape>(rEventObject.Source, uno::UNO_QUERY));
     709           0 :     else if (rEventObject.EventName == sShapeRemoved)
     710           0 :         RemoveShape (Reference<drawing::XShape>(rEventObject.Source, uno::UNO_QUERY));
     711             :     // else ignore unknown event.
     712           0 : }
     713             : 
     714             : 
     715             : 
     716             : 
     717             : //=====  view::XSelectionChangeListener  ======================================
     718             : 
     719             : void  SAL_CALL
     720           0 :     ChildrenManagerImpl::selectionChanged (const lang::EventObject& /*rEvent*/)
     721             :         throw (uno::RuntimeException, std::exception)
     722             : {
     723           0 :     UpdateSelection ();
     724           0 : }
     725             : 
     726             : 
     727             : 
     728             : 
     729           0 : void ChildrenManagerImpl::impl_dispose (void)
     730             : {
     731           0 :     Reference<frame::XController> xController(maShapeTreeInfo.GetController());
     732             :     // Remove from broadcasters.
     733             :     try
     734             :     {
     735             :         Reference<view::XSelectionSupplier> xSelectionSupplier (
     736           0 :             xController, uno::UNO_QUERY);
     737           0 :         if (xSelectionSupplier.is())
     738             :         {
     739           0 :             xSelectionSupplier->removeSelectionChangeListener (
     740           0 :                 static_cast<view::XSelectionChangeListener*>(this));
     741           0 :         }
     742             :     }
     743           0 :     catch( uno::RuntimeException&)
     744             :     {}
     745             : 
     746             :     try
     747             :     {
     748           0 :         if (xController.is())
     749           0 :             xController->removeEventListener(
     750           0 :                 static_cast<document::XEventListener*>(this));
     751             :     }
     752           0 :     catch( uno::RuntimeException&)
     753             :     {}
     754             : 
     755           0 :     maShapeTreeInfo.SetController (NULL);
     756             : 
     757             :     try
     758             :     {
     759             :         // Remove from broadcaster.
     760           0 :         if (maShapeTreeInfo.GetModelBroadcaster().is())
     761           0 :             maShapeTreeInfo.GetModelBroadcaster()->removeEventListener (
     762           0 :                 static_cast<document::XEventListener*>(this));
     763           0 :         maShapeTreeInfo.SetModelBroadcaster (NULL);
     764             :     }
     765           0 :     catch( uno::RuntimeException& )
     766             :     {}
     767             : 
     768           0 :     ClearAccessibleShapeList ();
     769           0 :     SetShapeList (NULL);
     770           0 : }
     771             : 
     772             : 
     773             : 
     774           0 : void SAL_CALL ChildrenManagerImpl::disposing (void)
     775             : {
     776           0 :     impl_dispose();
     777           0 : }
     778             : 
     779             : //=====  IAccessibleViewForwarderListener  ====================================
     780             : 
     781           0 : void ChildrenManagerImpl::ViewForwarderChanged (ChangeType aChangeType,
     782             :         const IAccessibleViewForwarder* pViewForwarder)
     783             : {
     784           0 :     if (aChangeType == IAccessibleViewForwarderListener::VISIBLE_AREA)
     785           0 :         Update (false);
     786             :     else
     787             :     {
     788           0 :         SolarMutexGuard g;
     789           0 :         ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end();
     790           0 :         for (I=maVisibleChildren.begin(); I != aEnd; ++I)
     791             :         {
     792           0 :             AccessibleShape* pShape = I->GetAccessibleShape();
     793           0 :             if (pShape != NULL)
     794           0 :                 pShape->ViewForwarderChanged (aChangeType, pViewForwarder);
     795           0 :         }
     796             :     }
     797           0 : }
     798             : 
     799             : 
     800             : 
     801             : 
     802             : //=====  IAccessibleParent  ===================================================
     803             : 
     804           0 : bool ChildrenManagerImpl::ReplaceChild (
     805             :     AccessibleShape* pCurrentChild,
     806             :     const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
     807             :     const long _nIndex,
     808             :     const AccessibleShapeTreeInfo& _rShapeTreeInfo)
     809             :     throw (uno::RuntimeException)
     810             : {
     811           0 :     AccessibleShapeInfo aShapeInfo( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex );
     812             :     // create the new child
     813           0 :     AccessibleShape* pNewChild = ShapeTypeHandler::Instance().CreateAccessibleObject (
     814             :         aShapeInfo,
     815             :         _rShapeTreeInfo
     816           0 :     );
     817           0 :     Reference< XAccessible > xNewChild( pNewChild );    // keep this alive (do this before calling Init!)
     818           0 :     if ( pNewChild )
     819           0 :         pNewChild->Init();
     820             : 
     821           0 :     bool bResult = false;
     822             : 
     823             :     // Iterate over the visible children.  If one of them has an already
     824             :     // created accessible object that matches pCurrentChild then replace
     825             :     // it.  Otherwise the child to replace is either not in the list or has
     826             :     // not ye been created (and is therefore not in the list, too) and a
     827             :     // replacement is not necessary.
     828           0 :     ChildDescriptorListType::iterator I,aEnd = maVisibleChildren.end();
     829           0 :     for (I=maVisibleChildren.begin(); I != aEnd; ++I)
     830             :     {
     831           0 :         if (I->GetAccessibleShape() == pCurrentChild)
     832             :         {
     833             :             // Dispose the current child and send an event about its deletion.
     834           0 :             pCurrentChild->dispose();
     835             :             mrContext.CommitChange (
     836             :                 AccessibleEventId::CHILD,
     837             :                 uno::Any(),
     838           0 :                 uno::makeAny (I->mxAccessibleShape));
     839             : 
     840             :             // Replace with replacement and send an event about existance
     841             :             // of the new child.
     842           0 :             I->mxAccessibleShape = pNewChild;
     843             :             mrContext.CommitChange (
     844             :                 AccessibleEventId::CHILD,
     845           0 :                 uno::makeAny (I->mxAccessibleShape),
     846           0 :                 uno::Any());
     847           0 :             bResult = true;
     848           0 :             break;
     849             :         }
     850             :     }
     851             : 
     852             :     // When not found among the visible children we have to search the list
     853             :     // of accessible shapes.  This is not yet implemented.
     854             : 
     855           0 :     return bResult;
     856             : }
     857             : 
     858             : // Add the impl method for IAccessibleParent interface
     859           0 : AccessibleControlShape * ChildrenManagerImpl::GetAccControlShapeFromModel(::com::sun::star::beans::XPropertySet* pSet) throw (::com::sun::star::uno::RuntimeException)
     860             : {
     861           0 :     sal_Int32 count = GetChildCount();
     862           0 :     for (sal_Int32 index=0;index<count;index++)
     863             :     {
     864           0 :         AccessibleShape* pAccShape = maVisibleChildren[index].GetAccessibleShape();
     865           0 :             if (pAccShape  && ::accessibility::ShapeTypeHandler::Instance().GetTypeId (pAccShape->GetXShape()) == DRAWING_CONTROL)
     866             :             {
     867           0 :             ::accessibility::AccessibleControlShape *pCtlAccShape = static_cast < ::accessibility::AccessibleControlShape* >(pAccShape);
     868           0 :             if (pCtlAccShape && pCtlAccShape->GetControlModel() == pSet)
     869           0 :                 return pCtlAccShape;
     870             :                 }
     871             :     }
     872           0 :     return NULL;
     873             : }
     874             : uno::Reference<XAccessible>
     875           0 :     ChildrenManagerImpl::GetAccessibleCaption (const uno::Reference<drawing::XShape>& xShape)
     876             :     throw (uno::RuntimeException)
     877             : {
     878           0 :     ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end();
     879           0 :     for (I = maVisibleChildren.begin(); I != aEnd; ++I)
     880             :     {
     881           0 :         if ( I->mxShape.get() == xShape.get() )
     882           0 :             return I->mxAccessibleShape;
     883             :     }
     884           0 :     return uno::Reference<XAccessible> ();
     885             : }
     886             : 
     887             : /** Update the <const>SELECTED</const> and the <const>FOCUSED</const> state
     888             :     of all visible children.  Maybe this should be changed to all children.
     889             : 
     890             :     Iterate over all descriptors of visible accessible shapes and look them
     891             :     up in the selection.
     892             : 
     893             :     If there is no valid controller then all shapes are deselected and
     894             :     unfocused.  If the controller's frame is not active then all shapes are
     895             :     unfocused.
     896             : */
     897           0 : void ChildrenManagerImpl::UpdateSelection (void)
     898             : {
     899           0 :     Reference<frame::XController> xController(maShapeTreeInfo.GetController());
     900             :     Reference<view::XSelectionSupplier> xSelectionSupplier (
     901           0 :         xController, uno::UNO_QUERY);
     902             : 
     903             :     // Try to cast the selection both to a multi selection and to a single
     904             :     // selection.
     905           0 :     Reference<container::XIndexAccess> xSelectedShapeAccess;
     906           0 :     Reference<drawing::XShape> xSelectedShape;
     907           0 :     if (xSelectionSupplier.is())
     908             :     {
     909           0 :         xSelectedShapeAccess = Reference<container::XIndexAccess> (
     910           0 :             xSelectionSupplier->getSelection(), uno::UNO_QUERY);
     911           0 :         xSelectedShape = Reference<drawing::XShape> (
     912           0 :             xSelectionSupplier->getSelection(), uno::UNO_QUERY);
     913             :     }
     914             : 
     915             :     // Remember the current and new focused shape.
     916           0 :     AccessibleShape* pCurrentlyFocusedShape = NULL;
     917           0 :     AccessibleShape* pNewFocusedShape = NULL;
     918             :     typedef std::pair< AccessibleShape* , sal_Bool > PAIR_SHAPE;//sal_Bool Selected,UnSelected.
     919             :     typedef std::vector< PAIR_SHAPE > VEC_SHAPE;
     920           0 :     VEC_SHAPE vecSelect;
     921           0 :     int nAddSelect=0;
     922           0 :     int nRemoveSelect=0;
     923           0 :     sal_Bool bHasSelectedShape=sal_False;
     924           0 :     ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end();
     925           0 :     for (I=maVisibleChildren.begin(); I != aEnd; ++I)
     926             :     {
     927           0 :         AccessibleShape* pAccessibleShape = I->GetAccessibleShape();
     928           0 :         if (I->mxAccessibleShape.is() && I->mxShape.is() && pAccessibleShape!=NULL)
     929             :         {
     930           0 :             short nRole = pAccessibleShape->getAccessibleRole();
     931             :             bool bDrawShape = (
     932           0 :                 nRole == AccessibleRole::GRAPHIC ||
     933           0 :                 nRole == AccessibleRole::EMBEDDED_OBJECT ||
     934           0 :                 nRole == AccessibleRole::SHAPE ||
     935           0 :                 nRole == AccessibleRole::IMAGE_MAP ||
     936           0 :                 nRole == AccessibleRole::TABLE_CELL ||
     937           0 :                 nRole == AccessibleRole::TABLE );
     938           0 :             bool bShapeIsSelected = false;
     939             : 
     940             :             // Look up the shape in the (single or multi-) selection.
     941           0 :             if (xSelectedShape.is())
     942             :             {
     943           0 :                 if  (I->mxShape == xSelectedShape)
     944             :                 {
     945           0 :                     bShapeIsSelected = true;
     946           0 :                     pNewFocusedShape = pAccessibleShape;
     947             :                 }
     948             :             }
     949           0 :             else if (xSelectedShapeAccess.is())
     950             :             {
     951           0 :                 sal_Int32 nCount=xSelectedShapeAccess->getCount();
     952           0 :                 for (sal_Int32 i=0; i<nCount&&!bShapeIsSelected; i++)
     953           0 :                     if (xSelectedShapeAccess->getByIndex(i) == I->mxShape)
     954             :                     {
     955           0 :                         bShapeIsSelected = true;
     956             :                         // In a multi-selection no shape has the focus.
     957           0 :                         if (nCount == 1)
     958           0 :                             pNewFocusedShape = pAccessibleShape;
     959             :                     }
     960             :             }
     961             : 
     962             :             // Set or reset the SELECTED state.
     963           0 :             if (bShapeIsSelected)
     964             :             {
     965           0 :                 if (pAccessibleShape->SetState (AccessibleStateType::SELECTED))
     966             :                 {
     967           0 :                     if (bDrawShape)
     968             :                     {
     969           0 :                         vecSelect.push_back(std::make_pair(pAccessibleShape,sal_True));
     970           0 :                         ++nAddSelect;
     971             :                     }
     972             :                 }
     973             :                 else
     974             :                 {//Selected not change,has selected shape before
     975           0 :                     bHasSelectedShape=sal_True;
     976             :                 }
     977             :             }
     978             :             else
     979             :                 //pAccessibleShape->ResetState (AccessibleStateType::SELECTED);
     980             :             {
     981           0 :                 if(pAccessibleShape->ResetState (AccessibleStateType::SELECTED))
     982             :                 {
     983           0 :                     if(bDrawShape)
     984             :                     {
     985           0 :                         vecSelect.push_back(std::make_pair(pAccessibleShape,sal_False));
     986           0 :                         ++nRemoveSelect;
     987             :                     }
     988             :                 }
     989             :             }
     990             :             // Does the shape have the current selection?
     991           0 :             if (pAccessibleShape->GetState (AccessibleStateType::FOCUSED))
     992           0 :                 pCurrentlyFocusedShape = pAccessibleShape;
     993             :         }
     994             :     }
     995             : 
     996           0 :     Window *pParentWindow = maShapeTreeInfo.GetWindow();
     997           0 :     bool bShapeActive= false;
     998             :     // For table cell, the table's parent must be checked to make sure it has focus.
     999           0 :     if (pParentWindow)
    1000             :     {
    1001           0 :         Window *pPWindow = pParentWindow->GetParent();
    1002           0 :         if (pParentWindow->HasFocus() || (pPWindow && pPWindow->HasFocus()))
    1003           0 :             bShapeActive =true;
    1004             :     }
    1005             :     // Move focus from current to newly focused shape.
    1006           0 :     if (pCurrentlyFocusedShape != pNewFocusedShape)
    1007             :     {
    1008           0 :         if (pCurrentlyFocusedShape != NULL)
    1009           0 :             pCurrentlyFocusedShape->ResetState (AccessibleStateType::FOCUSED);
    1010           0 :         if (pNewFocusedShape != NULL && bShapeActive)
    1011           0 :             pNewFocusedShape->SetState (AccessibleStateType::FOCUSED);
    1012             :     }
    1013             : 
    1014           0 :     if (nAddSelect >= 10 )//fire selection  within
    1015             :     {
    1016           0 :         mrContext.CommitChange(AccessibleEventId::SELECTION_CHANGED_WITHIN,uno::Any(),uno::Any());
    1017           0 :         nAddSelect =0 ;//not fire selection event
    1018             :     }
    1019             :     //VEC_SHAPE::iterator vi = vecSelect.begin();
    1020             :     //for (; vi != vecSelect.end() ;++vi)
    1021           0 :     VEC_SHAPE::reverse_iterator vi = vecSelect.rbegin();
    1022           0 :     for (; vi != vecSelect.rend() ;++vi)
    1023             : 
    1024             :     {
    1025           0 :         PAIR_SHAPE &pairShape= *vi;
    1026           0 :         Reference< XAccessible > xShape(pairShape.first);
    1027           0 :         uno::Any anyShape;
    1028           0 :         anyShape <<= xShape;
    1029             : 
    1030           0 :         if (pairShape.second)//Selection add
    1031             :         {
    1032           0 :             if (bHasSelectedShape)
    1033             :             {
    1034           0 :                 if (  nAddSelect > 0 )
    1035             :                 {
    1036           0 :                     mrContext.CommitChange(AccessibleEventId::SELECTION_CHANGED_ADD,anyShape,uno::Any());
    1037             :                 }
    1038             :             }
    1039             :             else
    1040             :             {
    1041             :                 //if has not selected shape ,first selected shape is fire selection event;
    1042           0 :                 if (nAddSelect > 0 )
    1043             :                 {
    1044           0 :                     mrContext.CommitChange(AccessibleEventId::SELECTION_CHANGED,anyShape,uno::Any());
    1045             :                 }
    1046           0 :                 if (nAddSelect > 1 )//check other selected shape fire selection add event
    1047             :                 {
    1048           0 :                     bHasSelectedShape=sal_True;
    1049             :                 }
    1050             :             }
    1051             :         }
    1052             :         else //selection remove
    1053             :         {
    1054           0 :             mrContext.CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE,anyShape,uno::Any());
    1055             :         }
    1056           0 :     }
    1057             : 
    1058             :     // Remember whether there is a shape that now has the focus.
    1059           0 :     mpFocusedShape = pNewFocusedShape;
    1060           0 : }
    1061             : 
    1062             : 
    1063             : 
    1064             : 
    1065           0 : bool ChildrenManagerImpl::HasFocus (void)
    1066             : {
    1067           0 :     return mpFocusedShape != NULL;
    1068             : }
    1069             : 
    1070             : 
    1071             : 
    1072             : 
    1073           0 : void ChildrenManagerImpl::RemoveFocus (void)
    1074             : {
    1075           0 :     if (mpFocusedShape != NULL)
    1076             :     {
    1077           0 :         mpFocusedShape->ResetState (AccessibleStateType::FOCUSED);
    1078           0 :         mpFocusedShape = NULL;
    1079             :     }
    1080           0 : }
    1081             : 
    1082             : 
    1083             : 
    1084           0 : void ChildrenManagerImpl::RegisterAsDisposeListener (
    1085             :     const Reference<drawing::XShape>& xShape)
    1086             : {
    1087           0 :     Reference<lang::XComponent> xComponent (xShape, uno::UNO_QUERY);
    1088           0 :     if (xComponent.is())
    1089           0 :         xComponent->addEventListener (
    1090           0 :             static_cast<document::XEventListener*>(this));
    1091           0 : }
    1092             : 
    1093             : 
    1094             : 
    1095             : 
    1096           0 : void ChildrenManagerImpl::UnregisterAsDisposeListener (
    1097             :     const Reference<drawing::XShape>& xShape)
    1098             : {
    1099           0 :     Reference<lang::XComponent> xComponent (xShape, uno::UNO_QUERY);
    1100           0 :     if (xComponent.is())
    1101           0 :         xComponent->removeEventListener (
    1102           0 :             static_cast<document::XEventListener*>(this));
    1103           0 : }
    1104             : 
    1105             : 
    1106             : 
    1107             : 
    1108             : //=====  AccessibleChildDescriptor  ===========================================
    1109             : 
    1110           0 : ChildDescriptor::ChildDescriptor (const Reference<drawing::XShape>& xShape)
    1111             :     : mxShape (xShape),
    1112             :       mxAccessibleShape (NULL),
    1113           0 :       mbCreateEventPending (true)
    1114             : {
    1115             :     // Empty.
    1116           0 : }
    1117             : 
    1118             : 
    1119             : 
    1120             : 
    1121           0 : ChildDescriptor::ChildDescriptor (const Reference<XAccessible>& rxAccessibleShape)
    1122             :     : mxShape (NULL),
    1123             :       mxAccessibleShape (rxAccessibleShape),
    1124           0 :       mbCreateEventPending (true)
    1125             : {
    1126             :     // Make sure that the accessible object has the <const>VISIBLE</const>
    1127             :     // state set.
    1128           0 :     AccessibleShape* pAccessibleShape = GetAccessibleShape();
    1129           0 :     pAccessibleShape->SetState (AccessibleStateType::VISIBLE);
    1130           0 : }
    1131             : 
    1132             : 
    1133             : 
    1134             : 
    1135           0 : ChildDescriptor::~ChildDescriptor (void)
    1136             : {
    1137           0 : }
    1138             : 
    1139             : 
    1140             : 
    1141             : 
    1142           0 : AccessibleShape* ChildDescriptor::GetAccessibleShape (void) const
    1143             : {
    1144           0 :     return static_cast<AccessibleShape*> (mxAccessibleShape.get());
    1145             : }
    1146             : 
    1147           0 : void ChildDescriptor::setIndexAtAccessibleShape(sal_Int32 _nIndex)
    1148             : {
    1149           0 :     AccessibleShape* pShape = GetAccessibleShape();
    1150           0 :     if ( pShape )
    1151           0 :         pShape->setIndexInParent(_nIndex);
    1152           0 : }
    1153             : 
    1154             : 
    1155             : 
    1156             : 
    1157             : 
    1158           0 : void ChildDescriptor::disposeAccessibleObject (AccessibleContextBase& rParent)
    1159             : {
    1160           0 :     if (mxAccessibleShape.is())
    1161             :     {
    1162             :         // Send event that the shape has been removed.
    1163           0 :         uno::Any aOldValue;
    1164           0 :         aOldValue <<= mxAccessibleShape;
    1165             :         rParent.CommitChange (
    1166             :             AccessibleEventId::CHILD,
    1167             :             uno::Any(),
    1168           0 :             aOldValue);
    1169             : 
    1170             :         // Dispose and remove the object.
    1171           0 :         Reference<lang::XComponent> xComponent (mxAccessibleShape, uno::UNO_QUERY);
    1172           0 :         if (xComponent.is())
    1173           0 :             xComponent->dispose ();
    1174             : 
    1175           0 :         mxAccessibleShape = NULL;
    1176             :     }
    1177           0 : }
    1178             : 
    1179             : 
    1180             : } // end of namespace accessibility
    1181             : 
    1182             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10