LCOV - code coverage report
Current view: top level - sw/source/core/access - accnotextframe.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 153 0.0 %
Date: 2014-04-14 Functions: 0 34 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>
      31             : #include "accnotextframe.hxx"
      32             : #include <fmturl.hxx>
      33             : #include <accnotexthyperlink.hxx>
      34             : #include <svtools/imap.hxx>
      35             : #include <unotools/accessiblerelationsethelper.hxx>
      36             : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
      37             : #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
      38             : #include <doc.hxx>
      39             : 
      40             : using namespace ::com::sun::star;
      41             : using namespace ::com::sun::star::accessibility;
      42             : using utl::AccessibleRelationSetHelper;
      43             : 
      44           0 : const SwNoTxtNode *SwAccessibleNoTextFrame::GetNoTxtNode() const
      45             : {
      46           0 :     const SwNoTxtNode *pNd  = 0;
      47           0 :     const SwFlyFrm *pFlyFrm = static_cast< const SwFlyFrm *>( GetFrm() );
      48           0 :     if( pFlyFrm->Lower() && pFlyFrm->Lower()->IsNoTxtFrm() )
      49             :     {
      50             :         const SwCntntFrm *pCntFrm =
      51           0 :             static_cast<const SwCntntFrm *>( pFlyFrm->Lower() );
      52           0 :         const SwCntntNode* pSwCntntNode = pCntFrm->GetNode();
      53           0 :         if(pSwCntntNode != NULL)
      54             :         {
      55           0 :             pNd = pSwCntntNode->GetNoTxtNode();
      56             :         }
      57             :     }
      58             : 
      59           0 :     return pNd;
      60             : }
      61             : 
      62           0 : SwAccessibleNoTextFrame::SwAccessibleNoTextFrame(
      63             :         SwAccessibleMap* pInitMap,
      64             :         sal_Int16 nInitRole,
      65             :         const SwFlyFrm* pFlyFrm  ) :
      66             :     SwAccessibleFrameBase( pInitMap, nInitRole, pFlyFrm ),
      67           0 :     aDepend( this, const_cast < SwNoTxtNode * >( GetNoTxtNode() ) ),
      68             :     msTitle(),
      69           0 :     msDesc()
      70             : {
      71           0 :     const SwNoTxtNode* pNd = GetNoTxtNode();
      72             :     // #i73249#
      73             :     // consider new attributes Title and Description
      74           0 :     if( pNd )
      75             :     {
      76           0 :         msTitle = pNd->GetTitle();
      77             : 
      78           0 :         msDesc = pNd->GetDescription();
      79           0 :         if ( msDesc.isEmpty() &&
      80           0 :              msTitle != GetName() )
      81             :         {
      82           0 :             msDesc = msTitle;
      83             :         }
      84             :     }
      85           0 : }
      86             : 
      87           0 : SwAccessibleNoTextFrame::~SwAccessibleNoTextFrame()
      88             : {
      89           0 : }
      90             : 
      91           0 : void SwAccessibleNoTextFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
      92             : {
      93           0 :     const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
      94             :     // #i73249#
      95             :     // suppress handling of RES_NAME_CHANGED in case that attribute Title is
      96             :     // used as the accessible name.
      97           0 :     if ( nWhich != RES_NAME_CHANGED ||
      98           0 :          msTitle.isEmpty() )
      99             :     {
     100           0 :         SwAccessibleFrameBase::Modify( pOld, pNew );
     101           0 :         if (!GetRegisteredIn())
     102           0 :             return; // probably was deleted - avoid doing anything
     103             :     }
     104             : 
     105           0 :     const SwNoTxtNode *pNd = GetNoTxtNode();
     106             :     OSL_ENSURE( pNd == aDepend.GetRegisteredIn(), "invalid frame" );
     107           0 :     switch( nWhich )
     108             :     {
     109             :         // #i73249#
     110             :         case RES_TITLE_CHANGED:
     111             :         {
     112             :             const OUString& sOldTitle(
     113           0 :                         dynamic_cast<const SwStringMsgPoolItem*>(pOld)->GetString() );
     114             :             const OUString& sNewTitle(
     115           0 :                         dynamic_cast<const SwStringMsgPoolItem*>(pNew)->GetString() );
     116           0 :             if ( sOldTitle == sNewTitle )
     117             :             {
     118           0 :                 break;
     119             :             }
     120           0 :             msTitle = sNewTitle;
     121           0 :             AccessibleEventObject aEvent;
     122           0 :             aEvent.EventId = AccessibleEventId::NAME_CHANGED;
     123           0 :             aEvent.OldValue <<= sOldTitle;
     124           0 :             aEvent.NewValue <<= msTitle;
     125           0 :             FireAccessibleEvent( aEvent );
     126             : 
     127           0 :             if ( !pNd->GetDescription().isEmpty() )
     128             :             {
     129           0 :                 break;
     130           0 :             }
     131             :         }
     132             :         // intentional no break here
     133             :         case RES_DESCRIPTION_CHANGED:
     134             :         {
     135           0 :             if ( pNd && GetFrm() )
     136             :             {
     137           0 :                 const OUString sOldDesc( msDesc );
     138             : 
     139           0 :                 const OUString& rDesc = pNd->GetDescription();
     140           0 :                 msDesc = rDesc;
     141           0 :                 if ( msDesc.isEmpty() &&
     142           0 :                      msTitle != GetName() )
     143             :                 {
     144           0 :                     msDesc = msTitle;
     145             :                 }
     146             : 
     147           0 :                 if ( msDesc != sOldDesc )
     148             :                 {
     149           0 :                     AccessibleEventObject aEvent;
     150           0 :                     aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
     151           0 :                     aEvent.OldValue <<= sOldDesc;
     152           0 :                     aEvent.NewValue <<= msDesc;
     153           0 :                     FireAccessibleEvent( aEvent );
     154           0 :                 }
     155             :             }
     156             :         }
     157           0 :         break;
     158             :     }
     159             : }
     160             : 
     161           0 : void SwAccessibleNoTextFrame::Dispose( sal_Bool bRecursive )
     162             : {
     163           0 :     SolarMutexGuard aGuard;
     164             : 
     165           0 :     if( aDepend.GetRegisteredIn() )
     166           0 :         const_cast < SwModify *>( aDepend.GetRegisteredIn() )->Remove( &aDepend );
     167             : 
     168           0 :     SwAccessibleFrameBase::Dispose( bRecursive );
     169           0 : }
     170             : 
     171             : // #i73249#
     172           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleName (void)
     173             :         throw (uno::RuntimeException, std::exception)
     174             : {
     175           0 :     SolarMutexGuard aGuard;
     176             : 
     177           0 :     CHECK_FOR_DEFUNC( XAccessibleContext )
     178             : 
     179           0 :     if ( !msTitle.isEmpty() )
     180             :     {
     181           0 :         return msTitle;
     182             :     }
     183             : 
     184           0 :     return SwAccessibleFrameBase::getAccessibleName();
     185             : }
     186             : 
     187           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleDescription (void)
     188             :         throw (uno::RuntimeException, std::exception)
     189             : {
     190           0 :     SolarMutexGuard aGuard;
     191             : 
     192           0 :     CHECK_FOR_DEFUNC( XAccessibleContext )
     193             : 
     194           0 :     return msDesc;
     195             : }
     196             : 
     197             : // XInterface
     198             : 
     199           0 : uno::Any SAL_CALL SwAccessibleNoTextFrame::queryInterface( const uno::Type& aType )
     200             :     throw (uno::RuntimeException, std::exception)
     201             : {
     202           0 :     if( aType ==
     203           0 :         ::getCppuType( static_cast<uno::Reference<XAccessibleImage>*>( NULL ) ) )
     204             :     {
     205           0 :         uno::Reference<XAccessibleImage> xImage = this;
     206           0 :         uno::Any aAny;
     207           0 :         aAny <<= xImage;
     208           0 :         return aAny;
     209             :     }
     210           0 :     else if ( aType == ::getCppuType((uno::Reference<XAccessibleHypertext> *)0) )
     211             :     {
     212           0 :         uno::Reference<XAccessibleHypertext> aAccHypertext = this;
     213           0 :         uno::Any aAny;
     214           0 :         aAny <<= aAccHypertext;
     215           0 :         return aAny;
     216             :     }
     217             :     else
     218           0 :         return SwAccessibleContext::queryInterface( aType );
     219             : }
     220             : 
     221             : // XTypeProvider
     222             : 
     223           0 : uno::Sequence< uno::Type > SAL_CALL SwAccessibleNoTextFrame::getTypes() throw(uno::RuntimeException, std::exception)
     224             : {
     225           0 :     uno::Sequence< uno::Type > aTypes( SwAccessibleFrameBase::getTypes() );
     226             : 
     227           0 :     sal_Int32 nIndex = aTypes.getLength();
     228           0 :     aTypes.realloc( nIndex + 1 );
     229             : 
     230           0 :     uno::Type* pTypes = aTypes.getArray();
     231           0 :     pTypes[nIndex] = ::getCppuType( static_cast< uno::Reference< XAccessibleImage > * >( 0 ) );
     232             : 
     233           0 :     return aTypes;
     234             : }
     235             : 
     236             : /// XAccessibleImage
     237             : /** implementation of the XAccessibleImage methods is a no-brainer, as
     238             :     all relevant information is already accessible through other
     239             :     methods. So we just delegate to those. */
     240             : 
     241           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageDescription()
     242             :     throw ( uno::RuntimeException, std::exception )
     243             : {
     244           0 :     return getAccessibleDescription();
     245             : }
     246             : 
     247           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageHeight(  )
     248             :     throw ( uno::RuntimeException, std::exception )
     249             : {
     250           0 :     return getSize().Height;
     251             : }
     252             : 
     253           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageWidth(  )
     254             :     throw ( uno::RuntimeException, std::exception )
     255             : {
     256           0 :     return getSize().Width;
     257             : }
     258             : 
     259             : //=====  XAccesibleText  ==================================================
     260           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getCaretPosition(  ) throw (::com::sun::star::uno::RuntimeException, std::exception){return 0;}
     261           0 : sal_Bool SAL_CALL SwAccessibleNoTextFrame::setCaretPosition( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception){return 0;}
     262           0 : sal_Unicode SAL_CALL SwAccessibleNoTextFrame::getCharacter( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception){return 0;}
     263           0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL SwAccessibleNoTextFrame::getCharacterAttributes( sal_Int32 , const ::com::sun::star::uno::Sequence< OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     264             : {
     265           0 :     uno::Sequence<beans::PropertyValue> aValues(0);
     266           0 :     return aValues;
     267             : }
     268           0 : ::com::sun::star::awt::Rectangle SAL_CALL SwAccessibleNoTextFrame::getCharacterBounds( sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception)
     269             : {
     270           0 :     return com::sun::star::awt::Rectangle(0, 0, 0, 0 );
     271             : }
     272           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getCharacterCount(  ) throw (::com::sun::star::uno::RuntimeException, std::exception){return 0;}
     273           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getIndexAtPoint( const ::com::sun::star::awt::Point& ) throw (::com::sun::star::uno::RuntimeException, std::exception){return 0;}
     274           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getSelectedText(  ) throw (::com::sun::star::uno::RuntimeException, std::exception){return OUString();}
     275           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getSelectionStart(  ) throw (::com::sun::star::uno::RuntimeException, std::exception){return 0;}
     276           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getSelectionEnd(  ) throw (::com::sun::star::uno::RuntimeException, std::exception){return 0;}
     277           0 : sal_Bool SAL_CALL SwAccessibleNoTextFrame::setSelection( sal_Int32 , sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception){return sal_True;}
     278           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getText(  ) throw (::com::sun::star::uno::RuntimeException, std::exception){return OUString();}
     279           0 : OUString SAL_CALL SwAccessibleNoTextFrame::getTextRange( sal_Int32 , sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception){return OUString();}
     280           0 : ::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextAtIndex( sal_Int32 , sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     281             : {
     282           0 :     ::com::sun::star::accessibility::TextSegment aResult;
     283           0 :     return aResult;
     284             : }
     285           0 : ::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextBeforeIndex( sal_Int32, sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     286             : {
     287           0 :     ::com::sun::star::accessibility::TextSegment aResult;
     288           0 :     return aResult;
     289             : }
     290           0 : ::com::sun::star::accessibility::TextSegment SAL_CALL SwAccessibleNoTextFrame::getTextBehindIndex( sal_Int32 , sal_Int16 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception)
     291             : {
     292           0 :     ::com::sun::star::accessibility::TextSegment aResult;
     293           0 :     return aResult;
     294             : }
     295             : 
     296           0 : sal_Bool SAL_CALL SwAccessibleNoTextFrame::copyText( sal_Int32, sal_Int32 ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException, std::exception){return sal_True;}
     297             : 
     298             : //  XAccessibleHyperText
     299             : 
     300           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getHyperLinkCount()
     301             : throw (uno::RuntimeException, std::exception)
     302             : {
     303           0 :     SolarMutexGuard aGuard;
     304             : 
     305           0 :     CHECK_FOR_DEFUNC( XAccessibleHypertext );
     306             : 
     307           0 :     sal_Int32 nCount = 0;
     308           0 :     SwFmtURL aURL( ((SwLayoutFrm*)GetFrm())->GetFmt()->GetURL() );
     309             : 
     310           0 :     if(aURL.GetMap() || !aURL.GetURL().isEmpty())
     311           0 :         nCount = 1;
     312             : 
     313           0 :     return nCount;
     314             : }
     315             : 
     316             : uno::Reference< XAccessibleHyperlink > SAL_CALL
     317           0 :     SwAccessibleNoTextFrame::getHyperLink( sal_Int32 nLinkIndex )
     318             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     319             : {
     320           0 :     SolarMutexGuard aGuard;
     321           0 :     CHECK_FOR_DEFUNC( XAccessibleHypertext );
     322             : 
     323           0 :     uno::Reference< XAccessibleHyperlink > xRet;
     324             : 
     325           0 :     SwFmtURL aURL( ((SwLayoutFrm*)GetFrm())->GetFmt()->GetURL() );
     326             : 
     327           0 :     if( nLinkIndex > 0 )
     328           0 :         throw lang::IndexOutOfBoundsException();
     329             : 
     330           0 :     if( aURL.GetMap() || !aURL.GetURL().isEmpty() )
     331             :     {
     332           0 :         if ( !alink.is() )
     333             :         {
     334           0 :             alink = new SwAccessibleNoTextHyperlink( this, GetFrm() );
     335             :         }
     336             : 
     337           0 :         return alink;
     338             :     }
     339             : 
     340           0 :     return NULL;
     341             : }
     342             : 
     343           0 : sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getHyperLinkIndex( sal_Int32 )
     344             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     345             : {
     346           0 :     SolarMutexGuard aGuard;
     347             : 
     348           0 :     return 0;
     349             : }
     350             : 
     351           0 : uno::Reference<XAccessibleRelationSet> SAL_CALL SwAccessibleNoTextFrame::getAccessibleRelationSet( )
     352             :     throw ( uno::RuntimeException, std::exception )
     353             : {
     354           0 :     SolarMutexGuard aGuard;
     355             : 
     356           0 :     return new AccessibleRelationSetHelper();
     357             : }
     358             : 
     359             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10