LCOV - code coverage report
Current view: top level - svtools/source/misc - svtaccessiblefactory.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 26 60 43.3 %
Date: 2015-06-13 12:38:46 Functions: 5 25 20.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 <config_features.h>
      21             : 
      22             : #include "svtaccessiblefactory.hxx"
      23             : 
      24             : #include <boost/noncopyable.hpp>
      25             : #include <osl/module.h>
      26             : 
      27             : namespace svt
      28             : {
      29             :     using namespace ::com::sun::star::uno;
      30             :     using namespace ::com::sun::star::awt;
      31             :     using namespace ::com::sun::star::accessibility;
      32             : 
      33             :     namespace
      34             :     {
      35             : #ifndef DISABLE_DYNLOADING
      36             :         static oslModule                                s_hAccessibleImplementationModule = NULL;
      37             : #endif
      38             : #if HAVE_FEATURE_DESKTOP
      39             :         static GetSvtAccessibilityComponentFactory      s_pAccessibleFactoryFunc = NULL;
      40             : #endif
      41         266 :         static ::rtl::Reference< IAccessibleFactory >   s_pFactory;
      42             : 
      43             : 
      44             :         //= AccessibleDummyFactory
      45             : 
      46             :         class AccessibleDummyFactory:
      47             :             public IAccessibleFactory, private boost::noncopyable
      48             :         {
      49             :         public:
      50             :             AccessibleDummyFactory();
      51             : 
      52             :         protected:
      53             :             virtual ~AccessibleDummyFactory();
      54             : 
      55             :         public:
      56             :             // IAccessibleFactory
      57             :             virtual IAccessibleTabListBox*
      58           0 :                 createAccessibleTabListBox(
      59             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
      60             :                     SvHeaderTabListBox& /*rBox*/
      61             :                 ) const SAL_OVERRIDE
      62             :             {
      63           0 :                 return NULL;
      64             :             }
      65             : 
      66             :             virtual IAccessibleBrowseBox*
      67           0 :                 createAccessibleBrowseBox(
      68             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
      69             :                     IAccessibleTableProvider& /*_rBrowseBox*/
      70             :                 ) const SAL_OVERRIDE
      71             :             {
      72           0 :                 return NULL;
      73             :             }
      74             : 
      75             :             virtual table::IAccessibleTableControl*
      76           0 :                 createAccessibleTableControl(
      77             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
      78             :                     table::IAccessibleTable& /*_rTable*/
      79             :                 ) const SAL_OVERRIDE
      80             :             {
      81           0 :                 return NULL;
      82             :             }
      83             : 
      84             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
      85           0 :                 createAccessibleIconChoiceCtrl(
      86             :                     SvtIconChoiceCtrl& /*_rIconCtrl*/,
      87             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_xParent*/
      88             :                 ) const SAL_OVERRIDE
      89             :             {
      90           0 :                 return NULL;
      91             :             }
      92             : 
      93             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
      94           0 :                 createAccessibleTabBar(
      95             :                     TabBar& /*_rTabBar*/
      96             :                 ) const SAL_OVERRIDE
      97             :             {
      98           0 :                 return NULL;
      99             :             }
     100             : 
     101             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     102           0 :                 createAccessibleTextWindowContext(
     103             :                     VCLXWindow* /*pVclXWindow*/, TextEngine& /*rEngine*/, TextView& /*rView*/
     104             :                 ) const SAL_OVERRIDE
     105             :             {
     106           0 :                 return NULL;
     107             :             }
     108             : 
     109             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     110           0 :                 createAccessibleTreeListBox(
     111             :                     SvTreeListBox& /*_rListBox*/,
     112             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_xParent*/
     113             :                 ) const SAL_OVERRIDE
     114             :             {
     115           0 :                 return NULL;
     116             :             }
     117             : 
     118             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     119           0 :                 createAccessibleBrowseBoxHeaderBar(
     120             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
     121             :                     IAccessibleTableProvider& /*_rOwningTable*/,
     122             :                     AccessibleBrowseBoxObjType /*_eObjType*/
     123             :                 ) const SAL_OVERRIDE
     124             :             {
     125           0 :                 return NULL;
     126             :             }
     127             : 
     128             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     129           0 :                 createAccessibleBrowseBoxTableCell(
     130             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
     131             :                     IAccessibleTableProvider& /*_rBrowseBox*/,
     132             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
     133             :                     sal_Int32 /*_nRowId*/,
     134             :                     sal_uInt16 /*_nColId*/,
     135             :                     sal_Int32 /*_nOffset*/
     136             :                 ) const SAL_OVERRIDE
     137             :             {
     138           0 :                 return NULL;
     139             :             }
     140             : 
     141             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     142           0 :                 createAccessibleBrowseBoxHeaderCell(
     143             :                     sal_Int32 /*_nColumnRowId*/,
     144             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
     145             :                     IAccessibleTableProvider& /*_rBrowseBox*/,
     146             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
     147             :                     AccessibleBrowseBoxObjType  /*_eObjType*/
     148             :                 ) const SAL_OVERRIDE
     149             :             {
     150           0 :                 return NULL;
     151             :             }
     152             : 
     153             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     154           0 :                 createAccessibleCheckBoxCell(
     155             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
     156             :                     IAccessibleTableProvider& /*_rBrowseBox*/,
     157             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
     158             :                     sal_Int32 /*_nRowPos*/,
     159             :                     sal_uInt16 /*_nColPos*/,
     160             :                     const TriState& /*_eState*/,
     161             :                     bool /*_bIsTriState*/
     162             :                 ) const SAL_OVERRIDE
     163             :             {
     164           0 :                 return NULL;
     165             :             }
     166             : 
     167             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     168           0 :                 createEditBrowseBoxTableCellAccess(
     169             :                     const ::com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
     170             :                     const ::com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessible >& /*_rxControlAccessible*/,
     171             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_rxFocusWindow*/,
     172             :                     IAccessibleTableProvider& /*_rBrowseBox*/,
     173             :                     sal_Int32 /*_nRowPos*/,
     174             :                     sal_uInt16 /*_nColPos*/
     175             :                 ) const SAL_OVERRIDE
     176             :             {
     177           0 :                 return NULL;
     178             :             }
     179             : 
     180             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     181           0 :                 createAccessibleToolPanelDeck(
     182             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*i_rAccessibleParent*/,
     183             :                     ::svt::ToolPanelDeck& /*i_rPanelDeck*/
     184             :                 ) SAL_OVERRIDE
     185             :             {
     186           0 :                 return NULL;
     187             :             }
     188             :             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
     189           0 :                 createAccessibleToolPanelTabBar(
     190             :                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*i_rAccessibleParent*/,
     191             :                     ::svt::IToolPanelDeck& /*i_rPanelDeck*/,
     192             :                     ::svt::PanelTabBar& /*i_rTabBar*/
     193             :                 ) SAL_OVERRIDE
     194             :             {
     195           0 :                 return NULL;
     196             :             }
     197             :         };
     198             : 
     199             : 
     200           0 :         AccessibleDummyFactory::AccessibleDummyFactory()
     201             :         {
     202           0 :         }
     203             : 
     204             : 
     205           0 :         AccessibleDummyFactory::~AccessibleDummyFactory()
     206             :         {
     207           0 :         }
     208             : 
     209             :     }
     210             : 
     211             : 
     212             :     //= AccessibleFactoryAccess
     213             : 
     214             : 
     215         623 :     AccessibleFactoryAccess::AccessibleFactoryAccess()
     216         623 :         :m_bInitialized( false )
     217             :     {
     218         623 :     }
     219             : 
     220             : #if HAVE_FEATURE_DESKTOP
     221             : #ifndef DISABLE_DYNLOADING
     222           0 :     extern "C" { static void SAL_CALL thisModule() {} }
     223             : #else
     224             :     extern "C" void* getSvtAccessibilityComponentFactory();
     225             : #endif
     226             : #endif // HAVE_FEATURE_DESKTOP
     227             : 
     228           3 :     void AccessibleFactoryAccess::ensureInitialized()
     229             :     {
     230           3 :         if ( m_bInitialized )
     231           3 :             return;
     232             : 
     233           3 :         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
     234             : 
     235             : #if HAVE_FEATURE_DESKTOP
     236             :         // load the library implementing the factory
     237           3 :         if ( !s_pFactory.get() )
     238             :         {
     239             : #ifndef DISABLE_DYNLOADING
     240           1 :             const OUString sModuleName( SVLIBRARY( "acc" ));
     241           1 :             s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
     242           1 :             if ( s_hAccessibleImplementationModule != NULL )
     243             :             {
     244           1 :                 const OUString sFactoryCreationFunc( "getSvtAccessibilityComponentFactory" );
     245             :                 s_pAccessibleFactoryFunc = reinterpret_cast<GetSvtAccessibilityComponentFactory>(
     246           1 :                     osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData ));
     247             : 
     248             :             }
     249             :             OSL_ENSURE( s_pAccessibleFactoryFunc, "ac_registerClient: could not load the library, or not retrieve the needed symbol!" );
     250             : #else
     251             :             s_pAccessibleFactoryFunc = getSvtAccessibilityComponentFactory;
     252             : #endif // DISABLE_DYNLOADING
     253             : 
     254             :             // get a factory instance
     255           1 :             if ( s_pAccessibleFactoryFunc )
     256             :             {
     257           1 :                 IAccessibleFactory* pFactory = static_cast< IAccessibleFactory* >( (*s_pAccessibleFactoryFunc)() );
     258           1 :                 if ( pFactory )
     259             :                 {
     260           1 :                     s_pFactory = pFactory;
     261           1 :                     pFactory->release();
     262             :                 }
     263           1 :             }
     264             :         }
     265             : #endif // HAVE_FEATURE_DESKTOP
     266             : 
     267           3 :         if ( !s_pFactory.get() )
     268             :             // the attempt to load the lib, or to create the factory, failed
     269             :             // -> fall back to a dummy factory
     270           0 :             s_pFactory = new AccessibleDummyFactory;
     271             : 
     272           3 :         m_bInitialized = true;
     273             :     }
     274             : 
     275           3 :     IAccessibleFactory& AccessibleFactoryAccess::getFactory()
     276             :     {
     277           3 :         ensureInitialized();
     278             :         DBG_ASSERT( s_pFactory.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
     279           3 :         return *s_pFactory;
     280             :     }
     281             : 
     282             : 
     283         798 : }   // namespace svt
     284             : 
     285             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11