LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/access - accpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 60 0.0 %
Date: 2012-12-27 Functions: 0 13 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 <vcl/window.hxx>
      21             : #include <vcl/svapp.hxx>
      22             : #include <unotools/accessiblestatesethelper.hxx>
      23             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      24             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      25             : #include <comphelper/servicehelper.hxx>
      26             : #include "accpage.hxx"
      27             : 
      28             : #include "access.hrc"
      29             : #include <pagefrm.hxx>
      30             : 
      31             : using namespace ::com::sun::star;
      32             : using namespace ::com::sun::star::accessibility;
      33             : 
      34             : using uno::Reference;
      35             : using uno::RuntimeException;
      36             : using uno::Sequence;
      37             : using ::rtl::OUString;
      38             : 
      39             : 
      40             : const sal_Char sServiceName[] = "com.sun.star.text.AccessiblePageView";
      41             : const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessiblePageView";
      42             : 
      43           0 : sal_Bool SwAccessiblePage::IsSelected()
      44             : {
      45           0 :     return GetMap()->IsPageSelected( static_cast < const SwPageFrm * >( GetFrm() ) );
      46             : }
      47             : 
      48           0 : void SwAccessiblePage::GetStates(
      49             :         ::utl::AccessibleStateSetHelper& rStateSet )
      50             : {
      51           0 :     SwAccessibleContext::GetStates( rStateSet );
      52             : 
      53             :     // FOCUSABLE
      54           0 :     rStateSet.AddState( AccessibleStateType::FOCUSABLE );
      55             : 
      56             :     // FOCUSED
      57           0 :     if( IsSelected() )
      58             :     {
      59             :         OSL_ENSURE( bIsSelected, "bSelected out of sync" );
      60           0 :         ::rtl::Reference < SwAccessibleContext > xThis( this );
      61           0 :         GetMap()->SetCursorContext( xThis );
      62             : 
      63           0 :         Window *pWin = GetWindow();
      64           0 :         if( pWin && pWin->HasFocus() )
      65           0 :             rStateSet.AddState( AccessibleStateType::FOCUSED );
      66             :     }
      67           0 : }
      68             : 
      69           0 : void SwAccessiblePage::_InvalidateCursorPos()
      70             : {
      71           0 :     sal_Bool bNewSelected = IsSelected();
      72             :     sal_Bool bOldSelected;
      73             : 
      74             :     {
      75           0 :         osl::MutexGuard aGuard( aMutex );
      76           0 :         bOldSelected = bIsSelected;
      77           0 :         bIsSelected = bNewSelected;
      78             :     }
      79             : 
      80           0 :     if( bNewSelected )
      81             :     {
      82             :         // remember that object as the one that has the caret. This is
      83             :         // neccessary to notify that object if the cursor leaves it.
      84           0 :         ::rtl::Reference < SwAccessibleContext > xThis( this );
      85           0 :         GetMap()->SetCursorContext( xThis );
      86             :     }
      87             : 
      88           0 :     if( bOldSelected != bNewSelected )
      89             :     {
      90           0 :         Window *pWin = GetWindow();
      91           0 :         if( pWin && pWin->HasFocus() )
      92           0 :             FireStateChangedEvent( AccessibleStateType::FOCUSED, bNewSelected );
      93             :     }
      94           0 : }
      95             : 
      96           0 : void SwAccessiblePage::_InvalidateFocus()
      97             : {
      98           0 :     Window *pWin = GetWindow();
      99           0 :     if( pWin )
     100             :     {
     101             :         sal_Bool bSelected;
     102             : 
     103             :         {
     104           0 :             osl::MutexGuard aGuard( aMutex );
     105           0 :             bSelected = bIsSelected;
     106             :         }
     107             :         OSL_ENSURE( bSelected, "focus object should be selected" );
     108             : 
     109             :         FireStateChangedEvent( AccessibleStateType::FOCUSED,
     110           0 :                                pWin->HasFocus() && bSelected );
     111             :     }
     112           0 : }
     113             : 
     114           0 : SwAccessiblePage::SwAccessiblePage( SwAccessibleMap* pInitMap,
     115             :                                     const SwFrm* pFrame )
     116             :     : SwAccessibleContext( pInitMap, AccessibleRole::PANEL, pFrame )
     117           0 :     , bIsSelected( sal_False )
     118             : {
     119             :     OSL_ENSURE( pFrame != NULL, "need frame" );
     120             :     OSL_ENSURE( pInitMap != NULL, "need map" );
     121             :     OSL_ENSURE( pFrame->IsPageFrm(), "need page frame" );
     122             : 
     123           0 :     SolarMutexGuard aGuard;
     124             : 
     125             :     OUString sPage = OUString::valueOf(
     126             :         static_cast<sal_Int32>(
     127           0 :             static_cast<const SwPageFrm*>( GetFrm() )->GetPhyPageNum() ) );
     128           0 :     SetName( GetResource( STR_ACCESS_PAGE_NAME, &sPage ) );
     129           0 : }
     130             : 
     131           0 : SwAccessiblePage::~SwAccessiblePage()
     132             : {
     133           0 : }
     134             : 
     135           0 : sal_Bool SwAccessiblePage::HasCursor()
     136             : {
     137           0 :     osl::MutexGuard aGuard( aMutex );
     138           0 :     return bIsSelected;
     139             : }
     140             : 
     141           0 : OUString SwAccessiblePage::getImplementationName( )
     142             :     throw( RuntimeException )
     143             : {
     144           0 :     return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName));
     145             : }
     146             : 
     147           0 : sal_Bool SwAccessiblePage::supportsService( const OUString& rServiceName)
     148             :     throw( RuntimeException )
     149             : {
     150           0 :     return rServiceName.equalsAsciiL( sServiceName, sizeof(sServiceName)-1 ) ||
     151             :            rServiceName.equalsAsciiL( sAccessibleServiceName,
     152           0 :                                    sizeof(sAccessibleServiceName)-1 );
     153             : }
     154             : 
     155           0 : Sequence<OUString> SwAccessiblePage::getSupportedServiceNames( )
     156             :     throw( RuntimeException )
     157             : {
     158           0 :     Sequence< OUString > aRet(2);
     159           0 :     OUString* pArray = aRet.getArray();
     160           0 :     pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) );
     161           0 :     pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
     162           0 :     return aRet;
     163             : }
     164             : 
     165             : namespace
     166             : {
     167             :     class theSwAccessiblePageImplementationId : public rtl::Static< UnoTunnelIdInit, theSwAccessiblePageImplementationId > {};
     168             : }
     169             : 
     170           0 : Sequence< sal_Int8 > SAL_CALL SwAccessiblePage::getImplementationId()
     171             :         throw(RuntimeException)
     172             : {
     173           0 :     return theSwAccessiblePageImplementationId::get().getSeq();
     174             : }
     175             : 
     176           0 : OUString SwAccessiblePage::getAccessibleDescription( )
     177             :     throw( RuntimeException )
     178             : {
     179           0 :     CHECK_FOR_DEFUNC( ::com::sun::star::accessibility::XAccessibleContext );
     180             : 
     181           0 :     OUString sArg( GetFormattedPageNumber() );
     182           0 :     return GetResource( STR_ACCESS_PAGE_DESC, &sArg );
     183             : }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10