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

Generated by: LCOV version 1.10