LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/access - accnotextframe.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 31 94 33.0 %
Date: 2013-07-09 Functions: 7 15 46.7 %
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 <osl/mutex.hxx>
      21             : #include <vcl/svapp.hxx>
      22             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      23             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      24             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      25             : #include <unotools/accessiblestatesethelper.hxx>
      26             : #include <frmfmt.hxx>
      27             : #include <ndnotxt.hxx>
      28             : #include <flyfrm.hxx>
      29             : #include <cntfrm.hxx>
      30             : #include <hints.hxx> //#i73249#
      31             : #include "accnotextframe.hxx"
      32             : 
      33             : using namespace ::com::sun::star;
      34             : using namespace ::com::sun::star::accessibility;
      35             : 
      36           2 : const SwNoTxtNode *SwAccessibleNoTextFrame::GetNoTxtNode() const
      37             : {
      38           2 :     const SwNoTxtNode *pNd  = 0;
      39           2 :     const SwFlyFrm *pFlyFrm = static_cast< const SwFlyFrm *>( GetFrm() );
      40           2 :     if( pFlyFrm->Lower() && pFlyFrm->Lower()->IsNoTxtFrm() )
      41             :     {
      42             :         const SwCntntFrm *pCntFrm =
      43           2 :             static_cast<const SwCntntFrm *>( pFlyFrm->Lower() );
      44           2 :         pNd = pCntFrm->GetNode()->GetNoTxtNode();
      45             :     }
      46             : 
      47           2 :     return pNd;
      48             : }
      49             : 
      50           1 : SwAccessibleNoTextFrame::SwAccessibleNoTextFrame(
      51             :         SwAccessibleMap* pInitMap,
      52             :         sal_Int16 nInitRole,
      53             :         const SwFlyFrm* pFlyFrm  ) :
      54             :     SwAccessibleFrameBase( pInitMap, nInitRole, pFlyFrm ),
      55           1 :     aDepend( this, const_cast < SwNoTxtNode * >( GetNoTxtNode() ) ),
      56             :     msTitle(),
      57           2 :     msDesc()
      58             : {
      59           1 :     const SwNoTxtNode* pNd = GetNoTxtNode();
      60             :     // #i73249#
      61             :     // consider new attributes Title and Description
      62           1 :     if( pNd )
      63             :     {
      64           1 :         msTitle = pNd->GetTitle();
      65             : 
      66           1 :         msDesc = pNd->GetDescription();
      67           2 :         if ( msDesc.isEmpty() &&
      68           1 :              msTitle != GetName() )
      69             :         {
      70           1 :             msDesc = msTitle;
      71             :         }
      72             :     }
      73           1 : }
      74             : 
      75           1 : SwAccessibleNoTextFrame::~SwAccessibleNoTextFrame()
      76             : {
      77           1 : }
      78             : 
      79           0 : void SwAccessibleNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
      80             : {
      81           0 :     const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
      82             :     // #i73249#
      83             :     // suppress handling of RES_NAME_CHANGED in case that attribute Title is
      84             :     // used as the accessible name.
      85           0 :     if ( nWhich != RES_NAME_CHANGED ||
      86           0 :          msTitle.isEmpty() )
      87             :     {
      88           0 :         SwAccessibleFrameBase::Modify( pOld, pNew );
      89             :     }
      90             : 
      91           0 :     const SwNoTxtNode *pNd = GetNoTxtNode();
      92             :     OSL_ENSURE( pNd == aDepend.GetRegisteredIn(), "invalid frame" );
      93           0 :     switch( nWhich )
      94             :     {
      95             :         // #i73249#
      96             :         case RES_TITLE_CHANGED:
      97             :         {
      98             :             const String& sOldTitle(
      99           0 :                         dynamic_cast<const SwStringMsgPoolItem*>(pOld)->GetString() );
     100             :             const String& sNewTitle(
     101           0 :                         dynamic_cast<const SwStringMsgPoolItem*>(pNew)->GetString() );
     102           0 :             if ( sOldTitle == sNewTitle )
     103             :             {
     104           0 :                 break;
     105             :             }
     106           0 :             msTitle = sNewTitle;
     107           0 :             AccessibleEventObject aEvent;
     108           0 :             aEvent.EventId = AccessibleEventId::NAME_CHANGED;
     109           0 :             aEvent.OldValue <<= OUString( sOldTitle );
     110           0 :             aEvent.NewValue <<= msTitle;
     111           0 :             FireAccessibleEvent( aEvent );
     112             : 
     113           0 :             if ( pNd->GetDescription().Len() != 0 )
     114             :             {
     115           0 :                 break;
     116           0 :             }
     117             :         }
     118             :         // intentional no break here
     119             :         case RES_DESCRIPTION_CHANGED:
     120             :         {
     121           0 :             if ( pNd && GetFrm() )
     122             :             {
     123           0 :                 const OUString sOldDesc( msDesc );
     124             : 
     125           0 :                 const String& rDesc = pNd->GetDescription();
     126           0 :                 msDesc = rDesc;
     127           0 :                 if ( msDesc.isEmpty() &&
     128           0 :                      msTitle != GetName() )
     129             :                 {
     130           0 :                     msDesc = msTitle;
     131             :                 }
     132             : 
     133           0 :                 if ( msDesc != sOldDesc )
     134             :                 {
     135           0 :                     AccessibleEventObject aEvent;
     136           0 :                     aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
     137           0 :                     aEvent.OldValue <<= sOldDesc;
     138           0 :                     aEvent.NewValue <<= msDesc;
     139           0 :                     FireAccessibleEvent( aEvent );
     140           0 :                 }
     141             :             }
     142             :         }
     143           0 :         break;
     144             :     }
     145           0 : }
     146             : 
     147           1 : void SwAccessibleNoTextFrame::Dispose( sal_Bool bRecursive )
     148             : {
     149           1 :     SolarMutexGuard aGuard;
     150             : 
     151           1 :     if( aDepend.GetRegisteredIn() )
     152           1 :         const_cast < SwModify *>( aDepend.GetRegisteredIn() )->Remove( &aDepend );
     153             : 
     154           1 :     SwAccessibleFrameBase::Dispose( bRecursive );
     155           1 : }
     156             : 
     157             : // #i73249#
     158           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleName (void)
     159             :         throw (uno::RuntimeException)
     160             : {
     161           0 :     SolarMutexGuard aGuard;
     162             : 
     163           0 :     CHECK_FOR_DEFUNC( XAccessibleContext )
     164             : 
     165           0 :     if ( !msTitle.isEmpty() )
     166             :     {
     167           0 :         return msTitle;
     168             :     }
     169             : 
     170           0 :     return SwAccessibleFrameBase::getAccessibleName();
     171             : }
     172             : 
     173           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleDescription (void)
     174             :         throw (uno::RuntimeException)
     175             : {
     176           0 :     SolarMutexGuard aGuard;
     177             : 
     178           0 :     CHECK_FOR_DEFUNC( XAccessibleContext )
     179             : 
     180           0 :     return msDesc;
     181             : }
     182             : 
     183             : // XInterface
     184             : 
     185          43 : uno::Any SAL_CALL SwAccessibleNoTextFrame::queryInterface( const uno::Type& aType )
     186             :     throw (uno::RuntimeException)
     187             : {
     188          43 :     if( aType ==
     189          43 :         ::getCppuType( static_cast<uno::Reference<XAccessibleImage>*>( NULL ) ) )
     190             :     {
     191           0 :         uno::Reference<XAccessibleImage> xImage = this;
     192           0 :         uno::Any aAny;
     193           0 :         aAny <<= xImage;
     194           0 :         return aAny;
     195             :     }
     196             :     else
     197          43 :         return SwAccessibleContext::queryInterface( aType );
     198             : }
     199             : 
     200             : 
     201             : // XTypeProvider
     202             : 
     203           0 : uno::Sequence< uno::Type > SAL_CALL SwAccessibleNoTextFrame::getTypes() throw(uno::RuntimeException)
     204             : {
     205           0 :     uno::Sequence< uno::Type > aTypes( SwAccessibleFrameBase::getTypes() );
     206             : 
     207           0 :     sal_Int32 nIndex = aTypes.getLength();
     208           0 :     aTypes.realloc( nIndex + 1 );
     209             : 
     210           0 :     uno::Type* pTypes = aTypes.getArray();
     211           0 :     pTypes[nIndex] = ::getCppuType( static_cast< uno::Reference< XAccessibleImage > * >( 0 ) );
     212             : 
     213           0 :     return aTypes;
     214             : }
     215             : 
     216             : /// XAccessibleImage
     217             : /** implementation of the XAccessibleImage methods is a no-brainer, as
     218             :     all relevant information is already accessible through other
     219             :     methods. So we just delegate to those. */
     220             : 
     221           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageDescription()
     222             :     throw ( uno::RuntimeException )
     223             : {
     224           0 :     return getAccessibleDescription();
     225             : }
     226             : 
     227           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageHeight(  )
     228             :     throw ( uno::RuntimeException )
     229             : {
     230           0 :     return getSize().Height;
     231             : }
     232             : 
     233           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageWidth(  )
     234             :     throw ( uno::RuntimeException )
     235             : {
     236           0 :     return getSize().Width;
     237          99 : }
     238             : 
     239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10