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