LCOV - code coverage report
Current view: top level - sd/source/ui/accessibility - AccessibleOutlineView.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 94 1.1 %
Date: 2014-11-03 Functions: 2 22 9.1 %
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 <com/sun/star/drawing/XDrawPage.hpp>
      21             : #include <com/sun/star/drawing/XDrawView.hpp>
      22             : #include <com/sun/star/drawing/XShapes.hpp>
      23             : #include <com/sun/star/container/XChild.hpp>
      24             : #include <com/sun/star/frame/XController.hpp>
      25             : #include <com/sun/star/frame/XFrame.hpp>
      26             : #include <com/sun/star/document/XEventBroadcaster.hpp>
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      29             : #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
      30             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      31             : #include <rtl/ustring.h>
      32             : #include <sfx2/viewfrm.hxx>
      33             : 
      34             : #include <svx/AccessibleShape.hxx>
      35             : 
      36             : #include <svx/svdobj.hxx>
      37             : #include <svx/svdmodel.hxx>
      38             : #include <svx/unoapi.hxx>
      39             : #include <toolkit/helper/vclunohelper.hxx>
      40             : #include <vcl/svapp.hxx>
      41             : #include "Window.hxx"
      42             : #include "ViewShell.hxx"
      43             : #include "OutlineViewShell.hxx"
      44             : #include "View.hxx"
      45             : #include "AccessibleOutlineView.hxx"
      46             : #include "AccessibleOutlineEditSource.hxx"
      47             : 
      48             : #include <memory>
      49             : 
      50             : #include "accessibility.hrc"
      51             : #include "sdresid.hxx"
      52             : #include <osl/mutex.hxx>
      53             : 
      54             : using namespace ::com::sun::star;
      55             : using namespace ::com::sun::star::accessibility;
      56             : 
      57             : namespace accessibility {
      58             : 
      59             : //=====  internal  ============================================================
      60             : 
      61           0 : AccessibleOutlineView::AccessibleOutlineView (
      62             :     ::sd::Window* pSdWindow,
      63             :     ::sd::OutlineViewShell* pViewShell,
      64             :     const uno::Reference<frame::XController>& rxController,
      65             :     const uno::Reference<XAccessible>& rxParent)
      66             :     : AccessibleDocumentViewBase (pSdWindow, pViewShell, rxController, rxParent),
      67           0 :       maTextHelper( ::std::unique_ptr< SvxEditSource >() )
      68             : {
      69           0 :     SolarMutexGuard aGuard;
      70             : 
      71             :     // Beware! Here we leave the paths of the UNO API and descend into the
      72             :     // depths of the core.  Necessary for making the edit engine accessible.
      73           0 :     if (pSdWindow)
      74             :     {
      75           0 :         ::sd::View* pView = pViewShell->GetView();
      76             : 
      77           0 :         if (pView && pView->ISA(::sd::OutlineView))
      78             :         {
      79             :             OutlinerView* pOutlineView = static_cast< ::sd::OutlineView*>(
      80           0 :                 pView)->GetViewByWindow( pSdWindow );
      81             :             SdrOutliner& rOutliner =
      82           0 :                 static_cast< ::sd::OutlineView*>(pView)->GetOutliner();
      83             : 
      84           0 :             if( pOutlineView )
      85             :             {
      86             :                 maTextHelper.SetEditSource( ::std::unique_ptr< SvxEditSource >( new AccessibleOutlineEditSource(
      87           0 :                                                                                   rOutliner, *pView, *pOutlineView, *pSdWindow ) ) );
      88             :             }
      89             :         }
      90           0 :     }
      91           0 : }
      92             : 
      93           0 : AccessibleOutlineView::~AccessibleOutlineView (void)
      94             : {
      95             :     OSL_TRACE ("~AccessibleOutlineView");
      96           0 : }
      97             : 
      98           0 : void AccessibleOutlineView::Init (void)
      99             : {
     100             :     // Set event source _before_ starting to listen
     101           0 :     maTextHelper.SetEventSource(this);
     102             : 
     103           0 :     AccessibleDocumentViewBase::Init ();
     104           0 : }
     105             : 
     106           0 : void AccessibleOutlineView::ViewForwarderChanged (ChangeType aChangeType,
     107             :     const IAccessibleViewForwarder* pViewForwarder)
     108             : {
     109           0 :     AccessibleDocumentViewBase::ViewForwarderChanged (aChangeType, pViewForwarder);
     110             : 
     111           0 :     UpdateChildren();
     112           0 : }
     113             : 
     114             : //=====  XAccessibleContext  ==================================================
     115             : 
     116             : sal_Int32 SAL_CALL
     117           0 :     AccessibleOutlineView::getAccessibleChildCount (void)
     118             :     throw (uno::RuntimeException, std::exception)
     119             : {
     120           0 :     ThrowIfDisposed ();
     121             : 
     122             :     // forward
     123           0 :     return maTextHelper.GetChildCount();
     124             : }
     125             : 
     126             : uno::Reference<XAccessible> SAL_CALL
     127           0 :     AccessibleOutlineView::getAccessibleChild (sal_Int32 nIndex)
     128             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     129             : {
     130           0 :     ThrowIfDisposed ();
     131             :     // Forward request to children manager.
     132           0 :     return maTextHelper.GetChild(nIndex);
     133             : }
     134             : 
     135             : #include <drawdoc.hxx>
     136             : 
     137             : OUString SAL_CALL
     138           0 :     AccessibleOutlineView::getAccessibleName(void)
     139             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     140             : {
     141           0 :     SolarMutexGuard g;
     142             : 
     143           0 :     OUString sName = SdResId(SID_SD_A11Y_D_PRESENTATION);
     144           0 :     ::sd::View* pSdView = static_cast< ::sd::View* >( maShapeTreeInfo.GetSdrView() );
     145           0 :     if ( pSdView )
     146             :     {
     147           0 :         SdDrawDocument& rDoc = pSdView->GetDoc();
     148           0 :         rtl::OUString sFileName = rDoc.getDocAccTitle();
     149           0 :         if (sFileName.isEmpty())
     150             :         {
     151           0 :             ::sd::DrawDocShell* pDocSh = pSdView->GetDocSh();
     152           0 :             if ( pDocSh )
     153             :             {
     154           0 :                 sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME );
     155             :             }
     156             :         }
     157           0 :         if (!sFileName.isEmpty())
     158             :         {
     159           0 :             sName = sFileName + " - " + sName;
     160           0 :         }
     161             :     }
     162           0 :     return sName;
     163             : }
     164             : 
     165             : //=====  XAccessibleEventBroadcaster  ========================================
     166             : 
     167           0 : void SAL_CALL AccessibleOutlineView::addAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException, std::exception)
     168             : {
     169             :     // delegate listener handling to children manager.
     170           0 :     if ( ! IsDisposed())
     171           0 :         maTextHelper.AddEventListener(xListener);
     172           0 :     AccessibleContextBase::addEventListener(xListener);
     173           0 : }
     174             : 
     175           0 : void SAL_CALL AccessibleOutlineView::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException, std::exception)
     176             : {
     177             :     // forward
     178           0 :     if ( ! IsDisposed())
     179           0 :         maTextHelper.RemoveEventListener(xListener);
     180           0 :     AccessibleContextBase::removeEventListener(xListener);
     181           0 : }
     182             : 
     183             : //=====  XServiceInfo  ========================================================
     184             : 
     185             : OUString SAL_CALL
     186           0 :     AccessibleOutlineView::getImplementationName (void)
     187             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     188             : {
     189           0 :     return OUString("AccessibleOutlineView");
     190             : }
     191             : 
     192             : //=====  XEventListener  ======================================================
     193             : 
     194             : void SAL_CALL
     195           0 :     AccessibleOutlineView::disposing (const lang::EventObject& rEventObject)
     196             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     197             : {
     198           0 :     AccessibleDocumentViewBase::disposing (rEventObject);
     199           0 : }
     200             : 
     201             : //=====  protected internal  ==================================================
     202             : 
     203           0 : void AccessibleOutlineView::FireEvent(const AccessibleEventObject& aEvent )
     204             : {
     205             :     // delegate listener handling to children manager.
     206           0 :     maTextHelper.FireEvent(aEvent);
     207           0 : }
     208             : 
     209           0 : void AccessibleOutlineView::Activated (void)
     210             : {
     211           0 :     SolarMutexGuard aGuard;
     212             : 
     213             :     // delegate listener handling to children manager.
     214           0 :     maTextHelper.SetFocus(true);
     215           0 : }
     216             : 
     217           0 : void AccessibleOutlineView::Deactivated (void)
     218             : {
     219           0 :     SolarMutexGuard aGuard;
     220             : 
     221             :     // delegate listener handling to children manager.
     222           0 :     maTextHelper.SetFocus(false);
     223           0 : }
     224             : 
     225           0 : void SAL_CALL AccessibleOutlineView::disposing (void)
     226             : {
     227             :     // dispose children
     228           0 :     maTextHelper.Dispose();
     229             : 
     230           0 :     AccessibleDocumentViewBase::disposing ();
     231           0 : }
     232             : 
     233             : //=====  XPropertyChangeListener  =============================================
     234             : 
     235             : void SAL_CALL
     236           0 :     AccessibleOutlineView::propertyChange (const beans::PropertyChangeEvent& rEventObject)
     237             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     238             : {
     239           0 :     ThrowIfDisposed ();
     240             : 
     241           0 :     AccessibleDocumentViewBase::propertyChange (rEventObject);
     242             : 
     243             :     OSL_TRACE ("AccessibleOutlineView::propertyChange");
     244             :     //add page switch event for slide show mode
     245           0 :     if (rEventObject.PropertyName == "CurrentPage" ||
     246           0 :         rEventObject.PropertyName == "PageChange")
     247             :     {
     248             :         OSL_TRACE ("    current page changed");
     249             : 
     250             :         // The current page changed. Update the children accordingly.
     251           0 :         UpdateChildren();
     252           0 :         CommitChange(AccessibleEventId::PAGE_CHANGED,rEventObject.NewValue, rEventObject.OldValue);
     253             :     }
     254           0 :     else if ( rEventObject.PropertyName == "VisibleArea" )
     255             :     {
     256             :         OSL_TRACE ("    visible area changed");
     257             : 
     258             :         // The visible area changed. Update the children accordingly.
     259           0 :         UpdateChildren();
     260             :     }
     261             :     else
     262             :     {
     263             :         OSL_TRACE ("  unhandled");
     264             :     }
     265             :     OSL_TRACE ("  done");
     266           0 : }
     267             : 
     268             : /// Create a name for this view.
     269             : OUString
     270           0 :     AccessibleOutlineView::CreateAccessibleName (void)
     271             :     throw (::com::sun::star::uno::RuntimeException)
     272             : {
     273           0 :     SolarMutexGuard aGuard;
     274             : 
     275           0 :     return SD_RESSTR(SID_SD_A11Y_I_OUTLINEVIEW_N);
     276             : }
     277             : 
     278             : /** Create a description for this view.  Use the model's description or URL
     279             :     if a description is not available.
     280             : */
     281             : OUString
     282           0 :     AccessibleOutlineView::CreateAccessibleDescription (void)
     283             :     throw (::com::sun::star::uno::RuntimeException)
     284             : {
     285           0 :     SolarMutexGuard aGuard;
     286             : 
     287           0 :     return SD_RESSTR(SID_SD_A11Y_I_OUTLINEVIEW_D);
     288             : }
     289             : 
     290           0 : void AccessibleOutlineView::UpdateChildren()
     291             : {
     292           0 :     SolarMutexGuard aGuard;
     293             : 
     294             :     // Update visible children
     295           0 :     maTextHelper.UpdateChildren();
     296           0 : }
     297             : 
     298         114 : } // end of namespace accessibility
     299             : 
     300             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10