LCOV - code coverage report
Current view: top level - sw/source/core/access - accnotexthyperlink.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 108 0.9 %
Date: 2014-11-03 Functions: 2 12 16.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             : #include <comphelper/accessiblekeybindinghelper.hxx>
      20             : #include <swurl.hxx>
      21             : #include <vcl/svapp.hxx>
      22             : #include <ndtxt.hxx>
      23             : #include <txtinet.hxx>
      24             : #include <frmfmt.hxx>
      25             : 
      26             : #include <accnotexthyperlink.hxx>
      27             : 
      28             : #include <fmturl.hxx>
      29             : 
      30             : #include <svtools/imap.hxx>
      31             : #include <svtools/imapobj.hxx>
      32             : 
      33             : #include <accmap.hxx>
      34             : 
      35             : using namespace css;
      36             : using namespace css::lang;
      37             : using namespace css::uno;
      38             : using namespace css::accessibility;
      39             : 
      40           0 : SwAccessibleNoTextHyperlink::SwAccessibleNoTextHyperlink( SwAccessibleNoTextFrame *p, const SwFrm *aFrm, sal_uInt16 nIndex) :
      41             :     xFrame( p ),
      42             :     mpFrm( aFrm ),
      43           0 :     mnIndex(nIndex)
      44             : {
      45           0 : }
      46             : 
      47             : // XAccessibleAction
      48           0 : sal_Int32 SAL_CALL SwAccessibleNoTextHyperlink::getAccessibleActionCount()
      49             :         throw (RuntimeException, std::exception)
      50             : {
      51           0 :     SolarMutexGuard g;
      52             : 
      53           0 :     SwFmtURL aURL( GetFmt()->GetURL() );
      54           0 :     ImageMap* pMap = aURL.GetMap();
      55           0 :     if( pMap != NULL )
      56             :     {
      57           0 :         return pMap->GetIMapObjectCount();
      58             :     }
      59           0 :     else if( !aURL.GetURL().isEmpty() )
      60             :     {
      61           0 :         return 1;
      62             :     }
      63             : 
      64           0 :     return 0;
      65             : }
      66             : 
      67           0 : sal_Bool SAL_CALL SwAccessibleNoTextHyperlink::doAccessibleAction( sal_Int32 nIndex )
      68             :         throw (IndexOutOfBoundsException, RuntimeException, std::exception)
      69             : {
      70           0 :     SolarMutexGuard aGuard;
      71             : 
      72           0 :     if(nIndex < 0 || nIndex >= getAccessibleActionCount())
      73           0 :         throw lang::IndexOutOfBoundsException();
      74             : 
      75           0 :     bool bRet = false;
      76           0 :     SwFmtURL aURL( GetFmt()->GetURL() );
      77           0 :     ImageMap* pMap = aURL.GetMap();
      78           0 :     if( pMap != NULL )
      79             :     {
      80           0 :         IMapObject* pMapObj = pMap->GetIMapObject(nIndex);
      81           0 :         if (!pMapObj->GetURL().isEmpty())
      82             :         {
      83           0 :             SwViewShell *pVSh = xFrame->GetShell();
      84           0 :             if( pVSh )
      85             :             {
      86           0 :                 LoadURL( *pVSh, pMapObj->GetURL(), URLLOAD_NOFILTER,
      87           0 :                          pMapObj->GetTarget() );
      88           0 :                 bRet = true;
      89             :             }
      90             :         }
      91             :     }
      92           0 :     else if (!aURL.GetURL().isEmpty())
      93             :     {
      94           0 :         SwViewShell *pVSh = xFrame->GetShell();
      95           0 :         if( pVSh )
      96             :         {
      97             :             LoadURL( *pVSh, aURL.GetURL(), URLLOAD_NOFILTER,
      98           0 :                      aURL.GetTargetFrameName() );
      99           0 :             bRet = true;
     100             :         }
     101             :     }
     102             : 
     103           0 :     return bRet;
     104             : }
     105             : 
     106           0 : OUString SAL_CALL SwAccessibleNoTextHyperlink::getAccessibleActionDescription(
     107             :         sal_Int32 nIndex )
     108             :         throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     109             : {
     110           0 :     SolarMutexGuard g;
     111             : 
     112           0 :     OUString sDesc;
     113             : 
     114           0 :     if(nIndex < 0 || nIndex >= getAccessibleActionCount())
     115           0 :         throw lang::IndexOutOfBoundsException();
     116             : 
     117           0 :     SwFmtURL aURL( GetFmt()->GetURL() );
     118           0 :     ImageMap* pMap = aURL.GetMap();
     119           0 :     if( pMap != NULL )
     120             :     {
     121           0 :         IMapObject* pMapObj = pMap->GetIMapObject(nIndex);
     122           0 :         if (!pMapObj->GetDesc().isEmpty())
     123           0 :             sDesc = pMapObj->GetDesc();
     124           0 :         else if (!pMapObj->GetURL().isEmpty())
     125           0 :             sDesc = pMapObj->GetURL();
     126             :     }
     127           0 :     else if( !aURL.GetURL().isEmpty() )
     128           0 :         sDesc = aURL.GetName();
     129             : 
     130           0 :     return sDesc;
     131             : }
     132             : 
     133             : Reference< XAccessibleKeyBinding > SAL_CALL
     134           0 :     SwAccessibleNoTextHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex )
     135             :     throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     136             : {
     137           0 :     SolarMutexGuard g;
     138             : 
     139           0 :     Reference< XAccessibleKeyBinding > xKeyBinding;
     140             : 
     141           0 :     if(nIndex < 0 || nIndex >= getAccessibleActionCount())
     142           0 :         throw lang::IndexOutOfBoundsException();
     143             : 
     144           0 :     bool bIsValid = false;
     145           0 :     SwFmtURL aURL( GetFmt()->GetURL() );
     146           0 :     ImageMap* pMap = aURL.GetMap();
     147           0 :     if( pMap != NULL )
     148             :     {
     149           0 :         IMapObject* pMapObj = pMap->GetIMapObject(nIndex);
     150           0 :         if (!pMapObj->GetURL().isEmpty())
     151           0 :             bIsValid = true;
     152             :     }
     153           0 :     else if (!aURL.GetURL().isEmpty())
     154           0 :         bIsValid = true;
     155             : 
     156           0 :     if(bIsValid)
     157             :     {
     158             :         ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper =
     159           0 :             new ::comphelper::OAccessibleKeyBindingHelper();
     160           0 :         xKeyBinding = pKeyBindingHelper;
     161             : 
     162           0 :         ::com::sun::star::awt::KeyStroke aKeyStroke;
     163           0 :         aKeyStroke.Modifiers = 0;
     164           0 :         aKeyStroke.KeyCode = KEY_RETURN;
     165           0 :         aKeyStroke.KeyChar = 0;
     166           0 :         aKeyStroke.KeyFunc = 0;
     167           0 :         pKeyBindingHelper->AddKeyBinding( aKeyStroke );
     168             :     }
     169             : 
     170           0 :     return xKeyBinding;
     171             : }
     172             : 
     173             : // XAccessibleHyperlink
     174           0 : Any SAL_CALL SwAccessibleNoTextHyperlink::getAccessibleActionAnchor(
     175             :         sal_Int32 nIndex )
     176             :         throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     177             : {
     178           0 :     SolarMutexGuard g;
     179             : 
     180           0 :     if(nIndex < 0 || nIndex >= getAccessibleActionCount())
     181           0 :         throw lang::IndexOutOfBoundsException();
     182             : 
     183           0 :     Any aRet;
     184             :     //SwFrm* pAnchor = ((SwFlyFrm*)mpFrm)->GetAnchor();
     185           0 :     Reference< XAccessible > xAnchor = xFrame->GetAccessibleMap()->GetContext(mpFrm, true);
     186             :     //SwAccessibleNoTextFrame* pFrame = xFrame.get();
     187             :     //Reference< XAccessible > xAnchor = (XAccessible*)pFrame;
     188           0 :     aRet <<= xAnchor;
     189           0 :     return aRet;
     190             : }
     191             : 
     192           0 : Any SAL_CALL SwAccessibleNoTextHyperlink::getAccessibleActionObject(
     193             :             sal_Int32 nIndex )
     194             :     throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     195             : {
     196           0 :     SolarMutexGuard g;
     197             : 
     198           0 :     if(nIndex < 0 || nIndex >= getAccessibleActionCount())
     199           0 :         throw lang::IndexOutOfBoundsException();
     200             : 
     201           0 :     SwFmtURL aURL( GetFmt()->GetURL() );
     202           0 :     OUString retText;
     203           0 :     ImageMap* pMap = aURL.GetMap();
     204           0 :     if( pMap != NULL )
     205             :     {
     206           0 :         IMapObject* pMapObj = pMap->GetIMapObject(nIndex);
     207           0 :         if (!pMapObj->GetURL().isEmpty())
     208           0 :             retText = pMapObj->GetURL();
     209             :     }
     210           0 :     else if ( !aURL.GetURL().isEmpty() )
     211           0 :         retText = aURL.GetURL();
     212             : 
     213           0 :     Any aRet;
     214           0 :     aRet <<= retText;
     215           0 :     return aRet;
     216             : }
     217             : 
     218           0 : sal_Int32 SAL_CALL SwAccessibleNoTextHyperlink::getStartIndex()
     219             :         throw (RuntimeException, std::exception)
     220             : {
     221           0 :     return 0;
     222             : }
     223             : 
     224           0 : sal_Int32 SAL_CALL SwAccessibleNoTextHyperlink::getEndIndex()
     225             :         throw (RuntimeException, std::exception)
     226             : {
     227           0 :     return 0;
     228             : }
     229             : 
     230           0 : sal_Bool SAL_CALL SwAccessibleNoTextHyperlink::isValid(  )
     231             :         throw (::com::sun::star::uno::RuntimeException, std::exception)
     232             : {
     233           0 :     SolarMutexGuard g;
     234             : 
     235           0 :     SwFmtURL aURL( GetFmt()->GetURL() );
     236             : 
     237           0 :     if( aURL.GetMap() || !aURL.GetURL().isEmpty() )
     238           0 :         return sal_True;
     239           0 :     return sal_False;
     240         270 : }
     241             : 
     242             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10