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

Generated by: LCOV version 1.10