LCOV - code coverage report
Current view: top level - comphelper/source/misc - accimplaccess.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 10 44 22.7 %
Date: 2014-11-03 Functions: 5 13 38.5 %
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/accimplaccess.hxx>
      21             : #include <com/sun/star/accessibility/XAccessible.hpp>
      22             : #include <com/sun/star/accessibility/XAccessibleContext.hpp>
      23             : #include <cppuhelper/typeprovider.hxx>
      24             : 
      25             : #include <set>
      26             : #include <string.h>
      27             : 
      28             : 
      29             : namespace comphelper
      30             : {
      31             : 
      32             : 
      33             :     using ::com::sun::star::uno::Reference;
      34             :     using ::com::sun::star::uno::Sequence;
      35             :     using ::com::sun::star::uno::Exception;
      36             :     using ::com::sun::star::uno::UNO_QUERY;
      37             :     using ::com::sun::star::uno::RuntimeException;
      38             :     using ::com::sun::star::lang::XUnoTunnel;
      39             :     using ::com::sun::star::accessibility::XAccessible;
      40             :     using ::com::sun::star::accessibility::XAccessibleContext;
      41             : 
      42             : 
      43             :     //= OAccImpl_Impl
      44             : 
      45        1378 :     struct OAccImpl_Impl
      46             :     {
      47             :         Reference< XAccessible >    m_xAccParent;
      48             :         sal_Int64                   m_nForeignControlledStates;
      49             :     };
      50             : 
      51             : 
      52             : 
      53             :     //= OAccessibleImplementationAccess
      54             : 
      55             : 
      56         718 :     OAccessibleImplementationAccess::OAccessibleImplementationAccess( )
      57         718 :         :m_pImpl( new OAccImpl_Impl )
      58             :     {
      59         718 :     }
      60             : 
      61             : 
      62        1320 :     OAccessibleImplementationAccess::~OAccessibleImplementationAccess( )
      63             :     {
      64         660 :         delete m_pImpl;
      65         660 :         m_pImpl = NULL;
      66         660 :     }
      67             : 
      68             : 
      69       14376 :     Reference< XAccessible > OAccessibleImplementationAccess::implGetForeignControlledParent( ) const
      70             :     {
      71       14376 :         return m_pImpl->m_xAccParent;
      72             :     }
      73             : 
      74             : 
      75           0 :     void OAccessibleImplementationAccess::setAccessibleParent( const Reference< XAccessible >& _rxAccParent )
      76             :     {
      77           0 :         m_pImpl->m_xAccParent = _rxAccParent;
      78           0 :     }
      79             : 
      80             : 
      81           0 :     sal_Int64 OAccessibleImplementationAccess::implGetForeignControlledStates( ) const
      82             :     {
      83           0 :         return m_pImpl->m_nForeignControlledStates;
      84             :     }
      85             : 
      86             : 
      87           0 :     void OAccessibleImplementationAccess::setStateBit( const sal_Int16 _nState, const bool _bSet )
      88             :     {
      89             :         OSL_ENSURE( _nState >= 0 && static_cast< sal_uInt16 >(_nState) < sizeof( sal_Int64 ) * 8, "OAccessibleImplementationAccess::setStateBit: no more bits (shutting down the universe now)!" );
      90             : 
      91           0 :         sal_uInt64 nBitMask( 1 );
      92           0 :         nBitMask <<= _nState;
      93           0 :         if ( _bSet )
      94           0 :             m_pImpl->m_nForeignControlledStates |= nBitMask;
      95             :         else
      96           0 :             m_pImpl->m_nForeignControlledStates &= ~nBitMask;
      97           0 :     }
      98             : 
      99             :     namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; }
     100             : 
     101             : 
     102           0 :     const Sequence< sal_Int8 > OAccessibleImplementationAccess::getUnoTunnelImplementationId()
     103             :     {
     104           0 :         ::cppu::OImplementationId &rID = lcl_ImplId::get();
     105           0 :         return rID.getImplementationId();
     106             :     }
     107             : 
     108             : 
     109           0 :     sal_Int64 SAL_CALL OAccessibleImplementationAccess::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw (RuntimeException, std::exception)
     110             :     {
     111           0 :         sal_Int64 nReturn( 0 );
     112             : 
     113           0 :         if  (   ( _rIdentifier.getLength() == 16 )
     114           0 :             &&  ( 0 == memcmp( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
     115             :             )
     116           0 :             nReturn = reinterpret_cast< sal_Int64 >( this );
     117             : 
     118           0 :         return nReturn;
     119             :     }
     120             : 
     121             : 
     122           0 :     OAccessibleImplementationAccess* OAccessibleImplementationAccess::getImplementation( const Reference< XAccessibleContext >& _rxComponent )
     123             :     {
     124           0 :         OAccessibleImplementationAccess* pImplementation = NULL;
     125             :         try
     126             :         {
     127           0 :             Reference< XUnoTunnel > xTunnel( _rxComponent, UNO_QUERY );
     128           0 :             if ( xTunnel.is() )
     129             :             {
     130             :                 pImplementation = reinterpret_cast< OAccessibleImplementationAccess* >(
     131           0 :                         xTunnel->getSomething( getUnoTunnelImplementationId() ) );
     132           0 :             }
     133             :         }
     134           0 :         catch( const Exception& )
     135             :         {
     136             :             OSL_FAIL( "OAccessibleImplementationAccess::setAccessibleParent: caught an exception while retrieving the implementation!" );
     137             :         }
     138           0 :         return pImplementation;
     139             :     }
     140             : 
     141             : 
     142           0 :     bool OAccessibleImplementationAccess::setAccessibleParent(
     143             :             const Reference< XAccessibleContext >& _rxComponent, const Reference< XAccessible >& _rxNewParent )
     144             :     {
     145           0 :         OAccessibleImplementationAccess* pImplementation = getImplementation( _rxComponent );
     146             : 
     147           0 :         if ( pImplementation )
     148           0 :             pImplementation->setAccessibleParent( _rxNewParent );
     149             : 
     150           0 :         return ( NULL != pImplementation );
     151             :     }
     152             : 
     153             : 
     154             : }   // namespace comphelper
     155             : 
     156             : 
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10