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

Generated by: LCOV version 1.10