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 
24 
25 #include <tools/svlibrary.h>
26 #include <tools/debug.hxx>
27 
28 #include <osl/module.h>
29 #include <osl/diagnose.h>
30 #include <rtl/ref.hxx>
31 
32 namespace vcl
33 {
34  using namespace ::com::sun::star::uno;
35  using namespace ::com::sun::star::awt;
36  using namespace ::com::sun::star::accessibility;
37 
38  namespace
39  {
40 #ifndef DISABLE_DYNLOADING
41  static oslModule s_hAccessibleImplementationModule = nullptr;
42 #endif
43 #if HAVE_FEATURE_DESKTOP
44  static GetSvtAccessibilityComponentFactory s_pAccessibleFactoryFunc = nullptr;
45 #endif
46  static ::rtl::Reference< IAccessibleFactory > s_pFactory;
47 
48 
49  //= AccessibleDummyFactory
50 
51  class AccessibleDummyFactory:
52  public IAccessibleFactory
53  {
54  public:
55  AccessibleDummyFactory();
56  AccessibleDummyFactory(const AccessibleDummyFactory&) = delete;
57  AccessibleDummyFactory& operator=(const AccessibleDummyFactory&) = delete;
58 
59  protected:
60  virtual ~AccessibleDummyFactory() override;
61 
62  public:
63  // IAccessibleFactory
65  createAccessibleTabListBox(
66  const css::uno::Reference< css::accessibility::XAccessible >& /*rxParent*/,
67  SvHeaderTabListBox& /*rBox*/
68  ) const override
69  {
70  return nullptr;
71  }
72 
73  virtual css::uno::Reference< css::accessibility::XAccessible >
74  createAccessibleTreeListBox(
75  SvTreeListBox& /*_rListBox*/,
76  const css::uno::Reference< css::accessibility::XAccessible >& /*_xParent*/
77  ) const override
78  {
79  return nullptr;
80  }
81 
83  createAccessibleBrowseBox(
84  const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
85  vcl::IAccessibleTableProvider& /*_rBrowseBox*/
86  ) const override
87  {
88  return nullptr;
89  }
90 
91  virtual table::IAccessibleTableControl*
92  createAccessibleTableControl(
93  const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
94  table::IAccessibleTable& /*_rTable*/
95  ) const override
96  {
97  return nullptr;
98  }
99 
100  virtual css::uno::Reference< css::accessibility::XAccessible >
101  createAccessibleIconChoiceCtrl(
102  SvtIconChoiceCtrl& /*_rIconCtrl*/,
103  const css::uno::Reference< css::accessibility::XAccessible >& /*_xParent*/
104  ) const override
105  {
106  return nullptr;
107  }
108 
109  virtual css::uno::Reference< css::accessibility::XAccessible >
110  createAccessibleTabBar(
111  TabBar& /*_rTabBar*/
112  ) const override
113  {
114  return nullptr;
115  }
116 
117  virtual css::uno::Reference< css::accessibility::XAccessibleContext >
118  createAccessibleTextWindowContext(
119  VCLXWindow* /*pVclXWindow*/, TextEngine& /*rEngine*/, TextView& /*rView*/
120  ) const override
121  {
122  return nullptr;
123  }
124 
125  virtual css::uno::Reference< css::accessibility::XAccessible >
126  createAccessibleBrowseBoxHeaderBar(
127  const css::uno::Reference< css::accessibility::XAccessible >& /*rxParent*/,
128  vcl::IAccessibleTableProvider& /*_rOwningTable*/,
129  vcl::AccessibleBrowseBoxObjType /*_eObjType*/
130  ) const override
131  {
132  return nullptr;
133  }
134 
135  virtual css::uno::Reference< css::accessibility::XAccessible >
136  createAccessibleBrowseBoxTableCell(
137  const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
138  vcl::IAccessibleTableProvider& /*_rBrowseBox*/,
139  const css::uno::Reference< css::awt::XWindow >& /*_xFocusWindow*/,
140  sal_Int32 /*_nRowId*/,
141  sal_uInt16 /*_nColId*/,
142  sal_Int32 /*_nOffset*/
143  ) const override
144  {
145  return nullptr;
146  }
147 
148  virtual css::uno::Reference< css::accessibility::XAccessible >
149  createAccessibleBrowseBoxHeaderCell(
150  sal_Int32 /*_nColumnRowId*/,
151  const css::uno::Reference< css::accessibility::XAccessible >& /*rxParent*/,
152  vcl::IAccessibleTableProvider& /*_rBrowseBox*/,
153  const css::uno::Reference< css::awt::XWindow >& /*_xFocusWindow*/,
154  vcl::AccessibleBrowseBoxObjType /*_eObjType*/
155  ) const override
156  {
157  return nullptr;
158  }
159 
160  virtual css::uno::Reference< css::accessibility::XAccessible >
161  createAccessibleCheckBoxCell(
162  const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
163  vcl::IAccessibleTableProvider& /*_rBrowseBox*/,
164  const css::uno::Reference< css::awt::XWindow >& /*_xFocusWindow*/,
165  sal_Int32 /*_nRowPos*/,
166  sal_uInt16 /*_nColPos*/,
167  const TriState& /*_eState*/,
168  bool /*_bIsTriState*/
169  ) const override
170  {
171  return nullptr;
172  }
173 
174  virtual css::uno::Reference< css::accessibility::XAccessible >
175  createEditBrowseBoxTableCellAccess(
176  const css::uno::Reference< css::accessibility::XAccessible >& /*_rxParent*/,
177  const css::uno::Reference< css::accessibility::XAccessible >& /*_rxControlAccessible*/,
178  const css::uno::Reference< css::awt::XWindow >& /*_rxFocusWindow*/,
179  vcl::IAccessibleTableProvider& /*_rBrowseBox*/,
180  sal_Int32 /*_nRowPos*/,
181  sal_uInt16 /*_nColPos*/
182  ) const override
183  {
184  return nullptr;
185  }
186  };
187 
188 
189  AccessibleDummyFactory::AccessibleDummyFactory()
190  {
191  }
192 
193 
194  AccessibleDummyFactory::~AccessibleDummyFactory()
195  {
196  }
197 
198  }
199 
200 
201  //= AccessibleFactoryAccess
202 
203 
205  :m_bInitialized( false )
206  {
207  }
208 
209 #if HAVE_FEATURE_DESKTOP
210 #ifndef DISABLE_DYNLOADING
211  extern "C" { static void thisModule() {} }
212 #else
213  extern "C" void* getSvtAccessibilityComponentFactory();
214 #endif
215 #endif // HAVE_FEATURE_DESKTOP
216 
218  {
219  if ( m_bInitialized )
220  return;
221 
222  ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
223 
224 #if HAVE_FEATURE_DESKTOP
225  // load the library implementing the factory
226  if (!s_pFactory)
227  {
228 #ifndef DISABLE_DYNLOADING
229  const OUString sModuleName( SVLIBRARY( "acc" ));
230  s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
231  if ( s_hAccessibleImplementationModule != nullptr )
232  {
233  const OUString sFactoryCreationFunc( "getSvtAccessibilityComponentFactory" );
234  s_pAccessibleFactoryFunc = reinterpret_cast<GetSvtAccessibilityComponentFactory>(
235  osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData ));
236 
237  }
238  OSL_ENSURE( s_pAccessibleFactoryFunc, "ac_registerClient: could not load the library, or not retrieve the needed symbol!" );
239 #else
240  s_pAccessibleFactoryFunc = getSvtAccessibilityComponentFactory;
241 #endif // DISABLE_DYNLOADING
242 
243  // get a factory instance
244  if ( s_pAccessibleFactoryFunc )
245  {
246  IAccessibleFactory* pFactory = static_cast< IAccessibleFactory* >( (*s_pAccessibleFactoryFunc)() );
247  if ( pFactory )
248  {
249  s_pFactory = pFactory;
250  pFactory->release();
251  }
252  }
253  }
254 #endif // HAVE_FEATURE_DESKTOP
255 
256  if (!s_pFactory)
257  // the attempt to load the lib, or to create the factory, failed
258  // -> fall back to a dummy factory
259  s_pFactory = new AccessibleDummyFactory;
260 
261  m_bInitialized = true;
262  }
263 
265  {
267  DBG_ASSERT( s_pFactory.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
268  return *s_pFactory;
269  }
270 
271 } // namespace vcl
272 
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This abstract class provides methods to implement an accessible table object.
#define DBG_ASSERT(sCon, aError)
interface for an implementation of a table control's Accessible component
interface for an implementation of a browse box's Accessible component
AccessibleBrowseBoxObjType
This enumeration contains a constant for each kind of accessible object of a BrowseBox.
#define SVLIBRARY(Base)
void *(* GetSvtAccessibilityComponentFactory)()
a function which is able to create a factory for the standard Accessible/Context components needed fo...
TriState
static void thisModule()
Definition: svapp.cxx:1428