LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/access - acchyperlink.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 66 0.0 %
Date: 2012-12-17 Functions: 0 12 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 <comphelper/accessiblekeybindinghelper.hxx>
      21             : #include <swurl.hxx>
      22             : #include <osl/mutex.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <ndtxt.hxx>
      25             : #include <txtinet.hxx>
      26             : #include <accpara.hxx>
      27             : #include <acchyperlink.hxx>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : using namespace ::com::sun::star::accessibility;
      31             : using ::rtl::OUString;
      32             : 
      33           0 : SwAccessibleHyperlink::SwAccessibleHyperlink( sal_uInt16 nHPos,
      34             :     SwAccessibleParagraph *p, sal_Int32 nStt, sal_Int32 nEnd ) :
      35             :     nHintPos( nHPos ),
      36             :     xPara( p ),
      37             :     nStartIdx( nStt ),
      38           0 :     nEndIdx( nEnd )
      39             : {
      40           0 : }
      41             : 
      42           0 : const SwTxtAttr *SwAccessibleHyperlink::GetTxtAttr() const
      43             : {
      44           0 :     const SwTxtAttr *pTxtAttr = 0;
      45           0 :     if( xPara.is() && xPara->GetMap() )
      46             :     {
      47           0 :         const SwTxtNode *pTxtNd = xPara->GetTxtNode();
      48           0 :         const SwpHints *pHints = pTxtNd->GetpSwpHints();
      49           0 :         if( pHints && nHintPos < pHints->Count() )
      50             :         {
      51           0 :             const SwTxtAttr *pHt = (*pHints)[nHintPos];
      52           0 :             if( RES_TXTATR_INETFMT == pHt->Which() )
      53           0 :                 pTxtAttr = pHt;
      54             :         }
      55             :     }
      56             : 
      57           0 :     return pTxtAttr;
      58             : }
      59             : 
      60             : 
      61             : // XAccessibleAction
      62           0 : sal_Int32 SAL_CALL SwAccessibleHyperlink::getAccessibleActionCount()
      63             :         throw (uno::RuntimeException)
      64             : {
      65           0 :      return isValid() ? 1 : 0;
      66             : }
      67             : 
      68           0 : sal_Bool SAL_CALL SwAccessibleHyperlink::doAccessibleAction( sal_Int32 nIndex )
      69             :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
      70             : {
      71           0 :     SolarMutexGuard aGuard;
      72             : 
      73           0 :     sal_Bool bRet = sal_False;
      74             : 
      75           0 :     const SwTxtAttr *pTxtAttr = GetTxtAttr();
      76           0 :     if( pTxtAttr && 0 == nIndex )
      77             :     {
      78           0 :         const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt();
      79           0 :         if( rINetFmt.GetValue().Len() )
      80             :         {
      81           0 :             ViewShell *pVSh = xPara->GetShell();
      82           0 :             if( pVSh )
      83             :             {
      84           0 :                 LoadURL(*pVSh, rINetFmt.GetValue(), URLLOAD_NOFILTER,
      85           0 :                          rINetFmt.GetTargetFrame());
      86             :                 OSL_ENSURE( pTxtAttr == rINetFmt.GetTxtINetFmt(),
      87             :                          "lost my txt attr" );
      88           0 :                 const SwTxtINetFmt* pTxtAttr2 = rINetFmt.GetTxtINetFmt();
      89           0 :                 if( pTxtAttr2 )
      90             :                 {
      91           0 :                     const_cast<SwTxtINetFmt*>(pTxtAttr2)->SetVisited(true);
      92           0 :                     const_cast<SwTxtINetFmt*>(pTxtAttr2)->SetVisitedValid(true);
      93             :                 }
      94           0 :                 bRet = sal_True;
      95             :             }
      96             :         }
      97             :     }
      98             : 
      99           0 :     return bRet;
     100             : }
     101             : 
     102           0 : OUString SAL_CALL SwAccessibleHyperlink::getAccessibleActionDescription(
     103             :         sal_Int32 nIndex )
     104             :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     105             : {
     106           0 :     OUString sDesc;
     107             : 
     108           0 :     const SwTxtAttr *pTxtAttr = GetTxtAttr();
     109           0 :     if( pTxtAttr && 0 == nIndex )
     110             :     {
     111           0 :         const SwFmtINetFmt& rINetFmt = pTxtAttr->GetINetFmt();
     112           0 :         sDesc = OUString( rINetFmt.GetValue() );
     113             :     }
     114             : 
     115           0 :     return sDesc;
     116             : }
     117             : 
     118             : uno::Reference< XAccessibleKeyBinding > SAL_CALL
     119           0 :     SwAccessibleHyperlink::getAccessibleActionKeyBinding( sal_Int32 nIndex )
     120             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     121             : {
     122           0 :     uno::Reference< XAccessibleKeyBinding > xKeyBinding;
     123             : 
     124           0 :     if( isValid() && 0==nIndex )
     125             :     {
     126             :         ::comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper =
     127           0 :                new ::comphelper::OAccessibleKeyBindingHelper();
     128           0 :         xKeyBinding = pKeyBindingHelper;
     129             : 
     130           0 :         awt::KeyStroke aKeyStroke;
     131           0 :         aKeyStroke.Modifiers = 0;
     132           0 :         aKeyStroke.KeyCode = KEY_RETURN;
     133           0 :         aKeyStroke.KeyChar = 0;
     134           0 :         aKeyStroke.KeyFunc = 0;
     135           0 :         pKeyBindingHelper->AddKeyBinding( aKeyStroke );
     136             :     }
     137             : 
     138           0 :     return xKeyBinding;
     139             : }
     140             : 
     141             : // XAccessibleHyperlink
     142           0 : uno::Any SAL_CALL SwAccessibleHyperlink::getAccessibleActionAnchor(
     143             :         sal_Int32 /*nIndex*/ )
     144             :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     145             : {
     146           0 :     return uno::Any();
     147             : }
     148             : 
     149           0 : uno::Any SAL_CALL SwAccessibleHyperlink::getAccessibleActionObject(
     150             :             sal_Int32 /*nIndex*/ )
     151             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     152             : {
     153           0 :     return uno::Any();
     154             : }
     155             : 
     156           0 : sal_Int32 SAL_CALL SwAccessibleHyperlink::getStartIndex()
     157             :         throw (uno::RuntimeException)
     158             : {
     159           0 :     return nStartIdx;
     160             : }
     161             : 
     162           0 : sal_Int32 SAL_CALL SwAccessibleHyperlink::getEndIndex()
     163             :         throw (uno::RuntimeException)
     164             : {
     165           0 :     return nEndIdx;
     166             : }
     167             : 
     168           0 : sal_Bool SAL_CALL SwAccessibleHyperlink::isValid(  )
     169             :         throw (uno::RuntimeException)
     170             : {
     171           0 :     SolarMutexGuard aGuard;
     172           0 :     return xPara.is();
     173             : }
     174             : 
     175           0 : void SwAccessibleHyperlink::Invalidate()
     176             : {
     177           0 :     SolarMutexGuard aGuard;
     178           0 :     xPara = 0;
     179           0 : }
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10