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_feature_desktop.h>
21 #include <config_wasm_strip.h>
23 #include <vcl/svtaccessiblefactory.hxx>
24 #include <vcl/accessiblefactory.hxx>
26 #include <tools/svlibrary.h>
27 #include <tools/debug.hxx>
29 #include <osl/module.h>
30 #include <osl/diagnose.h>
31 #include <rtl/ref.hxx>
35 using namespace ::com::sun::star::uno
;
36 using namespace ::com::sun::star::awt
;
37 using namespace ::com::sun::star::accessibility
;
41 #ifndef DISABLE_DYNLOADING
42 oslModule s_hAccessibleImplementationModule
= nullptr;
44 #if HAVE_FEATURE_DESKTOP
45 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
46 GetSvtAccessibilityComponentFactory s_pAccessibleFactoryFunc
= nullptr;
49 ::rtl::Reference
< IAccessibleFactory
> s_pFactory
;
52 //= AccessibleDummyFactory
54 class AccessibleDummyFactory
:
55 public IAccessibleFactory
58 AccessibleDummyFactory();
59 AccessibleDummyFactory(const AccessibleDummyFactory
&) = delete;
60 AccessibleDummyFactory
& operator=(const AccessibleDummyFactory
&) = delete;
63 virtual ~AccessibleDummyFactory() override
;
67 virtual vcl::IAccessibleTabListBox
*
68 createAccessibleTabListBox(
69 const css::uno::Reference
< css::accessibility::XAccessible
>& /*rxParent*/,
70 SvHeaderTabListBox
& /*rBox*/
76 virtual css::uno::Reference
< css::accessibility::XAccessible
>
77 createAccessibleTreeListBox(
78 SvTreeListBox
& /*_rListBox*/,
79 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_xParent*/
85 virtual css::uno::Reference
< css::accessibility::XAccessible
>
86 createAccessibleIconView(
87 SvTreeListBox
& /*_rListBox*/,
88 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_xParent*/
94 virtual vcl::IAccessibleBrowseBox
*
95 createAccessibleBrowseBox(
96 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_rxParent*/,
97 vcl::IAccessibleTableProvider
& /*_rBrowseBox*/
103 virtual table::IAccessibleTableControl
*
104 createAccessibleTableControl(
105 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_rxParent*/,
106 table::IAccessibleTable
& /*_rTable*/
112 virtual css::uno::Reference
< css::accessibility::XAccessible
>
113 createAccessibleIconChoiceCtrl(
114 SvtIconChoiceCtrl
& /*_rIconCtrl*/,
115 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_xParent*/
121 virtual css::uno::Reference
< css::accessibility::XAccessible
>
122 createAccessibleTabBar(
129 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
>
130 createAccessibleTextWindowContext(
131 VCLXWindow
* /*pVclXWindow*/, TextEngine
& /*rEngine*/, TextView
& /*rView*/
137 virtual css::uno::Reference
< css::accessibility::XAccessible
>
138 createAccessibleBrowseBoxHeaderBar(
139 const css::uno::Reference
< css::accessibility::XAccessible
>& /*rxParent*/,
140 vcl::IAccessibleTableProvider
& /*_rOwningTable*/,
141 AccessibleBrowseBoxObjType
/*_eObjType*/
147 virtual css::uno::Reference
< css::accessibility::XAccessible
>
148 createAccessibleBrowseBoxTableCell(
149 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_rxParent*/,
150 vcl::IAccessibleTableProvider
& /*_rBrowseBox*/,
151 const css::uno::Reference
< css::awt::XWindow
>& /*_xFocusWindow*/,
152 sal_Int32
/*_nRowId*/,
153 sal_uInt16
/*_nColId*/,
154 sal_Int32
/*_nOffset*/
160 virtual css::uno::Reference
< css::accessibility::XAccessible
>
161 createAccessibleBrowseBoxHeaderCell(
162 sal_Int32
/*_nColumnRowId*/,
163 const css::uno::Reference
< css::accessibility::XAccessible
>& /*rxParent*/,
164 vcl::IAccessibleTableProvider
& /*_rBrowseBox*/,
165 const css::uno::Reference
< css::awt::XWindow
>& /*_xFocusWindow*/,
166 AccessibleBrowseBoxObjType
/*_eObjType*/
172 virtual css::uno::Reference
< css::accessibility::XAccessible
>
173 createAccessibleCheckBoxCell(
174 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_rxParent*/,
175 vcl::IAccessibleTableProvider
& /*_rBrowseBox*/,
176 const css::uno::Reference
< css::awt::XWindow
>& /*_xFocusWindow*/,
177 sal_Int32
/*_nRowPos*/,
178 sal_uInt16
/*_nColPos*/,
179 const TriState
& /*_eState*/,
180 bool /*_bIsTriState*/
186 virtual css::uno::Reference
< css::accessibility::XAccessible
>
187 createEditBrowseBoxTableCellAccess(
188 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_rxParent*/,
189 const css::uno::Reference
< css::accessibility::XAccessible
>& /*_rxControlAccessible*/,
190 const css::uno::Reference
< css::awt::XWindow
>& /*_rxFocusWindow*/,
191 vcl::IAccessibleTableProvider
& /*_rBrowseBox*/,
192 sal_Int32
/*_nRowPos*/,
193 sal_uInt16
/*_nColPos*/
201 AccessibleDummyFactory::AccessibleDummyFactory()
206 AccessibleDummyFactory::~AccessibleDummyFactory()
213 //= AccessibleFactoryAccess
216 AccessibleFactoryAccess::AccessibleFactoryAccess()
217 :m_bInitialized( false )
221 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
222 #if HAVE_FEATURE_DESKTOP
223 #ifndef DISABLE_DYNLOADING
224 extern "C" { static void thisModule() {} }
226 extern "C" void* getSvtAccessibilityComponentFactory();
228 #endif // HAVE_FEATURE_DESKTOP
229 #endif // ENABLE_WASM_STRIP_ACCESSIBILITY
231 void AccessibleFactoryAccess::ensureInitialized()
233 if ( m_bInitialized
)
236 ::osl::MutexGuard
aGuard( ::osl::Mutex::getGlobalMutex() );
238 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
239 #if HAVE_FEATURE_DESKTOP
240 // load the library implementing the factory
243 #ifndef DISABLE_DYNLOADING
244 const OUString
sModuleName( SVLIBRARY( "acc" ));
245 s_hAccessibleImplementationModule
= osl_loadModuleRelative( &thisModule
, sModuleName
.pData
, 0 );
246 if ( s_hAccessibleImplementationModule
!= nullptr )
248 const OUString
sFactoryCreationFunc( "getSvtAccessibilityComponentFactory" );
249 s_pAccessibleFactoryFunc
= reinterpret_cast<GetSvtAccessibilityComponentFactory
>(
250 osl_getFunctionSymbol( s_hAccessibleImplementationModule
, sFactoryCreationFunc
.pData
));
253 OSL_ENSURE( s_pAccessibleFactoryFunc
, "ac_registerClient: could not load the library, or not retrieve the needed symbol!" );
255 s_pAccessibleFactoryFunc
= getSvtAccessibilityComponentFactory
;
256 #endif // DISABLE_DYNLOADING
258 // get a factory instance
259 if ( s_pAccessibleFactoryFunc
)
261 IAccessibleFactory
* pFactory
= static_cast< IAccessibleFactory
* >( (*s_pAccessibleFactoryFunc
)() );
264 s_pFactory
= pFactory
;
269 #endif // HAVE_FEATURE_DESKTOP
270 #endif // ENABLE_WASM_STRIP_ACCESSIBILITY
273 // the attempt to load the lib, or to create the factory, failed
274 // -> fall back to a dummy factory
275 s_pFactory
= new AccessibleDummyFactory
;
277 m_bInitialized
= true;
280 IAccessibleFactory
& AccessibleFactoryAccess::getFactory()
283 DBG_ASSERT( s_pFactory
.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */