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