bump product version to 7.6.3.2-android
[LibreOffice.git] / vcl / source / helper / svtaccessiblefactory.cxx
blobf6728732a2e72577dae2946f44966f71a4982d36
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
33 namespace vcl
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::awt;
37 using namespace ::com::sun::star::accessibility;
39 namespace
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
49 ::rtl::Reference< IAccessibleFactory > s_pFactory;
52 //= AccessibleDummyFactory
54 class AccessibleDummyFactory:
55 public IAccessibleFactory
57 public:
58 AccessibleDummyFactory();
59 AccessibleDummyFactory(const AccessibleDummyFactory&) = delete;
60 AccessibleDummyFactory& operator=(const AccessibleDummyFactory&) = delete;
62 protected:
63 virtual ~AccessibleDummyFactory() override;
65 public:
66 // IAccessibleFactory
67 virtual vcl::IAccessibleTabListBox*
68 createAccessibleTabListBox(
69 const css::uno::Reference< css::accessibility::XAccessible >& /*rxParent*/,
70 SvHeaderTabListBox& /*rBox*/
71 ) const override
73 return nullptr;
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
82 return nullptr;
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
91 return nullptr;
94 virtual vcl::IAccessibleBrowseBox*
95 createAccessibleBrowseBox(
96 const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
97 vcl::IAccessibleTableProvider& /*_rBrowseBox*/
98 ) const override
100 return nullptr;
103 virtual table::IAccessibleTableControl*
104 createAccessibleTableControl(
105 const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
106 table::IAccessibleTable& /*_rTable*/
107 ) const override
109 return nullptr;
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
118 return nullptr;
121 virtual css::uno::Reference< css::accessibility::XAccessible >
122 createAccessibleTabBar(
123 TabBar& /*_rTabBar*/
124 ) const override
126 return nullptr;
129 virtual css::uno::Reference< css::accessibility::XAccessibleContext >
130 createAccessibleTextWindowContext(
131 VCLXWindow* /*pVclXWindow*/, TextEngine& /*rEngine*/, TextView& /*rView*/
132 ) const override
134 return nullptr;
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
144 return nullptr;
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
157 return nullptr;
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
169 return nullptr;
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
183 return nullptr;
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
196 return nullptr;
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() {} }
225 #else
226 extern "C" void* getSvtAccessibilityComponentFactory();
227 #endif
228 #endif // HAVE_FEATURE_DESKTOP
229 #endif // ENABLE_WASM_STRIP_ACCESSIBILITY
231 void AccessibleFactoryAccess::ensureInitialized()
233 if ( m_bInitialized )
234 return;
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
241 if (!s_pFactory)
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!" );
254 #else
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)() );
262 if ( pFactory )
264 s_pFactory = pFactory;
265 pFactory->release();
269 #endif // HAVE_FEATURE_DESKTOP
270 #endif // ENABLE_WASM_STRIP_ACCESSIBILITY
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;
277 m_bInitialized = true;
280 IAccessibleFactory& AccessibleFactoryAccess::getFactory()
282 ensureInitialized();
283 DBG_ASSERT( s_pFactory.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
284 return *s_pFactory;
287 } // namespace vcl
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */