1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include "svtaccessiblefactory.hxx"
24 #include <boost/noncopyable.hpp>
25 #include <osl/module.h>
29 using namespace ::com::sun::star::uno
;
30 using namespace ::com::sun::star::awt
;
31 using namespace ::com::sun::star::accessibility
;
35 #ifndef DISABLE_DYNLOADING
36 static oslModule s_hAccessibleImplementationModule
= NULL
;
38 #if HAVE_FEATURE_DESKTOP
39 static GetSvtAccessibilityComponentFactory s_pAccessibleFactoryFunc
= NULL
;
41 static ::rtl::Reference
< IAccessibleFactory
> s_pFactory
;
44 //= AccessibleDummyFactory
46 class AccessibleDummyFactory
:
47 public IAccessibleFactory
, private boost::noncopyable
50 AccessibleDummyFactory();
53 virtual ~AccessibleDummyFactory();
57 virtual IAccessibleTabListBox
*
58 createAccessibleTabListBox(
59 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& /*rxParent*/,
60 SvHeaderTabListBox
& /*rBox*/
66 virtual IAccessibleBrowseBox
*
67 createAccessibleBrowseBox(
68 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& /*_rxParent*/,
69 IAccessibleTableProvider
& /*_rBrowseBox*/
75 virtual table::IAccessibleTableControl
*
76 createAccessibleTableControl(
77 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& /*_rxParent*/,
78 table::IAccessibleTable
& /*_rTable*/
84 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
85 createAccessibleIconChoiceCtrl(
86 SvtIconChoiceCtrl
& /*_rIconCtrl*/,
87 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& /*_xParent*/
93 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
94 createAccessibleTabBar(
101 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
>
102 createAccessibleTextWindowContext(
103 VCLXWindow
* /*pVclXWindow*/, TextEngine
& /*rEngine*/, TextView
& /*rView*/
109 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
110 createAccessibleTreeListBox(
111 SvTreeListBox
& /*_rListBox*/,
112 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& /*_xParent*/
118 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
119 createAccessibleBrowseBoxHeaderBar(
120 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& /*rxParent*/,
121 IAccessibleTableProvider
& /*_rOwningTable*/,
122 AccessibleBrowseBoxObjType
/*_eObjType*/
128 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
129 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*/
141 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
142 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*/
153 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
154 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*/
167 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>
168 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*/
180 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
>
181 createAccessibleToolPanelDeck(
182 const ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
>& /*i_rAccessibleParent*/,
183 ::svt::ToolPanelDeck
& /*i_rPanelDeck*/
188 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
>
189 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*/
200 AccessibleDummyFactory::AccessibleDummyFactory()
205 AccessibleDummyFactory::~AccessibleDummyFactory()
212 //= AccessibleFactoryAccess
215 AccessibleFactoryAccess::AccessibleFactoryAccess()
216 :m_bInitialized( false )
220 #if HAVE_FEATURE_DESKTOP
221 #ifndef DISABLE_DYNLOADING
222 extern "C" { static void SAL_CALL
thisModule() {} }
224 extern "C" void* getSvtAccessibilityComponentFactory();
226 #endif // HAVE_FEATURE_DESKTOP
228 void AccessibleFactoryAccess::ensureInitialized()
230 if ( m_bInitialized
)
233 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
235 #if HAVE_FEATURE_DESKTOP
236 // load the library implementing the factory
237 if ( !s_pFactory
.get() )
239 #ifndef DISABLE_DYNLOADING
240 const OUString
sModuleName( SVLIBRARY( "acc" ));
241 s_hAccessibleImplementationModule
= osl_loadModuleRelative( &thisModule
, sModuleName
.pData
, 0 );
242 if ( s_hAccessibleImplementationModule
!= NULL
)
244 const OUString
sFactoryCreationFunc( "getSvtAccessibilityComponentFactory" );
245 s_pAccessibleFactoryFunc
= reinterpret_cast<GetSvtAccessibilityComponentFactory
>(
246 osl_getFunctionSymbol( s_hAccessibleImplementationModule
, sFactoryCreationFunc
.pData
));
249 OSL_ENSURE( s_pAccessibleFactoryFunc
, "ac_registerClient: could not load the library, or not retrieve the needed symbol!" );
251 s_pAccessibleFactoryFunc
= getSvtAccessibilityComponentFactory
;
252 #endif // DISABLE_DYNLOADING
254 // get a factory instance
255 if ( s_pAccessibleFactoryFunc
)
257 IAccessibleFactory
* pFactory
= static_cast< IAccessibleFactory
* >( (*s_pAccessibleFactoryFunc
)() );
260 s_pFactory
= pFactory
;
265 #endif // HAVE_FEATURE_DESKTOP
267 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 s_pFactory
= new AccessibleDummyFactory
;
272 m_bInitialized
= true;
275 IAccessibleFactory
& AccessibleFactoryAccess::getFactory()
278 DBG_ASSERT( s_pFactory
.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */