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

Generated by: LCOV version 1.10