From 51968db2b61ed450d239006d5152eaa952d7aa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 3 Apr 2012 17:10:34 +0100 Subject: [PATCH] Resolves: fdo#47068 we don't need an ImplIntrospectionAccess anyway refactor out-of-jail circularity --- stoc/source/inspect/introspection.cxx | 82 ++++++++++++++++++-------------- 1 files changed, 46 insertions(+), 36 deletions(-) diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index a1f239f..1b57eb7 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -712,9 +712,6 @@ class ImplIntrospectionAdapter : public XEnumerationAccess, public XIdlArray, public OWeakObject { - // Parent-Objekt - ImplIntrospectionAccess* mpAccess; - // Untersuchtes Objekt const Any& mrInspectedObject; @@ -734,8 +731,7 @@ class ImplIntrospectionAdapter : Reference mxObjIdlArray; public: - ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_, - const Any& obj, + ImplIntrospectionAdapter( const Any& obj, rtl::Reference< IntrospectionAccessStatic_Impl > const & pStaticImpl_ ); // Methoden von XInterface @@ -813,10 +809,9 @@ public: throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException ); }; -ImplIntrospectionAdapter::ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_, - const Any& obj, +ImplIntrospectionAdapter::ImplIntrospectionAdapter(const Any& obj, rtl::Reference< IntrospectionAccessStatic_Impl > const & pStaticImpl_ ) - : mpAccess( pAccess_), mrInspectedObject( obj ), mpStaticImpl( pStaticImpl_ ) + : mrInspectedObject( obj ), mpStaticImpl( pStaticImpl_ ) { // Objekt als Interfaceholen TypeClass eType = mrInspectedObject.getValueType().getTypeClass(); @@ -1035,16 +1030,54 @@ Sequence< Property > ImplIntrospectionAdapter::getProperties(void) throw( Runtim return mpStaticImpl->getProperties(); } +namespace +{ + Property getPropertyImpl(IntrospectionAccessStatic_Impl *pStaticImpl, const OUString& Name, sal_Int32 PropertyConcepts) + throw( NoSuchElementException, RuntimeException ) + { + Property aRet; + sal_Int32 i = pStaticImpl->getPropertyIndex( Name ); + sal_Bool bFound = sal_False; + if( i != -1 ) + { + sal_Int32 nConcept = pStaticImpl->getPropertyConcepts().getConstArray()[ i ]; + if( (PropertyConcepts & nConcept) != 0 ) + { + const Property* pProps = pStaticImpl->getProperties().getConstArray(); + aRet = pProps[ i ]; + bFound = sal_True; + } + } + if( !bFound ) + throw NoSuchElementException() ; + return aRet; + } + + sal_Bool hasPropertyImpl(IntrospectionAccessStatic_Impl *pStaticImpl, const OUString& Name, sal_Int32 PropertyConcepts) + throw( RuntimeException ) + { + sal_Int32 i = pStaticImpl->getPropertyIndex( Name ); + sal_Bool bRet = sal_False; + if( i != -1 ) + { + sal_Int32 nConcept = pStaticImpl->getPropertyConcepts().getConstArray()[ i ]; + if( (PropertyConcepts & nConcept) != 0 ) + bRet = sal_True; + } + return bRet; + } +} + Property ImplIntrospectionAdapter::getPropertyByName(const OUString& Name) throw( RuntimeException ) { - return mpAccess->getProperty( Name, PropertyConcept::ALL ); + return getPropertyImpl(mpStaticImpl.get(), Name, PropertyConcept::ALL); } sal_Bool ImplIntrospectionAdapter::hasPropertyByName(const OUString& Name) throw( RuntimeException ) { - return mpAccess->hasProperty( Name, PropertyConcept::ALL ); + return hasPropertyImpl(mpStaticImpl.get(), Name, PropertyConcept::ALL); } // Methoden von XElementAccess @@ -1189,36 +1222,13 @@ sal_Int32 ImplIntrospectionAccess::getSuppliedPropertyConcepts(void) Property ImplIntrospectionAccess::getProperty(const OUString& Name, sal_Int32 PropertyConcepts) throw( NoSuchElementException, RuntimeException ) { - Property aRet; - sal_Int32 i = mpStaticImpl->getPropertyIndex( Name ); - sal_Bool bFound = sal_False; - if( i != -1 ) - { - sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ]; - if( (PropertyConcepts & nConcept) != 0 ) - { - const Property* pProps = mpStaticImpl->getProperties().getConstArray(); - aRet = pProps[ i ]; - bFound = sal_True; - } - } - if( !bFound ) - throw NoSuchElementException() ; - return aRet; + return getPropertyImpl(mpStaticImpl.get(), Name, PropertyConcepts); } sal_Bool ImplIntrospectionAccess::hasProperty(const OUString& Name, sal_Int32 PropertyConcepts) throw( RuntimeException ) { - sal_Int32 i = mpStaticImpl->getPropertyIndex( Name ); - sal_Bool bRet = sal_False; - if( i != -1 ) - { - sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ]; - if( (PropertyConcepts & nConcept) != 0 ) - bRet = sal_True; - } - return bRet; + return hasPropertyImpl(mpStaticImpl.get(), Name, PropertyConcepts); } Sequence< Property > ImplIntrospectionAccess::getProperties(sal_Int32 PropertyConcepts) @@ -1405,7 +1415,7 @@ Reference SAL_CALL ImplIntrospectionAccess::queryAdapter( const Type if( !mpAdapter.is() ) { ((ImplIntrospectionAccess*)this)->mpAdapter = - new ImplIntrospectionAdapter( this, maInspectedObject, mpStaticImpl ); + new ImplIntrospectionAdapter( maInspectedObject, mpStaticImpl ); } Reference xRet; -- 1.7.7.6