LCOV - code coverage report
Current view: top level - comphelper/source/misc - accimplaccess.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 10 37 27.0 %
Date: 2015-06-13 12:38:46 Functions: 5 12 41.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 <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             : #include <osl/diagnose.h>
      25             : 
      26             : #include <set>
      27             : #include <string.h>
      28             : 
      29             : 
      30             : namespace comphelper
      31             : {
      32             : 
      33             : 
      34             :     using ::com::sun::star::uno::Reference;
      35             :     using ::com::sun::star::uno::Sequence;
      36             :     using ::com::sun::star::uno::Exception;
      37             :     using ::com::sun::star::uno::UNO_QUERY;
      38             :     using ::com::sun::star::uno::RuntimeException;
      39             :     using ::com::sun::star::lang::XUnoTunnel;
      40             :     using ::com::sun::star::accessibility::XAccessible;
      41             :     using ::com::sun::star::accessibility::XAccessibleContext;
      42             : 
      43         565 :     struct OAccImpl_Impl
      44             :     {
      45             :         Reference< XAccessible >    m_xAccParent;
      46             :         sal_Int64                   m_nForeignControlledStates;
      47             :     };
      48             : 
      49         295 :     OAccessibleImplementationAccess::OAccessibleImplementationAccess( )
      50         295 :         :m_pImpl( new OAccImpl_Impl )
      51             :     {
      52         295 :     }
      53             : 
      54             : 
      55         540 :     OAccessibleImplementationAccess::~OAccessibleImplementationAccess( )
      56             :     {
      57         270 :         delete m_pImpl;
      58         270 :         m_pImpl = NULL;
      59         270 :     }
      60             : 
      61             : 
      62        7116 :     Reference< XAccessible > OAccessibleImplementationAccess::implGetForeignControlledParent( ) const
      63             :     {
      64        7116 :         return m_pImpl->m_xAccParent;
      65             :     }
      66             : 
      67             : 
      68           0 :     void OAccessibleImplementationAccess::setAccessibleParent( const Reference< XAccessible >& _rxAccParent )
      69             :     {
      70           0 :         m_pImpl->m_xAccParent = _rxAccParent;
      71           0 :     }
      72             : 
      73             : 
      74           0 :     sal_Int64 OAccessibleImplementationAccess::implGetForeignControlledStates( ) const
      75             :     {
      76           0 :         return m_pImpl->m_nForeignControlledStates;
      77             :     }
      78             : 
      79             :     namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; }
      80             : 
      81             : 
      82           0 :     const Sequence< sal_Int8 > OAccessibleImplementationAccess::getUnoTunnelImplementationId()
      83             :     {
      84           0 :         ::cppu::OImplementationId &rID = lcl_ImplId::get();
      85           0 :         return rID.getImplementationId();
      86             :     }
      87             : 
      88             : 
      89           0 :     sal_Int64 SAL_CALL OAccessibleImplementationAccess::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw (RuntimeException, std::exception)
      90             :     {
      91           0 :         sal_Int64 nReturn( 0 );
      92             : 
      93           0 :         if  (   ( _rIdentifier.getLength() == 16 )
      94           0 :             &&  ( 0 == memcmp( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ) )
      95             :             )
      96           0 :             nReturn = reinterpret_cast< sal_Int64 >( this );
      97             : 
      98           0 :         return nReturn;
      99             :     }
     100             : 
     101             : 
     102           0 :     OAccessibleImplementationAccess* OAccessibleImplementationAccess::getImplementation( const Reference< XAccessibleContext >& _rxComponent )
     103             :     {
     104           0 :         OAccessibleImplementationAccess* pImplementation = NULL;
     105             :         try
     106             :         {
     107           0 :             Reference< XUnoTunnel > xTunnel( _rxComponent, UNO_QUERY );
     108           0 :             if ( xTunnel.is() )
     109             :             {
     110             :                 pImplementation = reinterpret_cast< OAccessibleImplementationAccess* >(
     111           0 :                         xTunnel->getSomething( getUnoTunnelImplementationId() ) );
     112           0 :             }
     113             :         }
     114           0 :         catch( const Exception& )
     115             :         {
     116             :             OSL_FAIL( "OAccessibleImplementationAccess::setAccessibleParent: caught an exception while retrieving the implementation!" );
     117             :         }
     118           0 :         return pImplementation;
     119             :     }
     120             : 
     121             : 
     122           0 :     bool OAccessibleImplementationAccess::setAccessibleParent(
     123             :             const Reference< XAccessibleContext >& _rxComponent, const Reference< XAccessible >& _rxNewParent )
     124             :     {
     125           0 :         OAccessibleImplementationAccess* pImplementation = getImplementation( _rxComponent );
     126             : 
     127           0 :         if ( pImplementation )
     128           0 :             pImplementation->setAccessibleParent( _rxNewParent );
     129             : 
     130           0 :         return ( NULL != pImplementation );
     131             :     }
     132             : 
     133             : 
     134             : }   // namespace comphelper
     135             : 
     136             : 
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11