1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_stoc.hxx"
26 
27 #include "tdmgr_common.hxx"
28 #include "rtl/ustrbuf.hxx"
29 #include "typelib/typedescription.h"
30 #include "com/sun/star/beans/PropertyAttribute.hpp"
31 #include "com/sun/star/reflection/XConstantsTypeDescription.hpp"
32 #include "com/sun/star/reflection/XIndirectTypeDescription.hpp"
33 #include "com/sun/star/reflection/XEnumTypeDescription.hpp"
34 #include "com/sun/star/reflection/XStructTypeDescription.hpp"
35 #include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp"
36 #include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp"
37 #include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp"
38 #include "com/sun/star/reflection/XServiceTypeDescription2.hpp"
39 #include "com/sun/star/reflection/XSingletonTypeDescription2.hpp"
40 
41 
42 using ::rtl::OUString;
43 using ::rtl::OUStringBuffer;
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::uno;
46 using namespace ::stoc_tdmgr;
47 
48 namespace {
49 
getTypeClassName(TypeClass tc)50 OUString getTypeClassName( TypeClass tc )
51 {
52     typelib_EnumTypeDescription * typeDescr = 0;
53     OUString name = OUSTR("com.sun.star.uno.TypeClass");
54     typelib_typedescription_getByName(
55         reinterpret_cast<typelib_TypeDescription **>(&typeDescr), name.pData );
56     OSL_ASSERT( typeDescr != 0 );
57     if (typeDescr == 0)
58         return OUSTR("Cannot get type description of ") + name;
59     typelib_typedescription_complete(
60         reinterpret_cast<typelib_TypeDescription **>(&typeDescr) );
61 
62     sal_Int32 const * pValues = typeDescr->pEnumValues;
63     sal_Int32 nPos = typeDescr->nEnumValues;
64     while (nPos--)
65     {
66         if (pValues[ nPos ] == (sal_Int32) tc)
67             break;
68     }
69     if (nPos >= 0)
70         name = typeDescr->ppEnumNames[ nPos ];
71     else
72         name = OUSTR("unknown TypeClass value: ") +
73             OUString::valueOf( (sal_Int32) tc );
74 
75     typelib_typedescription_release(
76         reinterpret_cast<typelib_TypeDescription *>(typeDescr) );
77     return name;
78 }
79 
getPropertyFlagsAsString(sal_Int16 attributes)80 OUString getPropertyFlagsAsString( sal_Int16 attributes )
81 {
82     OUStringBuffer buf;
83     if ((attributes & beans::PropertyAttribute::MAYBEVOID) != 0)
84         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEVOID, ") );
85     if ((attributes & beans::PropertyAttribute::BOUND) != 0)
86         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("BOUND, ") );
87     if ((attributes & beans::PropertyAttribute::CONSTRAINED) != 0)
88         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("CONSTRAINED, ") );
89     if ((attributes & beans::PropertyAttribute::TRANSIENT) != 0)
90         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("TRANSIENT, ") );
91     if ((attributes & beans::PropertyAttribute::READONLY) != 0)
92         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("READONLY, ") );
93     if ((attributes & beans::PropertyAttribute::MAYBEAMBIGUOUS) != 0)
94         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEAMBIGUOUS, ") );
95     if ((attributes & beans::PropertyAttribute::MAYBEDEFAULT) != 0)
96         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEDEFAULT, ") );
97     if ((attributes & beans::PropertyAttribute::REMOVEABLE) != 0)
98         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("REMOVEABLE, ") );
99     if ((attributes & beans::PropertyAttribute::OPTIONAL) != 0)
100         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("OPTIONAL") );
101     else if (buf.getLength() > 0)
102         buf.setLength( buf.getLength() - 2 ); // truncate ", "
103     return buf.makeStringAndClear();
104 }
105 
typeError(OUString const & msg,OUString const & context)106 void typeError( OUString const & msg, OUString const & context )
107 {
108     OUStringBuffer buf;
109     if (context.getLength() > 0) {
110         buf.append( static_cast<sal_Unicode>('[') );
111         buf.append( context );
112         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] ") );
113     }
114     buf.append( msg );
115     throw IncompatibleTypeException( buf.makeStringAndClear() );
116 }
117 
118 template<typename T>
checkSeq(Sequence<Reference<T>> const & newTypes,Sequence<Reference<T>> const & existingTypes,OUString const & context,bool optionalMode=false)119 void checkSeq( Sequence< Reference<T> > const & newTypes,
120             Sequence< Reference<T> > const & existingTypes,
121             OUString const & context,
122             bool optionalMode = false )
123 {
124     sal_Int32 len = newTypes.getLength();
125     if (len != existingTypes.getLength())
126     {
127         if (!optionalMode || len < newTypes.getLength())
128             typeError( OUSTR("Different number of types!"), context );
129         len = existingTypes.getLength();
130     }
131 
132     Reference<T> const * pNewTypes = newTypes.getConstArray();
133     Reference<T> const * pExistingTypes = existingTypes.getConstArray();
134     for ( sal_Int32 pos = 0; pos < len; ++pos )
135     {
136         OUStringBuffer buf;
137         buf.append( context );
138         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", position ") );
139         buf.append( pos );
140         check( pNewTypes[pos].get(), pExistingTypes[pos].get(),
141                buf.makeStringAndClear() );
142     }
143 }
144 
checkEnum(Reference<reflection::XEnumTypeDescription> const & xNewTD,Reference<reflection::XEnumTypeDescription> const & xExistingTD)145 void checkEnum(
146     Reference<reflection::XEnumTypeDescription> const & xNewTD,
147     Reference<reflection::XEnumTypeDescription> const & xExistingTD )
148 {
149     if (xNewTD->getEnumNames() != xExistingTD->getEnumNames())
150         typeError( OUSTR("ENUM names don't match!"), xNewTD->getName() );
151     if (xNewTD->getEnumValues() != xExistingTD->getEnumValues())
152         typeError( OUSTR("ENUM values don't match!"), xNewTD->getName() );
153 }
154 
checkStruct(Reference<reflection::XCompoundTypeDescription> const & xNewTD,Reference<reflection::XCompoundTypeDescription> const & xExistingTD)155 void checkStruct(
156     Reference<reflection::XCompoundTypeDescription> const & xNewTD,
157     Reference<reflection::XCompoundTypeDescription> const & xExistingTD )
158 {
159     check( xNewTD->getBaseType(), xExistingTD->getBaseType(),
160            xNewTD->getName() + OUSTR(", base type") );
161     checkSeq( xNewTD->getMemberTypes(), xExistingTD->getMemberTypes(),
162               xNewTD->getName() + OUSTR(", member types") );
163 
164     if (xNewTD->getMemberNames() != xExistingTD->getMemberNames())
165         typeError( OUSTR("Different member names!"), xNewTD->getName() );
166 
167     if (xNewTD->getTypeClass() == TypeClass_STRUCT)
168     {
169         Reference<reflection::XStructTypeDescription> xNewStructTD(
170             xNewTD, UNO_QUERY );
171         Reference<reflection::XStructTypeDescription> xExistingStructTD(
172             xExistingTD, UNO_QUERY );
173         if (xNewStructTD.is() && xExistingStructTD.is())
174         {
175             if (xNewStructTD->getTypeParameters() !=
176                 xExistingStructTD->getTypeParameters())
177                 typeError( OUSTR("Different type parameters of instantiated "
178                                  "polymorphic STRUCT!"), xNewTD->getName() );
179             checkSeq( xNewStructTD->getTypeArguments(),
180                       xExistingStructTD->getTypeArguments(),
181                       xNewTD->getName() + OUSTR(", argument types") );
182         }
183         else if (xNewStructTD.is() || xExistingStructTD.is())
184             typeError( OUSTR("Mixing polymorphic STRUCT types "
185                              "with non-polymorphic!"), xNewTD->getName() );
186     }
187 }
188 
checkInterface(Reference<reflection::XInterfaceTypeDescription2> const & xNewTD,Reference<reflection::XInterfaceTypeDescription2> const & xExistingTD)189 void checkInterface(
190     Reference<reflection::XInterfaceTypeDescription2> const & xNewTD,
191     Reference<reflection::XInterfaceTypeDescription2> const & xExistingTD )
192 {
193     checkSeq( xNewTD->getBaseTypes(), xExistingTD->getBaseTypes(),
194               xNewTD->getName() + OUSTR(", base types") );
195     checkSeq(xNewTD->getOptionalBaseTypes(),xExistingTD->getOptionalBaseTypes(),
196              xNewTD->getName() + OUSTR(", optional base types") );
197     checkSeq( xNewTD->getMembers(), xExistingTD->getMembers(),
198               xNewTD->getName() + OUSTR(", members") );
199 }
200 
checkRestParam(Reference<reflection::XParameter> const & xNewParam,Reference<reflection::XParameter> const & xExistingParam,OUString const & context)201 void checkRestParam( Reference<reflection::XParameter> const & xNewParam,
202                      Reference<reflection::XParameter> const & xExistingParam,
203                      OUString const & context )
204 {
205     if (xNewParam->isRestParameter() != xExistingParam->isRestParameter())
206         typeError( OUSTR("Different ... parameters specified!"), context );
207 }
208 
checkRestParam(Reference<reflection::XMethodParameter> const &,Reference<reflection::XMethodParameter> const &,OUString const &)209 void checkRestParam( Reference<reflection::XMethodParameter> const &,
210                      Reference<reflection::XMethodParameter> const &,
211                      OUString const & )
212 {
213 }
214 
215 template<typename T>
checkParameters(Sequence<Reference<T>> const & newParams,Sequence<Reference<T>> const & existingParams,OUString const & context_)216 void checkParameters( Sequence< Reference<T> > const & newParams,
217                       Sequence< Reference<T> > const & existingParams,
218                       OUString const & context_ )
219 {
220     sal_Int32 len = newParams.getLength();
221     if (len != existingParams.getLength())
222         typeError( OUSTR("Different number of parameters!"), context_ );
223 	Reference<T> const * pNewParams = newParams.getConstArray();
224 	Reference<T> const * pExistingParams = existingParams.getConstArray();
225     for ( sal_Int32 pos = 0; pos < len; ++pos )
226     {
227         Reference<T> const & xNewParam = pNewParams[pos];
228         Reference<T> const & xExistingParam = pExistingParams[pos];
229 
230         OUStringBuffer buf;
231         buf.append( context_ );
232         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", parameter ") );
233         buf.append( pos );
234         OSL_ASSERT( pos == xNewParam->getPosition() &&
235                     pos == xExistingParam->getPosition() );
236         OUString context( buf.makeStringAndClear() );
237 
238         if (xNewParam->getName() != xExistingParam->getName())
239         {
240             buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("Name differs: ") );
241             buf.append( xNewParam->getName() );
242             buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") );
243             buf.append( xExistingParam->getName() );
244             typeError( buf.makeStringAndClear(), context );
245         }
246         check( xNewParam->getType(), xExistingParam->getType(), context );
247 
248         if (xNewParam->isIn() != xExistingParam->isIn())
249             typeError( OUSTR("IN attribute differs!"), context );
250         if (xNewParam->isOut() != xExistingParam->isOut())
251             typeError( OUSTR("OUT attribute differs!"), context );
252         checkRestParam( xNewParam, xExistingParam, context );
253     }
254 }
255 
checkMethod(Reference<reflection::XInterfaceMethodTypeDescription> const & xNewTD,Reference<reflection::XInterfaceMethodTypeDescription> const & xExistingTD)256 static void checkMethod(
257     Reference<reflection::XInterfaceMethodTypeDescription> const & xNewTD,
258     Reference<reflection::XInterfaceMethodTypeDescription> const & xExistingTD )
259 {
260 	check( xNewTD->getReturnType(), xExistingTD->getReturnType(),
261            xNewTD->getName() );
262 
263 	if (xNewTD->isOneway() != xExistingTD->isOneway())
264         typeError( OUSTR("Methods have differing OneWay attribute!"),
265                    xNewTD->getName() );
266 
267     checkParameters( xNewTD->getParameters(), xExistingTD->getParameters(),
268                      xNewTD->getName() );
269 
270     checkSeq( xNewTD->getExceptions(), xExistingTD->getExceptions(),
271               xNewTD->getName() + OUSTR(", declared exceptions") );
272 }
273 
checkAttribute(Reference<reflection::XInterfaceAttributeTypeDescription2> const & xNewTD,Reference<reflection::XInterfaceAttributeTypeDescription2> const & xExistingTD)274 void checkAttribute(
275     Reference<reflection::XInterfaceAttributeTypeDescription2> const & xNewTD,
276     Reference<reflection::XInterfaceAttributeTypeDescription2>
277     const & xExistingTD )
278 {
279 	if (xNewTD->isReadOnly() != xExistingTD->isReadOnly())
280         typeError( OUSTR("ReadOnly attribute differs!"), xNewTD->getName() );
281 
282     check( xNewTD->getType(), xExistingTD->getType(),
283            xNewTD->getName() + OUSTR(", attribute type") );
284 
285     if (xNewTD->isBound() != xExistingTD->isBound())
286         typeError( OUSTR("Bound attribute differs!"), xNewTD->getName() );
287 
288     checkSeq( xNewTD->getGetExceptions(), xExistingTD->getGetExceptions(),
289               xNewTD->getName() + OUSTR(", getter exceptions") );
290     checkSeq( xNewTD->getSetExceptions(), xExistingTD->getSetExceptions(),
291               xNewTD->getName() + OUSTR(", setter exceptions") );
292 }
293 
checkProperty(Reference<reflection::XPropertyTypeDescription> const & xNewTD,Reference<reflection::XPropertyTypeDescription> const & xExistingTD)294 void checkProperty(
295     Reference<reflection::XPropertyTypeDescription> const & xNewTD,
296     Reference<reflection::XPropertyTypeDescription> const & xExistingTD )
297 {
298     if (xNewTD->getPropertyFlags() != xExistingTD->getPropertyFlags())
299     {
300         OUStringBuffer buf;
301         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
302                              "Different set of property flags: { ") );
303         buf.append( getPropertyFlagsAsString(
304                         xNewTD->getPropertyFlags() ) );
305         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" } (new), { ") );
306         buf.append( getPropertyFlagsAsString(
307                         xExistingTD->getPropertyFlags() ) );
308         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" } (existing)!") );
309         typeError( buf.makeStringAndClear(), xNewTD->getName() );
310     }
311 
312     check( xNewTD->getPropertyTypeDescription(),
313            xExistingTD->getPropertyTypeDescription(),
314            xNewTD->getName() );
315 }
316 
checkSingleton(Reference<reflection::XSingletonTypeDescription2> const & xNewTD,Reference<reflection::XSingletonTypeDescription2> const & xExistingTD)317 void checkSingleton(
318     Reference<reflection::XSingletonTypeDescription2> const & xNewTD,
319     Reference<reflection::XSingletonTypeDescription2> const & xExistingTD )
320 {
321     sal_Bool ifaceBased = xNewTD->isInterfaceBased();
322     if (ifaceBased != xExistingTD->isInterfaceBased())
323         typeError(
324             OUSTR("Mixing interface and NON-interface based singletons!"),
325             xNewTD->getName() );
326     if (ifaceBased)
327         check( xNewTD->getInterface(), xExistingTD->getInterface(),
328                xNewTD->getName() );
329     else
330         check( xNewTD->getService().get(), xExistingTD->getService().get(),
331                xNewTD->getName() );
332 }
333 
checkService(Reference<reflection::XServiceTypeDescription2> const & xNewTD,Reference<reflection::XServiceTypeDescription2> const & xExistingTD)334 void checkService(
335     Reference<reflection::XServiceTypeDescription2> const & xNewTD,
336     Reference<reflection::XServiceTypeDescription2> const & xExistingTD )
337 {
338     sal_Bool singleIfaceBased = xNewTD->isSingleInterfaceBased();
339     if (singleIfaceBased != xExistingTD->isSingleInterfaceBased())
340         typeError( OUSTR("Mixing interface and NON-interface based services!"),
341                    xNewTD->getName() );
342     if (singleIfaceBased)
343     {
344         check( xNewTD->getInterface(), xExistingTD->getInterface(),
345                xNewTD->getName() );
346         Sequence< Reference<reflection::XServiceConstructorDescription> >
347             newCtors( xNewTD->getConstructors() );
348         Sequence< Reference<reflection::XServiceConstructorDescription> >
349             existingCtors( xExistingTD->getConstructors() );
350         sal_Int32 len = newCtors.getLength();
351         if (len != existingCtors.getLength())
352             typeError( OUSTR("Different number of service constructors!"),
353                        xNewTD->getName() );
354         Reference<reflection::XServiceConstructorDescription> const *
355             pNewCtors = newCtors.getConstArray();
356         Reference<reflection::XServiceConstructorDescription> const *
357             pExistingCtors = existingCtors.getConstArray();
358         for ( sal_Int32 pos = 0; pos < len; ++pos )
359         {
360             Reference<reflection::XServiceConstructorDescription> const &
361                 xNewCtor = pNewCtors[pos];
362             Reference<reflection::XServiceConstructorDescription> const &
363                 xExistingCtor = pExistingCtors[pos];
364 
365             if (xNewCtor->getName() != xExistingCtor->getName())
366             {
367                 OUStringBuffer buf;
368                 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
369                                      "Different constructor names: ") );
370                 buf.append( xNewCtor->getName() );
371                 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") );
372                 buf.append( xExistingCtor->getName() );
373                 buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") );
374                 typeError( buf.makeStringAndClear(), xNewTD->getName() );
375             }
376 
377             OUStringBuffer buf;
378             buf.append( xNewTD->getName() );
379             buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", constructor ") );
380             buf.append( xNewCtor->getName() );
381             OUString context( buf.makeStringAndClear() );
382             checkParameters( xNewCtor->getParameters(),
383                              xExistingCtor->getParameters(),
384                              context );
385             checkSeq( xNewCtor->getExceptions(), xExistingCtor->getExceptions(),
386                       context + OUSTR(", exceptions") );
387         }
388     }
389     else // old-style service descriptions:
390     {
391         checkSeq( xNewTD->getMandatoryServices(),
392                   xExistingTD->getMandatoryServices(),
393                   xNewTD->getName() + OUSTR(", mandatory services") );
394         checkSeq( xNewTD->getOptionalServices(),
395                   xExistingTD->getOptionalServices(),
396                   xNewTD->getName() + OUSTR(", optional services"),
397                   true /* optionalMode */ );
398         checkSeq( xNewTD->getMandatoryInterfaces(),
399                   xExistingTD->getMandatoryInterfaces(),
400                   xNewTD->getName() + OUSTR(", mandatory interfaces") );
401         checkSeq( xNewTD->getOptionalInterfaces(),
402                   xExistingTD->getOptionalInterfaces(),
403                   xNewTD->getName() + OUSTR(", optional interfaces"),
404                   true /* optionalMode */ );
405 
406         Sequence< Reference<reflection::XPropertyTypeDescription> >
407             newProperties( xNewTD->getProperties() );
408         Sequence< Reference<reflection::XPropertyTypeDescription> >
409             existingProperties( xExistingTD->getProperties() );
410         checkSeq( newProperties, existingProperties,
411                   xNewTD->getName() + OUSTR(", properties"),
412                   true /* optionalMode */ );
413         if (newProperties.getLength() > existingProperties.getLength())
414         {
415             // check whether all added properties are OPTIONAL:
416             Reference<reflection::XPropertyTypeDescription> const *
417                 pNewProperties = newProperties.getConstArray();
418             for ( sal_Int32 pos = existingProperties.getLength() + 1;
419                   pos < newProperties.getLength(); ++pos )
420             {
421                 if ((pNewProperties[pos]->getPropertyFlags() &
422                      beans::PropertyAttribute::OPTIONAL) == 0)
423                     typeError( OUSTR("New property is not OPTIONAL!"),
424                                pNewProperties[pos]->getName() );
425             }
426         }
427     }
428 }
429 
430 }
431 
432 namespace stoc_tdmgr {
433 
check(Reference<reflection::XTypeDescription> const & xNewTD,Reference<reflection::XTypeDescription> const & xExistingTD,OUString const & context)434 void check( Reference<reflection::XTypeDescription> const & xNewTD,
435             Reference<reflection::XTypeDescription> const & xExistingTD,
436             OUString const & context )
437 {
438     if (xNewTD == xExistingTD)
439         return;
440     if (xNewTD->getName() != xExistingTD->getName())
441     {
442         OUStringBuffer buf;
443         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("Different type names: ") );
444         buf.append( xNewTD->getName() );
445         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") );
446         buf.append( xExistingTD->getName() );
447         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") );
448         typeError( buf.makeStringAndClear(), context );
449     }
450 
451     TypeClass tc = xNewTD->getTypeClass();
452     if (tc != xExistingTD->getTypeClass())
453     {
454         OUStringBuffer buf;
455         buf.append( xNewTD->getName() );
456         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
457                              " has different type classes: ") );
458         buf.append( getTypeClassName( tc ) );
459         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") );
460         buf.append( getTypeClassName( xExistingTD->getTypeClass() ) );
461         buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") );
462         typeError( buf.makeStringAndClear(), context );
463     }
464 
465     switch (tc)
466     {
467     case TypeClass_ENUM:
468         checkEnum( Reference<reflection::XEnumTypeDescription>(
469                        xNewTD, UNO_QUERY_THROW ),
470                    Reference<reflection::XEnumTypeDescription>(
471                        xExistingTD, UNO_QUERY_THROW ) );
472         break;
473 
474     case TypeClass_TYPEDEF:
475     case TypeClass_SEQUENCE:
476         check( Reference<reflection::XIndirectTypeDescription>(
477                    xNewTD, UNO_QUERY_THROW )->getReferencedType(),
478                Reference<reflection::XIndirectTypeDescription>(
479                    xExistingTD, UNO_QUERY_THROW )->getReferencedType() );
480         break;
481 
482     case TypeClass_STRUCT:
483     case TypeClass_EXCEPTION:
484         checkStruct( Reference<reflection::XCompoundTypeDescription>(
485                          xNewTD, UNO_QUERY_THROW ),
486                      Reference<reflection::XCompoundTypeDescription>(
487                          xExistingTD, UNO_QUERY_THROW ) );
488         break;
489 
490     case TypeClass_INTERFACE:
491         checkInterface( Reference<reflection::XInterfaceTypeDescription2>(
492                             xNewTD, UNO_QUERY_THROW ),
493                         Reference<reflection::XInterfaceTypeDescription2>(
494                             xExistingTD, UNO_QUERY_THROW ) );
495         break;
496 
497     case TypeClass_SERVICE:
498         checkService( Reference<reflection::XServiceTypeDescription2>(
499                           xNewTD, UNO_QUERY_THROW ),
500                       Reference<reflection::XServiceTypeDescription2>(
501                           xExistingTD, UNO_QUERY_THROW ) );
502         break;
503 
504     case TypeClass_INTERFACE_METHOD:
505         checkMethod( Reference<reflection::XInterfaceMethodTypeDescription>(
506                          xNewTD, UNO_QUERY_THROW ),
507                      Reference<reflection::XInterfaceMethodTypeDescription>(
508                          xExistingTD, UNO_QUERY_THROW ) );
509         break;
510     case TypeClass_INTERFACE_ATTRIBUTE:
511         checkAttribute(
512             Reference<reflection::XInterfaceAttributeTypeDescription2>(
513                 xNewTD, UNO_QUERY_THROW ),
514             Reference<reflection::XInterfaceAttributeTypeDescription2>(
515                 xExistingTD, UNO_QUERY_THROW ) );
516         break;
517 
518     case TypeClass_PROPERTY:
519         checkProperty( Reference<reflection::XPropertyTypeDescription>(
520                            xNewTD, UNO_QUERY_THROW ),
521                        Reference<reflection::XPropertyTypeDescription>(
522                            xExistingTD, UNO_QUERY_THROW ) );
523         break;
524 
525     case TypeClass_CONSTANT:
526         if (Reference<reflection::XConstantTypeDescription>(
527                 xNewTD, UNO_QUERY_THROW )->getConstantValue() !=
528             Reference<reflection::XConstantTypeDescription>(
529                 xExistingTD, UNO_QUERY_THROW )->getConstantValue())
530             typeError( OUSTR("Different constant value!"), xNewTD->getName() );
531         break;
532     case TypeClass_CONSTANTS:
533         checkSeq( Reference<reflection::XConstantsTypeDescription>(
534                       xNewTD, UNO_QUERY_THROW )->getConstants(),
535                   Reference<reflection::XConstantsTypeDescription>(
536                       xExistingTD, UNO_QUERY_THROW )->getConstants(),
537                   xNewTD->getName() );
538         break;
539 
540     case TypeClass_SINGLETON:
541         checkSingleton( Reference<reflection::XSingletonTypeDescription2>(
542                             xNewTD, UNO_QUERY_THROW ),
543                         Reference<reflection::XSingletonTypeDescription2>(
544                             xExistingTD, UNO_QUERY_THROW ) );
545         break;
546 
547     default:
548         break;
549     }
550 }
551 
552 }
553