update emoji autocorrect entries from po-files
[LibreOffice.git] / toolkit / source / helper / accessibilityclient.cxx
blobecf3c3c624ba7bff71417f28779a8893c146ee1b
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 <sal/config.h>
24 #include <boost/noncopyable.hpp>
26 #include <toolkit/helper/accessiblefactory.hxx>
27 #include <osl/module.h>
28 #include <osl/diagnose.h>
29 #include <osl/mutex.hxx>
30 #include <tools/solar.h>
32 #include "helper/accessibilityclient.hxx"
34 namespace toolkit
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::accessibility;
39 namespace
41 #ifndef DISABLE_DYNLOADING
42 static oslModule s_hAccessibleImplementationModule = NULL;
43 #endif
44 #if HAVE_FEATURE_DESKTOP
45 static GetStandardAccComponentFactory s_pAccessibleFactoryFunc = NULL;
46 #endif
47 static ::rtl::Reference< IAccessibleFactory > s_pFactory;
51 //= AccessibleDummyFactory
53 class AccessibleDummyFactory:
54 public IAccessibleFactory, private boost::noncopyable
56 public:
57 AccessibleDummyFactory();
59 protected:
60 virtual ~AccessibleDummyFactory();
62 public:
63 // IAccessibleFactory
64 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
65 createAccessibleContext( VCLXButton* /*_pXWindow*/ ) SAL_OVERRIDE
67 return NULL;
69 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
70 createAccessibleContext( VCLXCheckBox* /*_pXWindow*/ ) SAL_OVERRIDE
72 return NULL;
74 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
75 createAccessibleContext( VCLXRadioButton* /*_pXWindow*/ ) SAL_OVERRIDE
77 return NULL;
79 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
80 createAccessibleContext( VCLXListBox* /*_pXWindow*/ ) SAL_OVERRIDE
82 return NULL;
84 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
85 createAccessibleContext( VCLXFixedHyperlink* /*_pXWindow*/ ) SAL_OVERRIDE
87 return NULL;
89 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
90 createAccessibleContext( VCLXFixedText* /*_pXWindow*/ ) SAL_OVERRIDE
92 return NULL;
94 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
95 createAccessibleContext( VCLXScrollBar* /*_pXWindow*/ ) SAL_OVERRIDE
97 return NULL;
99 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
100 createAccessibleContext( VCLXEdit* /*_pXWindow*/ ) SAL_OVERRIDE
102 return NULL;
104 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
105 createAccessibleContext( VCLXComboBox* /*_pXWindow*/ ) SAL_OVERRIDE
107 return NULL;
109 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
110 createAccessibleContext( VCLXToolBox* /*_pXWindow*/ ) SAL_OVERRIDE
112 return NULL;
114 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
115 createAccessibleContext( VCLXWindow* /*_pXWindow*/ ) SAL_OVERRIDE
117 return NULL;
119 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
120 createAccessible( Menu* /*_pMenu*/, bool /*_bIsMenuBar*/ ) SAL_OVERRIDE
122 return NULL;
127 AccessibleDummyFactory::AccessibleDummyFactory()
132 AccessibleDummyFactory::~AccessibleDummyFactory()
137 //= AccessibilityClient
140 AccessibilityClient::AccessibilityClient()
141 :m_bInitialized( false )
145 #if HAVE_FEATURE_DESKTOP
146 #ifndef DISABLE_DYNLOADING
147 extern "C" { static void SAL_CALL thisModule() {} }
148 #else
149 extern "C" void *getStandardAccessibleFactory();
150 #endif
151 #endif // HAVE_FEATURE_DESKTOP
153 void AccessibilityClient::ensureInitialized()
155 if ( m_bInitialized )
156 return;
158 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
160 #if HAVE_FEATURE_DESKTOP
161 // load the library implementing the factory
162 if ( !s_pFactory.get() )
164 #ifndef DISABLE_DYNLOADING
165 const OUString sModuleName( SVLIBRARY( "acc" ) );
166 s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
167 if ( s_hAccessibleImplementationModule != NULL )
169 const OUString sFactoryCreationFunc =
170 OUString("getStandardAccessibleFactory");
171 s_pAccessibleFactoryFunc = reinterpret_cast<GetStandardAccComponentFactory>(
172 osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData ));
175 OSL_ENSURE( s_pAccessibleFactoryFunc, "AccessibilityClient::ensureInitialized: could not load the library, or not retrieve the needed symbol!" );
176 #else
177 s_pAccessibleFactoryFunc = getStandardAccessibleFactory;
178 #endif // DISABLE_DYNLOADING
180 // get a factory instance
181 if ( s_pAccessibleFactoryFunc )
183 IAccessibleFactory* pFactory = static_cast< IAccessibleFactory* >( (*s_pAccessibleFactoryFunc)() );
184 OSL_ENSURE( pFactory, "AccessibilityClient::ensureInitialized: no factory provided by the A11Y lib!" );
185 if ( pFactory )
187 s_pFactory = pFactory;
188 pFactory->release();
192 #endif // HAVE_FEATURE_DESKTOP
194 if ( !s_pFactory.get() )
195 // the attempt to load the lib, or to create the factory, failed
196 // -> fall back to a dummy factory
197 s_pFactory = new AccessibleDummyFactory;
199 m_bInitialized = true;
202 IAccessibleFactory& AccessibilityClient::getFactory()
204 ensureInitialized();
205 OSL_ENSURE( s_pFactory.is(), "AccessibilityClient::getFactory: at least a dummy factory should have been created!" );
206 return *s_pFactory;
210 } // namespace toolkit
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */