Bump version to 5.0-14
[LibreOffice.git] / svtools / source / misc / svtaccessiblefactory.cxx
blob4c6cdf7def9d1f6035273f93d08ce92d12cf6f52
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_features.h>
22 #include "svtaccessiblefactory.hxx"
24 #include <boost/noncopyable.hpp>
25 #include <osl/module.h>
27 namespace svt
29 using namespace ::com::sun::star::uno;
30 using namespace ::com::sun::star::awt;
31 using namespace ::com::sun::star::accessibility;
33 namespace
35 #ifndef DISABLE_DYNLOADING
36 static oslModule s_hAccessibleImplementationModule = NULL;
37 #endif
38 #if HAVE_FEATURE_DESKTOP
39 static GetSvtAccessibilityComponentFactory s_pAccessibleFactoryFunc = NULL;
40 #endif
41 static ::rtl::Reference< IAccessibleFactory > s_pFactory;
44 //= AccessibleDummyFactory
46 class AccessibleDummyFactory:
47 public IAccessibleFactory, private boost::noncopyable
49 public:
50 AccessibleDummyFactory();
52 protected:
53 virtual ~AccessibleDummyFactory();
55 public:
56 // IAccessibleFactory
57 virtual IAccessibleTabListBox*
58 createAccessibleTabListBox(
59 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
60 SvHeaderTabListBox& /*rBox*/
61 ) const SAL_OVERRIDE
63 return NULL;
66 virtual IAccessibleBrowseBox*
67 createAccessibleBrowseBox(
68 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
69 IAccessibleTableProvider& /*_rBrowseBox*/
70 ) const SAL_OVERRIDE
72 return NULL;
75 virtual table::IAccessibleTableControl*
76 createAccessibleTableControl(
77 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
78 table::IAccessibleTable& /*_rTable*/
79 ) const SAL_OVERRIDE
81 return NULL;
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*/
88 ) const SAL_OVERRIDE
90 return NULL;
93 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
94 createAccessibleTabBar(
95 TabBar& /*_rTabBar*/
96 ) const SAL_OVERRIDE
98 return NULL;
101 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
102 createAccessibleTextWindowContext(
103 VCLXWindow* /*pVclXWindow*/, TextEngine& /*rEngine*/, TextView& /*rView*/
104 ) const SAL_OVERRIDE
106 return NULL;
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*/
113 ) const SAL_OVERRIDE
115 return NULL;
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*/
123 ) const SAL_OVERRIDE
125 return NULL;
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*/
136 ) const SAL_OVERRIDE
138 return NULL;
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*/
148 ) const SAL_OVERRIDE
150 return NULL;
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*/
162 ) const SAL_OVERRIDE
164 return NULL;
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*/
175 ) const SAL_OVERRIDE
177 return NULL;
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*/
184 ) SAL_OVERRIDE
186 return NULL;
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*/
193 ) SAL_OVERRIDE
195 return NULL;
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() {} }
223 #else
224 extern "C" void* getSvtAccessibilityComponentFactory();
225 #endif
226 #endif // HAVE_FEATURE_DESKTOP
228 void AccessibleFactoryAccess::ensureInitialized()
230 if ( m_bInitialized )
231 return;
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!" );
250 #else
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)() );
258 if ( pFactory )
260 s_pFactory = pFactory;
261 pFactory->release();
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()
277 ensureInitialized();
278 DBG_ASSERT( s_pFactory.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
279 return *s_pFactory;
283 } // namespace svt
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */