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 | |
parent | 41324964f5a2200fd5763a51204b20ff0fa1034b (diff) |
Simplify access to theCoreReflection singleton
Change-Id: I9901991a320b87895230a92095c9c7d3109380a6
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 8 | ||||
-rw-r--r-- | basic/source/classes/sbunoobj.cxx | 25 | ||||
-rw-r--r-- | basic/source/comp/dim.cxx | 17 | ||||
-rw-r--r-- | include/cppuhelper/propertysetmixin.hxx | 6 | ||||
-rw-r--r-- | javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java | 32 | ||||
-rw-r--r-- | stoc/source/inspect/introspection.cxx | 31 | ||||
-rw-r--r-- | stoc/source/invocation/invocation.cxx | 18 |
7 files changed, 30 insertions, 107 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 10cfe47f1071..4d8f0d93e1cd 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -55,6 +55,7 @@ #include <com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp> #include <com/sun/star/reflection/XIdlMethod.hpp> #include <com/sun/star/reflection/XIdlField.hpp> +#include <com/sun/star/reflection/theCoreReflection.hpp> #include <com/sun/star/uno/Exception.hpp> namespace basctl @@ -2895,10 +2896,9 @@ UnoTypeCodeCompletetor::UnoTypeCodeCompletetor( const std::vector< OUString >& a try { - xFactory = Reference< lang::XMultiServiceFactory >( comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); - xRefl = Reference< reflection::XIdlReflection >( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW ); - if( xRefl.is() ) - xClass = xRefl->forName( sVarType );//get the base class for reflection + // Get the base class for reflection: + xClass = css::reflection::theCoreReflection::get( + comphelper::getProcessComponentContext())->forName(sVarType); } catch( const Exception& ) { diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 667d7ab244ef..15d869f1a4a9 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -61,6 +61,7 @@ #include <com/sun/star/reflection/XIdlArray.hpp> #include <com/sun/star/reflection/XIdlReflection.hpp> #include <com/sun/star/reflection/XServiceConstructorDescription.hpp> +#include <com/sun/star/reflection/theCoreReflection.hpp> #include <com/sun/star/bridge/oleautomation/NamedArgument.hpp> #include <com/sun/star/bridge/oleautomation/Date.hpp> #include <com/sun/star/bridge/oleautomation/Decimal.hpp> @@ -168,28 +169,8 @@ void SetSbUnoObjectDfltPropName( SbxObject* pObj ) // save CoreReflection statically Reference< XIdlReflection > getCoreReflection_Impl( void ) { - static Reference< XIdlReflection > xCoreReflection; - - // Do we have already CoreReflection; if not obtain it - if( !xCoreReflection.is() ) - { - Reference< XComponentContext > xContext( - comphelper::getProcessComponentContext() ); - if( xContext.is() ) - { - xContext->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 >() ); - } - } - return xCoreReflection; + return css::reflection::theCoreReflection::get( + comphelper::getProcessComponentContext()); } // save CoreReflection statically diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index faa521abfc40..1987e92890cf 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -21,7 +21,7 @@ #include "sbcomp.hxx" #include "sbunoobj.hxx" #include <svtools/miscopt.hxx> -#include <com/sun/star/reflection/XIdlReflection.hpp> +#include <com/sun/star/reflection/theCoreReflection.hpp> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/configurationhelper.hxx> @@ -1335,19 +1335,8 @@ bool SbiParser::IsUnoInterface(const OUString& sTypeName) { try { - Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), UNO_SET_THROW ); - Reference< reflection::XIdlReflection > xRefl( xFactory->createInstance("com.sun.star.reflection.CoreReflection"), UNO_QUERY_THROW ); - //DBG_ASSERT(xRefl.Is(), "No reflection class!"); ??? - if( !xRefl.is() ) - { - return false; - } - Reference< reflection::XIdlClass > xClass = xRefl->forName(sTypeName); - if( xClass != NULL ) - { - return true; - } - return false; + return css::reflection::theCoreReflection::get( + comphelper::getProcessComponentContext())->forName(sTypeName).is(); } catch(const Exception&) { diff --git a/include/cppuhelper/propertysetmixin.hxx b/include/cppuhelper/propertysetmixin.hxx index 8cdb0f361a08..b2faa5c403c0 100644 --- a/include/cppuhelper/propertysetmixin.hxx +++ b/include/cppuhelper/propertysetmixin.hxx @@ -429,9 +429,9 @@ protected: <code>std::bad_alloc</code>. @param context the component context used by this class template; must - not be null, and must supply the service - <code>com.sun.star.reflection.CoreReflection</code> and the singleton - <code>com.sun.star.reflection.theTypeDescriptionManager</code> + not be null, and must supply the + <code>com.sun.star.reflection.theCoreReflection</code> and + <code>com.sun.star.reflection.theTypeDescriptionManager</code> singletons @param implements a combination of zero or more flags specifying what UNO interface types shall be supported diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java index 0f548fe10d93..14f887f82011 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java @@ -34,20 +34,18 @@ import com.sun.star.lang.DisposedException; import com.sun.star.lang.EventObject; import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.WrappedTargetRuntimeException; -import com.sun.star.lang.XComponent; import com.sun.star.reflection.XCompoundTypeDescription; import com.sun.star.reflection.XIdlClass; import com.sun.star.reflection.XIdlField2; -import com.sun.star.reflection.XIdlReflection; import com.sun.star.reflection.XIndirectTypeDescription; import com.sun.star.reflection.XInterfaceAttributeTypeDescription2; import com.sun.star.reflection.XInterfaceMemberTypeDescription; import com.sun.star.reflection.XInterfaceTypeDescription2; import com.sun.star.reflection.XStructTypeDescription; import com.sun.star.reflection.XTypeDescription; +import com.sun.star.reflection.theCoreReflection; import com.sun.star.uno.Any; import com.sun.star.uno.AnyConverter; -import com.sun.star.uno.DeploymentException; import com.sun.star.uno.Type; import com.sun.star.uno.TypeClass; import com.sun.star.uno.UnoRuntime; @@ -79,9 +77,9 @@ public final class PropertySetMixin { The constructor. @param context the component context used by this instance; must not be - null, and must supply the service - <code>com.sun.star.reflection.CoreReflection</code> and the singleton - <code>com.sun.star.reflection.theTypeDescriptionManager</code> + null, and must supply the + <code>com.sun.star.reflection.theCoreReflection</code> and + <code>com.sun.star.reflection.theTypeDescriptionManager</code> singletons @param object the client UNO object into which this instance is mixed in; must not be null, and must support the given <code>type</code> @@ -565,27 +563,7 @@ public final class PropertySetMixin { } private XIdlClass getReflection(String typeName) { - XIdlReflection refl; - try { - refl = UnoRuntime.queryInterface( - XIdlReflection.class, - context.getServiceManager().createInstanceWithContext( - "com.sun.star.reflection.CoreReflection", context)); - } catch (com.sun.star.uno.Exception e) { - throw new DeploymentException( - ("component context fails to supply service" - + " com.sun.star.reflection.CoreReflection: " - + e.getMessage()), - context); - } - try { - return refl.forName(typeName); - } finally { - XComponent comp = UnoRuntime.queryInterface(XComponent.class, refl); - if (comp != null) { - comp.dispose(); - } - } + return theCoreReflection.get(context).forName(typeName); } private void initProperties( 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() {} |