LibreOffice Module vcl (master) 1
svtaccessiblefactory.cxx
Go to the documentation of this file.
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_feature_desktop.h>
21#include <config_wasm_strip.h>
22
25
26#include <tools/svlibrary.h>
27#include <tools/debug.hxx>
28
29#include <osl/module.h>
30#include <osl/diagnose.h>
31#include <rtl/ref.hxx>
32
33namespace vcl
34{
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::awt;
37 using namespace ::com::sun::star::accessibility;
38
39 namespace
40 {
41#ifndef DISABLE_DYNLOADING
42 oslModule s_hAccessibleImplementationModule = nullptr;
43#endif
44#if HAVE_FEATURE_DESKTOP
45#if !ENABLE_WASM_STRIP_ACCESSIBILITY
46 GetSvtAccessibilityComponentFactory s_pAccessibleFactoryFunc = nullptr;
47#endif
48#endif
50
51
52 //= AccessibleDummyFactory
53
54 class AccessibleDummyFactory:
55 public IAccessibleFactory
56 {
57 public:
58 AccessibleDummyFactory();
59 AccessibleDummyFactory(const AccessibleDummyFactory&) = delete;
60 AccessibleDummyFactory& operator=(const AccessibleDummyFactory&) = delete;
61
62 protected:
63 virtual ~AccessibleDummyFactory() override;
64
65 public:
66 // IAccessibleFactory
68 createAccessibleTabListBox(
69 const css::uno::Reference< css::accessibility::XAccessible >& /*rxParent*/,
70 SvHeaderTabListBox& /*rBox*/
71 ) const override
72 {
73 return nullptr;
74 }
75
76 virtual css::uno::Reference< css::accessibility::XAccessible >
77 createAccessibleTreeListBox(
78 SvTreeListBox& /*_rListBox*/,
79 const css::uno::Reference< css::accessibility::XAccessible >& /*_xParent*/
80 ) const override
81 {
82 return nullptr;
83 }
84
85 virtual css::uno::Reference< css::accessibility::XAccessible >
86 createAccessibleIconView(
87 SvTreeListBox& /*_rListBox*/,
88 const css::uno::Reference< css::accessibility::XAccessible >& /*_xParent*/
89 ) const override
90 {
91 return nullptr;
92 }
93
95 createAccessibleBrowseBox(
96 const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
97 vcl::IAccessibleTableProvider& /*_rBrowseBox*/
98 ) const override
99 {
100 return nullptr;
101 }
102
103 virtual table::IAccessibleTableControl*
104 createAccessibleTableControl(
105 const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
106 table::IAccessibleTable& /*_rTable*/
107 ) const override
108 {
109 return nullptr;
110 }
111
112 virtual css::uno::Reference< css::accessibility::XAccessible >
113 createAccessibleIconChoiceCtrl(
114 SvtIconChoiceCtrl& /*_rIconCtrl*/,
115 const css::uno::Reference< css::accessibility::XAccessible >& /*_xParent*/
116 ) const override
117 {
118 return nullptr;
119 }
120
121 virtual css::uno::Reference< css::accessibility::XAccessible >
122 createAccessibleTabBar(
123 TabBar& /*_rTabBar*/
124 ) const override
125 {
126 return nullptr;
127 }
128
129 virtual css::uno::Reference< css::accessibility::XAccessibleContext >
130 createAccessibleTextWindowContext(
131 VCLXWindow* /*pVclXWindow*/, TextEngine& /*rEngine*/, TextView& /*rView*/
132 ) const override
133 {
134 return nullptr;
135 }
136
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*/
142 ) const override
143 {
144 return nullptr;
145 }
146
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*/
155 ) const override
156 {
157 return nullptr;
158 }
159
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*/
167 ) const override
168 {
169 return nullptr;
170 }
171
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*/
181 ) const override
182 {
183 return nullptr;
184 }
185
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*/
194 ) const override
195 {
196 return nullptr;
197 }
198 };
199
200
201 AccessibleDummyFactory::AccessibleDummyFactory()
202 {
203 }
204
205
206 AccessibleDummyFactory::~AccessibleDummyFactory()
207 {
208 }
209
210 }
211
212
213 //= AccessibleFactoryAccess
214
215
216 AccessibleFactoryAccess::AccessibleFactoryAccess()
217 :m_bInitialized( false )
218 {
219 }
220
221#if !ENABLE_WASM_STRIP_ACCESSIBILITY
222#if HAVE_FEATURE_DESKTOP
223#ifndef DISABLE_DYNLOADING
224 extern "C" { static void thisModule() {} }
225#else
226 extern "C" void* getSvtAccessibilityComponentFactory();
227#endif
228#endif // HAVE_FEATURE_DESKTOP
229#endif // ENABLE_WASM_STRIP_ACCESSIBILITY
230
231 void AccessibleFactoryAccess::ensureInitialized()
232 {
233 if ( m_bInitialized )
234 return;
235
236 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
237
238#if !ENABLE_WASM_STRIP_ACCESSIBILITY
239#if HAVE_FEATURE_DESKTOP
240 // load the library implementing the factory
241 if (!s_pFactory)
242 {
243#ifndef DISABLE_DYNLOADING
244 const OUString sModuleName( SVLIBRARY( "acc" ));
245 s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
246 if ( s_hAccessibleImplementationModule != nullptr )
247 {
248 const OUString sFactoryCreationFunc( "getSvtAccessibilityComponentFactory" );
249 s_pAccessibleFactoryFunc = reinterpret_cast<GetSvtAccessibilityComponentFactory>(
250 osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData ));
251
252 }
253 OSL_ENSURE( s_pAccessibleFactoryFunc, "ac_registerClient: could not load the library, or not retrieve the needed symbol!" );
254#else
255 s_pAccessibleFactoryFunc = getSvtAccessibilityComponentFactory;
256#endif // DISABLE_DYNLOADING
257
258 // get a factory instance
259 if ( s_pAccessibleFactoryFunc )
260 {
261 IAccessibleFactory* pFactory = static_cast< IAccessibleFactory* >( (*s_pAccessibleFactoryFunc)() );
262 if ( pFactory )
263 {
264 s_pFactory = pFactory;
265 pFactory->release();
266 }
267 }
268 }
269#endif // HAVE_FEATURE_DESKTOP
270#endif // ENABLE_WASM_STRIP_ACCESSIBILITY
271
272 if (!s_pFactory)
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;
276
277 m_bInitialized = true;
278 }
279
280 IAccessibleFactory& AccessibleFactoryAccess::getFactory()
281 {
282 ensureInitialized();
283 DBG_ASSERT( s_pFactory.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
284 return *s_pFactory;
285 }
286
287} // namespace vcl
288
289/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AccessibleBrowseBoxObjType
This enumeration contains a constant for each kind of accessible object of a BrowseBox.
interface for an implementation of a browse box's Accessible component
interface for an implementation of a table control's Accessible component
This abstract class provides methods to implement an accessible table object.
#define DBG_ASSERT(sCon, aError)
TriState
void *(* GetSvtAccessibilityComponentFactory)()
a function which is able to create a factory for the standard Accessible/Context components needed fo...
static void thisModule()
Definition: svapp.cxx:1588
#define SVLIBRARY(Base)