diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-02-07 12:03:03 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-02-07 12:03:03 +0100 |
commit | bd20500cf3d88d0bd81d7e57df01b0130e7166f6 (patch) | |
tree | 63e6f08b5c17bcab3e3a2c57c6f4063033f3f52c /stoc | |
parent | 41324964f5a2200fd5763a51204b20ff0fa1034b (diff) |
Simplify access to theCoreReflection singleton
Change-Id: I9901991a320b87895230a92095c9c7d3109380a6
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/inspect/introspection.cxx | 31 | ||||
-rw-r--r-- | stoc/source/invocation/invocation.cxx | 18 |
2 files changed, 12 insertions, 37 deletions
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 <com/sun/star/reflection/XIdlReflection.hpp> #include <com/sun/star/reflection/XIdlClass.hpp> #include <com/sun/star/reflection/XIdlField2.hpp> +#include <com/sun/star/reflection/theCoreReflection.hpp> #include <com/sun/star/beans/UnknownPropertyException.hpp> #include <com/sun/star/beans/Property.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -1661,10 +1662,6 @@ ImplIntrospection::ImplIntrospection( const Reference<XMultiServiceFactory> & 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<XMultiServiceFactory> & 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<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XMultiServiceFactory > & xMgr ) +Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XIdlReflection > & xRefl ) { - static Reference< XIdlReflection > xRefl; - // void als Default-Klasse eintragen Reference<XIdlClass> xRetClass; typelib_TypeDescription * pTD = 0; @@ -1882,11 +1876,6 @@ Reference<XIdlClass> 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<XIdlMethod>& rxMethod = pSourceMethods[i]; // void als Default-Klasse eintragen - Reference<XIdlClass> xListenerClass = TypeToIdlClass( getCppuVoidType(), m_xSMgr ); + Reference<XIdlClass> xListenerClass = TypeToIdlClass( getCppuVoidType(), mxCoreReflection ); // ALT: Reference<XIdlClass> xListenerClass = Void_getReflection()->getIdlClass(); // 1. Moeglichkeit: Parameter nach einer Listener-Klasse durchsuchen @@ -2718,7 +2707,7 @@ rtl::Reference< IntrospectionAccessStatic_Impl > ImplIntrospection::implInspect( Sequence< Reference<XIdlClass> > aParams = rxMethod->getParameterTypes(); const Reference<XIdlClass>* pParamArray2 = aParams.getConstArray(); - Reference<XIdlClass> xEventListenerClass = TypeToIdlClass( getCppuType( (Reference<XEventListener>*) NULL ), m_xSMgr ); + Reference<XIdlClass> xEventListenerClass = TypeToIdlClass( getCppuType( (Reference<XEventListener>*) NULL ), mxCoreReflection ); // ALT: Reference<XIdlClass> 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<XIdlClass> xClassRef = aToInspectObj.getReflection()->getIdlClass(); - Reference<XIdlClass> xClassRef = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr ); + Reference<XIdlClass> 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 <cppuhelper/typeprovider.hxx> #include <cppuhelper/implbase2.hxx> -#include <com/sun/star/uno/DeploymentException.hpp> #include <com/sun/star/script/FailReason.hpp> #include <com/sun/star/script/XTypeConverter.hpp> #include <com/sun/star/script/XInvocation.hpp> #include <com/sun/star/script/XInvocation2.hpp> #include <com/sun/star/reflection/XIdlReflection.hpp> +#include <com/sun/star/reflection/theCoreReflection.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> @@ -1093,6 +1093,7 @@ private: InvocationService::InvocationService( const Reference<XComponentContext> & xCtx ) : mxCtx( xCtx ) , mxSMgr( xCtx->getServiceManager() ) + , xCoreReflection( css::reflection::theCoreReflection::get(mxCtx) ) { xTypeConverter = Reference<XTypeConverter>( mxSMgr->createInstanceWithContext( @@ -1100,21 +1101,6 @@ InvocationService::InvocationService( const Reference<XComponentContext> & 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<XIdlReflection>( -// mxSMgr->createInstanceWithContext( -// OUString("com.sun.star.reflection.CoreReflection"), -// xCtx), -// UNO_QUERY); } InvocationService::~InvocationService() {} |