Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <osl/diagnose.h>
30 : : #include <osl/mutex.hxx>
31 : : #include <cppuhelper/weak.hxx>
32 : : #include <cppuhelper/bootstrap.hxx>
33 : : #include <cppuhelper/component.hxx>
34 : : #include <cppuhelper/factory.hxx>
35 : : #include <cppuhelper/implbase3.hxx>
36 : : #include <cppuhelper/shlib.hxx>
37 : : #include <cppuhelper/typeprovider.hxx>
38 : : #include <rtl/instance.hxx>
39 : : #include <rtl/unload.h>
40 : :
41 : : #include "cppuhelper/propshlp.hxx"
42 : :
43 : : #include <com/sun/star/lang/XServiceInfo.hpp>
44 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
45 : : #include <com/sun/star/lang/XSingleComponentFactory.hpp>
46 : : #include <com/sun/star/lang/XInitialization.hpp>
47 : : #include <com/sun/star/loader/XImplementationLoader.hpp>
48 : : #include <com/sun/star/lang/XComponent.hpp>
49 : : #include <com/sun/star/lang/IllegalArgumentException.hpp>
50 : : #include <com/sun/star/uno/XUnloadingPreference.hpp>
51 : : #include "com/sun/star/beans/PropertyAttribute.hpp"
52 : :
53 : : #include <memory>
54 : :
55 : : #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
56 : :
57 : :
58 : : using namespace osl;
59 : : using namespace com::sun::star;
60 : : using namespace com::sun::star::uno;
61 : : using namespace com::sun::star::lang;
62 : : using namespace com::sun::star::loader;
63 : : using namespace com::sun::star::registry;
64 : :
65 : : using ::rtl::OUString;
66 : :
67 : : namespace cppu
68 : : {
69 : :
70 : : class OSingleFactoryHelper
71 : : : public XServiceInfo
72 : : , public XSingleServiceFactory
73 : : , public lang::XSingleComponentFactory
74 : : , public XUnloadingPreference
75 : : {
76 : : public:
77 : 30336 : OSingleFactoryHelper(
78 : : const Reference<XMultiServiceFactory > & rServiceManager,
79 : : const OUString & rImplementationName_,
80 : : ComponentInstantiation pCreateFunction_,
81 : : ComponentFactoryFunc fptr,
82 : : const Sequence< OUString > * pServiceNames_ )
83 : : SAL_THROW(())
84 : : : xSMgr( rServiceManager )
85 : : , pCreateFunction( pCreateFunction_ )
86 : : , m_fptr( fptr )
87 [ + - ]: 30336 : , aImplementationName( rImplementationName_ )
88 : : {
89 [ + + ]: 30336 : if( pServiceNames_ )
90 [ + - ]: 29922 : aServiceNames = *pServiceNames_;
91 : 30336 : }
92 : :
93 : : // old function, only for backward compatibility
94 : : OSingleFactoryHelper(
95 : : const Reference<XMultiServiceFactory > & rServiceManager,
96 : : const OUString & rImplementationName_ )
97 : : SAL_THROW(())
98 : : : xSMgr( rServiceManager )
99 : : , pCreateFunction( NULL )
100 : : , m_fptr( 0 )
101 : : , aImplementationName( rImplementationName_ )
102 : : {}
103 : :
104 : : virtual ~OSingleFactoryHelper();
105 : :
106 : : // XInterface
107 : : Any SAL_CALL queryInterface( const Type & rType )
108 : : throw(::com::sun::star::uno::RuntimeException);
109 : :
110 : : // XSingleServiceFactory
111 : : Reference<XInterface > SAL_CALL createInstance()
112 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
113 : : virtual Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments)
114 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
115 : : // XSingleComponentFactory
116 : : virtual Reference< XInterface > SAL_CALL createInstanceWithContext(
117 : : Reference< XComponentContext > const & xContext )
118 : : throw (Exception, RuntimeException);
119 : : virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
120 : : Sequence< Any > const & rArguments,
121 : : Reference< XComponentContext > const & xContext )
122 : : throw (Exception, RuntimeException);
123 : :
124 : : // XServiceInfo
125 : : OUString SAL_CALL getImplementationName()
126 : : throw(::com::sun::star::uno::RuntimeException);
127 : : sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
128 : : throw(::com::sun::star::uno::RuntimeException);
129 : : Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
130 : : throw(::com::sun::star::uno::RuntimeException);
131 : :
132 : : protected:
133 : : /**
134 : : * Create an instance specified by the factory. The one instance logic is implemented
135 : : * in the createInstance and createInstanceWithArguments methods.
136 : : * @return the newly created instance. Do not return a previous (one instance) instance.
137 : : */
138 : : virtual Reference<XInterface > createInstanceEveryTime(
139 : : Reference< XComponentContext > const & xContext )
140 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
141 : :
142 : : Reference<XMultiServiceFactory > xSMgr;
143 : : ComponentInstantiation pCreateFunction;
144 : : ComponentFactoryFunc m_fptr;
145 : : Sequence< OUString > aServiceNames;
146 : : OUString aImplementationName;
147 : : };
148 [ + - ]: 25411 : OSingleFactoryHelper::~OSingleFactoryHelper()
149 : : {
150 [ - + ]: 25411 : }
151 : :
152 : :
153 : : //-----------------------------------------------------------------------------
154 : 32639 : Any OSingleFactoryHelper::queryInterface( const Type & rType )
155 : : throw(::com::sun::star::uno::RuntimeException)
156 : : {
157 : : return ::cppu::queryInterface(
158 : : rType,
159 : : static_cast< XSingleComponentFactory * >( this ),
160 : : static_cast< XSingleServiceFactory * >( this ),
161 : : static_cast< XServiceInfo * >( this ) ,
162 : 32639 : static_cast< XUnloadingPreference * >( this ));
163 : : }
164 : :
165 : : // OSingleFactoryHelper
166 : 629073 : Reference<XInterface > OSingleFactoryHelper::createInstanceEveryTime(
167 : : Reference< XComponentContext > const & xContext )
168 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
169 : : {
170 [ + + ]: 629073 : if (m_fptr)
171 : : {
172 : 69728 : return (*m_fptr)( xContext );
173 : : }
174 [ + - ]: 559345 : else if( pCreateFunction )
175 : : {
176 [ + - ]: 559345 : if (xContext.is())
177 : : {
178 : : Reference< lang::XMultiServiceFactory > xContextMgr(
179 [ + - ][ + - ]: 559345 : xContext->getServiceManager(), UNO_QUERY );
[ + - ]
180 [ + - ]: 559345 : if (xContextMgr.is())
181 [ + - ][ - + ]: 559345 : return (*pCreateFunction)( xContextMgr );
182 : : }
183 : 0 : return (*pCreateFunction)( xSMgr );
184 : : }
185 : : else
186 : : {
187 : 629073 : return Reference< XInterface >();
188 : : }
189 : : }
190 : :
191 : : // XSingleServiceFactory
192 : 1725 : Reference<XInterface > OSingleFactoryHelper::createInstance()
193 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
194 : : {
195 [ + - ]: 1725 : return createInstanceWithContext( Reference< XComponentContext >() );
196 : : }
197 : :
198 : : // XSingleServiceFactory
199 : 0 : Reference<XInterface > OSingleFactoryHelper::createInstanceWithArguments(
200 : : const Sequence<Any>& Arguments )
201 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
202 : : {
203 : : return createInstanceWithArgumentsAndContext(
204 [ # # ]: 0 : Arguments, Reference< XComponentContext >() );
205 : : }
206 : :
207 : : // XSingleComponentFactory
208 : : //__________________________________________________________________________________________________
209 : 629477 : Reference< XInterface > OSingleFactoryHelper::createInstanceWithContext(
210 : : Reference< XComponentContext > const & xContext )
211 : : throw (Exception, RuntimeException)
212 : : {
213 : 629477 : return createInstanceEveryTime( xContext );
214 : : }
215 : : //__________________________________________________________________________________________________
216 : 29741 : Reference< XInterface > OSingleFactoryHelper::createInstanceWithArgumentsAndContext(
217 : : Sequence< Any > const & rArguments,
218 : : Reference< XComponentContext > const & xContext )
219 : : throw (Exception, RuntimeException)
220 : : {
221 [ + - ]: 29741 : Reference< XInterface > xRet( createInstanceWithContext( xContext ) );
222 : :
223 [ + - ]: 29741 : Reference< lang::XInitialization > xInit( xRet, UNO_QUERY );
224 : : // always call initialize, even if there are no arguments.
225 : : // #i63511# / 2006-03-27 / frank.schoenheit@sun.com
226 [ + + ]: 29741 : if (xInit.is())
227 : : {
228 [ + - ][ + + ]: 29732 : xInit->initialize( rArguments );
229 : : }
230 : : else
231 : : {
232 [ - + ]: 9 : if ( rArguments.getLength() )
233 : : {
234 : : // dispose the here created UNO object before throwing out exception
235 : : // to avoid risk of memory leaks #i113722#
236 [ # # ]: 0 : Reference<XComponent> xComp( xRet, UNO_QUERY );
237 [ # # ]: 0 : if (xComp.is())
238 [ # # ][ # # ]: 0 : xComp->dispose();
239 : :
240 : : throw lang::IllegalArgumentException(
241 : : OUString( RTL_CONSTASCII_USTRINGPARAM("cannot pass arguments to component => no XInitialization implemented!") ),
242 [ # # ][ # # ]: 0 : Reference< XInterface >(), 0 );
243 : : }
244 : : }
245 : :
246 : 29741 : return xRet;
247 : : }
248 : :
249 : : // XServiceInfo
250 : 7875 : OUString OSingleFactoryHelper::getImplementationName()
251 : : throw(::com::sun::star::uno::RuntimeException)
252 : : {
253 : 7875 : return aImplementationName;
254 : : }
255 : :
256 : : // XServiceInfo
257 : 0 : sal_Bool OSingleFactoryHelper::supportsService(
258 : : const OUString& ServiceName )
259 : : throw(::com::sun::star::uno::RuntimeException)
260 : : {
261 [ # # ]: 0 : Sequence< OUString > seqServices = getSupportedServiceNames();
262 : 0 : const OUString * pServices = seqServices.getConstArray();
263 [ # # ]: 0 : for( sal_Int32 i = 0; i < seqServices.getLength(); i++ )
264 [ # # ]: 0 : if( pServices[i] == ServiceName )
265 : 0 : return sal_True;
266 : :
267 [ # # ]: 0 : return sal_False;
268 : : }
269 : :
270 : : // XServiceInfo
271 : 7461 : Sequence< OUString > OSingleFactoryHelper::getSupportedServiceNames(void)
272 : : throw(::com::sun::star::uno::RuntimeException)
273 : : {
274 : 7461 : return aServiceNames;
275 : : }
276 : :
277 : 55747 : struct OFactoryComponentHelper_Mutex
278 : : {
279 : : Mutex aMutex;
280 : : };
281 : :
282 : : class OFactoryComponentHelper
283 : : : public OFactoryComponentHelper_Mutex
284 : : , public OComponentHelper
285 : : , public OSingleFactoryHelper
286 : : {
287 : : public:
288 : 414 : OFactoryComponentHelper(
289 : : const Reference<XMultiServiceFactory > & rServiceManager,
290 : : const OUString & rImplementationName_,
291 : : ComponentInstantiation pCreateFunction_,
292 : : ComponentFactoryFunc fptr,
293 : : const Sequence< OUString > * pServiceNames_,
294 : : sal_Bool bOneInstance_ = sal_False )
295 : : SAL_THROW(())
296 : : : OComponentHelper( aMutex )
297 : : , OSingleFactoryHelper( rServiceManager, rImplementationName_, pCreateFunction_, fptr, pServiceNames_ )
298 : : , bOneInstance( bOneInstance_ )
299 [ + - ][ + - ]: 414 : , pModuleCount(0)
300 : : {
301 : 414 : }
302 : :
303 : : // Used by the createXXXFactory functions. The argument pModCount is used to prevent the unloading of the module
304 : : // which contains pCreateFunction_
305 : 29922 : OFactoryComponentHelper(
306 : : const Reference<XMultiServiceFactory > & rServiceManager,
307 : : const OUString & rImplementationName_,
308 : : ComponentInstantiation pCreateFunction_,
309 : : ComponentFactoryFunc fptr,
310 : : const Sequence< OUString > * pServiceNames_,
311 : : rtl_ModuleCount * pModCount,
312 : : sal_Bool bOneInstance_ = sal_False )
313 : : SAL_THROW(())
314 : : : OComponentHelper( aMutex )
315 : : , OSingleFactoryHelper( rServiceManager, rImplementationName_, pCreateFunction_, fptr, pServiceNames_ )
316 : : , bOneInstance( bOneInstance_ )
317 [ + - ][ + - ]: 29922 : , pModuleCount(pModCount)
318 : : {
319 [ + + ]: 29922 : if(pModuleCount)
320 [ + - ]: 10892 : pModuleCount->acquire( pModuleCount);
321 : 29922 : }
322 : :
323 : : // old function, only for backward compatibility
324 : : OFactoryComponentHelper(
325 : : const Reference<XMultiServiceFactory > & rServiceManager,
326 : : const OUString & rImplementationName_,
327 : : sal_Bool bOneInstance_ = sal_False )
328 : : SAL_THROW(())
329 : : : OComponentHelper( aMutex )
330 : : , OSingleFactoryHelper( rServiceManager, rImplementationName_ )
331 : : , bOneInstance( bOneInstance_ )
332 : : , pModuleCount(0)
333 : : {
334 : : }
335 : :
336 : 50802 : ~OFactoryComponentHelper()
337 [ + - ][ + - ]: 25411 : {
338 [ + + ]: 25411 : if(pModuleCount)
339 [ + - ]: 7338 : pModuleCount->release( pModuleCount);
340 [ - + ]: 50802 : }
341 : :
342 : : // XInterface
343 : : Any SAL_CALL queryInterface( const Type & rType )
344 : : throw(::com::sun::star::uno::RuntimeException);
345 : 475761 : void SAL_CALL acquire() throw()
346 : 475761 : { OComponentHelper::acquire(); }
347 : 462168 : void SAL_CALL release() throw()
348 : 462168 : { OComponentHelper::release(); }
349 : :
350 : : // XSingleServiceFactory
351 : : Reference<XInterface > SAL_CALL createInstance()
352 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
353 : : Reference<XInterface > SAL_CALL createInstanceWithArguments( const Sequence<Any>& Arguments )
354 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
355 : : // XSingleComponentFactory
356 : : virtual Reference< XInterface > SAL_CALL createInstanceWithContext(
357 : : Reference< XComponentContext > const & xContext )
358 : : throw (Exception, RuntimeException);
359 : : virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
360 : : Sequence< Any > const & rArguments,
361 : : Reference< XComponentContext > const & xContext )
362 : : throw (Exception, RuntimeException);
363 : :
364 : : // XTypeProvider
365 : : virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
366 : : virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
367 : :
368 : : // XAggregation
369 : : Any SAL_CALL queryAggregation( const Type & rType )
370 : : throw(::com::sun::star::uno::RuntimeException);
371 : :
372 : : // XUnloadingPreference
373 : : virtual sal_Bool SAL_CALL releaseOnNotification()
374 : : throw(::com::sun::star::uno::RuntimeException);
375 : :
376 : : // OComponentHelper
377 : : void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
378 : :
379 : : private:
380 : : Reference<XInterface > xTheInstance;
381 : : sal_Bool bOneInstance;
382 : : rtl_ModuleCount * pModuleCount;
383 : : protected:
384 : : // needed for implementing XUnloadingPreference in inheriting classes
385 : 0 : sal_Bool isOneInstance() {return bOneInstance;}
386 : 0 : sal_Bool isInstance() {return xTheInstance.is();}
387 : : };
388 : :
389 : :
390 : 96903 : Any SAL_CALL OFactoryComponentHelper::queryInterface( const Type & rType )
391 : : throw(::com::sun::star::uno::RuntimeException)
392 : : {
393 [ - + ]: 96903 : if( rType == ::getCppuType( (Reference<XUnloadingPreference>*)0))
394 : : {
395 : : return makeAny(
396 : : Reference< XUnloadingPreference >(
397 [ # # ]: 0 : static_cast< XUnloadingPreference * >(this) ) );
398 : : }
399 : 96903 : return OComponentHelper::queryInterface( rType );
400 : : }
401 : :
402 : : // XAggregation
403 : 96903 : Any OFactoryComponentHelper::queryAggregation( const Type & rType )
404 : : throw(::com::sun::star::uno::RuntimeException)
405 : : {
406 [ + - ]: 96903 : Any aRet( OComponentHelper::queryAggregation( rType ) );
407 [ + + ][ + - ]: 96903 : return (aRet.hasValue() ? aRet : OSingleFactoryHelper::queryInterface( rType ));
408 : : }
409 : :
410 : : // XTypeProvider
411 : 0 : Sequence< Type > OFactoryComponentHelper::getTypes()
412 : : throw (::com::sun::star::uno::RuntimeException)
413 : : {
414 [ # # ]: 0 : Type ar[ 4 ];
415 [ # # ]: 0 : ar[ 0 ] = ::getCppuType( (const Reference< XSingleServiceFactory > *)0 );
416 [ # # ]: 0 : ar[ 1 ] = ::getCppuType( (const Reference< XServiceInfo > *)0 );
417 [ # # ]: 0 : ar[ 2 ] = ::getCppuType( (const Reference< XUnloadingPreference > *)0 );
418 : :
419 [ # # ]: 0 : if (m_fptr)
420 [ # # ]: 0 : ar[ 3 ] = ::getCppuType( (const Reference< XSingleComponentFactory > *)0 );
421 : :
422 [ # # ][ # # ]: 0 : return Sequence< Type >( ar, m_fptr ? 4 : 3 );
[ # # ][ # # ]
423 : : }
424 : :
425 : : namespace
426 : : {
427 : : class theOFactoryComponentHelperImplementationId :
428 : : public rtl::Static<OImplementationId, theOFactoryComponentHelperImplementationId>{};
429 : : }
430 : :
431 : 0 : Sequence< sal_Int8 > OFactoryComponentHelper::getImplementationId()
432 : : throw (::com::sun::star::uno::RuntimeException)
433 : : {
434 : 0 : return theOFactoryComponentHelperImplementationId::get().getImplementationId();
435 : : }
436 : :
437 : : // XSingleServiceFactory
438 : 1725 : Reference<XInterface > OFactoryComponentHelper::createInstance()
439 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
440 : : {
441 [ - + ]: 1725 : if( bOneInstance )
442 : : {
443 [ # # ]: 0 : if( !xTheInstance.is() )
444 : : {
445 [ # # ]: 0 : MutexGuard aGuard( aMutex );
446 [ # # ]: 0 : if( !xTheInstance.is() )
447 [ # # ][ # # ]: 0 : xTheInstance = OSingleFactoryHelper::createInstance();
[ # # ]
448 : : }
449 : 0 : return xTheInstance;
450 : : }
451 : 1725 : return OSingleFactoryHelper::createInstance();
452 : : }
453 : :
454 : 0 : Reference<XInterface > OFactoryComponentHelper::createInstanceWithArguments(
455 : : const Sequence<Any>& Arguments )
456 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
457 : : {
458 [ # # ]: 0 : if( bOneInstance )
459 : : {
460 [ # # ]: 0 : if( !xTheInstance.is() )
461 : : {
462 [ # # ]: 0 : MutexGuard aGuard( aMutex );
463 : : // OSL_ENSURE( !xTheInstance.is(), "### arguments will be ignored!" );
464 [ # # ]: 0 : if( !xTheInstance.is() )
465 [ # # ][ # # ]: 0 : xTheInstance = OSingleFactoryHelper::createInstanceWithArguments( Arguments );
[ # # ]
466 : : }
467 : 0 : return xTheInstance;
468 : : }
469 : 0 : return OSingleFactoryHelper::createInstanceWithArguments( Arguments );
470 : : }
471 : :
472 : : // XSingleComponentFactory
473 : : //__________________________________________________________________________________________________
474 : 1113657 : Reference< XInterface > OFactoryComponentHelper::createInstanceWithContext(
475 : : Reference< XComponentContext > const & xContext )
476 : : throw (Exception, RuntimeException)
477 : : {
478 [ + + ]: 1113657 : if( bOneInstance )
479 : : {
480 [ + + ]: 490025 : if( !xTheInstance.is() )
481 : : {
482 [ + - ]: 5845 : MutexGuard aGuard( aMutex );
483 : : // OSL_ENSURE( !xTheInstance.is(), "### context will be ignored!" );
484 [ + - ]: 5845 : if( !xTheInstance.is() )
485 [ + - ][ + - ]: 5845 : xTheInstance = OSingleFactoryHelper::createInstanceWithContext( xContext );
[ + - ]
486 : : }
487 : 490025 : return xTheInstance;
488 : : }
489 : 1113657 : return OSingleFactoryHelper::createInstanceWithContext( xContext );
490 : : }
491 : : //__________________________________________________________________________________________________
492 : 31199 : Reference< XInterface > OFactoryComponentHelper::createInstanceWithArgumentsAndContext(
493 : : Sequence< Any > const & rArguments,
494 : : Reference< XComponentContext > const & xContext )
495 : : throw (Exception, RuntimeException)
496 : : {
497 [ + + ]: 31199 : if( bOneInstance )
498 : : {
499 [ + + ]: 1752 : if( !xTheInstance.is() )
500 : : {
501 [ + - ]: 294 : MutexGuard aGuard( aMutex );
502 : : // OSL_ENSURE( !xTheInstance.is(), "### context and arguments will be ignored!" );
503 [ + - ]: 294 : if( !xTheInstance.is() )
504 [ + - ][ + - ]: 294 : xTheInstance = OSingleFactoryHelper::createInstanceWithArgumentsAndContext( rArguments, xContext );
[ + - ]
505 : : }
506 : 1752 : return xTheInstance;
507 : : }
508 : 31199 : return OSingleFactoryHelper::createInstanceWithArgumentsAndContext( rArguments, xContext );
509 : : }
510 : :
511 : :
512 : : // OComponentHelper
513 : 25411 : void OFactoryComponentHelper::dispose()
514 : : throw(::com::sun::star::uno::RuntimeException)
515 : : {
516 [ + - ]: 25411 : OComponentHelper::dispose();
517 : :
518 : 25411 : Reference<XInterface > x;
519 : : {
520 : : // do not delete in the guard section
521 [ + - ]: 25411 : MutexGuard aGuard( aMutex );
522 [ + - ]: 25411 : x = xTheInstance;
523 [ + - ][ + - ]: 25411 : xTheInstance = Reference<XInterface >();
524 : : }
525 : : // if it is a component call dispose at the component
526 [ + - ]: 25411 : Reference<XComponent > xComp( x, UNO_QUERY );
527 [ + + ]: 25411 : if( xComp.is() )
528 [ + - ][ + - ]: 25411 : xComp->dispose();
529 : 25411 : }
530 : :
531 : : // XUnloadingPreference
532 : : // This class is used for single factories, component factories and
533 : : // one-instance factories. Depending on the usage this function has
534 : : // to return different values.
535 : : // one-instance factory: sal_False
536 : : // single factory: sal_True
537 : : // component factory: sal_True
538 : 0 : sal_Bool SAL_CALL OFactoryComponentHelper::releaseOnNotification() throw(::com::sun::star::uno::RuntimeException)
539 : : {
540 [ # # ]: 0 : if( bOneInstance)
541 : 0 : return sal_False;
542 : 0 : return sal_True;
543 : : }
544 : :
545 [ + - ][ + - ]: 40 : class ORegistryFactoryHelper : public OFactoryComponentHelper,
[ - + ]
546 : : public OPropertySetHelper
547 : :
548 : : {
549 : : public:
550 : 414 : ORegistryFactoryHelper(
551 : : const Reference<XMultiServiceFactory > & rServiceManager,
552 : : const OUString & rImplementationName_,
553 : : const Reference<XRegistryKey > & xImplementationKey_,
554 : : sal_Bool bOneInstance_ = sal_False ) SAL_THROW(())
555 : : : OFactoryComponentHelper(
556 : : rServiceManager, rImplementationName_, 0, 0, 0, bOneInstance_ ),
557 : : OPropertySetHelper( OComponentHelper::rBHelper ),
558 [ + - ]: 414 : xImplementationKey( xImplementationKey_ )
559 : 414 : {}
560 : :
561 : : // XInterface
562 : : virtual Any SAL_CALL queryInterface( Type const & type )
563 : : throw (RuntimeException);
564 : : virtual void SAL_CALL acquire() throw ();
565 : : virtual void SAL_CALL release() throw ();
566 : : // XTypeProvider
567 : : virtual Sequence< Type > SAL_CALL getTypes()
568 : : throw (RuntimeException);
569 : : // XPropertySet
570 : : virtual Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
571 : : throw (RuntimeException);
572 : :
573 : : // OPropertySetHelper
574 : : virtual IPropertyArrayHelper & SAL_CALL getInfoHelper();
575 : : virtual sal_Bool SAL_CALL convertFastPropertyValue(
576 : : Any & rConvertedValue, Any & rOldValue,
577 : : sal_Int32 nHandle, Any const & rValue )
578 : : throw (lang::IllegalArgumentException);
579 : : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
580 : : sal_Int32 nHandle, Any const & rValue )
581 : : throw (Exception);
582 : : using OPropertySetHelper::getFastPropertyValue;
583 : : virtual void SAL_CALL getFastPropertyValue(
584 : : Any & rValue, sal_Int32 nHandle ) const;
585 : :
586 : : // OSingleFactoryHelper
587 : : Reference<XInterface > createInstanceEveryTime(
588 : : Reference< XComponentContext > const & xContext )
589 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
590 : :
591 : : // XSingleServiceFactory
592 : : Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments)
593 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
594 : : // XSingleComponentFactory
595 : : Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
596 : : Sequence< Any > const & rArguments,
597 : : Reference< XComponentContext > const & xContext )
598 : : throw (Exception, RuntimeException);
599 : :
600 : : // XServiceInfo
601 : : Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
602 : : throw(::com::sun::star::uno::RuntimeException);
603 : : // XUnloadingPreference
604 : : sal_Bool SAL_CALL releaseOnNotification()
605 : : throw( RuntimeException);
606 : :
607 : :
608 : : private:
609 : : Reference< XInterface > createModuleFactory()
610 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
611 : :
612 : : /** The registry key of the implementation section */
613 : : Reference<XRegistryKey > xImplementationKey;
614 : : /** The factory created with the loader. */
615 : : Reference<XSingleComponentFactory > xModuleFactory;
616 : : Reference<XSingleServiceFactory > xModuleFactoryDepr;
617 : : Reference< beans::XPropertySetInfo > m_xInfo;
618 : : ::std::auto_ptr< IPropertyArrayHelper > m_property_array_helper;
619 : : protected:
620 : : using OPropertySetHelper::getTypes;
621 : : };
622 : :
623 : : // XInterface
624 : : //______________________________________________________________________________
625 : 2943 : Any SAL_CALL ORegistryFactoryHelper::queryInterface(
626 : : Type const & type ) throw (RuntimeException)
627 : : {
628 [ + - ]: 2943 : Any ret( OFactoryComponentHelper::queryInterface( type ) );
629 [ + - ]: 2943 : if (ret.hasValue())
630 : 2943 : return ret;
631 : : else
632 [ # # ]: 2943 : return OPropertySetHelper::queryInterface( type );
633 : : }
634 : :
635 : : //______________________________________________________________________________
636 : 12246 : void ORegistryFactoryHelper::acquire() throw ()
637 : : {
638 : 12246 : OFactoryComponentHelper::acquire();
639 : 12246 : }
640 : :
641 : : //______________________________________________________________________________
642 : 10670 : void ORegistryFactoryHelper::release() throw ()
643 : : {
644 : 10670 : OFactoryComponentHelper::release();
645 : 10670 : }
646 : :
647 : : // XTypeProvider
648 : : //______________________________________________________________________________
649 : 0 : Sequence< Type > ORegistryFactoryHelper::getTypes() throw (RuntimeException)
650 : : {
651 : 0 : Sequence< Type > types( OFactoryComponentHelper::getTypes() );
652 : 0 : sal_Int32 pos = types.getLength();
653 [ # # ]: 0 : types.realloc( pos + 3 );
654 [ # # ]: 0 : Type * p = types.getArray();
655 : : p[ pos++ ] = ::getCppuType(
656 [ # # ]: 0 : reinterpret_cast< Reference< beans::XMultiPropertySet > const * >(0) );
657 : : p[ pos++ ] = ::getCppuType(
658 [ # # ]: 0 : reinterpret_cast< Reference< beans::XFastPropertySet > const * >(0) );
659 : : p[ pos++ ] = ::getCppuType(
660 [ # # ]: 0 : reinterpret_cast< Reference< beans::XPropertySet > const * >(0) );
661 : 0 : return types;
662 : : }
663 : :
664 : : // XPropertySet
665 : : //______________________________________________________________________________
666 : : Reference< beans::XPropertySetInfo >
667 : 0 : ORegistryFactoryHelper::getPropertySetInfo() throw (RuntimeException)
668 : : {
669 [ # # ]: 0 : ::osl::MutexGuard guard( aMutex );
670 [ # # ]: 0 : if (! m_xInfo.is())
671 [ # # ][ # # ]: 0 : m_xInfo = createPropertySetInfo( getInfoHelper() );
[ # # ]
672 [ # # ]: 0 : return m_xInfo;
673 : : }
674 : :
675 : : // OPropertySetHelper
676 : : //______________________________________________________________________________
677 : 0 : IPropertyArrayHelper & ORegistryFactoryHelper::getInfoHelper()
678 : : {
679 [ # # ]: 0 : ::osl::MutexGuard guard( aMutex );
680 [ # # ]: 0 : if (m_property_array_helper.get() == 0)
681 : : {
682 : : beans::Property prop(
683 : : OUSTR("ImplementationKey") /* name */,
684 : : 0 /* handle */,
685 [ # # ]: 0 : ::getCppuType( &xImplementationKey ),
686 : : beans::PropertyAttribute::READONLY |
687 [ # # ]: 0 : beans::PropertyAttribute::OPTIONAL );
688 : : m_property_array_helper.reset(
689 [ # # ]: 0 : new ::cppu::OPropertyArrayHelper( &prop, 1 ) );
690 : : }
691 [ # # ]: 0 : return *m_property_array_helper.get();
692 : : }
693 : :
694 : : //______________________________________________________________________________
695 : 0 : sal_Bool ORegistryFactoryHelper::convertFastPropertyValue(
696 : : Any &, Any &, sal_Int32, Any const & )
697 : : throw (lang::IllegalArgumentException)
698 : : {
699 : : OSL_FAIL( "unexpected!" );
700 : 0 : return false;
701 : : }
702 : :
703 : : //______________________________________________________________________________
704 : 0 : void ORegistryFactoryHelper::setFastPropertyValue_NoBroadcast(
705 : : sal_Int32, Any const & )
706 : : throw (Exception)
707 : : {
708 : : throw beans::PropertyVetoException(
709 : : OUSTR("unexpected: only readonly properties!"),
710 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >(this) );
[ # # ]
711 : : }
712 : :
713 : : //______________________________________________________________________________
714 : 0 : void ORegistryFactoryHelper::getFastPropertyValue(
715 : : Any & rValue, sal_Int32 nHandle ) const
716 : : {
717 [ # # ]: 0 : if (nHandle == 0)
718 : : {
719 : 0 : rValue <<= xImplementationKey;
720 : : }
721 : : else
722 : : {
723 : 0 : rValue.clear();
724 : : throw beans::UnknownPropertyException(
725 : : OUSTR("unknown property!"), static_cast< OWeakObject * >(
726 [ # # ][ # # ]: 0 : const_cast< ORegistryFactoryHelper * >(this) ) );
[ # # ]
727 : : }
728 : 0 : }
729 : :
730 : 404 : Reference<XInterface > ORegistryFactoryHelper::createInstanceEveryTime(
731 : : Reference< XComponentContext > const & xContext )
732 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
733 : : {
734 [ + - ][ + - ]: 404 : if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
[ + - ]
735 : : {
736 [ + - ]: 404 : Reference< XInterface > x( createModuleFactory() );
737 [ + - ]: 404 : if (x.is())
738 : : {
739 [ + - ]: 404 : MutexGuard aGuard( aMutex );
740 [ + - ][ + - ]: 404 : if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
[ + - ]
741 : : {
742 [ + - ]: 404 : xModuleFactory.set( x, UNO_QUERY );
743 [ + - ]: 404 : xModuleFactoryDepr.set( x, UNO_QUERY );
744 [ + - ]: 404 : }
745 : 404 : }
746 : : }
747 [ + - ]: 404 : if( xModuleFactory.is() )
748 : : {
749 : 404 : return xModuleFactory->createInstanceWithContext( xContext );
750 : : }
751 [ # # ]: 0 : else if( xModuleFactoryDepr.is() )
752 : : {
753 : 0 : return xModuleFactoryDepr->createInstance();
754 : : }
755 : :
756 : 404 : return Reference<XInterface >();
757 : : }
758 : :
759 : 0 : Reference<XInterface > SAL_CALL ORegistryFactoryHelper::createInstanceWithArguments(
760 : : const Sequence<Any>& Arguments )
761 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
762 : : {
763 [ # # ][ # # ]: 0 : if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
[ # # ]
764 : : {
765 [ # # ]: 0 : Reference< XInterface > x( createModuleFactory() );
766 [ # # ]: 0 : if (x.is())
767 : : {
768 [ # # ]: 0 : MutexGuard aGuard( aMutex );
769 [ # # ][ # # ]: 0 : if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
[ # # ]
770 : : {
771 [ # # ]: 0 : xModuleFactory.set( x, UNO_QUERY );
772 [ # # ]: 0 : xModuleFactoryDepr.set( x, UNO_QUERY );
773 [ # # ]: 0 : }
774 : 0 : }
775 : : }
776 [ # # ]: 0 : if( xModuleFactoryDepr.is() )
777 : : {
778 : 0 : return xModuleFactoryDepr->createInstanceWithArguments( Arguments );
779 : : }
780 [ # # ]: 0 : else if( xModuleFactory.is() )
781 : : {
782 : : #if OSL_DEBUG_LEVEL > 1
783 : : OSL_TRACE( "### no context ORegistryFactoryHelper::createInstanceWithArgumentsAndContext()!" );
784 : : #endif
785 [ # # ]: 0 : return xModuleFactory->createInstanceWithArgumentsAndContext( Arguments, Reference< XComponentContext >() );
786 : : }
787 : :
788 : 0 : return Reference<XInterface >();
789 : : }
790 : :
791 : 15 : Reference< XInterface > ORegistryFactoryHelper::createInstanceWithArgumentsAndContext(
792 : : Sequence< Any > const & rArguments,
793 : : Reference< XComponentContext > const & xContext )
794 : : throw (Exception, RuntimeException)
795 : : {
796 [ + + ][ + - ]: 15 : if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
[ + + ]
797 : : {
798 [ + - ]: 10 : Reference< XInterface > x( createModuleFactory() );
799 [ + - ]: 10 : if (x.is())
800 : : {
801 [ + - ]: 10 : MutexGuard aGuard( aMutex );
802 [ + - ][ + - ]: 10 : if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
[ + - ]
803 : : {
804 [ + - ]: 10 : xModuleFactory.set( x, UNO_QUERY );
805 [ + - ]: 10 : xModuleFactoryDepr.set( x, UNO_QUERY );
806 [ + - ]: 10 : }
807 : 10 : }
808 : : }
809 [ + - ]: 15 : if( xModuleFactory.is() )
810 : : {
811 : 15 : return xModuleFactory->createInstanceWithArgumentsAndContext( rArguments, xContext );
812 : : }
813 [ # # ]: 0 : else if( xModuleFactoryDepr.is() )
814 : : {
815 : : #if OSL_DEBUG_LEVEL > 1
816 : : if (xContext.is())
817 : : {
818 : : OSL_TRACE( "### ignoring context calling ORegistryFactoryHelper::createInstanceWithArgumentsAndContext()!" );
819 : : }
820 : : #endif
821 : 0 : return xModuleFactoryDepr->createInstanceWithArguments( rArguments );
822 : : }
823 : :
824 : 15 : return Reference<XInterface >();
825 : : }
826 : :
827 : :
828 : : // OSingleFactoryHelper
829 : 414 : Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
830 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
831 : : {
832 : 414 : OUString aActivatorUrl;
833 : 414 : OUString aActivatorName;
834 : 414 : OUString aLocation;
835 : :
836 [ + - ]: 414 : Reference<XRegistryKey > xActivatorKey = xImplementationKey->openKey(
837 [ + - ][ + - ]: 414 : OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) );
838 [ + - ][ + - ]: 414 : if( xActivatorKey.is() && xActivatorKey->getValueType() == RegistryValueType_ASCII )
[ + - ][ + - ]
[ + - ]
839 : : {
840 [ + - ][ + - ]: 414 : aActivatorUrl = xActivatorKey->getAsciiValue();
841 : :
842 : 414 : OUString tmpActivator(aActivatorUrl.getStr());
843 : 414 : sal_Int32 nIndex = 0;
844 : 414 : aActivatorName = tmpActivator.getToken(0, ':', nIndex );
845 : :
846 [ + - ]: 414 : Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey(
847 [ + - ][ + - ]: 414 : OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") ) );
848 [ + - ][ + - ]: 414 : if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII )
[ + - ][ + - ]
[ + - ]
849 [ + - ][ + - ]: 414 : aLocation = xLocationKey->getAsciiValue();
850 : : }
851 : : else
852 : : {
853 : : // old style"url"
854 : : // the location of the program code of the implementation
855 [ # # ]: 0 : Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey(
856 [ # # ][ # # ]: 0 : OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/URL") ) );
857 : : // is the the key of the right type ?
858 [ # # ][ # # ]: 0 : if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII )
[ # # ][ # # ]
[ # # ]
859 : : {
860 : : // one implementation found -> try to activate
861 [ # # ][ # # ]: 0 : aLocation = xLocationKey->getAsciiValue();
862 : :
863 : : // search protocol delimiter
864 : : sal_Int32 nPos = aLocation.indexOf(
865 [ # # ]: 0 : OUString( RTL_CONSTASCII_USTRINGPARAM("://") ) );
866 [ # # ]: 0 : if( nPos != -1 )
867 : : {
868 : 0 : aActivatorName = aLocation.copy( 0, nPos );
869 [ # # ]: 0 : if( aActivatorName.compareToAscii( "java" ) == 0 )
870 [ # # ]: 0 : aActivatorName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.Java") );
871 [ # # ]: 0 : else if( aActivatorName.compareToAscii( "module" ) == 0 )
872 [ # # ]: 0 : aActivatorName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary") );
873 : 0 : aLocation = aLocation.copy( nPos + 3 );
874 : : }
875 : 0 : }
876 : : }
877 : :
878 : 414 : Reference< XInterface > xFactory;
879 [ + - ]: 414 : if( !aActivatorName.isEmpty() )
880 : : {
881 [ + - ][ + - ]: 414 : Reference<XInterface > x = xSMgr->createInstance( aActivatorName );
882 [ + - ]: 414 : Reference<XImplementationLoader > xLoader( x, UNO_QUERY );
883 : 414 : Reference<XInterface > xMF;
884 [ + - ]: 414 : if (xLoader.is())
885 : : {
886 [ + - ][ + - ]: 414 : xFactory = xLoader->activate( aImplementationName, aActivatorUrl, aLocation, xImplementationKey );
[ + - ]
887 : 414 : }
888 : : }
889 : 414 : return xFactory;
890 : : }
891 : :
892 : : // XServiceInfo
893 : 414 : Sequence< OUString > ORegistryFactoryHelper::getSupportedServiceNames(void)
894 : : throw(::com::sun::star::uno::RuntimeException)
895 : : {
896 [ + - ]: 414 : MutexGuard aGuard( aMutex );
897 [ + - ]: 414 : if( aServiceNames.getLength() == 0 )
898 : : {
899 : : // not yet loaded
900 : : try
901 : : {
902 [ + - ]: 414 : Reference<XRegistryKey > xKey = xImplementationKey->openKey(
903 [ + - ][ + - ]: 414 : OUString( RTL_CONSTASCII_USTRINGPARAM("UNO/SERVICES") ) );
904 : :
905 [ + - ]: 414 : if (xKey.is())
906 : : {
907 : : // length of prefix. +1 for the '/' at the end
908 [ + - ][ + - ]: 414 : sal_Int32 nPrefixLen = xKey->getKeyName().getLength() + 1;
909 : :
910 : : // Full qualified names like "IMPLEMENTATIONS/TEST/UNO/SERVICES/com.sun.star..."
911 [ + - ][ + - ]: 414 : Sequence<OUString> seqKeys = xKey->getKeyNames();
912 [ + - ]: 414 : OUString* pKeys = seqKeys.getArray();
913 [ + + ]: 828 : for( sal_Int32 i = 0; i < seqKeys.getLength(); i++ )
914 : 414 : pKeys[i] = pKeys[i].copy(nPrefixLen);
915 : :
916 [ + - ][ + - ]: 414 : aServiceNames = seqKeys;
917 [ # # ]: 414 : }
918 : : }
919 [ # # ]: 0 : catch (InvalidRegistryException &)
920 : : {
921 : : }
922 : : }
923 [ + - ][ + - ]: 414 : return aServiceNames;
924 : : }
925 : :
926 : 0 : sal_Bool SAL_CALL ORegistryFactoryHelper::releaseOnNotification() throw(::com::sun::star::uno::RuntimeException)
927 : : {
928 : 0 : sal_Bool retVal= sal_True;
929 [ # # ][ # # ]: 0 : if( isOneInstance() && isInstance())
[ # # ]
930 : : {
931 : 0 : retVal= sal_False;
932 : : }
933 [ # # ]: 0 : else if( ! isOneInstance())
934 : : {
935 : : // try to delegate
936 [ # # ]: 0 : if( xModuleFactory.is())
937 : : {
938 [ # # ]: 0 : Reference<XUnloadingPreference> xunloading( xModuleFactory, UNO_QUERY);
939 [ # # ]: 0 : if( xunloading.is())
940 [ # # ][ # # ]: 0 : retVal= xunloading->releaseOnNotification();
941 : : }
942 [ # # ]: 0 : else if( xModuleFactoryDepr.is())
943 : : {
944 [ # # ]: 0 : Reference<XUnloadingPreference> xunloading( xModuleFactoryDepr, UNO_QUERY);
945 [ # # ]: 0 : if( xunloading.is())
946 [ # # ][ # # ]: 0 : retVal= xunloading->releaseOnNotification();
947 : : }
948 : : }
949 : 0 : return retVal;
950 : : }
951 : :
952 [ # # ]: 0 : class OFactoryProxyHelper : public WeakImplHelper3< XServiceInfo, XSingleServiceFactory,
953 : : XUnloadingPreference >
954 : : {
955 : : Reference<XSingleServiceFactory > xFactory;
956 : :
957 : : public:
958 : :
959 : 0 : OFactoryProxyHelper( const Reference<XSingleServiceFactory > & rFactory )
960 : : SAL_THROW(())
961 : 0 : : xFactory( rFactory )
962 : 0 : {}
963 : :
964 : : // XSingleServiceFactory
965 : : Reference<XInterface > SAL_CALL createInstance()
966 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
967 : : Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments)
968 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
969 : :
970 : : // XServiceInfo
971 : : OUString SAL_CALL getImplementationName()
972 : : throw(::com::sun::star::uno::RuntimeException);
973 : : sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
974 : : throw(::com::sun::star::uno::RuntimeException);
975 : : Sequence< OUString > SAL_CALL getSupportedServiceNames(void)
976 : : throw(::com::sun::star::uno::RuntimeException);
977 : : //XUnloadingPreference
978 : : sal_Bool SAL_CALL releaseOnNotification()
979 : : throw(::com::sun::star::uno::RuntimeException);
980 : :
981 : : };
982 : :
983 : : // XSingleServiceFactory
984 : 0 : Reference<XInterface > OFactoryProxyHelper::createInstance()
985 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
986 : : {
987 : 0 : return xFactory->createInstance();
988 : : }
989 : :
990 : : // XSingleServiceFactory
991 : 0 : Reference<XInterface > OFactoryProxyHelper::createInstanceWithArguments
992 : : (
993 : : const Sequence<Any>& Arguments
994 : : )
995 : : throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
996 : : {
997 : 0 : return xFactory->createInstanceWithArguments( Arguments );
998 : : }
999 : :
1000 : : // XServiceInfo
1001 : 0 : OUString OFactoryProxyHelper::getImplementationName()
1002 : : throw(::com::sun::star::uno::RuntimeException)
1003 : : {
1004 [ # # ]: 0 : Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY );
1005 [ # # ]: 0 : if( xInfo.is() )
1006 [ # # ][ # # ]: 0 : return xInfo->getImplementationName();
1007 : 0 : return OUString();
1008 : : }
1009 : :
1010 : : // XServiceInfo
1011 : 0 : sal_Bool OFactoryProxyHelper::supportsService(const OUString& ServiceName)
1012 : : throw(::com::sun::star::uno::RuntimeException)
1013 : : {
1014 [ # # ]: 0 : Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY );
1015 [ # # ]: 0 : if( xInfo.is() )
1016 [ # # ][ # # ]: 0 : return xInfo->supportsService( ServiceName );
1017 : 0 : return sal_False;
1018 : : }
1019 : :
1020 : : // XServiceInfo
1021 : 0 : Sequence< OUString > OFactoryProxyHelper::getSupportedServiceNames(void)
1022 : : throw(::com::sun::star::uno::RuntimeException)
1023 : : {
1024 [ # # ]: 0 : Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY );
1025 [ # # ]: 0 : if( xInfo.is() )
1026 [ # # ][ # # ]: 0 : return xInfo->getSupportedServiceNames();
1027 [ # # ]: 0 : return Sequence< OUString >();
1028 : : }
1029 : :
1030 : 0 : sal_Bool SAL_CALL OFactoryProxyHelper::releaseOnNotification() throw(::com::sun::star::uno::RuntimeException)
1031 : : {
1032 : :
1033 [ # # ]: 0 : Reference<XUnloadingPreference> pref( xFactory, UNO_QUERY);
1034 [ # # ]: 0 : if( pref.is())
1035 [ # # ][ # # ]: 0 : return pref->releaseOnNotification();
1036 : 0 : return sal_True;
1037 : : }
1038 : :
1039 : : // global function
1040 : 8898 : Reference<XSingleServiceFactory > SAL_CALL createSingleFactory(
1041 : : const Reference<XMultiServiceFactory > & rServiceManager,
1042 : : const OUString & rImplementationName,
1043 : : ComponentInstantiation pCreateFunction,
1044 : : const Sequence< OUString > & rServiceNames,
1045 : : rtl_ModuleCount *pModCount )
1046 : : SAL_THROW(())
1047 : : {
1048 : : return new OFactoryComponentHelper(
1049 [ + - ][ + - ]: 8898 : rServiceManager, rImplementationName, pCreateFunction, 0, &rServiceNames, pModCount, sal_False );
1050 : : }
1051 : :
1052 : : // global function
1053 : 0 : Reference<XSingleServiceFactory > SAL_CALL createFactoryProxy(
1054 : : SAL_UNUSED_PARAMETER const Reference<XMultiServiceFactory > &,
1055 : : const Reference<XSingleServiceFactory > & rFactory )
1056 : : SAL_THROW(())
1057 : : {
1058 [ # # ][ # # ]: 0 : return new OFactoryProxyHelper( rFactory );
1059 : : }
1060 : :
1061 : : // global function
1062 : 5562 : Reference<XSingleServiceFactory > SAL_CALL createOneInstanceFactory(
1063 : : const Reference<XMultiServiceFactory > & rServiceManager,
1064 : : const OUString & rImplementationName,
1065 : : ComponentInstantiation pCreateFunction,
1066 : : const Sequence< OUString > & rServiceNames,
1067 : : rtl_ModuleCount *pModCount )
1068 : : SAL_THROW(())
1069 : : {
1070 : : return new OFactoryComponentHelper(
1071 [ + - ][ + - ]: 5562 : rServiceManager, rImplementationName, pCreateFunction, 0, &rServiceNames, pModCount, sal_True );
1072 : : }
1073 : :
1074 : : // global function
1075 : 414 : Reference<XSingleServiceFactory > SAL_CALL createSingleRegistryFactory(
1076 : : const Reference<XMultiServiceFactory > & rServiceManager,
1077 : : const OUString & rImplementationName,
1078 : : const Reference<XRegistryKey > & rImplementationKey )
1079 : : SAL_THROW(())
1080 : : {
1081 : : return new ORegistryFactoryHelper(
1082 [ + - ][ + - ]: 414 : rServiceManager, rImplementationName, rImplementationKey, sal_False );
1083 : : }
1084 : :
1085 : : // global function
1086 : 0 : Reference<XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory(
1087 : : const Reference<XMultiServiceFactory > & rServiceManager,
1088 : : const OUString & rImplementationName,
1089 : : const Reference<XRegistryKey > & rImplementationKey )
1090 : : SAL_THROW(())
1091 : : {
1092 : : return new ORegistryFactoryHelper(
1093 [ # # ][ # # ]: 0 : rServiceManager, rImplementationName, rImplementationKey, sal_True );
1094 : : }
1095 : :
1096 : : //##################################################################################################
1097 : 15179 : Reference< lang::XSingleComponentFactory > SAL_CALL createSingleComponentFactory(
1098 : : ComponentFactoryFunc fptr,
1099 : : OUString const & rImplementationName,
1100 : : Sequence< OUString > const & rServiceNames,
1101 : : rtl_ModuleCount * pModCount)
1102 : : SAL_THROW(())
1103 : : {
1104 : : return new OFactoryComponentHelper(
1105 [ + - ][ + - ]: 15179 : Reference< XMultiServiceFactory >(), rImplementationName, 0, fptr, &rServiceNames, pModCount, sal_False );
[ + - ]
1106 : : }
1107 : :
1108 : 283 : Reference< lang::XSingleComponentFactory > SAL_CALL createOneInstanceComponentFactory(
1109 : : ComponentFactoryFunc fptr,
1110 : : OUString const & rImplementationName,
1111 : : Sequence< OUString > const & rServiceNames,
1112 : : rtl_ModuleCount * pModCount)
1113 : : SAL_THROW(())
1114 : : {
1115 : : return new OFactoryComponentHelper(
1116 [ + - ][ + - ]: 283 : Reference< XMultiServiceFactory >(), rImplementationName, 0, fptr, &rServiceNames, pModCount, sal_True );
[ + - ]
1117 : : }
1118 : :
1119 : : }
1120 : :
1121 : :
1122 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|