LibreOffice Module cppuhelper (master) 1
factory.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 <sal/log.hxx>
21#include <osl/diagnose.h>
22#include <osl/mutex.hxx>
24#include <cppuhelper/weak.hxx>
30#include <rtl/unload.h>
31
33#include <o3tl/string_view.hxx>
34
35#include <com/sun/star/lang/XServiceInfo.hpp>
36#include <com/sun/star/lang/XSingleServiceFactory.hpp>
37#include <com/sun/star/lang/XSingleComponentFactory.hpp>
38#include <com/sun/star/lang/XInitialization.hpp>
39#include <com/sun/star/lang/XMultiServiceFactory.hpp>
40#include <com/sun/star/loader/XImplementationLoader.hpp>
41#include <com/sun/star/lang/XComponent.hpp>
42#include <com/sun/star/lang/IllegalArgumentException.hpp>
43#include <com/sun/star/uno/XUnloadingPreference.hpp>
44#include <com/sun/star/beans/PropertyAttribute.hpp>
45
46#include <memory>
47#include <utility>
48
49
50using namespace osl;
51using namespace com::sun::star;
52using namespace com::sun::star::uno;
53using namespace com::sun::star::lang;
54using namespace com::sun::star::loader;
55using namespace com::sun::star::registry;
56
57namespace cppu
58{
59
60namespace {
61
62class OFactoryComponentHelper
63 : public cppu::BaseMutex
64 , public WeakComponentImplHelper<
65 XServiceInfo,
66 XSingleServiceFactory,
67 lang::XSingleComponentFactory,
68 XUnloadingPreference>
69{
70public:
71 OFactoryComponentHelper(
72 const Reference<XMultiServiceFactory > & rServiceManager,
73 OUString aImplementationName_,
74 ComponentInstantiation pCreateFunction_,
75 ComponentFactoryFunc fptr,
76 const Sequence< OUString > * pServiceNames_,
77 bool bOneInstance_ )
78 : WeakComponentImplHelper( m_aMutex )
79 , bOneInstance( bOneInstance_ )
80 , xSMgr( rServiceManager )
81 , pCreateFunction( pCreateFunction_ )
82 , m_fptr( fptr )
83 , aImplementationName(std::move( aImplementationName_ ))
84 {
85 if( pServiceNames_ )
86 aServiceNames = *pServiceNames_;
87 }
88
89 // XSingleServiceFactory
90 Reference<XInterface > SAL_CALL createInstance() override;
91 Reference<XInterface > SAL_CALL createInstanceWithArguments( const Sequence<Any>& Arguments ) override;
92 // XSingleComponentFactory
93 virtual Reference< XInterface > SAL_CALL createInstanceWithContext(
94 Reference< XComponentContext > const & xContext ) override;
95 virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
96 Sequence< Any > const & rArguments,
97 Reference< XComponentContext > const & xContext ) override;
98
99 // XServiceInfo
100 OUString SAL_CALL getImplementationName() override;
101 sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
103
104 // XTypeProvider
105 virtual Sequence< Type > SAL_CALL getTypes() override;
106
107 // XUnloadingPreference
108 virtual sal_Bool SAL_CALL releaseOnNotification() override;
109
110 // WeakComponentImplHelper
111 void SAL_CALL disposing() override;
112
113private:
114 css::uno::Reference<css::uno::XInterface> createInstanceWithArgumentsEveryTime(
115 css::uno::Sequence<css::uno::Any> const & rArguments,
116 css::uno::Reference<css::uno::XComponentContext> const & xContext);
117
120protected:
121 // needed for implementing XUnloadingPreference in inheriting classes
122 bool isOneInstance() const {return bOneInstance;}
123 bool isInstance() const {return xTheInstance.is();}
124
132 virtual Reference<XInterface > createInstanceEveryTime(
133 Reference< XComponentContext > const & xContext );
134
136 ComponentInstantiation pCreateFunction;
137 ComponentFactoryFunc m_fptr;
140};
141
142}
143
144// XTypeProvider
145Sequence< Type > OFactoryComponentHelper::getTypes()
146{
147 Type ar[ 4 ];
151
152 if (m_fptr)
154
155 return Sequence< Type >( ar, m_fptr ? 4 : 3 );
156}
157
158// OFactoryComponentHelper
159Reference<XInterface > OFactoryComponentHelper::createInstanceEveryTime(
160 Reference< XComponentContext > const & xContext )
161{
162 if (m_fptr)
163 {
164 return (*m_fptr)( xContext );
165 }
166 if( pCreateFunction )
167 {
168 if (xContext.is())
169 {
171 xContext->getServiceManager(), UNO_QUERY );
172 if (xContextMgr.is())
173 return (*pCreateFunction)( xContextMgr );
174 }
175 return (*pCreateFunction)( xSMgr );
176 }
178}
179
180// XSingleServiceFactory
181Reference<XInterface > OFactoryComponentHelper::createInstance()
182{
183 if( bOneInstance )
184 {
185 if( !xTheInstance.is() )
186 {
187 MutexGuard aGuard( m_aMutex );
188 if( !xTheInstance.is() )
189 xTheInstance = createInstanceEveryTime( Reference< XComponentContext >() );
190 }
191 return xTheInstance;
192 }
193 return createInstanceEveryTime( Reference< XComponentContext >() );
194}
195
196Reference<XInterface > OFactoryComponentHelper::createInstanceWithArguments(
197 const Sequence<Any>& Arguments )
198{
199 if( bOneInstance )
200 {
201 if( !xTheInstance.is() )
202 {
203 MutexGuard aGuard( m_aMutex );
204// OSL_ENSURE( !xTheInstance.is(), "### arguments will be ignored!" );
205 if( !xTheInstance.is() )
206 xTheInstance = createInstanceWithArgumentsEveryTime(
207 Arguments, Reference< XComponentContext >() );
208 }
209 return xTheInstance;
210 }
211 return createInstanceWithArgumentsEveryTime( Arguments, Reference< XComponentContext >() );
212}
213
214// XSingleComponentFactory
215
216Reference< XInterface > OFactoryComponentHelper::createInstanceWithContext(
217 Reference< XComponentContext > const & xContext )
218{
219 if( bOneInstance )
220 {
221 if( !xTheInstance.is() )
222 {
223 MutexGuard aGuard( m_aMutex );
224// OSL_ENSURE( !xTheInstance.is(), "### context will be ignored!" );
225 if( !xTheInstance.is() )
226 xTheInstance = createInstanceEveryTime( xContext );
227 }
228 return xTheInstance;
229 }
230 return createInstanceEveryTime( xContext );
231}
232
233Reference< XInterface > OFactoryComponentHelper::createInstanceWithArgumentsAndContext(
234 Sequence< Any > const & rArguments,
235 Reference< XComponentContext > const & xContext )
236{
237 if( bOneInstance )
238 {
239 if( !xTheInstance.is() )
240 {
241 MutexGuard aGuard( m_aMutex );
242// OSL_ENSURE( !xTheInstance.is(), "### context and arguments will be ignored!" );
243 if( !xTheInstance.is() )
244 xTheInstance = createInstanceWithArgumentsEveryTime( rArguments, xContext );
245 }
246 return xTheInstance;
247 }
248 return createInstanceWithArgumentsEveryTime( rArguments, xContext );
249}
250
251css::uno::Reference<css::uno::XInterface>
252OFactoryComponentHelper::createInstanceWithArgumentsEveryTime(
253 css::uno::Sequence<css::uno::Any> const & rArguments,
254 css::uno::Reference<css::uno::XComponentContext> const & xContext)
255{
256 Reference< XInterface > xRet( createInstanceEveryTime( xContext ) );
257
258 Reference< lang::XInitialization > xInit( xRet, UNO_QUERY );
259 // always call initialize, even if there are no arguments. #i63511#
260 if (xInit.is())
261 {
262 xInit->initialize( rArguments );
263 }
264 else
265 {
266 if ( rArguments.hasElements() )
267 {
268 // dispose the here created UNO object before throwing out exception
269 // to avoid risk of memory leaks #i113722#
270 Reference<XComponent> xComp( xRet, UNO_QUERY );
271 if (xComp.is())
272 xComp->dispose();
273
274 throw lang::IllegalArgumentException(
275 "cannot pass arguments to component => no XInitialization implemented!",
277 }
278 }
279
280 return xRet;
281}
282
283
284// WeakComponentImplHelper
285void OFactoryComponentHelper::disposing()
286{
288 {
289 // do not delete in the guard section
290 MutexGuard aGuard( m_aMutex );
291 x = xTheInstance;
292 xTheInstance.clear();
293 }
294 // if it is a component call dispose at the component
295 Reference<XComponent > xComp( x, UNO_QUERY );
296 if( xComp.is() )
297 xComp->dispose();
298}
299
300// XServiceInfo
301OUString OFactoryComponentHelper::getImplementationName()
302{
303 return aImplementationName;
304}
305
306// XServiceInfo
308 const OUString& ServiceName )
309{
310 return cppu::supportsService(this, ServiceName);
311}
312
313// XServiceInfo
314Sequence< OUString > OFactoryComponentHelper::getSupportedServiceNames()
315{
316 return aServiceNames;
317}
318
319// XUnloadingPreference
320// This class is used for single factories, component factories and
321// one-instance factories. Depending on the usage this function has
322// to return different values.
323// one-instance factory: sal_False
324// single factory: sal_True
325// component factory: sal_True
326sal_Bool SAL_CALL OFactoryComponentHelper::releaseOnNotification()
327{
328 if( bOneInstance)
329 return false;
330 return true;
331}
332
333namespace {
334
335class ORegistryFactoryHelper : public OFactoryComponentHelper,
336 public OPropertySetHelper
337
338{
339public:
340 ORegistryFactoryHelper(
341 const Reference<XMultiServiceFactory > & rServiceManager,
342 const OUString & rImplementationName_,
343 const Reference<XRegistryKey > & xImplementationKey_,
344 bool bOneInstance_ )
345 : OFactoryComponentHelper(
346 rServiceManager, rImplementationName_, nullptr, nullptr, nullptr, bOneInstance_ ),
347 OPropertySetHelper( WeakComponentImplHelper::rBHelper ),
348 xImplementationKey( xImplementationKey_ )
349 {}
350
351 // XInterface
352 virtual Any SAL_CALL queryInterface( Type const & type ) override;
353 virtual void SAL_CALL acquire() noexcept override;
354 virtual void SAL_CALL release() noexcept override;
355 // XTypeProvider
356 virtual Sequence< Type > SAL_CALL getTypes() override;
357 // XPropertySet
358 virtual Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
359
360 // OPropertySetHelper
361 virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
362 virtual sal_Bool SAL_CALL convertFastPropertyValue(
363 Any & rConvertedValue, Any & rOldValue,
364 sal_Int32 nHandle, Any const & rValue ) override;
365 virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
366 sal_Int32 nHandle, Any const & rValue ) override;
367 using OPropertySetHelper::getFastPropertyValue;
368 virtual void SAL_CALL getFastPropertyValue(
369 Any & rValue, sal_Int32 nHandle ) const override;
370
371 // OFactoryComponentHelper
372 Reference<XInterface > createInstanceEveryTime(
373 Reference< XComponentContext > const & xContext ) override;
374
375 // XSingleServiceFactory
376 Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments) override;
377 // XSingleComponentFactory
378 Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext(
379 Sequence< Any > const & rArguments,
380 Reference< XComponentContext > const & xContext ) override;
381
382 // XServiceInfo
383 Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
384 // XUnloadingPreference
385 sal_Bool SAL_CALL releaseOnNotification() override;
386
387
388private:
391 Reference< XInterface > createModuleFactory();
392
396 Reference<XSingleComponentFactory > xModuleFactory;
397 Reference<XSingleServiceFactory > xModuleFactoryDepr;
398 Reference< beans::XPropertySetInfo > m_xInfo;
399 std::unique_ptr< IPropertyArrayHelper > m_property_array_helper;
400protected:
401 using OPropertySetHelper::getTypes;
402};
403
404}
405
406// XInterface
407
408Any SAL_CALL ORegistryFactoryHelper::queryInterface(
409 Type const & type )
410{
412 if (ret.hasValue())
413 return ret;
415}
416
417
418void ORegistryFactoryHelper::acquire() noexcept
419{
420 OFactoryComponentHelper::acquire();
421}
422
423
424void ORegistryFactoryHelper::release() noexcept
425{
426 OFactoryComponentHelper::release();
427}
428
429// XTypeProvider
430
431Sequence< Type > ORegistryFactoryHelper::getTypes()
432{
433 Sequence< Type > types( OFactoryComponentHelper::getTypes() );
434 sal_Int32 pos = types.getLength();
435 types.realloc( pos + 3 );
436 Type * p = types.getArray();
440 return types;
441}
442
443// XPropertySet
444
446ORegistryFactoryHelper::getPropertySetInfo()
447{
448 ::osl::MutexGuard guard( m_aMutex );
449 if (! m_xInfo.is())
450 m_xInfo = createPropertySetInfo( getInfoHelper() );
451 return m_xInfo;
452}
453
454// OPropertySetHelper
455
456IPropertyArrayHelper & ORegistryFactoryHelper::getInfoHelper()
457{
458 ::osl::MutexGuard guard( m_aMutex );
459 if (m_property_array_helper == nullptr)
460 {
461 beans::Property prop(
462 "ImplementationKey" /* name */,
463 0 /* handle */,
464 cppu::UnoType<decltype(xImplementationKey)>::get(),
465 beans::PropertyAttribute::READONLY |
466 beans::PropertyAttribute::OPTIONAL );
468 new ::cppu::OPropertyArrayHelper( &prop, 1 ) );
469 }
471}
472
473
474sal_Bool ORegistryFactoryHelper::convertFastPropertyValue(
475 Any &, Any &, sal_Int32, Any const & )
476{
477 OSL_FAIL( "unexpected!" );
478 return false;
479}
480
481
482void ORegistryFactoryHelper::setFastPropertyValue_NoBroadcast(
483 sal_Int32, Any const & )
484{
485 throw beans::PropertyVetoException(
486 "unexpected: only readonly properties!",
487 static_cast< OWeakObject * >(this) );
488}
489
490
491void ORegistryFactoryHelper::getFastPropertyValue(
492 Any & rValue, sal_Int32 nHandle ) const
493{
494 if (nHandle == 0)
495 {
496 rValue <<= xImplementationKey;
497 }
498 else
499 {
500 rValue.clear();
501 throw beans::UnknownPropertyException(
502 "unknown property!", static_cast< OWeakObject * >(
503 const_cast< ORegistryFactoryHelper * >(this) ) );
504 }
505}
506
507Reference<XInterface > ORegistryFactoryHelper::createInstanceEveryTime(
508 Reference< XComponentContext > const & xContext )
509{
510 if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
511 {
512 Reference< XInterface > x( createModuleFactory() );
513 if (x.is())
514 {
515 MutexGuard aGuard( m_aMutex );
516 if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
517 {
518 xModuleFactory.set( x, UNO_QUERY );
519 xModuleFactoryDepr.set( x, UNO_QUERY );
520 }
521 }
522 }
523 if( xModuleFactory.is() )
524 {
525 return xModuleFactory->createInstanceWithContext( xContext );
526 }
527 if( xModuleFactoryDepr.is() )
528 {
529 return xModuleFactoryDepr->createInstance();
530 }
531
532 return Reference<XInterface >();
533}
534
535Reference<XInterface > SAL_CALL ORegistryFactoryHelper::createInstanceWithArguments(
536 const Sequence<Any>& Arguments )
537{
538 if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
539 {
540 Reference< XInterface > x( createModuleFactory() );
541 if (x.is())
542 {
543 MutexGuard aGuard( m_aMutex );
544 if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
545 {
546 xModuleFactory.set( x, UNO_QUERY );
547 xModuleFactoryDepr.set( x, UNO_QUERY );
548 }
549 }
550 }
551 if( xModuleFactoryDepr.is() )
552 {
553 return xModuleFactoryDepr->createInstanceWithArguments( Arguments );
554 }
555 if( xModuleFactory.is() )
556 {
557 SAL_INFO("cppuhelper", "no context ORegistryFactoryHelper::createInstanceWithArgumentsAndContext()!");
558 return xModuleFactory->createInstanceWithArgumentsAndContext( Arguments, Reference< XComponentContext >() );
559 }
560
561 return Reference<XInterface >();
562}
563
564Reference< XInterface > ORegistryFactoryHelper::createInstanceWithArgumentsAndContext(
565 Sequence< Any > const & rArguments,
566 Reference< XComponentContext > const & xContext )
567{
568 if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
569 {
570 Reference< XInterface > x( createModuleFactory() );
571 if (x.is())
572 {
573 MutexGuard aGuard( m_aMutex );
574 if( !xModuleFactory.is() && !xModuleFactoryDepr.is() )
575 {
576 xModuleFactory.set( x, UNO_QUERY );
577 xModuleFactoryDepr.set( x, UNO_QUERY );
578 }
579 }
580 }
581 if( xModuleFactory.is() )
582 {
583 return xModuleFactory->createInstanceWithArgumentsAndContext( rArguments, xContext );
584 }
585 if( xModuleFactoryDepr.is() )
586 {
587 SAL_INFO_IF(xContext.is(), "cppuhelper", "ignoring context calling ORegistryFactoryHelper::createInstanceWithArgumentsAndContext()!");
588 return xModuleFactoryDepr->createInstanceWithArguments( rArguments );
589 }
590
591 return Reference<XInterface >();
592}
593
594
595Reference< XInterface > ORegistryFactoryHelper::createModuleFactory()
596{
597 OUString aActivatorUrl;
598 OUString aActivatorName;
599 OUString aLocation;
600
601 Reference<XRegistryKey > xActivatorKey = xImplementationKey->openKey(
602 "/UNO/ACTIVATOR" );
603 if( xActivatorKey.is() && xActivatorKey->getValueType() == RegistryValueType_ASCII )
604 {
605 aActivatorUrl = xActivatorKey->getAsciiValue();
606
607 aActivatorName = o3tl::getToken(aActivatorUrl, 0, ':');
608
609 Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey(
610 "/UNO/LOCATION" );
611 if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII )
612 aLocation = xLocationKey->getAsciiValue();
613 }
614 else
615 {
616 // old style"url"
617 // the location of the program code of the implementation
618 Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey(
619 "/UNO/URL" );
620 // is the key of the right type ?
621 if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII )
622 {
623 // one implementation found -> try to activate
624 aLocation = xLocationKey->getAsciiValue();
625
626 // search protocol delimiter
627 sal_Int32 nPos = aLocation.indexOf("://");
628 if( nPos != -1 )
629 {
630 aActivatorName = aLocation.subView( 0, nPos );
631 if( aActivatorName == u"java" )
632 aActivatorName = u"com.sun.star.loader.Java";
633 else if( aActivatorName == u"module" )
634 aActivatorName = u"com.sun.star.loader.SharedLibrary";
635 aLocation = aLocation.copy( nPos + 3 );
636 }
637 }
638 }
639
641 if( !aActivatorName.isEmpty() )
642 {
643 Reference<XInterface > x = xSMgr->createInstance( aActivatorName );
644 Reference<XImplementationLoader > xLoader( x, UNO_QUERY );
645 if (xLoader.is())
646 {
647 xFactory = xLoader->activate( aImplementationName, aActivatorUrl, aLocation, xImplementationKey );
648 }
649 }
650 return xFactory;
651}
652
653// XServiceInfo
654Sequence< OUString > ORegistryFactoryHelper::getSupportedServiceNames()
655{
656 MutexGuard aGuard( m_aMutex );
657 if( !aServiceNames.hasElements() )
658 {
659 // not yet loaded
660 try
661 {
662 Reference<XRegistryKey > xKey = xImplementationKey->openKey( "UNO/SERVICES" );
663
664 if (xKey.is())
665 {
666 // length of prefix. +1 for the '/' at the end
667 sal_Int32 nPrefixLen = xKey->getKeyName().getLength() + 1;
668
669 // Full qualified names like "IMPLEMENTATIONS/TEST/UNO/SERVICES/com.sun.star..."
670 Sequence<OUString> seqKeys = xKey->getKeyNames();
671 for( OUString & key : asNonConstRange(seqKeys) )
672 key = key.copy(nPrefixLen);
673
674 aServiceNames = seqKeys;
675 }
676 }
677 catch (InvalidRegistryException &)
678 {
679 }
680 }
681 return aServiceNames;
682}
683
684sal_Bool SAL_CALL ORegistryFactoryHelper::releaseOnNotification()
685{
686 bool retVal= true;
687 if( isOneInstance() && isInstance())
688 {
689 retVal= false;
690 }
691 else if( ! isOneInstance())
692 {
693 // try to delegate
694 if( xModuleFactory.is())
695 {
696 Reference<XUnloadingPreference> xunloading( xModuleFactory, UNO_QUERY);
697 if( xunloading.is())
698 retVal= xunloading->releaseOnNotification();
699 }
700 else if( xModuleFactoryDepr.is())
701 {
703 if( xunloading.is())
704 retVal= xunloading->releaseOnNotification();
705 }
706 }
707 return retVal;
708}
709
710namespace {
711
712class OFactoryProxyHelper : public WeakImplHelper< XServiceInfo, XSingleServiceFactory,
713 XUnloadingPreference >
714{
716
717public:
718
719 explicit OFactoryProxyHelper( const Reference<XSingleServiceFactory > & rFactory )
720 : xFactory( rFactory )
721 {}
722
723 // XSingleServiceFactory
724 Reference<XInterface > SAL_CALL createInstance() override;
725 Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments) override;
726
727 // XServiceInfo
728 OUString SAL_CALL getImplementationName() override;
729 sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
731 //XUnloadingPreference
732 sal_Bool SAL_CALL releaseOnNotification() override;
733
734};
735
736}
737
738// XSingleServiceFactory
739Reference<XInterface > OFactoryProxyHelper::createInstance()
740{
741 return xFactory->createInstance();
742}
743
744// XSingleServiceFactory
745Reference<XInterface > OFactoryProxyHelper::createInstanceWithArguments
746(
747 const Sequence<Any>& Arguments
748)
749{
750 return xFactory->createInstanceWithArguments( Arguments );
751}
752
753// XServiceInfo
754OUString OFactoryProxyHelper::getImplementationName()
755{
756 Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY );
757 if( xInfo.is() )
758 return xInfo->getImplementationName();
759 return OUString();
760}
761
762// XServiceInfo
763sal_Bool OFactoryProxyHelper::supportsService(const OUString& ServiceName)
764{
765 return cppu::supportsService(this, ServiceName);
766}
767
768// XServiceInfo
769Sequence< OUString > OFactoryProxyHelper::getSupportedServiceNames()
770{
771 Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY );
772 if( xInfo.is() )
773 return xInfo->getSupportedServiceNames();
774 return Sequence< OUString >();
775}
776
777sal_Bool SAL_CALL OFactoryProxyHelper::releaseOnNotification()
778{
779
781 if( pref.is())
782 return pref->releaseOnNotification();
783 return true;
784}
785
786// global function
788 const Reference<XMultiServiceFactory > & rServiceManager,
789 const OUString & rImplementationName,
790 ComponentInstantiation pCreateFunction,
791 const Sequence< OUString > & rServiceNames,
792 rtl_ModuleCount * )
793{
794 return new OFactoryComponentHelper(
795 rServiceManager, rImplementationName, pCreateFunction, nullptr, &rServiceNames, false );
796}
797
798// global function
800 SAL_UNUSED_PARAMETER const Reference<XMultiServiceFactory > &,
801 const Reference<XSingleServiceFactory > & rFactory )
802{
803 return new OFactoryProxyHelper( rFactory );
804}
805
806// global function
808 const Reference<XMultiServiceFactory > & rServiceManager,
809 const OUString & rImplementationName,
810 ComponentInstantiation pCreateFunction,
811 const Sequence< OUString > & rServiceNames,
812 rtl_ModuleCount * )
813{
814 return new OFactoryComponentHelper(
815 rServiceManager, rImplementationName, pCreateFunction, nullptr, &rServiceNames, true );
816}
817
818// global function
820 const Reference<XMultiServiceFactory > & rServiceManager,
821 const OUString & rImplementationName,
822 const Reference<XRegistryKey > & rImplementationKey )
823{
824 return new ORegistryFactoryHelper(
825 rServiceManager, rImplementationName, rImplementationKey, false );
826}
827
828// global function
830 const Reference<XMultiServiceFactory > & rServiceManager,
831 const OUString & rImplementationName,
832 const Reference<XRegistryKey > & rImplementationKey )
833{
834 return new ORegistryFactoryHelper(
835 rServiceManager, rImplementationName, rImplementationKey, true );
836}
837
838
840 ComponentFactoryFunc fptr,
841 OUString const & rImplementationName,
842 Sequence< OUString > const & rServiceNames,
843 rtl_ModuleCount *)
844{
845 return new OFactoryComponentHelper(
846 Reference< XMultiServiceFactory >(), rImplementationName, nullptr, fptr, &rServiceNames, false );
847}
848
850 ComponentFactoryFunc fptr,
851 OUString const & rImplementationName,
852 Sequence< OUString > const & rServiceNames,
853 rtl_ModuleCount *)
854{
855 return new OFactoryComponentHelper(
856 Reference< XMultiServiceFactory >(), rImplementationName, nullptr, fptr, &rServiceNames, true );
857}
858
859}
860
861
862/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
HRESULT createInstance(REFIID iid, Ifc **ppIfc)
base class for all classes who want derive from cppu::WeakComponentImplHelperXX.
Definition: basemutex.hxx:40
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) SAL_OVERRIDE
Only returns a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and XEventListener.
Definition: propshlp.cxx:208
css::uno::Type const & get()
float u
float x
Reference< XInterface > xTheInstance
Definition: factory.cxx:118
Reference< XMultiServiceFactory > xSMgr
Definition: factory.cxx:135
std::unique_ptr< IPropertyArrayHelper > m_property_array_helper
Definition: factory.cxx:399
Reference< XSingleServiceFactory > xFactory
Definition: factory.cxx:715
Reference< XRegistryKey > xImplementationKey
The registry key of the implementation section.
Definition: factory.cxx:394
Sequence< OUString > aServiceNames
Definition: factory.cxx:138
ComponentInstantiation pCreateFunction
Definition: factory.cxx:136
Reference< beans::XPropertySetInfo > m_xInfo
Definition: factory.cxx:398
Reference< XSingleComponentFactory > xModuleFactory
The factory created with the loader.
Definition: factory.cxx:396
OUString aImplementationName
Definition: factory.cxx:139
ComponentFactoryFunc m_fptr
Definition: factory.cxx:137
bool bOneInstance
Definition: factory.cxx:119
Reference< XSingleServiceFactory > xModuleFactoryDepr
Definition: factory.cxx:397
std::mutex m_aMutex
void * p
sal_uInt16 nPos
#define SAL_INFO_IF(condition, area, stream)
#define SAL_INFO(area, stream)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
Type
Reference< XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory(const Reference< XMultiServiceFactory > &rServiceManager, const OUString &rImplementationName, const Reference< XRegistryKey > &rImplementationKey)
Definition: factory.cxx:829
css::uno::Reference< css::uno::XInterface >(SAL_CALL *ComponentFactoryFunc)(css CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleComponentFactory > SAL_CALL createSingleComponentFactory(ComponentFactoryFunc fptr, ::rtl::OUString const &rImplementationName, css::uno::Sequence< ::rtl::OUString > const &rServiceNames, rtl_ModuleCount *pModCount=NULL)
Function pointer declaration.
Definition: factory.hxx:146
Reference< XSingleServiceFactory > SAL_CALL createSingleRegistryFactory(const Reference< XMultiServiceFactory > &rServiceManager, const OUString &rImplementationName, const Reference< XRegistryKey > &rImplementationKey)
Definition: factory.cxx:819
Reference< XSingleServiceFactory > SAL_CALL createOneInstanceFactory(const Reference< XMultiServiceFactory > &rServiceManager, const OUString &rImplementationName, ComponentInstantiation pCreateFunction, const Sequence< OUString > &rServiceNames, rtl_ModuleCount *)
Definition: factory.cxx:807
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Reference< lang::XSingleComponentFactory > SAL_CALL createOneInstanceComponentFactory(ComponentFactoryFunc fptr, OUString const &rImplementationName, Sequence< OUString > const &rServiceNames, rtl_ModuleCount *)
Definition: factory.cxx:849
css::uno::Reference< css::uno::XInterface >(SAL_CALL *ComponentInstantiation)(const css CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL createSingleFactory(const css::uno::Reference< css::lang::XMultiServiceFactory > &rServiceManager, const ::rtl::OUString &rImplementationName, ComponentInstantiation pCreateFunction, const css::uno::Sequence< ::rtl::OUString > &rServiceNames, rtl_ModuleCount *pModCount=NULL)
Deprecated.
Definition: factory.hxx:193
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
A helper for implementations of com.sun.star.lang.XServiceInfo.
Reference< XSingleServiceFactory > SAL_CALL createFactoryProxy(SAL_UNUSED_PARAMETER const Reference< XMultiServiceFactory > &, const Reference< XSingleServiceFactory > &rFactory)
Definition: factory.cxx:799
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
unsigned char sal_Bool
ResultType type
size_t pos