From b679a2a02180c017bd8b596fb2e4f283bad93b75 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 4 Sep 2012 16:12:17 +0200 Subject: fdo#46808, Adapt reflection::CoreReflection UNO service to new style The XComponent part of the interface made no sense for a singleton, so it was removed. Explicitly document the 'theCoreReflection' singleton and move it into it's own file. Deprecated the now old CoreReflection service. Change-Id: Ib8befa87c7da7eb53a2f587948fd54a64c082472 --- .../source/eventattachermgr/eventattachermgr.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'comphelper') diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx index 644d2d9a54ef..9b2402604b7c 100644 --- a/comphelper/source/eventattachermgr/eventattachermgr.cxx +++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx @@ -23,6 +23,7 @@ #endif #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -94,14 +96,14 @@ class ImplEventAttacherManager OInterfaceContainerHelper aScriptListeners; // Instance of EventAttacher Reference< XEventAttacher2 > xAttacher; - Reference< XMultiServiceFactory > mxSMgr; + Reference< XComponentContext > mxContext; Reference< XIdlReflection > mxCoreReflection; Reference< XIntrospection > mxIntrospection; Reference< XTypeConverter > xConverter; sal_Int16 nVersion; public: ImplEventAttacherManager( const Reference< XIntrospection > & rIntrospection, - const Reference< XMultiServiceFactory > rSMgr ); + const Reference< XComponentContext > xContext ); ~ImplEventAttacherManager(); // Methods of XEventAttacherManager @@ -361,7 +363,7 @@ Reference< XEventAttacherManager > createEventAttacherManager( const Reference< if ( xIFace.is() ) { Reference< XIntrospection > xIntrospection( xIFace, UNO_QUERY); - return new ImplEventAttacherManager( xIntrospection, rSMgr ); + return new ImplEventAttacherManager( xIntrospection, comphelper::ComponentContext(rSMgr).getUNOContext() ); } } @@ -370,19 +372,20 @@ Reference< XEventAttacherManager > createEventAttacherManager( const Reference< //----------------------------------------------------------------------------- ImplEventAttacherManager::ImplEventAttacherManager( const Reference< XIntrospection > & rIntrospection, - const Reference< XMultiServiceFactory > rSMgr ) + const Reference< XComponentContext > xContext ) : aScriptListeners( aLock ) - , mxSMgr( rSMgr ) + , mxContext( xContext ) , mxIntrospection( rIntrospection ) { - if ( rSMgr.is() ) + if ( xContext.is() ) { - Reference< XInterface > xIFace( rSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.EventAttacher" )) ) ); + Reference< XInterface > xIFace( xContext->getServiceManager()->createInstanceWithContext( + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.EventAttacher" )), xContext) ); if ( xIFace.is() ) { xAttacher = Reference< XEventAttacher2 >::query( xIFace ); } - xConverter = Converter::create(comphelper::ComponentContext(rSMgr).getUNOContext()); + xConverter = Converter::create(xContext); } Reference< XInitialization > xInit( xAttacher, UNO_QUERY ); @@ -405,8 +408,7 @@ Reference< XIdlReflection > ImplEventAttacherManager::getReflection() throw( Exc // Do we already have a service? If not, create one. if( !mxCoreReflection.is() ) { - Reference< XInterface > xIFace( mxSMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.reflection.CoreReflection" )) ) ); - mxCoreReflection = Reference< XIdlReflection >( xIFace, UNO_QUERY); + mxCoreReflection = theCoreReflection::get(mxContext); } return mxCoreReflection; } -- cgit