summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorKevin Hunter <hunteke@earlham.edu>2011-10-04 12:58:10 -0400
committerStephan Bergmann <sbergman@redhat.com>2011-10-05 08:52:09 +0200
commita313cf86071795bbd051feb9b99258be0a5c8c48 (patch)
tree21c714bc66f7c1ce9639733096e4da80a8968051 /stoc
parent23af3341322143f2edde5a6c6668294c915c3ae5 (diff)
Fix logic of isDerivedFrom function
From an email conversation with Stephen Bergmann "I think the real intent always was to actually look through all the returned getSuperclasses(), and the error that superclasses past the first one are effectively ignored has never been noticed."
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/inspect/introspection.cxx25
1 files changed, 7 insertions, 18 deletions
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx
index 36f1acce8e02..dd6e32cb9db4 100644
--- a/stoc/source/inspect/introspection.cxx
+++ b/stoc/source/inspect/introspection.cxx
@@ -110,29 +110,18 @@ sal_Bool isDerivedFrom( Reference<XIdlClass> xToTestClass, Reference<XIdlClass>
{
Sequence< Reference<XIdlClass> > aClassesSeq = xToTestClass->getSuperclasses();
const Reference<XIdlClass>* pClassesArray = aClassesSeq.getConstArray();
+
sal_Int32 nSuperClassCount = aClassesSeq.getLength();
- sal_Int32 i;
- for( i = 0 ;
- i < nSuperClassCount ;
- /* No "increment" expression needed as the body always
- * returns, and in fact MSVC warns about unreachable code if
- * we include one. On the other hand, what's the point in
- * using a for loop here then if all we ever will look at is
- * pClassesArray[0] ?
- */ )
+ for ( sal_Int32 i = 0; i < nSuperClassCount; ++i )
{
const Reference<XIdlClass>& rxClass = pClassesArray[i];
- if( xDerivedFromClass->equals( rxClass ) )
- {
- // Treffer
+
+ if ( xDerivedFromClass->equals( rxClass ) ||
+ isDerivedFrom( rxClass, xDerivedFromClass )
+ )
return sal_True;
- }
- else
- {
- // Rekursiv weitersuchen
- return isDerivedFrom( rxClass, xDerivedFromClass );
- }
}
+
return sal_False;
}