LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/accessibility - AccessibleDrawDocumentView.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 267 0.0 %
Date: 2012-12-27 Functions: 0 21 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 "AccessibleDrawDocumentView.hxx"
      21             : #include <com/sun/star/drawing/XDrawPage.hpp>
      22             : #include <com/sun/star/drawing/XDrawView.hpp>
      23             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      24             : #include <com/sun/star/drawing/XShapes.hpp>
      25             : #include <com/sun/star/container/XChild.hpp>
      26             : #include <com/sun/star/frame/XController.hpp>
      27             : #include <com/sun/star/frame/XFrame.hpp>
      28             : #include <com/sun/star/document/XEventBroadcaster.hpp>
      29             : #include <com/sun/star/beans/XPropertySet.hpp>
      30             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      31             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      32             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      33             : #include <rtl/ustring.h>
      34             : #include<sfx2/viewfrm.hxx>
      35             : 
      36             : #include <svx/AccessibleShape.hxx>
      37             : 
      38             : #include <svx/svdobj.hxx>
      39             : #include <svx/svdmodel.hxx>
      40             : #include <svx/unoapi.hxx>
      41             : #include <svx/unoshcol.hxx>
      42             : #include <toolkit/helper/vclunohelper.hxx>
      43             : #include "Window.hxx"
      44             : #include <vcl/svapp.hxx>
      45             : 
      46             : 
      47             : #include "ViewShell.hxx"
      48             : #include "View.hxx"
      49             : #include <memory>
      50             : 
      51             : #include "accessibility.hrc"
      52             : #include "sdresid.hxx"
      53             : #include <osl/mutex.hxx>
      54             : 
      55             : using ::rtl::OUString;
      56             : using namespace ::com::sun::star;
      57             : using namespace ::com::sun::star::uno;
      58             : using namespace ::com::sun::star::accessibility;
      59             : 
      60             : namespace accessibility {
      61             : 
      62             : 
      63             : //=====  internal  ============================================================
      64             : 
      65           0 : AccessibleDrawDocumentView::AccessibleDrawDocumentView (
      66             :     ::sd::Window* pSdWindow,
      67             :     ::sd::ViewShell* pViewShell,
      68             :     const uno::Reference<frame::XController>& rxController,
      69             :     const uno::Reference<XAccessible>& rxParent)
      70             :     : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent),
      71           0 :       mpChildrenManager (NULL)
      72             : {
      73             :     OSL_TRACE ("AccessibleDrawDocumentView");
      74           0 :     UpdateAccessibleName();
      75           0 : }
      76             : 
      77             : 
      78             : 
      79             : 
      80           0 : AccessibleDrawDocumentView::~AccessibleDrawDocumentView (void)
      81             : {
      82             :     OSL_TRACE ("~AccessibleDrawDocumentView");
      83             :     DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose,
      84             :         "~AccessibleDrawDocumentView: object has not been disposed");
      85           0 : }
      86             : 
      87             : 
      88             : 
      89             : 
      90           0 : void AccessibleDrawDocumentView::Init (void)
      91             : {
      92           0 :     AccessibleDocumentViewBase::Init ();
      93             : 
      94             :     // Determine the list of shapes on the current page.
      95           0 :     uno::Reference<drawing::XShapes> xShapeList;
      96           0 :     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
      97           0 :     if (xView.is())
      98             :         xShapeList = uno::Reference<drawing::XShapes> (
      99           0 :             xView->getCurrentPage(), uno::UNO_QUERY);
     100             : 
     101             :     // Create the children manager.
     102           0 :     mpChildrenManager = new ChildrenManager(this, xShapeList, maShapeTreeInfo, *this);
     103           0 :     if (mpChildrenManager != NULL)
     104             :     {
     105             :         // Create the page shape and initialize it.  The shape is acquired
     106             :         // before initialization and released after transferring ownership
     107             :         // to the children manager to prevent premature disposing of the
     108             :         // shape.
     109           0 :         AccessiblePageShape* pPage = CreateDrawPageShape();
     110           0 :         if (pPage != NULL)
     111             :         {
     112           0 :             pPage->acquire();
     113           0 :             pPage->Init();
     114             :             mpChildrenManager->AddAccessibleShape (
     115           0 :                 std::auto_ptr<AccessibleShape>(pPage));
     116           0 :             pPage->release();
     117           0 :             mpChildrenManager->Update ();
     118             :         }
     119           0 :         mpChildrenManager->UpdateSelection ();
     120           0 :     }
     121           0 : }
     122             : 
     123             : 
     124             : 
     125             : 
     126           0 : void AccessibleDrawDocumentView::ViewForwarderChanged (ChangeType aChangeType,
     127             :     const IAccessibleViewForwarder* pViewForwarder)
     128             : {
     129           0 :     AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder);
     130           0 :     if (mpChildrenManager != NULL)
     131           0 :         mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
     132           0 : }
     133             : 
     134             : 
     135             : 
     136             : 
     137             : /**  The page shape is created on every call at the moment (provided that
     138             :      every thing goes well).
     139             : */
     140           0 : AccessiblePageShape* AccessibleDrawDocumentView::CreateDrawPageShape (void)
     141             : {
     142           0 :     AccessiblePageShape* pShape = NULL;
     143             : 
     144             :     // Create a shape that represents the actual draw page.
     145           0 :     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
     146           0 :     if (xView.is())
     147             :     {
     148             :         uno::Reference<beans::XPropertySet> xSet (
     149           0 :             uno::Reference<beans::XPropertySet> (xView->getCurrentPage(), uno::UNO_QUERY));
     150           0 :         if (xSet.is())
     151             :         {
     152             :             // Create a rectangle shape that will represent the draw page.
     153           0 :             uno::Reference<lang::XMultiServiceFactory> xFactory (mxModel, uno::UNO_QUERY);
     154           0 :             uno::Reference<drawing::XShape> xRectangle;
     155           0 :             if (xFactory.is())
     156           0 :                 xRectangle = uno::Reference<drawing::XShape>(xFactory->createInstance ("com.sun.star.drawing.RectangleShape"),
     157           0 :                     uno::UNO_QUERY);
     158             : 
     159             :             // Set the shape's size and position.
     160           0 :             if (xRectangle.is())
     161             :             {
     162           0 :                 uno::Any aValue;
     163           0 :                 awt::Point aPosition;
     164           0 :                 awt::Size aSize;
     165             : 
     166             :                 // Set size and position of the shape to those of the draw
     167             :                 // page.
     168           0 :                 aValue = xSet->getPropertyValue ("BorderLeft");
     169           0 :                 aValue >>= aPosition.X;
     170           0 :                 aValue = xSet->getPropertyValue ("BorderTop");
     171           0 :                 aValue >>= aPosition.Y;
     172           0 :                 xRectangle->setPosition (aPosition);
     173             : 
     174           0 :                 aValue = xSet->getPropertyValue ("Width");
     175           0 :                 aValue >>= aSize.Width;
     176           0 :                 aValue = xSet->getPropertyValue ("Height");
     177           0 :                 aValue >>= aSize.Height;
     178           0 :                 xRectangle->setSize (aSize);
     179             : 
     180             :                 // Create the accessible object for the shape and
     181             :                 // initialize it.
     182             :                 pShape = new AccessiblePageShape (
     183           0 :                     xView->getCurrentPage(), this, maShapeTreeInfo);
     184           0 :             }
     185           0 :         }
     186             :     }
     187           0 :     return pShape;
     188             : }
     189             : 
     190             : 
     191             : 
     192             : 
     193             : //=====  XAccessibleContext  ==================================================
     194             : 
     195             : sal_Int32 SAL_CALL
     196           0 :     AccessibleDrawDocumentView::getAccessibleChildCount (void)
     197             :     throw (uno::RuntimeException)
     198             : {
     199           0 :     ThrowIfDisposed ();
     200             : 
     201           0 :     long mpChildCount = AccessibleDocumentViewBase::getAccessibleChildCount();
     202             : 
     203             :     // Forward request to children manager.
     204           0 :     if (mpChildrenManager != NULL)
     205           0 :         mpChildCount += mpChildrenManager->GetChildCount ();
     206             : 
     207           0 :     return mpChildCount;
     208             : }
     209             : 
     210             : 
     211             : 
     212             : 
     213             : uno::Reference<XAccessible> SAL_CALL
     214           0 :     AccessibleDrawDocumentView::getAccessibleChild (sal_Int32 nIndex)
     215             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     216             : {
     217           0 :     ThrowIfDisposed ();
     218             : 
     219           0 :     ::osl::ClearableMutexGuard aGuard (maMutex);
     220             : 
     221             :     // Take care of children of the base class.
     222           0 :     sal_Int32 nCount = AccessibleDocumentViewBase::getAccessibleChildCount();
     223           0 :     if (nCount > 0)
     224             :     {
     225           0 :         if (nIndex < nCount)
     226           0 :             return AccessibleDocumentViewBase::getAccessibleChild(nIndex);
     227             :         else
     228           0 :             nIndex -= nCount;
     229             :     }
     230             : 
     231             :     // Create a copy of the pointer to the children manager and release the
     232             :     // mutex before calling any of its methods.
     233           0 :     ChildrenManager* pChildrenManager = mpChildrenManager;
     234           0 :     aGuard.clear();
     235             : 
     236             :     // Forward request to children manager.
     237           0 :     if (pChildrenManager != NULL)
     238             :     {
     239           0 :         return pChildrenManager->GetChild (nIndex);
     240             :     }
     241             :     else
     242             :         throw lang::IndexOutOfBoundsException (
     243           0 :             "no accessible child with index " + rtl::OUString::valueOf(nIndex),
     244           0 :             static_cast<uno::XWeak*>(this));
     245             : }
     246             : 
     247             : 
     248             : 
     249             : 
     250             : //=====  XEventListener  ======================================================
     251             : 
     252             : void SAL_CALL
     253           0 :     AccessibleDrawDocumentView::disposing (const lang::EventObject& rEventObject)
     254             :     throw (::com::sun::star::uno::RuntimeException)
     255             : {
     256           0 :     ThrowIfDisposed ();
     257             : 
     258           0 :     AccessibleDocumentViewBase::disposing (rEventObject);
     259           0 :     if (rEventObject.Source == mxModel)
     260             :     {
     261           0 :         ::osl::Guard< ::osl::Mutex> aGuard (::osl::Mutex::getGlobalMutex());
     262             :         // maShapeTreeInfo has been modified in base class.
     263           0 :         if (mpChildrenManager != NULL)
     264           0 :             mpChildrenManager->SetInfo (maShapeTreeInfo);
     265             :     }
     266           0 : }
     267             : 
     268             : 
     269             : 
     270             : 
     271             : //=====  XPropertyChangeListener  =============================================
     272             : 
     273             : void SAL_CALL
     274           0 :     AccessibleDrawDocumentView::propertyChange (const beans::PropertyChangeEvent& rEventObject)
     275             :     throw (::com::sun::star::uno::RuntimeException)
     276             : {
     277           0 :     ThrowIfDisposed ();
     278             : 
     279           0 :     AccessibleDocumentViewBase::propertyChange (rEventObject);
     280             : 
     281             :     OSL_TRACE ("AccessibleDrawDocumentView::propertyChange");
     282           0 :     if ( rEventObject.PropertyName == "CurrentPage" )
     283             :     {
     284             :         OSL_TRACE ("    current page changed");
     285             : 
     286             :         // Update the accessible name to reflect the current slide.
     287           0 :         UpdateAccessibleName();
     288             : 
     289             :         // The current page changed.  Update the children manager accordingly.
     290           0 :         uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
     291           0 :         if (xView.is() && mpChildrenManager!=NULL)
     292             :         {
     293             :             // Inform the children manager to forget all children and give
     294             :             // him the new ones.
     295           0 :             mpChildrenManager->ClearAccessibleShapeList ();
     296             :             mpChildrenManager->SetShapeList (uno::Reference<drawing::XShapes> (
     297           0 :                 xView->getCurrentPage(), uno::UNO_QUERY));
     298             : 
     299             :             // Create the page shape and initialize it.  The shape is
     300             :             // acquired before initialization and released after
     301             :             // transferring ownership to the children manager to prevent
     302             :             // premature disposing of the shape.
     303           0 :             AccessiblePageShape* pPage = CreateDrawPageShape ();
     304           0 :             if (pPage != NULL)
     305             :             {
     306           0 :                 pPage->acquire();
     307           0 :                 pPage->Init();
     308             :                 mpChildrenManager->AddAccessibleShape (
     309           0 :                     std::auto_ptr<AccessibleShape>(pPage));
     310           0 :                 mpChildrenManager->Update (false);
     311           0 :                 pPage->release();
     312             :             }
     313             :         }
     314             :         else
     315           0 :             OSL_TRACE ("View invalid");
     316             :     }
     317           0 :     else if ( rEventObject.PropertyName == "VisibleArea" )
     318             :     {
     319             :         OSL_TRACE ("    visible area changed");
     320           0 :         if (mpChildrenManager != NULL)
     321             :             mpChildrenManager->ViewForwarderChanged (
     322             :                 IAccessibleViewForwarderListener::VISIBLE_AREA,
     323           0 :                 &maViewForwarder);
     324             :     }
     325             :     else
     326             :     {
     327             :         OSL_TRACE ("  unhandled");
     328             :     }
     329             :     OSL_TRACE ("  done");
     330           0 : }
     331             : 
     332             : 
     333             : 
     334             : //=====  XServiceInfo  ========================================================
     335             : 
     336             : ::rtl::OUString SAL_CALL
     337           0 :     AccessibleDrawDocumentView::getImplementationName (void)
     338             :     throw (::com::sun::star::uno::RuntimeException)
     339             : {
     340           0 :     return ::rtl::OUString("AccessibleDrawDocumentView");
     341             : }
     342             : 
     343             : 
     344             : 
     345             : 
     346             : ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
     347           0 :     AccessibleDrawDocumentView::getSupportedServiceNames (void)
     348             :     throw (::com::sun::star::uno::RuntimeException)
     349             : {
     350           0 :     ThrowIfDisposed();
     351             :     // Get list of supported service names from base class...
     352             :     uno::Sequence<OUString> aServiceNames =
     353           0 :         AccessibleDocumentViewBase::getSupportedServiceNames();
     354           0 :     sal_Int32 nCount (aServiceNames.getLength());
     355             : 
     356             :     // ...and add additional names.
     357           0 :     aServiceNames.realloc (nCount + 1);
     358           0 :     static const OUString sAdditionalServiceName ("com.sun.star.drawing.AccessibleDrawDocumentView");
     359           0 :     aServiceNames[nCount] = sAdditionalServiceName;
     360             : 
     361           0 :     return aServiceNames;
     362             : }
     363             : 
     364             : 
     365             : 
     366             : 
     367             : /// Create a name for this view.
     368             : ::rtl::OUString
     369           0 :     AccessibleDrawDocumentView::CreateAccessibleName (void)
     370             :     throw (::com::sun::star::uno::RuntimeException)
     371             : {
     372           0 :     rtl::OUString sName;
     373             : 
     374           0 :     uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
     375           0 :     if (xInfo.is())
     376             :     {
     377           0 :         uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() );
     378           0 :         OUString sFirstService = aServices[0];
     379           0 :         if ( sFirstService == "com.sun.star.drawing.DrawingDocumentDrawView" )
     380             :         {
     381           0 :             if( aServices.getLength() >= 2 && aServices[1] == "com.sun.star.presentation.PresentationView")
     382             :             {
     383           0 :                 SolarMutexGuard aGuard;
     384             : 
     385           0 :                 sName = SD_RESSTR(SID_SD_A11Y_I_DRAWVIEW_N);
     386             :             }
     387             :             else
     388             :             {
     389           0 :                 SolarMutexGuard aGuard;
     390             : 
     391           0 :                 sName = SD_RESSTR(SID_SD_A11Y_D_DRAWVIEW_N);
     392             :             }
     393             :         }
     394           0 :         else if ( sFirstService == "com.sun.star.presentation.NotesView" )
     395             :         {
     396           0 :             SolarMutexGuard aGuard;
     397             : 
     398           0 :             sName = SD_RESSTR(SID_SD_A11Y_I_NOTESVIEW_N);
     399             :         }
     400           0 :         else if ( sFirstService == "com.sun.star.presentation.HandoutView" )
     401             :         {
     402           0 :             SolarMutexGuard aGuard;
     403             : 
     404           0 :             sName = SD_RESSTR(SID_SD_A11Y_I_HANDOUTVIEW_N);
     405             :         }
     406             :         else
     407             :         {
     408           0 :             sName = sFirstService;
     409           0 :         }
     410             :     }
     411             :     else
     412             :     {
     413           0 :         sName = "AccessibleDrawDocumentView";
     414             :     }
     415           0 :     return sName;
     416             : }
     417             : 
     418             : 
     419             : 
     420             : 
     421             : /** Create a description for this view.  Use the model's description or URL
     422             :     if a description is not available.
     423             : */
     424             : ::rtl::OUString
     425           0 :     AccessibleDrawDocumentView::CreateAccessibleDescription (void)
     426             :     throw (::com::sun::star::uno::RuntimeException)
     427             : {
     428           0 :     rtl::OUString sDescription;
     429             : 
     430           0 :     uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY);
     431           0 :     if (xInfo.is())
     432             :     {
     433           0 :         uno::Sequence< ::rtl::OUString > aServices( xInfo->getSupportedServiceNames() );
     434           0 :         OUString sFirstService = aServices[0];
     435           0 :         if ( sFirstService == "com.sun.star.drawing.DrawingDocumentDrawView" )
     436             :         {
     437           0 :             if( aServices.getLength() >= 2 && aServices[1] == "com.sun.star.presentation.PresentationView")
     438             :             {
     439           0 :                 SolarMutexGuard aGuard;
     440             : 
     441           0 :                 sDescription = SD_RESSTR(SID_SD_A11Y_I_DRAWVIEW_D);
     442             :             }
     443             :             else
     444             :             {
     445           0 :                 SolarMutexGuard aGuard;
     446             : 
     447           0 :                 sDescription = SD_RESSTR(SID_SD_A11Y_D_DRAWVIEW_D);
     448             :             }
     449             :         }
     450           0 :         else if ( sFirstService == "com.sun.star.presentation.NotesView" )
     451             :         {
     452           0 :             SolarMutexGuard aGuard;
     453             : 
     454           0 :             sDescription = SD_RESSTR(SID_SD_A11Y_I_NOTESVIEW_D);
     455             :         }
     456           0 :         else if ( sFirstService == "com.sun.star.presentation.HandoutView" )
     457             :         {
     458           0 :             SolarMutexGuard aGuard;
     459             : 
     460           0 :             sDescription = SD_RESSTR(SID_SD_A11Y_I_HANDOUTVIEW_D);
     461             :         }
     462             :         else
     463             :         {
     464           0 :             sDescription = sFirstService;
     465           0 :         }
     466             :     }
     467             :     else
     468             :     {
     469           0 :         sDescription = "Accessible Draw Document";
     470             :     }
     471           0 :     return sDescription;
     472             : }
     473             : 
     474             : 
     475             : 
     476             : 
     477             : /** Return selection state of specified child
     478             : */
     479             : sal_Bool
     480           0 :     AccessibleDrawDocumentView::implIsSelected( sal_Int32 nAccessibleChildIndex )
     481             :     throw (uno::RuntimeException)
     482             : {
     483           0 :     const SolarMutexGuard aSolarGuard;
     484           0 :     uno::Reference< view::XSelectionSupplier >  xSel( mxController, uno::UNO_QUERY );
     485           0 :     sal_Bool                                    bRet = sal_False;
     486             : 
     487             :     OSL_ENSURE( 0 <= nAccessibleChildIndex, "AccessibleDrawDocumentView::implIsSelected: invalid index!" );
     488             : 
     489           0 :     if( xSel.is() && ( 0 <= nAccessibleChildIndex ) )
     490             :     {
     491           0 :         uno::Any                            aAny( xSel->getSelection() );
     492           0 :         uno::Reference< drawing::XShapes >  xShapes;
     493             : 
     494           0 :         aAny >>= xShapes;
     495             : 
     496           0 :         if( xShapes.is() )
     497             :         {
     498           0 :             AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( nAccessibleChildIndex ) );
     499             : 
     500           0 :             if( pAcc )
     501             :             {
     502           0 :                 uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() );
     503             : 
     504           0 :                 if( xShape.is() )
     505             :                 {
     506           0 :                     for( sal_Int32 i = 0, nCount = xShapes->getCount(); ( i < nCount ) && !bRet; ++i )
     507           0 :                         if( xShapes->getByIndex( i ) == xShape )
     508           0 :                             bRet = sal_True;
     509           0 :                 }
     510             :             }
     511           0 :         }
     512             :     }
     513             : 
     514           0 :     return( bRet );
     515             : }
     516             : 
     517             : 
     518             : 
     519             : 
     520             : /** Select or delselect the specified shapes.  The corresponding accessible
     521             :     shapes are notified over the selection change listeners registered with
     522             :     the XSelectionSupplier of the controller.
     523             : */
     524             : void
     525           0 :     AccessibleDrawDocumentView::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
     526             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     527             : {
     528           0 :     const SolarMutexGuard aSolarGuard;
     529           0 :     uno::Reference< view::XSelectionSupplier >  xSel( mxController, uno::UNO_QUERY );
     530             : 
     531           0 :     if( xSel.is() )
     532             :     {
     533           0 :         uno::Any aAny;
     534             : 
     535           0 :         if( ACCESSIBLE_SELECTION_CHILD_ALL == nAccessibleChildIndex )
     536             :         {
     537             :             // Select or deselect all children.
     538             : 
     539           0 :             if( !bSelect )
     540           0 :                 xSel->select( aAny );
     541             :             else
     542             :             {
     543           0 :                 uno::Reference< drawing::XShapes > xShapes( new SvxShapeCollection() );
     544             : 
     545           0 :                 for(sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
     546             :                 {
     547           0 :                     AccessibleShape* pAcc = AccessibleShape::getImplementation( getAccessibleChild( i ) );
     548             : 
     549           0 :                     if( pAcc && pAcc->GetXShape().is() )
     550           0 :                         xShapes->add( pAcc->GetXShape() );
     551             :                 }
     552             : 
     553           0 :                 if( xShapes->getCount() )
     554             :                 {
     555           0 :                     aAny <<= xShapes;
     556           0 :                     xSel->select( aAny );
     557           0 :                 }
     558             :             }
     559             :         }
     560           0 :         else if( nAccessibleChildIndex >= 0 )
     561             :         {
     562             :             // Select or deselect only the child with index
     563             :             // nAccessibleChildIndex.
     564             : 
     565             :             AccessibleShape* pAcc = AccessibleShape::getImplementation(
     566           0 :                 getAccessibleChild( nAccessibleChildIndex ));
     567             : 
     568             :             // Add or remove the shape that is made accessible from the
     569             :             // selection of the controller.
     570           0 :             if( pAcc )
     571             :             {
     572           0 :                 uno::Reference< drawing::XShape > xShape( pAcc->GetXShape() );
     573             : 
     574           0 :                 if( xShape.is() )
     575             :                 {
     576           0 :                     uno::Reference< drawing::XShapes >  xShapes;
     577           0 :                     sal_Bool                            bFound = sal_False;
     578             : 
     579           0 :                     aAny = xSel->getSelection();
     580           0 :                     aAny >>= xShapes;
     581             : 
     582             :                     // Search shape to be selected in current selection.
     583           0 :                     if (xShapes.is())
     584             :                     {
     585           0 :                         sal_Int32 nCount = xShapes->getCount();
     586           0 :                         for (sal_Int32 i=0; ( i < nCount ) && !bFound; ++i )
     587           0 :                             if( xShapes->getByIndex( i ) == xShape )
     588           0 :                                 bFound = sal_True;
     589             :                     }
     590             :                     else
     591             :                         // Create an empty selection to add the shape to.
     592           0 :                         xShapes = new SvxShapeCollection();
     593             : 
     594             :                     // Update the selection.
     595           0 :                     if( !bFound && bSelect )
     596           0 :                         xShapes->add( xShape );
     597           0 :                     else if( bFound && !bSelect )
     598           0 :                         xShapes->remove( xShape );
     599             : 
     600           0 :                     aAny <<= xShapes;
     601           0 :                     xSel->select( aAny );
     602           0 :                 }
     603             :             }
     604           0 :         }
     605           0 :     }
     606           0 : }
     607             : 
     608             : 
     609             : 
     610             : 
     611           0 : void AccessibleDrawDocumentView::Activated (void)
     612             : {
     613           0 :     if (mpChildrenManager != NULL)
     614             :     {
     615           0 :         mpChildrenManager->UpdateSelection();
     616             :         // When none of the children has the focus then claim it for the
     617             :         // view.
     618           0 :         if ( ! mpChildrenManager->HasFocus())
     619           0 :             SetState (AccessibleStateType::FOCUSED);
     620             :         else
     621           0 :             ResetState (AccessibleStateType::FOCUSED);
     622             :     }
     623           0 : }
     624             : 
     625             : 
     626             : 
     627             : 
     628           0 : void AccessibleDrawDocumentView::Deactivated (void)
     629             : {
     630           0 :     if (mpChildrenManager != NULL)
     631           0 :         mpChildrenManager->RemoveFocus();
     632           0 :     ResetState (AccessibleStateType::FOCUSED);
     633           0 : }
     634             : 
     635             : 
     636             : 
     637             : 
     638           0 : void AccessibleDrawDocumentView::impl_dispose (void)
     639             : {
     640           0 :     if (mpChildrenManager != NULL)
     641             :     {
     642           0 :         delete mpChildrenManager;
     643           0 :         mpChildrenManager = NULL;
     644             :     }
     645             : 
     646           0 :     AccessibleDocumentViewBase::impl_dispose();
     647           0 : }
     648             : 
     649             : 
     650             : 
     651             : /** This method is called from the component helper base class while
     652             :     disposing.
     653             : */
     654           0 : void SAL_CALL AccessibleDrawDocumentView::disposing (void)
     655             : {
     656             : 
     657             :     // Release resources.
     658           0 :     if (mpChildrenManager != NULL)
     659             :     {
     660           0 :         delete mpChildrenManager;
     661           0 :         mpChildrenManager = NULL;
     662             :     }
     663             : 
     664             :     // Forward call to base classes.
     665           0 :     AccessibleDocumentViewBase::disposing ();
     666           0 : }
     667             : 
     668             : 
     669             : 
     670             : 
     671           0 : void AccessibleDrawDocumentView::UpdateAccessibleName (void)
     672             : {
     673           0 :     OUString sNewName (CreateAccessibleName());
     674           0 :     sNewName += ": ";
     675             : 
     676             :     // Add the number of the current slide.
     677           0 :     uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY);
     678           0 :     if (xView.is())
     679             :     {
     680           0 :         uno::Reference<beans::XPropertySet> xProperties (xView->getCurrentPage(), UNO_QUERY);
     681           0 :         if (xProperties.is())
     682             :             try
     683             :             {
     684           0 :                 sal_Int16 nPageNumber (0);
     685           0 :                 if (xProperties->getPropertyValue("Number") >>= nPageNumber)
     686             :                 {
     687           0 :                     sNewName += OUString::valueOf(sal_Int32(nPageNumber));
     688             :                 }
     689             :             }
     690           0 :             catch (beans::UnknownPropertyException&)
     691             :             {
     692           0 :             }
     693             :     }
     694             : 
     695             :     // Add the number of pages/slides.
     696           0 :     Reference<drawing::XDrawPagesSupplier> xPagesSupplier (mxModel, UNO_QUERY);
     697           0 :     if (xPagesSupplier.is())
     698             :     {
     699           0 :         Reference<container::XIndexAccess> xPages (xPagesSupplier->getDrawPages(), UNO_QUERY);
     700           0 :         if (xPages.is())
     701             :         {
     702           0 :             sNewName += " / ";
     703           0 :             sNewName += OUString::valueOf(xPages->getCount());
     704           0 :         }
     705             :     }
     706             : 
     707           0 :     SetAccessibleName (sNewName, AutomaticallyCreated);
     708           0 : }
     709             : 
     710             : } // end of namespace accessibility
     711             : 
     712             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10