From bd20500cf3d88d0bd81d7e57df01b0130e7166f6 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 7 Feb 2014 12:03:03 +0100 Subject: Simplify access to theCoreReflection singleton Change-Id: I9901991a320b87895230a92095c9c7d3109380a6 --- stoc/source/inspect/introspection.cxx | 31 ++++++++++--------------------- stoc/source/invocation/invocation.cxx | 18 ++---------------- 2 files changed, 12 insertions(+), 37 deletions(-) (limited to 'stoc') diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 7cd15a7f0eed..821239761617 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -1661,10 +1662,6 @@ ImplIntrospection::ImplIntrospection( const Reference & rX mpCache = NULL; mpTypeProviderCache = NULL; - // Spezielle Klassen holen -// Reference< XInterface > xServiceIface = m_xSMgr->createInstance("com.sun.star.reflection.CoreReflection"); -// if( xServiceIface.is() ) -// mxCoreReflection = Reference< XIdlReflection >::query( xServiceIface ); Reference< XPropertySet > xProps( rXSMgr, UNO_QUERY ); OSL_ASSERT( xProps.is() ); if (xProps.is()) @@ -1675,9 +1672,8 @@ ImplIntrospection::ImplIntrospection( const Reference & rX OSL_ASSERT( xContext.is() ); if (xContext.is()) { - xContext->getValueByName( - OUString("/singletons/com.sun.star.reflection.theCoreReflection") ) >>= mxCoreReflection; - OSL_ENSURE( mxCoreReflection.is(), "### CoreReflection singleton not accessible!?" ); + mxCoreReflection = css::reflection::theCoreReflection::get( + xContext); } } if (! mxCoreReflection.is()) @@ -1871,10 +1867,8 @@ CheckedInterfacesMap; // TODO: Spaeter auslagern -Reference TypeToIdlClass( const Type& rType, const Reference< XMultiServiceFactory > & xMgr ) +Reference TypeToIdlClass( const Type& rType, const Reference< XIdlReflection > & xRefl ) { - static Reference< XIdlReflection > xRefl; - // void als Default-Klasse eintragen Reference xRetClass; typelib_TypeDescription * pTD = 0; @@ -1882,11 +1876,6 @@ Reference TypeToIdlClass( const Type& rType, const Reference< XMultiS if( pTD ) { OUString sOWName( pTD->pTypeName ); - if( !xRefl.is() ) - { - xRefl = Reference< XIdlReflection >( xMgr->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY ); - OSL_ENSURE( xRefl.is(), "### no corereflection!" ); - } xRetClass = xRefl->forName( sOWName ); } return xRetClass; @@ -1950,14 +1939,14 @@ rtl::Reference< IntrospectionAccessStatic_Impl > ImplIntrospection::implInspect( const Type* pTypes = SupportedTypesSeq.getConstArray(); for( sal_Int32 i = 0 ; i < nTypeCount ; i++ ) { - pClasses[ i ] = TypeToIdlClass( pTypes[ i ], m_xSMgr ); + pClasses[ i ] = TypeToIdlClass( pTypes[ i ], mxCoreReflection ); } // TODO: Caching! } } else { - xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr ); + xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), mxCoreReflection ); SupportedClassSeq.realloc( 1 ); SupportedClassSeq.getArray()[ 0 ] = xImplClass; } @@ -1969,7 +1958,7 @@ rtl::Reference< IntrospectionAccessStatic_Impl > ImplIntrospection::implInspect( } else { - xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr ); + xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), mxCoreReflection ); } if( xTypeProvider.is() ) @@ -2710,7 +2699,7 @@ rtl::Reference< IntrospectionAccessStatic_Impl > ImplIntrospection::implInspect( const Reference& rxMethod = pSourceMethods[i]; // void als Default-Klasse eintragen - Reference xListenerClass = TypeToIdlClass( getCppuVoidType(), m_xSMgr ); + Reference xListenerClass = TypeToIdlClass( getCppuVoidType(), mxCoreReflection ); // ALT: Reference xListenerClass = Void_getReflection()->getIdlClass(); // 1. Moeglichkeit: Parameter nach einer Listener-Klasse durchsuchen @@ -2718,7 +2707,7 @@ rtl::Reference< IntrospectionAccessStatic_Impl > ImplIntrospection::implInspect( Sequence< Reference > aParams = rxMethod->getParameterTypes(); const Reference* pParamArray2 = aParams.getConstArray(); - Reference xEventListenerClass = TypeToIdlClass( getCppuType( (Reference*) NULL ), m_xSMgr ); + Reference xEventListenerClass = TypeToIdlClass( getCppuType( (Reference*) NULL ), mxCoreReflection ); // ALT: Reference xEventListenerClass = XEventListener_getReflection()->getIdlClass(); sal_Int32 nParamCount = aParams.getLength(); sal_Int32 k; @@ -2789,7 +2778,7 @@ rtl::Reference< IntrospectionAccessStatic_Impl > ImplIntrospection::implInspect( { // Ist es ein Interface oder eine struct? //Reference xClassRef = aToInspectObj.getReflection()->getIdlClass(); - Reference xClassRef = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr ); + Reference xClassRef = TypeToIdlClass( aToInspectObj.getValueType(), mxCoreReflection ); if( !xClassRef.is() ) { SAL_WARN( "stoc", "Can't get XIdlClass from Reflection" ); diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 98ef7233425c..ecc8626c8646 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -26,12 +26,12 @@ #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -1093,6 +1093,7 @@ private: InvocationService::InvocationService( const Reference & xCtx ) : mxCtx( xCtx ) , mxSMgr( xCtx->getServiceManager() ) + , xCoreReflection( css::reflection::theCoreReflection::get(mxCtx) ) { xTypeConverter = Reference( mxSMgr->createInstanceWithContext( @@ -1100,21 +1101,6 @@ InvocationService::InvocationService( const Reference & xCtx xCtx ), UNO_QUERY ); xIntrospection = Introspection::create(xCtx); - mxCtx->getValueByName( - OUString("/singletons/com.sun.star.reflection.theCoreReflection") ) - >>= xCoreReflection; - OSL_ENSURE( xCoreReflection.is(), "### CoreReflection singleton not accessible!?" ); - if (! xCoreReflection.is()) - { - throw DeploymentException( - OUString("/singletons/com.sun.star.reflection.theCoreReflection singleton not accessible"), - Reference< XInterface >() ); - } -// xCoreReflection = Reference( -// mxSMgr->createInstanceWithContext( -// OUString("com.sun.star.reflection.CoreReflection"), -// xCtx), -// UNO_QUERY); } InvocationService::~InvocationService() {} -- cgit