LCOV - code coverage report
Current view: top level - toolkit/source/helper - accessibilityclient.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 26 56 46.4 %
Date: 2015-06-13 12:38:46 Functions: 5 23 21.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 <config_features.h>
      21             : 
      22             : #include <sal/config.h>
      23             : 
      24             : #include <boost/noncopyable.hpp>
      25             : 
      26             : #include <toolkit/helper/accessiblefactory.hxx>
      27             : #include <osl/module.h>
      28             : #include <osl/diagnose.h>
      29             : #include <osl/mutex.hxx>
      30             : #include <tools/solar.h>
      31             : 
      32             : #include "helper/accessibilityclient.hxx"
      33             : 
      34             : namespace toolkit
      35             : {
      36             :     using namespace ::com::sun::star::uno;
      37             :     using namespace ::com::sun::star::accessibility;
      38             : 
      39             :     namespace
      40             :     {
      41             : #ifndef DISABLE_DYNLOADING
      42             :         static oslModule                                s_hAccessibleImplementationModule = NULL;
      43             : #endif
      44             : #if HAVE_FEATURE_DESKTOP
      45             :         static GetStandardAccComponentFactory           s_pAccessibleFactoryFunc = NULL;
      46             : #endif
      47         266 :         static ::rtl::Reference< IAccessibleFactory >   s_pFactory;
      48             :     }
      49             : 
      50             : 
      51             :     //= AccessibleDummyFactory
      52             : 
      53             :     class AccessibleDummyFactory:
      54             :         public IAccessibleFactory, private boost::noncopyable
      55             :     {
      56             :     public:
      57             :         AccessibleDummyFactory();
      58             : 
      59             :     protected:
      60             :         virtual ~AccessibleDummyFactory();
      61             : 
      62             :     public:
      63             :         // IAccessibleFactory
      64             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
      65           0 :                 createAccessibleContext( VCLXButton* /*_pXWindow*/ ) SAL_OVERRIDE
      66             :         {
      67           0 :             return NULL;
      68             :         }
      69             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
      70           0 :                 createAccessibleContext( VCLXCheckBox* /*_pXWindow*/ ) SAL_OVERRIDE
      71             :         {
      72           0 :             return NULL;
      73             :         }
      74             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
      75           0 :                 createAccessibleContext( VCLXRadioButton* /*_pXWindow*/ ) SAL_OVERRIDE
      76             :         {
      77           0 :             return NULL;
      78             :         }
      79             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
      80           0 :                 createAccessibleContext( VCLXListBox* /*_pXWindow*/ ) SAL_OVERRIDE
      81             :         {
      82           0 :             return NULL;
      83             :         }
      84             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
      85           0 :                 createAccessibleContext( VCLXFixedHyperlink* /*_pXWindow*/ ) SAL_OVERRIDE
      86             :         {
      87           0 :             return NULL;
      88             :         }
      89             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
      90           0 :                 createAccessibleContext( VCLXFixedText* /*_pXWindow*/ ) SAL_OVERRIDE
      91             :         {
      92           0 :             return NULL;
      93             :         }
      94             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
      95           0 :                 createAccessibleContext( VCLXScrollBar* /*_pXWindow*/ ) SAL_OVERRIDE
      96             :         {
      97           0 :             return NULL;
      98             :         }
      99             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     100           0 :                 createAccessibleContext( VCLXEdit* /*_pXWindow*/ ) SAL_OVERRIDE
     101             :         {
     102           0 :             return NULL;
     103             :         }
     104             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     105           0 :                 createAccessibleContext( VCLXComboBox* /*_pXWindow*/ ) SAL_OVERRIDE
     106             :         {
     107           0 :             return NULL;
     108             :         }
     109             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     110           0 :                 createAccessibleContext( VCLXToolBox* /*_pXWindow*/ ) SAL_OVERRIDE
     111             :         {
     112           0 :             return NULL;
     113             :         }
     114             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     115           0 :                 createAccessibleContext( VCLXWindow* /*_pXWindow*/ ) SAL_OVERRIDE
     116             :         {
     117           0 :             return NULL;
     118             :         }
     119             :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     120           0 :                 createAccessible( Menu* /*_pMenu*/, bool /*_bIsMenuBar*/ ) SAL_OVERRIDE
     121             :         {
     122           0 :             return NULL;
     123             :         }
     124             :     };
     125             : 
     126             : 
     127           0 :     AccessibleDummyFactory::AccessibleDummyFactory()
     128             :     {
     129           0 :     }
     130             : 
     131             : 
     132           0 :     AccessibleDummyFactory::~AccessibleDummyFactory()
     133             :     {
     134           0 :     }
     135             : 
     136             : 
     137             :     //= AccessibilityClient
     138             : 
     139             : 
     140       79006 :     AccessibilityClient::AccessibilityClient()
     141       79006 :         :m_bInitialized( false )
     142             :     {
     143       79006 :     }
     144             : 
     145             : #if HAVE_FEATURE_DESKTOP
     146             : #ifndef DISABLE_DYNLOADING
     147           0 :     extern "C" { static void SAL_CALL thisModule() {} }
     148             : #else
     149             :     extern "C" void *getStandardAccessibleFactory();
     150             : #endif
     151             : #endif // HAVE_FEATURE_DESKTOP
     152             : 
     153         273 :     void AccessibilityClient::ensureInitialized()
     154             :     {
     155         273 :         if ( m_bInitialized )
     156         289 :             return;
     157             : 
     158         257 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     159             : 
     160             : #if HAVE_FEATURE_DESKTOP
     161             :         // load the library implementing the factory
     162         257 :         if ( !s_pFactory.get() )
     163             :         {
     164             : #ifndef DISABLE_DYNLOADING
     165          12 :             const OUString sModuleName( SVLIBRARY( "acc" ) );
     166          12 :             s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
     167          12 :             if ( s_hAccessibleImplementationModule != NULL )
     168             :             {
     169             :                 const OUString sFactoryCreationFunc =
     170          12 :                     OUString("getStandardAccessibleFactory");
     171             :                 s_pAccessibleFactoryFunc = reinterpret_cast<GetStandardAccComponentFactory>(
     172          12 :                     osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData ));
     173             : 
     174             :             }
     175             :             OSL_ENSURE( s_pAccessibleFactoryFunc, "AccessibilityClient::ensureInitialized: could not load the library, or not retrieve the needed symbol!" );
     176             : #else
     177             :             s_pAccessibleFactoryFunc = getStandardAccessibleFactory;
     178             : #endif // DISABLE_DYNLOADING
     179             : 
     180             :             // get a factory instance
     181          12 :             if ( s_pAccessibleFactoryFunc )
     182             :             {
     183          12 :                 IAccessibleFactory* pFactory = static_cast< IAccessibleFactory* >( (*s_pAccessibleFactoryFunc)() );
     184             :                 OSL_ENSURE( pFactory, "AccessibilityClient::ensureInitialized: no factory provided by the A11Y lib!" );
     185          12 :                 if ( pFactory )
     186             :                 {
     187          12 :                     s_pFactory = pFactory;
     188          12 :                     pFactory->release();
     189             :                 }
     190          12 :             }
     191             :         }
     192             : #endif // HAVE_FEATURE_DESKTOP
     193             : 
     194         257 :         if ( !s_pFactory.get() )
     195             :             // the attempt to load the lib, or to create the factory, failed
     196             :             // -> fall back to a dummy factory
     197           0 :             s_pFactory = new AccessibleDummyFactory;
     198             : 
     199         257 :         m_bInitialized = true;
     200             :     }
     201             : 
     202         273 :     IAccessibleFactory& AccessibilityClient::getFactory()
     203             :     {
     204         273 :         ensureInitialized();
     205             :         OSL_ENSURE( s_pFactory.is(), "AccessibilityClient::getFactory: at least a dummy factory should have been created!" );
     206         273 :         return *s_pFactory;
     207             :     }
     208             : 
     209             : 
     210         798 : }   // namespace toolkit
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11