LCOV - code coverage report
Current view: top level - sw/source/core/access - accpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 60 0.0 %
Date: 2012-08-25 Functions: 0 13 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 86 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            :  /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <vcl/window.hxx>
      30                 :            : #include <vcl/svapp.hxx>
      31                 :            : #include <unotools/accessiblestatesethelper.hxx>
      32                 :            : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      33                 :            : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      34                 :            : #include <comphelper/servicehelper.hxx>
      35                 :            : #include "accpage.hxx"
      36                 :            : 
      37                 :            : #include "access.hrc"
      38                 :            : #include <pagefrm.hxx>
      39                 :            : 
      40                 :            : using namespace ::com::sun::star;
      41                 :            : using namespace ::com::sun::star::accessibility;
      42                 :            : 
      43                 :            : using uno::Reference;
      44                 :            : using uno::RuntimeException;
      45                 :            : using uno::Sequence;
      46                 :            : using ::rtl::OUString;
      47                 :            : 
      48                 :            : 
      49                 :            : const sal_Char sServiceName[] = "com.sun.star.text.AccessiblePageView";
      50                 :            : const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessiblePageView";
      51                 :            : 
      52                 :          0 : sal_Bool SwAccessiblePage::IsSelected()
      53                 :            : {
      54                 :          0 :     return GetMap()->IsPageSelected( static_cast < const SwPageFrm * >( GetFrm() ) );
      55                 :            : }
      56                 :            : 
      57                 :          0 : void SwAccessiblePage::GetStates(
      58                 :            :         ::utl::AccessibleStateSetHelper& rStateSet )
      59                 :            : {
      60                 :          0 :     SwAccessibleContext::GetStates( rStateSet );
      61                 :            : 
      62                 :            :     // FOCUSABLE
      63                 :          0 :     rStateSet.AddState( AccessibleStateType::FOCUSABLE );
      64                 :            : 
      65                 :            :     // FOCUSED
      66         [ #  # ]:          0 :     if( IsSelected() )
      67                 :            :     {
      68                 :            :         OSL_ENSURE( bIsSelected, "bSelected out of sync" );
      69                 :          0 :         ::rtl::Reference < SwAccessibleContext > xThis( this );
      70         [ #  # ]:          0 :         GetMap()->SetCursorContext( xThis );
      71                 :            : 
      72         [ #  # ]:          0 :         Window *pWin = GetWindow();
      73 [ #  # ][ #  # ]:          0 :         if( pWin && pWin->HasFocus() )
         [ #  # ][ #  # ]
      74         [ #  # ]:          0 :             rStateSet.AddState( AccessibleStateType::FOCUSED );
      75                 :            :     }
      76                 :          0 : }
      77                 :            : 
      78                 :          0 : void SwAccessiblePage::_InvalidateCursorPos()
      79                 :            : {
      80                 :          0 :     sal_Bool bNewSelected = IsSelected();
      81                 :            :     sal_Bool bOldSelected;
      82                 :            : 
      83                 :            :     {
      84         [ #  # ]:          0 :         osl::MutexGuard aGuard( aMutex );
      85                 :          0 :         bOldSelected = bIsSelected;
      86         [ #  # ]:          0 :         bIsSelected = bNewSelected;
      87                 :            :     }
      88                 :            : 
      89         [ #  # ]:          0 :     if( bNewSelected )
      90                 :            :     {
      91                 :            :         // remember that object as the one that has the caret. This is
      92                 :            :         // neccessary to notify that object if the cursor leaves it.
      93                 :          0 :         ::rtl::Reference < SwAccessibleContext > xThis( this );
      94         [ #  # ]:          0 :         GetMap()->SetCursorContext( xThis );
      95                 :            :     }
      96                 :            : 
      97         [ #  # ]:          0 :     if( bOldSelected != bNewSelected )
      98                 :            :     {
      99                 :          0 :         Window *pWin = GetWindow();
     100 [ #  # ][ #  # ]:          0 :         if( pWin && pWin->HasFocus() )
                 [ #  # ]
     101                 :          0 :             FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected );
     102                 :            :     }
     103                 :          0 : }
     104                 :            : 
     105                 :          0 : void SwAccessiblePage::_InvalidateFocus()
     106                 :            : {
     107                 :          0 :     Window *pWin = GetWindow();
     108         [ #  # ]:          0 :     if( pWin )
     109                 :            :     {
     110                 :            :         sal_Bool bSelected;
     111                 :            : 
     112                 :            :         {
     113         [ #  # ]:          0 :             osl::MutexGuard aGuard( aMutex );
     114         [ #  # ]:          0 :             bSelected = bIsSelected;
     115                 :            :         }
     116                 :            :         OSL_ENSURE( bSelected, "focus object should be selected" );
     117                 :            : 
     118                 :            :         FireStateChangedEvent( AccessibleStateType::FOCUSED,
     119 [ #  # ][ #  # ]:          0 :                                pWin->HasFocus() && bSelected );
     120                 :            :     }
     121                 :          0 : }
     122                 :            : 
     123                 :          0 : SwAccessiblePage::SwAccessiblePage( SwAccessibleMap* pInitMap,
     124                 :            :                                     const SwFrm* pFrame )
     125                 :            :     : SwAccessibleContext( pInitMap, AccessibleRole::PANEL, pFrame )
     126                 :          0 :     , bIsSelected( sal_False )
     127                 :            : {
     128                 :            :     OSL_ENSURE( pFrame != NULL, "need frame" );
     129                 :            :     OSL_ENSURE( pInitMap != NULL, "need map" );
     130                 :            :     OSL_ENSURE( pFrame->IsPageFrm(), "need page frame" );
     131                 :            : 
     132         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     133                 :            : 
     134                 :            :     OUString sPage = OUString::valueOf(
     135                 :            :         static_cast<sal_Int32>(
     136                 :          0 :             static_cast<const SwPageFrm*>( GetFrm() )->GetPhyPageNum() ) );
     137 [ #  # ][ #  # ]:          0 :     SetName( GetResource( STR_ACCESS_PAGE_NAME, &sPage ) );
     138                 :          0 : }
     139                 :            : 
     140                 :          0 : SwAccessiblePage::~SwAccessiblePage()
     141                 :            : {
     142         [ #  # ]:          0 : }
     143                 :            : 
     144                 :          0 : sal_Bool SwAccessiblePage::HasCursor()
     145                 :            : {
     146         [ #  # ]:          0 :     osl::MutexGuard aGuard( aMutex );
     147         [ #  # ]:          0 :     return bIsSelected;
     148                 :            : }
     149                 :            : 
     150                 :          0 : OUString SwAccessiblePage::getImplementationName( )
     151                 :            :     throw( RuntimeException )
     152                 :            : {
     153                 :          0 :     return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName));
     154                 :            : }
     155                 :            : 
     156                 :          0 : sal_Bool SwAccessiblePage::supportsService( const OUString& rServiceName)
     157                 :            :     throw( RuntimeException )
     158                 :            : {
     159                 :          0 :     return rServiceName.equalsAsciiL( sServiceName, sizeof(sServiceName)-1 ) ||
     160                 :            :            rServiceName.equalsAsciiL( sAccessibleServiceName,
     161 [ #  # ][ #  # ]:          0 :                                    sizeof(sAccessibleServiceName)-1 );
     162                 :            : }
     163                 :            : 
     164                 :          0 : Sequence<OUString> SwAccessiblePage::getSupportedServiceNames( )
     165                 :            :     throw( RuntimeException )
     166                 :            : {
     167                 :          0 :     Sequence< OUString > aRet(2);
     168         [ #  # ]:          0 :     OUString* pArray = aRet.getArray();
     169         [ #  # ]:          0 :     pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) );
     170         [ #  # ]:          0 :     pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
     171                 :          0 :     return aRet;
     172                 :            : }
     173                 :            : 
     174                 :            : namespace
     175                 :            : {
     176                 :            :     class theSwAccessiblePageImplementationId : public rtl::Static< UnoTunnelIdInit, theSwAccessiblePageImplementationId > {};
     177                 :            : }
     178                 :            : 
     179                 :          0 : Sequence< sal_Int8 > SAL_CALL SwAccessiblePage::getImplementationId()
     180                 :            :         throw(RuntimeException)
     181                 :            : {
     182                 :          0 :     return theSwAccessiblePageImplementationId::get().getSeq();
     183                 :            : }
     184                 :            : 
     185                 :          0 : OUString SwAccessiblePage::getAccessibleDescription( )
     186                 :            :     throw( RuntimeException )
     187                 :            : {
     188 [ #  # ][ #  # ]:          0 :     CHECK_FOR_DEFUNC( ::com::sun::star::accessibility::XAccessibleContext );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     189                 :            : 
     190 [ #  # ][ #  # ]:          0 :     OUString sArg( GetFormattedPageNumber() );
                 [ #  # ]
     191         [ #  # ]:          0 :     return GetResource( STR_ACCESS_PAGE_DESC, &sArg );
     192                 :            : }
     193                 :            : 
     194                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10