LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/core/access - accfootnote.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 45 60.0 %
Date: 2013-07-09 Functions: 8 11 72.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             : 
      20             : #include <osl/mutex.hxx>
      21             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      22             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      23             : #include <unotools/accessiblestatesethelper.hxx>
      24             : #include <comphelper/servicehelper.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <ftnfrm.hxx>
      27             : #include <fmtftn.hxx>
      28             : #include <txtftn.hxx>
      29             : #include <viewsh.hxx>
      30             : #include <accmap.hxx>
      31             : #include "accfootnote.hxx"
      32             : #include "access.hrc"
      33             : 
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::uno;
      36             : using namespace ::com::sun::star::lang;
      37             : using namespace ::com::sun::star::accessibility;
      38             : 
      39             : const sal_Char sServiceNameFootnote[] = "com.sun.star.text.AccessibleFootnoteView";
      40             : const sal_Char sServiceNameEndnote[] = "com.sun.star.text.AccessibleEndnoteView";
      41             : const sal_Char sImplementationNameFootnote[] = "com.sun.star.comp.Writer.SwAccessibleFootnoteView";
      42             : const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccessibleEndnoteView";
      43             : 
      44           1 : SwAccessibleFootnote::SwAccessibleFootnote(
      45             :         SwAccessibleMap* pInitMap,
      46             :         sal_Bool bIsEndnote,
      47             :         sal_Int32 nFootEndNote,
      48             :         const SwFtnFrm *pFtnFrm ) :
      49             :     SwAccessibleContext( pInitMap,
      50             :         bIsEndnote ? AccessibleRole::END_NOTE : AccessibleRole::FOOTNOTE,
      51           1 :         pFtnFrm )
      52             : {
      53           1 :     SolarMutexGuard aGuard;
      54             : 
      55             :     sal_uInt16 nResId = bIsEndnote ? STR_ACCESS_ENDNOTE_NAME
      56           1 :                                    : STR_ACCESS_FOOTNOTE_NAME;
      57           2 :     OUString sArg( OUString::valueOf( nFootEndNote ) );
      58           2 :     SetName( GetResource( nResId, &sArg ) );
      59           1 : }
      60             : 
      61           2 : SwAccessibleFootnote::~SwAccessibleFootnote()
      62             : {
      63           2 : }
      64             : 
      65           7 : OUString SAL_CALL SwAccessibleFootnote::getAccessibleDescription (void)
      66             :         throw (uno::RuntimeException)
      67             : {
      68           7 :     SolarMutexGuard aGuard;
      69             : 
      70           7 :     CHECK_FOR_DEFUNC( XAccessibleContext )
      71             : 
      72           7 :     sal_uInt16 nResId = AccessibleRole::END_NOTE == GetRole()
      73             :         ? STR_ACCESS_ENDNOTE_DESC
      74           7 :         : STR_ACCESS_FOOTNOTE_DESC ;
      75             : 
      76          14 :     OUString sArg;
      77             :     const SwTxtFtn *pTxtFtn =
      78           7 :         static_cast< const SwFtnFrm *>( GetFrm() )->GetAttr();
      79           7 :     if( pTxtFtn )
      80             :     {
      81           7 :         const SwDoc *pDoc = GetMap()->GetShell()->GetDoc();
      82           7 :         sArg = pTxtFtn->GetFtn().GetViewNumStr( *pDoc );
      83             :     }
      84             : 
      85          14 :     return GetResource( nResId, &sArg );
      86             : }
      87             : 
      88           1 : OUString SAL_CALL SwAccessibleFootnote::getImplementationName()
      89             :         throw( RuntimeException )
      90             : {
      91           1 :     if( AccessibleRole::END_NOTE == GetRole() )
      92           1 :         return OUString(sImplementationNameEndnote);
      93             :     else
      94           0 :         return OUString(sImplementationNameFootnote);
      95             : }
      96             : 
      97           0 : sal_Bool SAL_CALL SwAccessibleFootnote::supportsService(
      98             :         const OUString& sTestServiceName)
      99             :     throw (uno::RuntimeException)
     100             : {
     101           0 :     if( sTestServiceName.equalsAsciiL( sAccessibleServiceName,
     102           0 :                                        sizeof(sAccessibleServiceName)-1 ) )
     103           0 :         return sal_True;
     104           0 :     else if( AccessibleRole::END_NOTE == GetRole() )
     105           0 :         return sTestServiceName.equalsAsciiL( sServiceNameEndnote, sizeof(sServiceNameEndnote)-1 );
     106             :     else
     107           0 :         return sTestServiceName.equalsAsciiL( sServiceNameFootnote, sizeof(sServiceNameFootnote)-1 );
     108             : 
     109             : }
     110             : 
     111           0 : Sequence< OUString > SAL_CALL SwAccessibleFootnote::getSupportedServiceNames()
     112             :         throw( uno::RuntimeException )
     113             : {
     114           0 :     Sequence< OUString > aRet(2);
     115           0 :     OUString* pArray = aRet.getArray();
     116           0 :     if( AccessibleRole::END_NOTE == GetRole() )
     117           0 :         pArray[0] = OUString( sServiceNameEndnote );
     118             :     else
     119           0 :         pArray[0] = OUString( sServiceNameFootnote );
     120           0 :     pArray[1] = OUString( sAccessibleServiceName );
     121           0 :     return aRet;
     122             : }
     123             : 
     124             : namespace
     125             : {
     126             :     class theSwAccessibleFootnoteImplementationId : public rtl::Static< UnoTunnelIdInit, theSwAccessibleFootnoteImplementationId > {};
     127             : }
     128             : 
     129           0 : Sequence< sal_Int8 > SAL_CALL SwAccessibleFootnote::getImplementationId()
     130             :         throw(RuntimeException)
     131             : {
     132           0 :     return theSwAccessibleFootnoteImplementationId::get().getSeq();
     133             : }
     134             : 
     135           1 : sal_Bool SwAccessibleFootnote::IsEndnote( const SwFtnFrm *pFtnFrm )
     136             : {
     137           1 :     const SwTxtFtn *pTxtFtn = pFtnFrm ->GetAttr();
     138           1 :     return pTxtFtn && pTxtFtn->GetFtn().IsEndNote() ;
     139          99 : }
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10