1*5900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*5900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5900e8ecSAndrew Rist  * distributed with this work for additional information
6*5900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
9*5900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5900e8ecSAndrew Rist  *
11*5900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5900e8ecSAndrew Rist  *
13*5900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5900e8ecSAndrew Rist  * software distributed under the License is distributed on an
15*5900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
17*5900e8ecSAndrew Rist  * specific language governing permissions and limitations
18*5900e8ecSAndrew Rist  * under the License.
19*5900e8ecSAndrew Rist  *
20*5900e8ecSAndrew Rist  *************************************************************/
21*5900e8ecSAndrew Rist 
22*5900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir #include "svtaccessiblefactory.hxx"
27cdf0e10cSrcweir #include <osl/module.h>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // #define UNLOAD_ON_LAST_CLIENT_DYING
30cdf0e10cSrcweir     // this is not recommended currently. If enabled, the implementation will log
31cdf0e10cSrcweir     // the number of active clients, and unload the acc library when the last client
32cdf0e10cSrcweir     // goes away.
33cdf0e10cSrcweir     // Sounds like a good idea, unfortunately, there's no guarantee that all objects
34cdf0e10cSrcweir     // implemented in this library are already dead.
35cdf0e10cSrcweir     // Iow, just because an object implementing an XAccessible (implemented in this lib
36cdf0e10cSrcweir     // here) died, it's not said that everybody released all references to the
37cdf0e10cSrcweir     // XAccessibleContext used by this component, and implemented in the acc lib.
38cdf0e10cSrcweir     // So we cannot really unload the lib.
39cdf0e10cSrcweir     //
40cdf0e10cSrcweir     // Alternatively, if the lib would us own "usage counting", i.e. every component
41cdf0e10cSrcweir     // implemented therein would affect a static ref count, the acc lib could care
42cdf0e10cSrcweir     // for unloading itself.
43cdf0e10cSrcweir 
44cdf0e10cSrcweir //........................................................................
45cdf0e10cSrcweir namespace svt
46cdf0e10cSrcweir {
47cdf0e10cSrcweir //........................................................................
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     using namespace ::com::sun::star::uno;
50cdf0e10cSrcweir     using namespace ::com::sun::star::awt;
51cdf0e10cSrcweir     using namespace ::com::sun::star::accessibility;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir     namespace
54cdf0e10cSrcweir     {
55cdf0e10cSrcweir #ifdef UNLOAD_ON_LAST_CLIENT_DYING
56cdf0e10cSrcweir         static oslInterlockedCount                      s_nAccessibleFactoryAccesss = 0;
57cdf0e10cSrcweir #endif // UNLOAD_ON_LAST_CLIENT_DYING
58cdf0e10cSrcweir         static oslModule                                s_hAccessibleImplementationModule = NULL;
59cdf0e10cSrcweir         static GetSvtAccessibilityComponentFactory      s_pAccessibleFactoryFunc = NULL;
60cdf0e10cSrcweir         static ::rtl::Reference< IAccessibleFactory >   s_pFactory;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         //====================================================================
63cdf0e10cSrcweir         //= AccessibleDummyFactory
64cdf0e10cSrcweir         //====================================================================
65cdf0e10cSrcweir         class AccessibleDummyFactory : public IAccessibleFactory
66cdf0e10cSrcweir         {
67cdf0e10cSrcweir         public:
68cdf0e10cSrcweir             AccessibleDummyFactory();
69cdf0e10cSrcweir 
70cdf0e10cSrcweir         protected:
71cdf0e10cSrcweir             virtual ~AccessibleDummyFactory();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         private:
74cdf0e10cSrcweir             AccessibleDummyFactory( const AccessibleDummyFactory& );            // never implemented
75cdf0e10cSrcweir             AccessibleDummyFactory& operator=( const AccessibleDummyFactory& ); // never implemented
76cdf0e10cSrcweir 
77cdf0e10cSrcweir             oslInterlockedCount m_refCount;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir         public:
80cdf0e10cSrcweir             // IReference
81cdf0e10cSrcweir 	        virtual oslInterlockedCount SAL_CALL acquire();
82cdf0e10cSrcweir 	        virtual oslInterlockedCount SAL_CALL release();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir             // IAccessibleFactory
85cdf0e10cSrcweir             virtual IAccessibleTabListBox*
createAccessibleTabListBox(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,SvHeaderTabListBox &) const86cdf0e10cSrcweir                 createAccessibleTabListBox(
87cdf0e10cSrcweir 		            const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
88cdf0e10cSrcweir 		            SvHeaderTabListBox& /*rBox*/
89cdf0e10cSrcweir                 ) const
90cdf0e10cSrcweir             {
91cdf0e10cSrcweir                 return NULL;
92cdf0e10cSrcweir             }
93cdf0e10cSrcweir 
94cdf0e10cSrcweir             virtual IAccessibleBrowseBox*
createAccessibleBrowseBox(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,IAccessibleTableProvider &) const95cdf0e10cSrcweir                 createAccessibleBrowseBox(
96cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
97cdf0e10cSrcweir                     IAccessibleTableProvider& /*_rBrowseBox*/
98cdf0e10cSrcweir 		        ) const
99cdf0e10cSrcweir             {
100cdf0e10cSrcweir                 return NULL;
101cdf0e10cSrcweir             }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 			virtual table::IAccessibleTableControl*
createAccessibleTableControl(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,table::IAccessibleTable &) const104cdf0e10cSrcweir                 createAccessibleTableControl(
105cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
106cdf0e10cSrcweir                     table::IAccessibleTable& /*_rTable*/
107cdf0e10cSrcweir 		        ) const
108cdf0e10cSrcweir             {
109cdf0e10cSrcweir                 return NULL;
110cdf0e10cSrcweir             }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
createAccessibleIconChoiceCtrl(SvtIconChoiceCtrl &,const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &) const113cdf0e10cSrcweir 		        createAccessibleIconChoiceCtrl(
114cdf0e10cSrcweir                     SvtIconChoiceCtrl& /*_rIconCtrl*/,
115cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_xParent*/
116cdf0e10cSrcweir                 ) const
117cdf0e10cSrcweir             {
118cdf0e10cSrcweir                 return NULL;
119cdf0e10cSrcweir             }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
createAccessibleTabBar(TabBar &) const122cdf0e10cSrcweir 		        createAccessibleTabBar(
123cdf0e10cSrcweir                     TabBar& /*_rTabBar*/
124cdf0e10cSrcweir                 ) const
125cdf0e10cSrcweir             {
126cdf0e10cSrcweir                 return NULL;
127cdf0e10cSrcweir             }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
createAccessibleTextWindowContext(VCLXWindow *,TextEngine &,TextView &,bool) const130cdf0e10cSrcweir 		        createAccessibleTextWindowContext(
131cdf0e10cSrcweir                     VCLXWindow* /*pVclXWindow*/, TextEngine& /*rEngine*/, TextView& /*rView*/, bool /*bCompoundControlChild*/
132cdf0e10cSrcweir                 ) const
133cdf0e10cSrcweir             {
134cdf0e10cSrcweir                 return NULL;
135cdf0e10cSrcweir             }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
createAccessibleTreeListBox(SvTreeListBox &,const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &) const138cdf0e10cSrcweir                 createAccessibleTreeListBox(
139cdf0e10cSrcweir                     SvTreeListBox& /*_rListBox*/,
140cdf0e10cSrcweir 				    const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_xParent*/
141cdf0e10cSrcweir                 ) const
142cdf0e10cSrcweir             {
143cdf0e10cSrcweir                 return NULL;
144cdf0e10cSrcweir             }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
createAccessibleBrowseBoxHeaderBar(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,IAccessibleTableProvider &,AccessibleBrowseBoxObjType) const147cdf0e10cSrcweir                 createAccessibleBrowseBoxHeaderBar(
148cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
149cdf0e10cSrcweir                     IAccessibleTableProvider& /*_rOwningTable*/,
150cdf0e10cSrcweir                     AccessibleBrowseBoxObjType /*_eObjType*/
151cdf0e10cSrcweir                 ) const
152cdf0e10cSrcweir             {
153cdf0e10cSrcweir                 return NULL;
154cdf0e10cSrcweir             }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
createAccessibleBrowseBoxTableCell(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,IAccessibleTableProvider &,const::com::sun::star::uno::Reference<::com::sun::star::awt::XWindow> &,sal_Int32,sal_uInt16,sal_Int32) const157cdf0e10cSrcweir                 createAccessibleBrowseBoxTableCell(
158cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
159cdf0e10cSrcweir 				    IAccessibleTableProvider& /*_rBrowseBox*/,
160cdf0e10cSrcweir 				    const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
161cdf0e10cSrcweir 				    sal_Int32 /*_nRowId*/,
162cdf0e10cSrcweir 				    sal_uInt16 /*_nColId*/,
163cdf0e10cSrcweir                     sal_Int32 /*_nOffset*/
164cdf0e10cSrcweir                 ) const
165cdf0e10cSrcweir             {
166cdf0e10cSrcweir                 return NULL;
167cdf0e10cSrcweir             }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
createAccessibleBrowseBoxHeaderCell(sal_Int32,const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,IAccessibleTableProvider &,const::com::sun::star::uno::Reference<::com::sun::star::awt::XWindow> &,AccessibleBrowseBoxObjType) const170cdf0e10cSrcweir                 createAccessibleBrowseBoxHeaderCell(
171cdf0e10cSrcweir                     sal_Int32 /*_nColumnRowId*/,
172cdf0e10cSrcweir 				    const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*rxParent*/,
173cdf0e10cSrcweir 				    IAccessibleTableProvider& /*_rBrowseBox*/,
174cdf0e10cSrcweir 				    const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
175cdf0e10cSrcweir 				    AccessibleBrowseBoxObjType  /*_eObjType*/
176cdf0e10cSrcweir                 ) const
177cdf0e10cSrcweir             {
178cdf0e10cSrcweir                 return NULL;
179cdf0e10cSrcweir             }
180cdf0e10cSrcweir 
181cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
createAccessibleCheckBoxCell(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,IAccessibleTableProvider &,const::com::sun::star::uno::Reference<::com::sun::star::awt::XWindow> &,sal_Int32,sal_uInt16,const TriState &,sal_Bool,sal_Bool) const182cdf0e10cSrcweir                 createAccessibleCheckBoxCell(
183cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
184cdf0e10cSrcweir 				    IAccessibleTableProvider& /*_rBrowseBox*/,
185cdf0e10cSrcweir 				    const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_xFocusWindow*/,
186cdf0e10cSrcweir 				    sal_Int32 /*_nRowPos*/,
187cdf0e10cSrcweir 				    sal_uInt16 /*_nColPos*/,
188cdf0e10cSrcweir 				    const TriState& /*_eState*/,
189cdf0e10cSrcweir 				    sal_Bool /*_bEnabled*/,
190cdf0e10cSrcweir 				    sal_Bool /*_bIsTriState*/
191cdf0e10cSrcweir                 ) const
192cdf0e10cSrcweir             {
193cdf0e10cSrcweir                 return NULL;
194cdf0e10cSrcweir             }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
createEditBrowseBoxTableCellAccess(const::com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> &,const::com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> &,const::com::sun::star::uno::Reference<::com::sun::star::awt::XWindow> &,IAccessibleTableProvider &,sal_Int32,sal_uInt16) const197cdf0e10cSrcweir                 createEditBrowseBoxTableCellAccess(
198cdf0e10cSrcweir 			        const ::com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessible >& /*_rxParent*/,
199cdf0e10cSrcweir 			        const ::com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessible >& /*_rxControlAccessible*/,
200cdf0e10cSrcweir 			        const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& /*_rxFocusWindow*/,
201cdf0e10cSrcweir                     IAccessibleTableProvider& /*_rBrowseBox*/,
202cdf0e10cSrcweir 			        sal_Int32 /*_nRowPos*/,
203cdf0e10cSrcweir 			        sal_uInt16 /*_nColPos*/
204cdf0e10cSrcweir 		        ) const
205cdf0e10cSrcweir             {
206cdf0e10cSrcweir                 return NULL;
207cdf0e10cSrcweir             }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
createAccessibleToolPanelDeck(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,::svt::ToolPanelDeck &)210cdf0e10cSrcweir                 createAccessibleToolPanelDeck(
211cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*i_rAccessibleParent*/,
212cdf0e10cSrcweir                     ::svt::ToolPanelDeck& /*i_rPanelDeck*/
213cdf0e10cSrcweir                 )
214cdf0e10cSrcweir             {
215cdf0e10cSrcweir                 return NULL;
216cdf0e10cSrcweir             }
217cdf0e10cSrcweir             virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
createAccessibleToolPanelTabBar(const::com::sun::star::uno::Reference<::com::sun::star::accessibility::XAccessible> &,::svt::IToolPanelDeck &,::svt::PanelTabBar &)218cdf0e10cSrcweir                 createAccessibleToolPanelTabBar(
219cdf0e10cSrcweir                     const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& /*i_rAccessibleParent*/,
220cdf0e10cSrcweir                     ::svt::IToolPanelDeck& /*i_rPanelDeck*/,
221cdf0e10cSrcweir                     ::svt::PanelTabBar& /*i_rTabBar*/
222cdf0e10cSrcweir                 )
223cdf0e10cSrcweir             {
224cdf0e10cSrcweir                 return NULL;
225cdf0e10cSrcweir             }
226cdf0e10cSrcweir         };
227cdf0e10cSrcweir 
228cdf0e10cSrcweir         //----------------------------------------------------------------
AccessibleDummyFactory()229cdf0e10cSrcweir         AccessibleDummyFactory::AccessibleDummyFactory()
230cdf0e10cSrcweir         {
231cdf0e10cSrcweir         }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir         //----------------------------------------------------------------
~AccessibleDummyFactory()234cdf0e10cSrcweir         AccessibleDummyFactory::~AccessibleDummyFactory()
235cdf0e10cSrcweir         {
236cdf0e10cSrcweir         }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir         //----------------------------------------------------------------
acquire()239cdf0e10cSrcweir 	    oslInterlockedCount SAL_CALL AccessibleDummyFactory::acquire()
240cdf0e10cSrcweir         {
241cdf0e10cSrcweir             return osl_incrementInterlockedCount( &m_refCount );
242cdf0e10cSrcweir         }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 	    //----------------------------------------------------------------
release()245cdf0e10cSrcweir 	    oslInterlockedCount SAL_CALL AccessibleDummyFactory::release()
246cdf0e10cSrcweir         {
247cdf0e10cSrcweir             if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
248cdf0e10cSrcweir             {
249cdf0e10cSrcweir                 delete this;
250cdf0e10cSrcweir                 return 0;
251cdf0e10cSrcweir             }
252cdf0e10cSrcweir             return m_refCount;
253cdf0e10cSrcweir         }
254cdf0e10cSrcweir     }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     //====================================================================
257cdf0e10cSrcweir     //= AccessibleFactoryAccess
258cdf0e10cSrcweir     //====================================================================
259cdf0e10cSrcweir     //--------------------------------------------------------------------
AccessibleFactoryAccess()260cdf0e10cSrcweir     AccessibleFactoryAccess::AccessibleFactoryAccess()
261cdf0e10cSrcweir         :m_bInitialized( false )
262cdf0e10cSrcweir     {
263cdf0e10cSrcweir     }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     //--------------------------------------------------------------------
thisModule()266cdf0e10cSrcweir     extern "C" { static void SAL_CALL thisModule() {} }
267cdf0e10cSrcweir 
ensureInitialized()268cdf0e10cSrcweir     void AccessibleFactoryAccess::ensureInitialized()
269cdf0e10cSrcweir     {
270cdf0e10cSrcweir         if ( m_bInitialized )
271cdf0e10cSrcweir             return;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
274cdf0e10cSrcweir 
275cdf0e10cSrcweir #ifdef UNLOAD_ON_LAST_CLIENT_DYING
276cdf0e10cSrcweir         if ( 1 == osl_incrementInterlockedCount( &s_nAccessibleFactoryAccesss ) )
277cdf0e10cSrcweir         {   // the first client
278cdf0e10cSrcweir #endif // UNLOAD_ON_LAST_CLIENT_DYING
279cdf0e10cSrcweir             // load the library implementing the factory
280cdf0e10cSrcweir             if ( !s_pFactory.get() )
281cdf0e10cSrcweir             {
282cdf0e10cSrcweir                 const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii(
283cdf0e10cSrcweir                     SVLIBRARY( "acc" )
284cdf0e10cSrcweir                 );
285cdf0e10cSrcweir                 s_hAccessibleImplementationModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, 0 );
286cdf0e10cSrcweir                 if ( s_hAccessibleImplementationModule != NULL )
287cdf0e10cSrcweir                 {
288cdf0e10cSrcweir                     const ::rtl::OUString sFactoryCreationFunc =
289cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii( "getSvtAccessibilityComponentFactory" );
290cdf0e10cSrcweir                     s_pAccessibleFactoryFunc = (GetSvtAccessibilityComponentFactory)
291cdf0e10cSrcweir                         osl_getFunctionSymbol( s_hAccessibleImplementationModule, sFactoryCreationFunc.pData );
292cdf0e10cSrcweir 
293cdf0e10cSrcweir                 }
294cdf0e10cSrcweir                 OSL_ENSURE( s_pAccessibleFactoryFunc, "ac_registerClient: could not load the library, or not retrieve the needed symbol!" );
295cdf0e10cSrcweir 
296cdf0e10cSrcweir                 // get a factory instance
297cdf0e10cSrcweir                 if ( s_pAccessibleFactoryFunc )
298cdf0e10cSrcweir                 {
299cdf0e10cSrcweir                     IAccessibleFactory* pFactory = static_cast< IAccessibleFactory* >( (*s_pAccessibleFactoryFunc)() );
300cdf0e10cSrcweir                     if ( pFactory )
301cdf0e10cSrcweir                     {
302cdf0e10cSrcweir                         s_pFactory = pFactory;
303cdf0e10cSrcweir                         pFactory->release();
304cdf0e10cSrcweir                     }
305cdf0e10cSrcweir                 }
306cdf0e10cSrcweir             }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir             if ( !s_pFactory.get() )
309cdf0e10cSrcweir                 // the attempt to load the lib, or to create the factory, failed
310cdf0e10cSrcweir                 // -> fall back to a dummy factory
311cdf0e10cSrcweir                 s_pFactory = new AccessibleDummyFactory;
312cdf0e10cSrcweir #ifdef UNLOAD_ON_LAST_CLIENT_DYING
313cdf0e10cSrcweir         }
314cdf0e10cSrcweir #endif
315cdf0e10cSrcweir 
316cdf0e10cSrcweir         m_bInitialized = true;
317cdf0e10cSrcweir     }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     //--------------------------------------------------------------------
~AccessibleFactoryAccess()320cdf0e10cSrcweir     AccessibleFactoryAccess::~AccessibleFactoryAccess()
321cdf0e10cSrcweir     {
322cdf0e10cSrcweir         if ( m_bInitialized )
323cdf0e10cSrcweir         {
324cdf0e10cSrcweir             ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
325cdf0e10cSrcweir 
326cdf0e10cSrcweir #ifdef UNLOAD_ON_LAST_CLIENT_DYING
327cdf0e10cSrcweir             if( 0 == osl_decrementInterlockedCount( &s_nAccessibleFactoryAccesss ) )
328cdf0e10cSrcweir             {
329cdf0e10cSrcweir                 s_pFactory = NULL;
330cdf0e10cSrcweir                 s_pAccessibleFactoryFunc = NULL;
331cdf0e10cSrcweir                 if ( s_hAccessibleImplementationModule )
332cdf0e10cSrcweir                 {
333cdf0e10cSrcweir                     osl_unloadModule( s_hAccessibleImplementationModule );
334cdf0e10cSrcweir                     s_hAccessibleImplementationModule = NULL;
335cdf0e10cSrcweir                 }
336cdf0e10cSrcweir             }
337cdf0e10cSrcweir #endif // UNLOAD_ON_LAST_CLIENT_DYING
338cdf0e10cSrcweir         }
339cdf0e10cSrcweir     }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     //--------------------------------------------------------------------
getFactory()342cdf0e10cSrcweir     IAccessibleFactory& AccessibleFactoryAccess::getFactory()
343cdf0e10cSrcweir     {
344cdf0e10cSrcweir         ensureInitialized();
345cdf0e10cSrcweir         DBG_ASSERT( s_pFactory.is(), "AccessibleFactoryAccess::getFactory: at least a dummy factory should have been created!" );
346cdf0e10cSrcweir         return *s_pFactory;
347cdf0e10cSrcweir     }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir //........................................................................
350cdf0e10cSrcweir }   // namespace svt
351cdf0e10cSrcweir //........................................................................
352