Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <string.h>
21 : :
22 : : #define INTROSPECTION_CACHE_MAX_SIZE 100
23 : :
24 : : #include <osl/diagnose.h>
25 : : #include <osl/mutex.hxx>
26 : : #include <osl/thread.h>
27 : : #include <cppuhelper/queryinterface.hxx>
28 : : #include <cppuhelper/weak.hxx>
29 : : #include <cppuhelper/component.hxx>
30 : : #include <cppuhelper/factory.hxx>
31 : : #include <cppuhelper/implbase3.hxx>
32 : : #include <cppuhelper/typeprovider.hxx>
33 : : #include <salhelper/simplereferenceobject.hxx>
34 : :
35 : : #include <com/sun/star/uno/DeploymentException.hpp>
36 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
37 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 : : #include <com/sun/star/lang/XServiceInfo.hpp>
39 : : #include <com/sun/star/lang/XEventListener.hpp>
40 : : #include <com/sun/star/reflection/XIdlReflection.hpp>
41 : : #include <com/sun/star/reflection/XIdlClass.hpp>
42 : : #include <com/sun/star/reflection/XIdlField2.hpp>
43 : : #include <com/sun/star/beans/UnknownPropertyException.hpp>
44 : : #include <com/sun/star/beans/Property.hpp>
45 : : #include <com/sun/star/beans/XPropertySet.hpp>
46 : : #include <com/sun/star/beans/XFastPropertySet.hpp>
47 : : #include <com/sun/star/beans/XIntrospection.hpp>
48 : : #include <com/sun/star/beans/XIntrospectionAccess.hpp>
49 : : #include <com/sun/star/beans/XMaterialHolder.hpp>
50 : : #include <com/sun/star/beans/XExactName.hpp>
51 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
52 : : #include <com/sun/star/beans/PropertyConcept.hpp>
53 : : #include <com/sun/star/beans/MethodConcept.hpp>
54 : : #include <com/sun/star/container/XNameContainer.hpp>
55 : : #include <com/sun/star/container/XIndexContainer.hpp>
56 : : #include <com/sun/star/container/XEnumerationAccess.hpp>
57 : :
58 : : #include <rtl/ref.hxx>
59 : : #include <rtl/ustrbuf.hxx>
60 : : #include <rtl/ref.hxx>
61 : : #include <rtl/strbuf.hxx>
62 : : #include <boost/unordered_map.hpp>
63 : :
64 : : using namespace com::sun::star::uno;
65 : : using namespace com::sun::star::lang;
66 : : using namespace com::sun::star::reflection;
67 : : using namespace com::sun::star::container;
68 : : using namespace com::sun::star::registry;
69 : : using namespace com::sun::star::beans;
70 : : using namespace com::sun::star::beans::PropertyAttribute;
71 : : using namespace com::sun::star::beans::PropertyConcept;
72 : : using namespace com::sun::star::beans::MethodConcept;
73 : : using namespace cppu;
74 : : using namespace osl;
75 : :
76 : : #define IMPLEMENTATION_NAME "com.sun.star.comp.stoc.Introspection"
77 : : #define SERVICE_NAME "com.sun.star.beans.Introspection"
78 : :
79 : : namespace stoc_inspect
80 : : {
81 : :
82 : : typedef WeakImplHelper3< XIntrospectionAccess, XMaterialHolder, XExactName > IntrospectionAccessHelper;
83 : :
84 : :
85 : : //==================================================================================================
86 : :
87 : : // Spezial-Wert fuer Method-Concept, um "normale" Funktionen kennzeichnen zu koennen
88 : : #define MethodConcept_NORMAL_IMPL 0x80000000
89 : :
90 : :
91 : : // Methode zur Feststellung, ob eine Klasse von einer anderen abgeleitet ist
92 : 5090 : sal_Bool isDerivedFrom( Reference<XIdlClass> xToTestClass, Reference<XIdlClass> xDerivedFromClass )
93 : : {
94 [ + - ][ + - ]: 5090 : Sequence< Reference<XIdlClass> > aClassesSeq = xToTestClass->getSuperclasses();
95 : 5090 : const Reference<XIdlClass>* pClassesArray = aClassesSeq.getConstArray();
96 : :
97 : 5090 : sal_Int32 nSuperClassCount = aClassesSeq.getLength();
98 [ + + ]: 5092 : for ( sal_Int32 i = 0; i < nSuperClassCount; ++i )
99 : : {
100 : 3536 : const Reference<XIdlClass>& rxClass = pClassesArray[i];
101 : :
102 [ + - ][ + - ]: 7074 : if ( xDerivedFromClass->equals( rxClass ) ||
[ + + ][ - + ]
[ + + ]
103 [ + - ][ + + ]: 3538 : isDerivedFrom( rxClass, xDerivedFromClass )
[ + + ]
[ # # # # ]
104 : : )
105 : 3534 : return sal_True;
106 : : }
107 : :
108 [ + - ]: 5090 : return sal_False;
109 : : }
110 : :
111 : : //========================================================================
112 : :
113 : : // *** Klassifizierung der Properties (kein enum, um Sequence verwenden zu koennen) ***
114 : : // Properties aus einem PropertySet-Interface
115 : : #define MAP_PROPERTY_SET 0
116 : : // Properties aus Fields
117 : : #define MAP_FIELD 1
118 : : // Properties, die durch get/set-Methoden beschrieben werden
119 : : #define MAP_GETSET 2
120 : : // Properties, die nur eine set-Methode haben
121 : : #define MAP_SETONLY 3
122 : :
123 : :
124 : : // Schrittweite, in der die Groesse der Sequences angepasst wird
125 : : #define ARRAY_SIZE_STEP 20
126 : :
127 : :
128 : :
129 : : //**************************************
130 : : //*** IntrospectionAccessStatic_Impl ***
131 : : //**************************************
132 : : // Entspricht dem alten IntrospectionAccessImpl, bildet jetzt den statischen
133 : : // Anteil des neuen Instanz-bezogenen ImplIntrospectionAccess
134 : :
135 : : // Hashtable fuer die Suche nach Namen
136 : : struct hashName_Impl
137 : : {
138 : 652143 : size_t operator()(const ::rtl::OUString Str) const
139 : : {
140 : 652143 : return (size_t)Str.hashCode();
141 : : }
142 : : };
143 : :
144 : : struct eqName_Impl
145 : : {
146 : 385855 : sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const
147 : : {
148 : 385855 : return ( Str1 == Str2 );
149 : : }
150 : : };
151 : :
152 : : typedef boost::unordered_map
153 : : <
154 : : ::rtl::OUString,
155 : : sal_Int32,
156 : : hashName_Impl,
157 : : eqName_Impl
158 : : >
159 : : IntrospectionNameMap;
160 : :
161 : :
162 : : // Hashtable zur Zuordnung der exakten Namen zu den zu Lower-Case
163 : : // konvertierten Namen, dient zur Unterst�tzung von XExactName
164 : : typedef boost::unordered_map
165 : : <
166 : : ::rtl::OUString,
167 : : ::rtl::OUString,
168 : : hashName_Impl,
169 : : eqName_Impl
170 : : >
171 : : LowerToExactNameMap;
172 : :
173 : :
174 : : class ImplIntrospectionAccess;
175 : : class IntrospectionAccessStatic_Impl: public salhelper::SimpleReferenceObject
176 : : {
177 : : friend class ImplIntrospection;
178 : : friend class ImplIntrospectionAccess;
179 : :
180 : : // CoreReflection halten
181 : : Reference< XIdlReflection > mxCoreReflection;
182 : :
183 : : // InterfaceSequences, um Zusatz-Infos zu einer Property speichern zu koennen.
184 : : // z.B. das Field bei MAP_FIELD, die get/set-Methoden bei MAP_GETSET usw.
185 : : Sequence< Reference<XInterface> > aInterfaceSeq1;
186 : : Sequence< Reference<XInterface> > aInterfaceSeq2;
187 : :
188 : : // Hashtables fuer die Namen
189 : : IntrospectionNameMap maPropertyNameMap;
190 : : IntrospectionNameMap maMethodNameMap;
191 : : LowerToExactNameMap maLowerToExactNameMap;
192 : :
193 : : // Sequence aller Properties, auch zum Liefern aus getProperties()
194 : : Sequence<Property> maAllPropertySeq;
195 : :
196 : : // Mapping der Properties auf Zugriffs-Arten
197 : : Sequence<sal_Int16> maMapTypeSeq;
198 : :
199 : : // Klassifizierung der gefundenen Methoden
200 : : Sequence<sal_Int32> maPropertyConceptSeq;
201 : :
202 : : // Anzahl der Properties
203 : : sal_Int32 mnPropCount;
204 : :
205 : : // Anzahl der Properties, die den jeweiligen Konzepten zugeordnet sind
206 : : //sal_Int32 mnDangerousPropCount;
207 : : sal_Int32 mnPropertySetPropCount;
208 : : sal_Int32 mnAttributePropCount;
209 : : sal_Int32 mnMethodPropCount;
210 : :
211 : : // Flag, ob ein FastPropertySet unterstuetzt wird
212 : : sal_Bool mbFastPropSet;
213 : :
214 : : // Original-Handles eines FastPropertySets
215 : : sal_Int32* mpOrgPropertyHandleArray;
216 : :
217 : : // MethodSequence, die alle Methoden aufnimmt
218 : : Sequence< Reference<XIdlMethod> > maAllMethodSeq;
219 : :
220 : : // Klassifizierung der gefundenen Methoden
221 : : Sequence<sal_Int32> maMethodConceptSeq;
222 : :
223 : : // Anzahl der Methoden
224 : : sal_Int32 mnMethCount;
225 : :
226 : : // Sequence der Listener, die angemeldet werden koennen
227 : : Sequence< Type > maSupportedListenerSeq;
228 : :
229 : : // BaseInit (soll spaeter in der Applikation erfolgen!)
230 : : void BaseInit( void );
231 : :
232 : : // Hilfs-Methoden zur Groessen-Anpassung der Sequences
233 : : void checkPropertyArraysSize
234 : : (
235 : : Property*& rpAllPropArray,
236 : : sal_Int16*& rpMapTypeArray,
237 : : sal_Int32*& rpPropertyConceptArray,
238 : : sal_Int32 iNextIndex
239 : : );
240 : : void checkInterfaceArraySize( Sequence< Reference<XInterface> >& rSeq, Reference<XInterface>*& rpInterfaceArray,
241 : : sal_Int32 iNextIndex );
242 : :
243 : : public:
244 : : IntrospectionAccessStatic_Impl( Reference< XIdlReflection > xCoreReflection_ );
245 : 2282 : ~IntrospectionAccessStatic_Impl()
246 [ + - ][ + - ]: 1141 : {
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
247 [ + + ]: 1141 : delete[] mpOrgPropertyHandleArray;
248 [ - + ]: 2282 : }
249 : : sal_Int32 getPropertyIndex( const ::rtl::OUString& aPropertyName ) const;
250 : : sal_Int32 getMethodIndex( const ::rtl::OUString& aMethodName ) const;
251 : :
252 : : // Methoden von XIntrospectionAccess (ALT, jetzt nur Impl)
253 : : void setPropertyValue(const Any& obj, const ::rtl::OUString& aPropertyName, const Any& aValue) const;
254 : : // void setPropertyValue(Any& obj, const ::rtl::OUString& aPropertyName, const Any& aValue) const;
255 : : Any getPropertyValue(const Any& obj, const ::rtl::OUString& aPropertyName) const;
256 : : void setPropertyValueByIndex(const Any& obj, sal_Int32 nIndex, const Any& aValue) const;
257 : : // void setPropertyValueByIndex(Any& obj, sal_Int32 nIndex, const Any& aValue) const;
258 : : Any getPropertyValueByIndex(const Any& obj, sal_Int32 nIndex) const;
259 : :
260 : 55414 : Sequence<Property> getProperties(void) const { return maAllPropertySeq; }
261 : 3932 : Sequence< Reference<XIdlMethod> > getMethods(void) const { return maAllMethodSeq; }
262 : 0 : Sequence< Type > getSupportedListeners(void) const { return maSupportedListenerSeq; }
263 : 254473 : Sequence<sal_Int32> getPropertyConcepts(void) const { return maPropertyConceptSeq; }
264 : 7668 : Sequence<sal_Int32> getMethodConcepts(void) const { return maMethodConceptSeq; }
265 : : };
266 : :
267 : :
268 : : // Ctor
269 : 1368 : IntrospectionAccessStatic_Impl::IntrospectionAccessStatic_Impl( Reference< XIdlReflection > xCoreReflection_ )
270 [ + - ][ + - ]: 1368 : : mxCoreReflection( xCoreReflection_ )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
271 : : {
272 [ + - ]: 1368 : aInterfaceSeq1.realloc( ARRAY_SIZE_STEP );
273 [ + - ]: 1368 : aInterfaceSeq2.realloc( ARRAY_SIZE_STEP );
274 : :
275 : : // Property-Daten
276 [ + - ]: 1368 : maAllPropertySeq.realloc( ARRAY_SIZE_STEP );
277 [ + - ]: 1368 : maMapTypeSeq.realloc( ARRAY_SIZE_STEP );
278 [ + - ]: 1368 : maPropertyConceptSeq.realloc( ARRAY_SIZE_STEP );
279 : :
280 : 1368 : mbFastPropSet = sal_False;
281 : 1368 : mpOrgPropertyHandleArray = NULL;
282 : :
283 : 1368 : mnPropCount = 0;
284 : : //mnDangerousPropCount = 0;
285 : 1368 : mnPropertySetPropCount = 0;
286 : 1368 : mnAttributePropCount = 0;
287 : 1368 : mnMethodPropCount = 0;
288 : :
289 : : // Method-Daten
290 : 1368 : mnMethCount = 0;
291 : 1368 : }
292 : :
293 : 360397 : sal_Int32 IntrospectionAccessStatic_Impl::getPropertyIndex( const ::rtl::OUString& aPropertyName ) const
294 : : {
295 : 360397 : sal_Int32 iHashResult = -1;
296 : 360397 : IntrospectionAccessStatic_Impl* pThis = (IntrospectionAccessStatic_Impl*)this;
297 [ + - ]: 360397 : IntrospectionNameMap::iterator aIt = pThis->maPropertyNameMap.find( aPropertyName );
298 [ + - ][ + + ]: 360397 : if( !( aIt == pThis->maPropertyNameMap.end() ) )
299 [ + - ]: 357299 : iHashResult = (*aIt).second;
300 : 360397 : return iHashResult;
301 : : }
302 : :
303 : 54986 : sal_Int32 IntrospectionAccessStatic_Impl::getMethodIndex( const ::rtl::OUString& aMethodName ) const
304 : : {
305 : 54986 : sal_Int32 iHashResult = -1;
306 : 54986 : IntrospectionAccessStatic_Impl* pThis = (IntrospectionAccessStatic_Impl*)this;
307 [ + - ]: 54986 : IntrospectionNameMap::iterator aIt = pThis->maMethodNameMap.find( aMethodName );
308 [ + - ][ + + ]: 54986 : if( !( aIt == pThis->maMethodNameMap.end() ) )
309 : : {
310 [ + - ]: 7620 : iHashResult = (*aIt).second;
311 : : }
312 : : // #95159 Check if full qualified name matches
313 : : else
314 : : {
315 : 47366 : sal_Int32 nSearchFrom = aMethodName.getLength();
316 : 47366 : nSearchFrom = aMethodName.getLength();
317 : 47366 : while( true )
318 : : {
319 : : // Strategy: Search back until the first '_' is found
320 : 47366 : sal_Int32 nFound = aMethodName.lastIndexOf( '_', nSearchFrom );
321 [ - + ]: 47366 : if( nFound == -1 )
322 : : break;
323 : :
324 : 0 : ::rtl::OUString aPureMethodName = aMethodName.copy( nFound + 1 );
325 : :
326 [ # # ]: 0 : aIt = pThis->maMethodNameMap.find( aPureMethodName );
327 [ # # ][ # # ]: 0 : if( !( aIt == pThis->maMethodNameMap.end() ) )
328 : : {
329 : : // Check if it can be a type?
330 : : // Problem: Does not work if package names contain _ ?!
331 : 0 : ::rtl::OUString aStr = aMethodName.copy( 0, nFound );
332 : 0 : ::rtl::OUString aTypeName = aStr.replace( '_', '.' );
333 [ # # ][ # # ]: 0 : Reference< XIdlClass > xClass = mxCoreReflection->forName( aTypeName );
334 [ # # ]: 0 : if( xClass.is() )
335 : : {
336 : : // If this is a valid class it could be the right method
337 : :
338 : : // Could be the right method, type has to be checked
339 [ # # ]: 0 : iHashResult = (*aIt).second;
340 : :
341 : 0 : const Reference<XIdlMethod>* pMethods = maAllMethodSeq.getConstArray();
342 : 0 : const Reference<XIdlMethod> xMethod = pMethods[ iHashResult ];
343 : :
344 [ # # ][ # # ]: 0 : Reference< XIdlClass > xMethClass = xMethod->getDeclaringClass();
345 [ # # ][ # # ]: 0 : if( xClass->equals( xMethClass ) )
[ # # ]
346 : : {
347 : : break;
348 : : }
349 : : else
350 : : {
351 : 0 : iHashResult = -1;
352 : :
353 : : // Could also be another method with the same name
354 : : // Iterate over all methods
355 : 0 : sal_Int32 nLen = maAllMethodSeq.getLength();
356 [ # # ]: 0 : for( int i = 0 ; i < nLen ; ++i )
357 : : {
358 : 0 : const Reference<XIdlMethod> xMethod2 = pMethods[ i ];
359 : :
360 [ # # ][ # # ]: 0 : ::rtl::OUString aTestClassName = xMethod2->getDeclaringClass()->getName();
[ # # ][ # # ]
361 [ # # ][ # # ]: 0 : ::rtl::OUString aTestMethodName = xMethod2->getName();
362 : :
363 [ # # ][ # # ]: 0 : if( xMethod2->getName() == aPureMethodName )
[ # # ]
364 : : {
365 [ # # ][ # # ]: 0 : Reference< XIdlClass > xMethClass2 = xMethod2->getDeclaringClass();
366 : :
367 [ # # ][ # # ]: 0 : if( xClass->equals( xMethClass2 ) )
[ # # ]
368 : : {
369 : 0 : iHashResult = i;
370 : : break;
371 [ # # ]: 0 : }
372 : : }
373 [ # # ][ # # ]: 0 : }
[ # # ]
374 : :
375 [ # # ]: 0 : if( iHashResult != -1 )
376 : : break;
377 [ # # ][ # # ]: 0 : }
378 [ # # ][ # # ]: 0 : }
[ # # ]
379 : : }
380 : :
381 : 0 : nSearchFrom = nFound - 1;
382 [ # # ]: 0 : if( nSearchFrom < 0 )
383 : : break;
384 [ # # ]: 0 : }
385 : : }
386 : 54986 : return iHashResult;
387 : : }
388 : :
389 : 55366 : void IntrospectionAccessStatic_Impl::setPropertyValue( const Any& obj, const ::rtl::OUString& aPropertyName, const Any& aValue ) const
390 : : //void IntrospectionAccessStatic_Impl::setPropertyValue( Any& obj, const ::rtl::OUString& aPropertyName, const Any& aValue ) const
391 : : {
392 : 55366 : sal_Int32 i = getPropertyIndex( aPropertyName );
393 [ + - ]: 55366 : if( i != -1 )
394 : 55366 : setPropertyValueByIndex( obj, (sal_Int32)i, aValue );
395 : : else
396 [ # # ]: 0 : throw UnknownPropertyException();
397 : 55366 : }
398 : :
399 : 55366 : void IntrospectionAccessStatic_Impl::setPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex, const Any& aValue) const
400 : : //void IntrospectionAccessStatic_Impl::setPropertyValueByIndex( Any& obj, sal_Int32 nSequenceIndex, const Any& aValue) const
401 : : {
402 : : // Handelt es sich bei dem uebergebenen Objekt ueberhaupt um was passendes?
403 : 55366 : TypeClass eObjType = obj.getValueType().getTypeClass();
404 : :
405 : 55366 : Reference<XInterface> xInterface;
406 [ + + ]: 55366 : if( eObjType == TypeClass_INTERFACE )
407 : : {
408 [ + - ]: 14 : xInterface = *( Reference<XInterface>*)obj.getValue();
409 : : }
410 [ + - ][ - + ]: 55352 : else if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) )
[ # # ]
411 : : {
412 [ # # ]: 0 : throw IllegalArgumentException();
413 : : }
414 : :
415 : : // Flags pruefen
416 : 55366 : const Property* pProps = maAllPropertySeq.getConstArray();
417 [ - + ]: 55366 : if( (pProps[ nSequenceIndex ].Attributes & READONLY) != 0 )
418 : : {
419 [ # # ]: 0 : throw UnknownPropertyException();
420 : : }
421 : :
422 : 55366 : const sal_Int16* pMapTypeArray = maMapTypeSeq.getConstArray();
423 [ + + + - ]: 55366 : switch( pMapTypeArray[ nSequenceIndex ] )
424 : : {
425 : : case MAP_PROPERTY_SET:
426 : : {
427 : : // Property besorgen
428 : 6 : const Property& rProp = maAllPropertySeq.getConstArray()[ nSequenceIndex ];
429 : :
430 : : // Interface-Parameter auf den richtigen Typ bringen
431 : 6 : sal_Bool bUseCopy = sal_False;
432 : 6 : Any aRealValue;
433 : :
434 : 6 : TypeClass eValType = aValue.getValueType().getTypeClass();
435 [ + + ]: 6 : if( eValType == TypeClass_INTERFACE )
436 : : {
437 : 2 : Type aPropType = rProp.Type;
438 : 2 : ::rtl::OUString aTypeName( aPropType.getTypeName() );
439 [ + - ][ + - ]: 2 : Reference< XIdlClass > xPropClass = mxCoreReflection->forName( aTypeName );
440 : : //Reference<XIdlClass> xPropClass = rProp.Type;
441 [ + - ][ + - ]: 2 : if( xPropClass.is() && xPropClass->getTypeClass() == TypeClass_INTERFACE )
[ + - ][ + - ]
[ + - ]
442 : : {
443 : 2 : Reference<XInterface> valInterface = *(Reference<XInterface>*)aValue.getValue();
444 [ + - ]: 2 : if( valInterface.is() )
445 : : {
446 : : //Any queryInterface( const Type& rType );
447 [ + - ][ + - ]: 2 : aRealValue = valInterface->queryInterface( aPropType );
448 [ + - ]: 2 : if( aRealValue.hasValue() )
449 : 2 : bUseCopy = sal_True;
450 : 2 : }
451 : 2 : }
452 : : }
453 : :
454 : : // Haben wir ein FastPropertySet und ein gueltiges Handle?
455 : : // ACHTUNG: An dieser Stelle wird ausgenutzt, dass das PropertySet
456 : : // zu Beginn des Introspection-Vorgangs abgefragt wird.
457 : : sal_Int32 nOrgHandle;
458 [ + - ][ + - ]: 6 : if( mbFastPropSet && ( nOrgHandle = mpOrgPropertyHandleArray[ nSequenceIndex ] ) != -1 )
[ + - ]
459 : : {
460 : : // PropertySet-Interface holen
461 : : Reference<XFastPropertySet> xFastPropSet =
462 [ + - ]: 6 : Reference<XFastPropertySet>::query( xInterface );
463 [ + - ]: 6 : if( xFastPropSet.is() )
464 : : {
465 [ + - ][ + + ]: 6 : xFastPropSet->setFastPropertyValue( nOrgHandle, bUseCopy ? aRealValue : aValue );
[ + - ]
466 : : }
467 : : else
468 : : {
469 : : // throw UnknownPropertyException
470 : 6 : }
471 : : }
472 : : // sonst eben das normale nehmen
473 : : else
474 : : {
475 : : // PropertySet-Interface holen
476 : : Reference<XPropertySet> xPropSet =
477 [ # # ]: 0 : Reference<XPropertySet>::query( xInterface );
478 [ # # ]: 0 : if( xPropSet.is() )
479 : : {
480 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( rProp.Name, bUseCopy ? aRealValue : aValue );
[ # # ]
481 : : }
482 : : else
483 : : {
484 : : // throw UnknownPropertyException
485 : 0 : }
486 : 6 : }
487 : : }
488 : 6 : break;
489 : :
490 : : case MAP_FIELD:
491 : : {
492 [ + - ][ + - ]: 55358 : Reference<XIdlField> xField = (XIdlField*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
493 [ + - ]: 55358 : Reference<XIdlField2> xField2(xField, UNO_QUERY);
494 [ + - ]: 55358 : if( xField2.is() )
495 : : {
496 [ + - ][ + - ]: 55358 : xField2->set( (Any&)obj, aValue );
497 : : // IllegalArgumentException
498 : : // NullPointerException
499 : : } else
500 [ # # ]: 0 : if( xField.is() )
501 : : {
502 [ # # ][ # # ]: 0 : xField->set( obj, aValue );
503 : : // IllegalArgumentException
504 : : // NullPointerException
505 : : }
506 : : else
507 : : {
508 : : // throw IllegalArgumentException();
509 : 55358 : }
510 : : }
511 : 55358 : break;
512 : :
513 : : case MAP_GETSET:
514 : : case MAP_SETONLY:
515 : : {
516 : : // set-Methode holen
517 [ + - ][ + - ]: 2 : Reference<XIdlMethod> xMethod = (XIdlMethod*)(aInterfaceSeq2.getConstArray()[ nSequenceIndex ].get());
518 [ + - ]: 2 : if( xMethod.is() )
519 : : {
520 [ + - ]: 2 : Sequence<Any> args( 1 );
521 [ + - ]: 2 : args.getArray()[0] = aValue;
522 [ + - ][ + - ]: 2 : xMethod->invoke( obj, args );
[ + - ]
523 : : }
524 : : else
525 : : {
526 : : // throw IllegalArgumentException();
527 : 2 : }
528 : : }
529 : 2 : break;
530 : 55366 : }
531 : 55366 : }
532 : :
533 : 47460 : Any IntrospectionAccessStatic_Impl::getPropertyValue( const Any& obj, const ::rtl::OUString& aPropertyName ) const
534 : : {
535 : 47460 : sal_Int32 i = getPropertyIndex( aPropertyName );
536 [ + - ]: 47460 : if( i != -1 )
537 : 47460 : return getPropertyValueByIndex( obj, i );
538 : :
539 [ # # ]: 0 : throw UnknownPropertyException();
540 : : }
541 : :
542 : 47460 : Any IntrospectionAccessStatic_Impl::getPropertyValueByIndex(const Any& obj, sal_Int32 nSequenceIndex) const
543 : : {
544 : 47460 : Any aRet;
545 : :
546 : : // Handelt es sich bei dem uebergebenen Objekt ueberhaupt um was passendes?
547 : 47460 : TypeClass eObjType = obj.getValueType().getTypeClass();
548 : :
549 : 47460 : Reference<XInterface> xInterface;
550 [ + + ]: 47460 : if( eObjType == TypeClass_INTERFACE )
551 : : {
552 [ + - ]: 471 : xInterface = *(Reference<XInterface>*)obj.getValue();
553 : : }
554 [ + - ][ - + ]: 46989 : else if( nSequenceIndex >= mnPropCount || ( eObjType != TypeClass_STRUCT && eObjType != TypeClass_EXCEPTION ) )
[ # # ]
555 : : {
556 : : // throw IllegalArgumentException();
557 : : return aRet;
558 : : }
559 : :
560 : 47460 : const sal_Int16* pMapTypeArray = maMapTypeSeq.getConstArray();
561 [ + + + - : 47460 : switch( pMapTypeArray[ nSequenceIndex ] )
- ]
562 : : {
563 : : case MAP_PROPERTY_SET:
564 : : {
565 : : // Property besorgen
566 : 6 : const Property& rProp = maAllPropertySeq.getConstArray()[ nSequenceIndex ];
567 : :
568 : : // Haben wir ein FastPropertySet und ein gueltiges Handle?
569 : : // ACHTUNG: An dieser Stelle wird ausgenutzt, dass das PropertySet
570 : : // zu Beginn des Introspection-Vorgangs abgefragt wird.
571 : : sal_Int32 nOrgHandle;
572 [ + - ][ + - ]: 6 : if( mbFastPropSet && ( nOrgHandle = mpOrgPropertyHandleArray[ nSequenceIndex ] ) != -1 )
[ + - ]
573 : : {
574 : : // PropertySet-Interface holen
575 : : Reference<XFastPropertySet> xFastPropSet =
576 [ + - ]: 6 : Reference<XFastPropertySet>::query( xInterface );
577 [ + - ]: 6 : if( xFastPropSet.is() )
578 : : {
579 [ + - ][ + - ]: 6 : aRet = xFastPropSet->getFastPropertyValue( nOrgHandle);
580 : : }
581 : : else
582 : : {
583 : : // throw UnknownPropertyException
584 : : return aRet;
585 [ + - ]: 6 : }
586 : : }
587 : : // sonst eben das normale nehmen
588 : : else
589 : : {
590 : : // PropertySet-Interface holen
591 : : Reference<XPropertySet> xPropSet =
592 [ # # ]: 0 : Reference<XPropertySet>::query( xInterface );
593 [ # # ]: 0 : if( xPropSet.is() )
594 : : {
595 [ # # ][ # # ]: 0 : aRet = xPropSet->getPropertyValue( rProp.Name );
596 : : }
597 : : else
598 : : {
599 : : // throw UnknownPropertyException
600 : : return aRet;
601 [ # # ]: 0 : }
602 : : }
603 : : }
604 : 6 : break;
605 : :
606 : : case MAP_FIELD:
607 : : {
608 [ + - ][ + - ]: 46999 : Reference<XIdlField> xField = (XIdlField*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
609 [ + - ]: 46999 : if( xField.is() )
610 : : {
611 [ + - ][ + - ]: 46999 : aRet = xField->get( obj );
612 : : // IllegalArgumentException
613 : : // NullPointerException
614 : : }
615 : : else
616 : : {
617 : : // throw IllegalArgumentException();
618 : : return aRet;
619 [ + - ]: 46999 : }
620 : : }
621 : 46999 : break;
622 : :
623 : : case MAP_GETSET:
624 : : {
625 : : // get-Methode holen
626 [ + - ][ + - ]: 455 : Reference<XIdlMethod> xMethod = (XIdlMethod*)(aInterfaceSeq1.getConstArray()[ nSequenceIndex ].get());
627 [ + - ]: 455 : if( xMethod.is() )
628 : : {
629 [ + - ]: 455 : Sequence<Any> args;
630 [ + - ][ + - ]: 455 : aRet = xMethod->invoke( obj, args );
[ + - ]
631 : : }
632 : : else
633 : : {
634 : : // throw IllegalArgumentException();
635 : : return aRet;
636 [ + - ]: 455 : }
637 : : }
638 : 47460 : break;
639 : :
640 : : case MAP_SETONLY:
641 : : // get-Methode gibt es nicht
642 : : // throw WriteOnlyPropertyException();
643 : : return aRet;
644 : : }
645 : 47460 : return aRet;
646 : : }
647 : :
648 : :
649 : : // Hilfs-Methoden zur Groessen-Anpassung der Sequences
650 : 30895 : void IntrospectionAccessStatic_Impl::checkPropertyArraysSize
651 : : (
652 : : Property*& rpAllPropArray,
653 : : sal_Int16*& rpMapTypeArray,
654 : : sal_Int32*& rpPropertyConceptArray,
655 : : sal_Int32 iNextIndex
656 : : )
657 : : {
658 : 30895 : sal_Int32 nLen = maAllPropertySeq.getLength();
659 [ + + ]: 30895 : if( iNextIndex >= nLen )
660 : : {
661 : 965 : maAllPropertySeq.realloc( nLen + ARRAY_SIZE_STEP );
662 : 965 : rpAllPropArray = maAllPropertySeq.getArray();
663 : :
664 : 965 : maMapTypeSeq.realloc( nLen + ARRAY_SIZE_STEP );
665 : 965 : rpMapTypeArray = maMapTypeSeq.getArray();
666 : :
667 : 965 : maPropertyConceptSeq.realloc( nLen + ARRAY_SIZE_STEP );
668 : 965 : rpPropertyConceptArray = maPropertyConceptSeq.getArray();
669 : : }
670 : 30895 : }
671 : :
672 : 19901 : void IntrospectionAccessStatic_Impl::checkInterfaceArraySize( Sequence< Reference<XInterface> >& rSeq,
673 : : Reference<XInterface>*& rpInterfaceArray, sal_Int32 iNextIndex )
674 : : {
675 : 19901 : sal_Int32 nLen = rSeq.getLength();
676 [ + + ]: 19901 : if( iNextIndex >= nLen )
677 : : {
678 : : // Neue Groesse mit ARRAY_SIZE_STEP abgleichen
679 : 1462 : sal_Int32 nMissingSize = iNextIndex - nLen + 1;
680 : 1462 : sal_Int32 nSteps = nMissingSize / ARRAY_SIZE_STEP + 1;
681 : 1462 : sal_Int32 nNewSize = nLen + nSteps * ARRAY_SIZE_STEP;
682 : :
683 : 1462 : rSeq.realloc( nNewSize );
684 : 1462 : rpInterfaceArray = rSeq.getArray();
685 : : }
686 : 19901 : }
687 : :
688 : :
689 : : //*******************************
690 : : //*** ImplIntrospectionAccess ***
691 : : //*******************************
692 : :
693 : : // Neue Impl-Klasse im Rahmen der Introspection-Umstellung auf Instanz-gebundene
694 : : // Introspection mit Property-Zugriff ueber XPropertySet. Die alte Klasse
695 : : // ImplIntrospectionAccess lebt als IntrospectionAccessStatic_Impl
696 : : class ImplIntrospectionAccess : public IntrospectionAccessHelper
697 : : {
698 : : friend class ImplIntrospection;
699 : :
700 : : // Untersuchtes Objekt
701 : : Any maInspectedObject;
702 : :
703 : : // Als Interface
704 : : Reference<XInterface> mxIface;
705 : :
706 : : // Statische Daten der Introspection
707 : : rtl::Reference< IntrospectionAccessStatic_Impl > mpStaticImpl;
708 : :
709 : : // Adapter-Implementation
710 : : WeakReference< XInterface > maAdapter;
711 : :
712 : : // Letzte Sequence, die bei getProperties geliefert wurde (Optimierung)
713 : : Sequence<Property> maLastPropertySeq;
714 : : sal_Int32 mnLastPropertyConcept;
715 : :
716 : : // Letzte Sequence, die bei getMethods geliefert wurde (Optimierung)
717 : : Sequence<Reference<XIdlMethod> > maLastMethodSeq;
718 : : sal_Int32 mnLastMethodConcept;
719 : :
720 : : public:
721 : : ImplIntrospectionAccess( const Any& obj, rtl::Reference< IntrospectionAccessStatic_Impl > const & pStaticImpl_ );
722 : : ~ImplIntrospectionAccess();
723 : :
724 : : // Methoden von XIntrospectionAccess
725 : : virtual sal_Int32 SAL_CALL getSuppliedMethodConcepts(void)
726 : : throw( RuntimeException );
727 : : virtual sal_Int32 SAL_CALL getSuppliedPropertyConcepts(void)
728 : : throw( RuntimeException );
729 : : virtual Property SAL_CALL getProperty(const ::rtl::OUString& Name, sal_Int32 PropertyConcepts)
730 : : throw( NoSuchElementException, RuntimeException );
731 : : virtual sal_Bool SAL_CALL hasProperty(const ::rtl::OUString& Name, sal_Int32 PropertyConcepts)
732 : : throw( RuntimeException );
733 : : virtual Sequence< Property > SAL_CALL getProperties(sal_Int32 PropertyConcepts)
734 : : throw( RuntimeException );
735 : : virtual Reference<XIdlMethod> SAL_CALL getMethod(const ::rtl::OUString& Name, sal_Int32 MethodConcepts)
736 : : throw( NoSuchMethodException, RuntimeException );
737 : : virtual sal_Bool SAL_CALL hasMethod(const ::rtl::OUString& Name, sal_Int32 MethodConcepts)
738 : : throw( RuntimeException );
739 : : virtual Sequence< Reference<XIdlMethod> > SAL_CALL getMethods(sal_Int32 MethodConcepts)
740 : : throw( RuntimeException );
741 : : virtual Sequence< Type > SAL_CALL getSupportedListeners(void)
742 : : throw( RuntimeException );
743 : : using OWeakObject::queryAdapter;
744 : : virtual Reference<XInterface> SAL_CALL queryAdapter( const Type& rType )
745 : : throw( IllegalTypeException, RuntimeException );
746 : :
747 : : // Methoden von XMaterialHolder
748 : : virtual Any SAL_CALL getMaterial(void) throw(RuntimeException);
749 : :
750 : : // Methoden von XExactName
751 : : virtual ::rtl::OUString SAL_CALL getExactName( const ::rtl::OUString& rApproximateName ) throw( RuntimeException );
752 : : };
753 : :
754 : 19952 : ImplIntrospectionAccess::ImplIntrospectionAccess
755 : : ( const Any& obj, rtl::Reference< IntrospectionAccessStatic_Impl > const & pStaticImpl_ )
756 [ + - ][ + - ]: 19952 : : maInspectedObject( obj ), mpStaticImpl( pStaticImpl_ ), maAdapter()
[ + - ][ + - ]
757 : : {
758 : : // Objekt als Interface merken, wenn moeglich
759 : 19952 : TypeClass eType = maInspectedObject.getValueType().getTypeClass();
760 [ + + ]: 19952 : if( eType == TypeClass_INTERFACE )
761 [ + - ]: 4451 : mxIface = *(Reference<XInterface>*)maInspectedObject.getValue();
762 : :
763 : 19952 : mnLastPropertyConcept = -1;
764 : 19952 : mnLastMethodConcept = -1;
765 : 19952 : }
766 : :
767 [ + - ][ + - ]: 19704 : ImplIntrospectionAccess::~ImplIntrospectionAccess()
[ + - ][ + - ]
768 : : {
769 [ - + ]: 39408 : }
770 : :
771 : :
772 : : //*******************************
773 : : //*** ImplIntrospectionAdapter ***
774 : : //*******************************
775 : :
776 : : // Neue Impl-Klasse im Rahmen der Introspection-Umstellung auf Instanz-gebundene
777 : : // Introspection mit Property-Zugriff ueber XPropertySet. Die alte Klasse
778 : : // ImplIntrospectionAccess lebt als IntrospectionAccessStatic_Impl
779 [ + - ][ + - ]: 229662 : class ImplIntrospectionAdapter :
[ - + ]
780 : : public XPropertySet, public XFastPropertySet, public XPropertySetInfo,
781 : : public XNameContainer, public XIndexContainer,
782 : : public XEnumerationAccess, public XIdlArray,
783 : : public OWeakObject
784 : : {
785 : : // Parent-Objekt
786 : : ::rtl::Reference< ImplIntrospectionAccess > mpAccess;
787 : :
788 : : // Untersuchtes Objekt
789 : : const Any& mrInspectedObject;
790 : :
791 : : // Statische Daten der Introspection
792 : : rtl::Reference< IntrospectionAccessStatic_Impl > mpStaticImpl;
793 : :
794 : : // Objekt als Interface
795 : : Reference<XInterface> mxIface;
796 : :
797 : : // Original-Interfaces des Objekts
798 : : Reference<XElementAccess> mxObjElementAccess;
799 : : Reference<XNameContainer> mxObjNameContainer;
800 : : Reference<XNameAccess> mxObjNameAccess;
801 : : Reference<XIndexAccess> mxObjIndexAccess;
802 : : Reference<XIndexContainer> mxObjIndexContainer;
803 : : Reference<XEnumerationAccess> mxObjEnumerationAccess;
804 : : Reference<XIdlArray> mxObjIdlArray;
805 : :
806 : : public:
807 : : ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_,
808 : : const Any& obj,
809 : : rtl::Reference< IntrospectionAccessStatic_Impl > const & pStaticImpl_ );
810 : :
811 : : // Methoden von XInterface
812 : : virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException );
813 : 593287 : virtual void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
814 : 592639 : virtual void SAL_CALL release() throw() { OWeakObject::release(); }
815 : :
816 : : // Methoden von XPropertySet
817 : : virtual Reference<XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( RuntimeException );
818 : : virtual void SAL_CALL setPropertyValue(const ::rtl::OUString& aPropertyName, const Any& aValue)
819 : : throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException );
820 : : virtual Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName)
821 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
822 : : virtual void SAL_CALL addPropertyChangeListener(const ::rtl::OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
823 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
824 : : virtual void SAL_CALL removePropertyChangeListener(const ::rtl::OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
825 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
826 : : virtual void SAL_CALL addVetoableChangeListener(const ::rtl::OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
827 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
828 : : virtual void SAL_CALL removeVetoableChangeListener(const ::rtl::OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
829 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
830 : :
831 : : // Methoden von XFastPropertySet
832 : : virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const Any& aValue)
833 : : throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException );
834 : : virtual Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle)
835 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
836 : :
837 : : // Methoden von XPropertySetInfo
838 : : virtual Sequence< Property > SAL_CALL getProperties(void) throw( RuntimeException );
839 : : virtual Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name) throw( RuntimeException );
840 : : virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name) throw( RuntimeException );
841 : :
842 : : // Methoden von XElementAccess
843 : : virtual Type SAL_CALL getElementType(void) throw( RuntimeException );
844 : : virtual sal_Bool SAL_CALL hasElements(void) throw( RuntimeException );
845 : :
846 : : // Methoden von XNameAccess
847 : : virtual Any SAL_CALL getByName(const ::rtl::OUString& Name)
848 : : throw( NoSuchElementException, WrappedTargetException, RuntimeException );
849 : : virtual Sequence< ::rtl::OUString > SAL_CALL getElementNames(void) throw( RuntimeException );
850 : : virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& Name) throw( RuntimeException );
851 : :
852 : : // Methoden von XNameContainer
853 : : virtual void SAL_CALL insertByName(const ::rtl::OUString& Name, const Any& Element)
854 : : throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException );
855 : : virtual void SAL_CALL replaceByName(const ::rtl::OUString& Name, const Any& Element)
856 : : throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException );
857 : : virtual void SAL_CALL removeByName(const ::rtl::OUString& Name)
858 : : throw( NoSuchElementException, WrappedTargetException, RuntimeException );
859 : :
860 : : // Methoden von XIndexAccess
861 : : virtual sal_Int32 SAL_CALL getCount(void) throw( RuntimeException );
862 : : virtual Any SAL_CALL getByIndex(sal_Int32 Index)
863 : : throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
864 : :
865 : : // Methoden von XIndexContainer
866 : : virtual void SAL_CALL insertByIndex(sal_Int32 Index, const Any& Element)
867 : : throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
868 : : virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const Any& Element)
869 : : throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
870 : : virtual void SAL_CALL removeByIndex(sal_Int32 Index)
871 : : throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException );
872 : :
873 : : // Methoden von XEnumerationAccess
874 : : virtual Reference<XEnumeration> SAL_CALL createEnumeration(void) throw( RuntimeException );
875 : :
876 : : // Methoden von XIdlArray
877 : : virtual void SAL_CALL realloc(Any& array, sal_Int32 length)
878 : : throw( IllegalArgumentException, RuntimeException );
879 : : virtual sal_Int32 SAL_CALL getLen(const Any& array) throw( IllegalArgumentException, RuntimeException );
880 : : virtual Any SAL_CALL get(const Any& array, sal_Int32 index)
881 : : throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException );
882 : : virtual void SAL_CALL set(Any& array, sal_Int32 index, const Any& value)
883 : : throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException );
884 : : };
885 : :
886 : 115043 : ImplIntrospectionAdapter::ImplIntrospectionAdapter( ImplIntrospectionAccess* pAccess_,
887 : : const Any& obj,
888 : : rtl::Reference< IntrospectionAccessStatic_Impl > const & pStaticImpl_ )
889 [ + - ]: 115043 : : mpAccess( pAccess_), mrInspectedObject( obj ), mpStaticImpl( pStaticImpl_ )
890 : : {
891 : : // Objekt als Interfaceholen
892 : 115043 : TypeClass eType = mrInspectedObject.getValueType().getTypeClass();
893 [ + + ]: 115043 : if( eType == TypeClass_INTERFACE )
894 : : {
895 [ + - ]: 8534 : mxIface = *( Reference< XInterface >*)mrInspectedObject.getValue();
896 : :
897 [ + - ][ + - ]: 8534 : mxObjElementAccess = Reference<XElementAccess>::query( mxIface );
898 [ + - ][ + - ]: 8534 : mxObjNameAccess = Reference<XNameAccess>::query( mxIface );
899 [ + - ][ + - ]: 8534 : mxObjNameContainer = Reference<XNameContainer>::query( mxIface );
900 [ + - ][ + - ]: 8534 : mxObjIndexAccess = Reference<XIndexAccess>::query( mxIface );
901 [ + - ][ + - ]: 8534 : mxObjIndexContainer = Reference<XIndexContainer>::query( mxIface );
902 [ + - ][ + - ]: 8534 : mxObjEnumerationAccess = Reference<XEnumerationAccess>::query( mxIface );
903 [ + - ][ + - ]: 8534 : mxObjIdlArray = Reference<XIdlArray>::query( mxIface );
904 : : }
905 : 115043 : }
906 : :
907 : : // Methoden von XInterface
908 : 284691 : Any SAL_CALL ImplIntrospectionAdapter::queryInterface( const Type& rType )
909 : : throw( RuntimeException )
910 : : {
911 : : Any aRet( ::cppu::queryInterface(
912 : : rType,
913 : : static_cast< XPropertySet * >( this ),
914 : : static_cast< XFastPropertySet * >( this ),
915 : 284691 : static_cast< XPropertySetInfo * >( this ) ) );
916 [ + + ]: 284691 : if( !aRet.hasValue() )
917 [ + - ]: 249397 : aRet = OWeakObject::queryInterface( rType );
918 : :
919 [ + + ]: 284691 : if( !aRet.hasValue() )
920 : : {
921 : : // Wrapper fuer die Objekt-Interfaces
922 [ + + + + : 747668 : if( ( mxObjElementAccess.is() && (aRet = ::cppu::queryInterface
+ + + + +
+ + + - +
# # - + #
# + + + +
- + # # ]
923 [ + - ][ + + ]: 117380 : ( rType, static_cast< XElementAccess* >( static_cast< XNameAccess* >( this ) ) ) ).hasValue() )
[ # # ]
924 [ + - ][ + + ]: 217712 : || ( mxObjNameAccess.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XNameAccess* >( this ) ) ).hasValue() )
[ # # ]
925 [ + - ][ + + ]: 213704 : || ( mxObjNameContainer.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XNameContainer* >( this ) ) ).hasValue() )
[ # # ]
926 [ # # ][ - + ]: 210368 : || ( mxObjIndexAccess.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIndexAccess* >( this ) ) ).hasValue() )
[ # # ]
927 [ # # ][ - + ]: 210368 : || ( mxObjIndexContainer.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIndexContainer* >( this ) ) ).hasValue() )
[ # # ]
928 [ + - ][ + + ]: 212978 : || ( mxObjEnumerationAccess .is() && (aRet = ::cppu::queryInterface( rType, static_cast< XEnumerationAccess* >( this ) ) ).hasValue() )
[ # # ]
929 [ # # ][ - + ]: 209498 : || ( mxObjIdlArray.is() && (aRet = ::cppu::queryInterface( rType, static_cast< XIdlArray* >( this ) ) ).hasValue() )
[ # # ]
930 : : )
931 : : {
932 : : }
933 : : }
934 : 284691 : return aRet;
935 : : }
936 : :
937 : :
938 : : //***************************************************
939 : : //*** Implementation von ImplIntrospectionAdapter ***
940 : : //***************************************************
941 : :
942 : : // Methoden von XPropertySet
943 : 0 : Reference<XPropertySetInfo> ImplIntrospectionAdapter::getPropertySetInfo(void)
944 : : throw( RuntimeException )
945 : : {
946 : 0 : return (XPropertySetInfo *)this;
947 : : }
948 : :
949 : 55366 : void ImplIntrospectionAdapter::setPropertyValue(const ::rtl::OUString& aPropertyName, const Any& aValue)
950 : : throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
951 : : {
952 : 55366 : mpStaticImpl->setPropertyValue( mrInspectedObject, aPropertyName, aValue );
953 : 55366 : }
954 : :
955 : 47460 : Any ImplIntrospectionAdapter::getPropertyValue(const ::rtl::OUString& aPropertyName)
956 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
957 : : {
958 : 47460 : return mpStaticImpl->getPropertyValue( mrInspectedObject, aPropertyName );
959 : : }
960 : :
961 : 0 : void ImplIntrospectionAdapter::addPropertyChangeListener(const ::rtl::OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
962 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
963 : : {
964 [ # # ]: 0 : if( mxIface.is() )
965 : : {
966 : : Reference<XPropertySet> xPropSet =
967 [ # # ]: 0 : Reference<XPropertySet>::query( mxIface );
968 : : //Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
969 [ # # ]: 0 : if( xPropSet.is() )
970 [ # # ][ # # ]: 0 : xPropSet->addPropertyChangeListener(aPropertyName, aListener);
971 : : }
972 : 0 : }
973 : :
974 : 0 : void ImplIntrospectionAdapter::removePropertyChangeListener(const ::rtl::OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener)
975 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
976 : : {
977 [ # # ]: 0 : if( mxIface.is() )
978 : : {
979 : : Reference<XPropertySet> xPropSet =
980 [ # # ]: 0 : Reference<XPropertySet>::query( mxIface );
981 : : //Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
982 [ # # ]: 0 : if( xPropSet.is() )
983 [ # # ][ # # ]: 0 : xPropSet->removePropertyChangeListener(aPropertyName, aListener);
984 : : }
985 : 0 : }
986 : :
987 : 0 : void ImplIntrospectionAdapter::addVetoableChangeListener(const ::rtl::OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
988 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
989 : : {
990 [ # # ]: 0 : if( mxIface.is() )
991 : : {
992 : : Reference<XPropertySet> xPropSet =
993 [ # # ]: 0 : Reference<XPropertySet>::query( mxIface );
994 : : //Reference<XPropertySet> xPropSet( mxIface, USR_QUERY );
995 [ # # ]: 0 : if( xPropSet.is() )
996 [ # # ][ # # ]: 0 : xPropSet->addVetoableChangeListener(aPropertyName, aListener);
997 : : }
998 : 0 : }
999 : :
1000 : 0 : void ImplIntrospectionAdapter::removeVetoableChangeListener(const ::rtl::OUString& aPropertyName, const Reference<XVetoableChangeListener>& aListener)
1001 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
1002 : : {
1003 [ # # ]: 0 : if( mxIface.is() )
1004 : : {
1005 : : Reference<XPropertySet> xPropSet =
1006 [ # # ]: 0 : Reference<XPropertySet>::query( mxIface );
1007 [ # # ]: 0 : if( xPropSet.is() )
1008 [ # # ][ # # ]: 0 : xPropSet->removeVetoableChangeListener(aPropertyName, aListener);
1009 : : }
1010 : 0 : }
1011 : :
1012 : :
1013 : : // Methoden von XFastPropertySet
1014 : 0 : void ImplIntrospectionAdapter::setFastPropertyValue(sal_Int32, const Any&)
1015 : : throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
1016 : : {
1017 : 0 : }
1018 : :
1019 : 0 : Any ImplIntrospectionAdapter::getFastPropertyValue(sal_Int32)
1020 : : throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
1021 : : {
1022 : 0 : return Any();
1023 : : }
1024 : :
1025 : : // Methoden von XPropertySetInfo
1026 : 0 : Sequence< Property > ImplIntrospectionAdapter::getProperties(void) throw( RuntimeException )
1027 : : {
1028 : 0 : return mpStaticImpl->getProperties();
1029 : : }
1030 : :
1031 : 0 : Property ImplIntrospectionAdapter::getPropertyByName(const ::rtl::OUString& Name)
1032 : : throw( RuntimeException )
1033 : : {
1034 : 0 : return mpAccess->getProperty( Name, PropertyConcept::ALL );
1035 : : }
1036 : :
1037 : 0 : sal_Bool ImplIntrospectionAdapter::hasPropertyByName(const ::rtl::OUString& Name)
1038 : : throw( RuntimeException )
1039 : : {
1040 : 0 : return mpAccess->hasProperty( Name, PropertyConcept::ALL );
1041 : : }
1042 : :
1043 : : // Methoden von XElementAccess
1044 : 0 : Type ImplIntrospectionAdapter::getElementType(void) throw( RuntimeException )
1045 : : {
1046 : 0 : return mxObjElementAccess->getElementType();
1047 : : }
1048 : :
1049 : 0 : sal_Bool ImplIntrospectionAdapter::hasElements(void) throw( RuntimeException )
1050 : : {
1051 : 0 : return mxObjElementAccess->hasElements();
1052 : : }
1053 : :
1054 : : // Methoden von XNameAccess
1055 : 0 : Any ImplIntrospectionAdapter::getByName(const ::rtl::OUString& Name)
1056 : : throw( NoSuchElementException, WrappedTargetException, RuntimeException )
1057 : : {
1058 : 0 : return mxObjNameAccess->getByName( Name );
1059 : : }
1060 : :
1061 : 0 : Sequence< ::rtl::OUString > ImplIntrospectionAdapter::getElementNames(void)
1062 : : throw( RuntimeException )
1063 : : {
1064 : 0 : return mxObjNameAccess->getElementNames();
1065 : : }
1066 : :
1067 : 0 : sal_Bool ImplIntrospectionAdapter::hasByName(const ::rtl::OUString& Name)
1068 : : throw( RuntimeException )
1069 : : {
1070 : 0 : return mxObjNameAccess->hasByName( Name );
1071 : : }
1072 : :
1073 : : // Methoden von XNameContainer
1074 : 0 : void ImplIntrospectionAdapter::insertByName(const ::rtl::OUString& Name, const Any& Element)
1075 : : throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException )
1076 : : {
1077 : 0 : mxObjNameContainer->insertByName( Name, Element );
1078 : 0 : }
1079 : :
1080 : 0 : void ImplIntrospectionAdapter::replaceByName(const ::rtl::OUString& Name, const Any& Element)
1081 : : throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException )
1082 : : {
1083 : 0 : mxObjNameContainer->replaceByName( Name, Element );
1084 : 0 : }
1085 : :
1086 : 0 : void ImplIntrospectionAdapter::removeByName(const ::rtl::OUString& Name)
1087 : : throw( NoSuchElementException, WrappedTargetException, RuntimeException )
1088 : : {
1089 : 0 : mxObjNameContainer->removeByName( Name );
1090 : 0 : }
1091 : :
1092 : : // Methoden von XIndexAccess
1093 : : // Schon in XNameAccess: virtual Reference<XIdlClass> getElementType(void) const
1094 : 0 : sal_Int32 ImplIntrospectionAdapter::getCount(void) throw( RuntimeException )
1095 : : {
1096 : 0 : return mxObjIndexAccess->getCount();
1097 : : }
1098 : :
1099 : 0 : Any ImplIntrospectionAdapter::getByIndex(sal_Int32 Index)
1100 : : throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
1101 : : {
1102 : 0 : return mxObjIndexAccess->getByIndex( Index );
1103 : : }
1104 : :
1105 : : // Methoden von XIndexContainer
1106 : 0 : void ImplIntrospectionAdapter::insertByIndex(sal_Int32 Index, const Any& Element)
1107 : : throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
1108 : : {
1109 : 0 : mxObjIndexContainer->insertByIndex( Index, Element );
1110 : 0 : }
1111 : :
1112 : 0 : void ImplIntrospectionAdapter::replaceByIndex(sal_Int32 Index, const Any& Element)
1113 : : throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
1114 : : {
1115 : 0 : mxObjIndexContainer->replaceByIndex( Index, Element );
1116 : 0 : }
1117 : :
1118 : 0 : void ImplIntrospectionAdapter::removeByIndex(sal_Int32 Index)
1119 : : throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
1120 : : {
1121 : 0 : mxObjIndexContainer->removeByIndex( Index );
1122 : 0 : }
1123 : :
1124 : : // Methoden von XEnumerationAccess
1125 : : // Schon in XNameAccess: virtual Reference<XIdlClass> getElementType(void) const;
1126 : 0 : Reference<XEnumeration> ImplIntrospectionAdapter::createEnumeration(void) throw( RuntimeException )
1127 : : {
1128 : 0 : return mxObjEnumerationAccess->createEnumeration();
1129 : : }
1130 : :
1131 : : // Methoden von XIdlArray
1132 : 0 : void ImplIntrospectionAdapter::realloc(Any& array, sal_Int32 length)
1133 : : throw( IllegalArgumentException, RuntimeException )
1134 : : {
1135 : 0 : mxObjIdlArray->realloc( array, length );
1136 : 0 : }
1137 : :
1138 : 0 : sal_Int32 ImplIntrospectionAdapter::getLen(const Any& array)
1139 : : throw( IllegalArgumentException, RuntimeException )
1140 : : {
1141 : 0 : return mxObjIdlArray->getLen( array );
1142 : : }
1143 : :
1144 : 0 : Any ImplIntrospectionAdapter::get(const Any& array, sal_Int32 index)
1145 : : throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException )
1146 : : {
1147 : 0 : return mxObjIdlArray->get( array, index );
1148 : : }
1149 : :
1150 : 0 : void ImplIntrospectionAdapter::set(Any& array, sal_Int32 index, const Any& value)
1151 : : throw( IllegalArgumentException, ArrayIndexOutOfBoundsException, RuntimeException )
1152 : : {
1153 : 0 : mxObjIdlArray->set( array, index, value );
1154 : 0 : }
1155 : :
1156 : :
1157 : : //**************************************************
1158 : : //*** Implementation von ImplIntrospectionAccess ***
1159 : : //**************************************************
1160 : :
1161 : : // Methoden von XIntrospectionAccess
1162 : 0 : sal_Int32 ImplIntrospectionAccess::getSuppliedMethodConcepts(void)
1163 : : throw( RuntimeException )
1164 : : {
1165 : : return MethodConcept::DANGEROUS |
1166 : : PROPERTY |
1167 : : LISTENER |
1168 : : ENUMERATION |
1169 : : NAMECONTAINER |
1170 : 0 : INDEXCONTAINER;
1171 : : }
1172 : :
1173 : 0 : sal_Int32 ImplIntrospectionAccess::getSuppliedPropertyConcepts(void)
1174 : : throw( RuntimeException )
1175 : : {
1176 : : return PropertyConcept::DANGEROUS |
1177 : : PROPERTYSET |
1178 : : ATTRIBUTES |
1179 : 0 : METHODS;
1180 : : }
1181 : :
1182 : 55414 : Property ImplIntrospectionAccess::getProperty(const ::rtl::OUString& Name, sal_Int32 PropertyConcepts)
1183 : : throw( NoSuchElementException, RuntimeException )
1184 : : {
1185 : 55414 : Property aRet;
1186 [ + - ]: 55414 : sal_Int32 i = mpStaticImpl->getPropertyIndex( Name );
1187 : 55414 : sal_Bool bFound = sal_False;
1188 [ + - ]: 55414 : if( i != -1 )
1189 : : {
1190 [ + - ][ + - ]: 55414 : sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ];
1191 [ + - ]: 55414 : if( (PropertyConcepts & nConcept) != 0 )
1192 : : {
1193 [ + - ][ + - ]: 55414 : const Property* pProps = mpStaticImpl->getProperties().getConstArray();
1194 : 55414 : aRet = pProps[ i ];
1195 : 55414 : bFound = sal_True;
1196 : : }
1197 : : }
1198 [ - + ]: 55414 : if( !bFound )
1199 [ # # ]: 0 : throw NoSuchElementException() ;
1200 : 55414 : return aRet;
1201 : : }
1202 : :
1203 : 202157 : sal_Bool ImplIntrospectionAccess::hasProperty(const ::rtl::OUString& Name, sal_Int32 PropertyConcepts)
1204 : : throw( RuntimeException )
1205 : : {
1206 : 202157 : sal_Int32 i = mpStaticImpl->getPropertyIndex( Name );
1207 : 202157 : sal_Bool bRet = sal_False;
1208 [ + + ]: 202157 : if( i != -1 )
1209 : : {
1210 : 199059 : sal_Int32 nConcept = mpStaticImpl->getPropertyConcepts().getConstArray()[ i ];
1211 [ + - ]: 199059 : if( (PropertyConcepts & nConcept) != 0 )
1212 : 199059 : bRet = sal_True;
1213 : : }
1214 : 202157 : return bRet;
1215 : : }
1216 : :
1217 : 0 : Sequence< Property > ImplIntrospectionAccess::getProperties(sal_Int32 PropertyConcepts)
1218 : : throw( RuntimeException )
1219 : : {
1220 : : // Wenn alle unterstuetzten Konzepte gefordert werden, Sequence einfach durchreichen
1221 : : sal_Int32 nAllSupportedMask = PROPERTYSET |
1222 : : ATTRIBUTES |
1223 : 0 : METHODS;
1224 [ # # ]: 0 : if( ( PropertyConcepts & nAllSupportedMask ) == nAllSupportedMask )
1225 : : {
1226 [ # # ]: 0 : return mpStaticImpl->getProperties();
1227 : : }
1228 : :
1229 : : // Gleiche Sequence wie beim vorigen mal?
1230 [ # # ]: 0 : if( mnLastPropertyConcept == PropertyConcepts )
1231 : : {
1232 [ # # ]: 0 : return maLastPropertySeq;
1233 : : }
1234 : :
1235 : : // Anzahl der zu liefernden Properties
1236 : 0 : sal_Int32 nCount = 0;
1237 : :
1238 : : // Es gibt zur Zeit keine DANGEROUS-Properties
1239 : : // if( PropertyConcepts & DANGEROUS )
1240 : : // nCount += mpStaticImpl->mnDangerousPropCount;
1241 [ # # ]: 0 : if( PropertyConcepts & PROPERTYSET )
1242 : 0 : nCount += mpStaticImpl->mnPropertySetPropCount;
1243 [ # # ]: 0 : if( PropertyConcepts & ATTRIBUTES )
1244 : 0 : nCount += mpStaticImpl->mnAttributePropCount;
1245 [ # # ]: 0 : if( PropertyConcepts & METHODS )
1246 : 0 : nCount += mpStaticImpl->mnMethodPropCount;
1247 : :
1248 : : // Sequence entsprechend der geforderten Anzahl reallocieren
1249 : 0 : ImplIntrospectionAccess* pThis = (ImplIntrospectionAccess*)this; // const umgehen
1250 [ # # ]: 0 : pThis->maLastPropertySeq.realloc( nCount );
1251 [ # # ]: 0 : Property* pDestProps = pThis->maLastPropertySeq.getArray();
1252 : :
1253 : : // Alle Properties durchgehen und entsprechend der Concepte uebernehmen
1254 [ # # ]: 0 : Sequence<Property> aPropSeq = mpStaticImpl->getProperties();
1255 : 0 : const Property* pSourceProps = aPropSeq.getConstArray();
1256 [ # # ][ # # ]: 0 : const sal_Int32* pConcepts = mpStaticImpl->getPropertyConcepts().getConstArray();
1257 : 0 : sal_Int32 nLen = aPropSeq.getLength();
1258 : :
1259 : 0 : sal_Int32 iDest = 0;
1260 [ # # ]: 0 : for( sal_Int32 i = 0 ; i < nLen ; i++ )
1261 : : {
1262 : 0 : sal_Int32 nConcept = pConcepts[ i ];
1263 [ # # ]: 0 : if( nConcept & PropertyConcepts )
1264 : 0 : pDestProps[ iDest++ ] = pSourceProps[ i ];
1265 : : }
1266 : :
1267 : : // PropertyConcept merken, dies entspricht maLastPropertySeq
1268 : 0 : pThis->mnLastPropertyConcept = PropertyConcepts;
1269 : :
1270 : : // Zusammengebastelte Sequence liefern
1271 [ # # ][ # # ]: 0 : return maLastPropertySeq;
1272 : : }
1273 : :
1274 : 3858 : Reference<XIdlMethod> ImplIntrospectionAccess::getMethod(const ::rtl::OUString& Name, sal_Int32 MethodConcepts)
1275 : : throw( NoSuchMethodException, RuntimeException )
1276 : : {
1277 : 3858 : Reference<XIdlMethod> xRet;
1278 [ + - ]: 3858 : sal_Int32 i = mpStaticImpl->getMethodIndex( Name );
1279 [ + - ]: 3858 : if( i != -1 )
1280 : : {
1281 : :
1282 [ + - ][ + - ]: 3858 : sal_Int32 nConcept = mpStaticImpl->getMethodConcepts().getConstArray()[ i ];
1283 [ + - ]: 3858 : if( (MethodConcepts & nConcept) != 0 )
1284 : : {
1285 [ + - ][ + - ]: 3858 : const Reference<XIdlMethod>* pMethods = mpStaticImpl->getMethods().getConstArray();
1286 [ + - ]: 3858 : xRet = pMethods[i];
1287 : : }
1288 : : }
1289 [ - + ]: 3858 : if( !xRet.is() )
1290 [ # # ]: 0 : throw NoSuchMethodException();
1291 : 3858 : return xRet;
1292 : : }
1293 : :
1294 : 51128 : sal_Bool ImplIntrospectionAccess::hasMethod(const ::rtl::OUString& Name, sal_Int32 MethodConcepts)
1295 : : throw( RuntimeException )
1296 : : {
1297 : 51128 : sal_Int32 i = mpStaticImpl->getMethodIndex( Name );
1298 : 51128 : sal_Bool bRet = sal_False;
1299 [ + + ]: 51128 : if( i != -1 )
1300 : : {
1301 : 3762 : sal_Int32 nConcept = mpStaticImpl->getMethodConcepts().getConstArray()[ i ];
1302 [ + - ]: 3762 : if( (MethodConcepts & nConcept) != 0 )
1303 : 3762 : bRet = sal_True;
1304 : : }
1305 : 51128 : return bRet;
1306 : : }
1307 : :
1308 : 74 : Sequence< Reference<XIdlMethod> > ImplIntrospectionAccess::getMethods(sal_Int32 MethodConcepts)
1309 : : throw( RuntimeException )
1310 : : {
1311 : 74 : ImplIntrospectionAccess* pThis = (ImplIntrospectionAccess*)this; // const umgehen
1312 : :
1313 : : // Wenn alle unterstuetzten Konzepte gefordert werden, Sequence einfach durchreichen
1314 : : sal_Int32 nAllSupportedMask = MethodConcept::DANGEROUS |
1315 : : PROPERTY |
1316 : : LISTENER |
1317 : : ENUMERATION |
1318 : : NAMECONTAINER |
1319 : : INDEXCONTAINER |
1320 : 74 : MethodConcept_NORMAL_IMPL;
1321 [ + + ]: 74 : if( ( MethodConcepts & nAllSupportedMask ) == nAllSupportedMask )
1322 : : {
1323 [ + - ]: 26 : return mpStaticImpl->getMethods();
1324 : : }
1325 : :
1326 : : // Gleiche Sequence wie beim vorigen mal?
1327 [ - + ]: 48 : if( mnLastMethodConcept == MethodConcepts )
1328 : : {
1329 [ # # ]: 0 : return maLastMethodSeq;
1330 : : }
1331 : :
1332 : : // Methoden-Sequences besorgen
1333 [ + - ]: 48 : Sequence< Reference<XIdlMethod> > aMethodSeq = mpStaticImpl->getMethods();
1334 : 48 : const Reference<XIdlMethod>* pSourceMethods = aMethodSeq.getConstArray();
1335 [ + - ][ + - ]: 48 : const sal_Int32* pConcepts = mpStaticImpl->getMethodConcepts().getConstArray();
1336 : 48 : sal_Int32 nLen = aMethodSeq.getLength();
1337 : :
1338 : : // Sequence entsprechend der geforderten Anzahl reallocieren
1339 : : // Anders als bei den Properties kann die Anzahl nicht durch
1340 : : // Zaehler in inspect() vorher ermittelt werden, da Methoden
1341 : : // mehreren Konzepten angehoeren koennen
1342 [ + - ]: 48 : pThis->maLastMethodSeq.realloc( nLen );
1343 [ + - ]: 48 : Reference<XIdlMethod>* pDestMethods = pThis->maLastMethodSeq.getArray();
1344 : :
1345 : : // Alle Methods durchgehen und entsprechend der Concepte uebernehmen
1346 : 48 : sal_Int32 iDest = 0;
1347 [ + + ]: 3600 : for( sal_Int32 i = 0 ; i < nLen ; i++ )
1348 : : {
1349 : 3552 : sal_Int32 nConcept = pConcepts[ i ];
1350 [ + + ]: 3552 : if( nConcept & MethodConcepts )
1351 [ + - ]: 992 : pDestMethods[ iDest++ ] = pSourceMethods[ i ];
1352 : :
1353 : : #if OSL_DEBUG_LEVEL > 0
1354 : : static bool debug = false;
1355 : : if ( debug )
1356 : : {
1357 : : // Methode mit Concepts ausgeben
1358 : : const Reference< XIdlMethod >& rxMethod = pSourceMethods[ i ];
1359 : : ::rtl::OString aNameStr = ::rtl::OUStringToOString( rxMethod->getName(), osl_getThreadTextEncoding() );
1360 : : ::rtl::OString ConceptStr;
1361 : : if( nConcept & MethodConcept::DANGEROUS )
1362 : : ConceptStr += "DANGEROUS |";
1363 : : if( nConcept & MethodConcept::PROPERTY )
1364 : : ConceptStr += "PROPERTY |";
1365 : : if( nConcept & MethodConcept::LISTENER )
1366 : : ConceptStr += "LISTENER |";
1367 : : if( nConcept & MethodConcept::ENUMERATION )
1368 : : ConceptStr += "ENUMERATION |";
1369 : : if( nConcept & MethodConcept::NAMECONTAINER )
1370 : : ConceptStr += "NAMECONTAINER |";
1371 : : if( nConcept & MethodConcept::INDEXCONTAINER )
1372 : : ConceptStr += "INDEXCONTAINER |";
1373 : : OSL_TRACE( "Method %ld: %s, Concepts = %s", i, aNameStr.getStr(), ConceptStr.getStr() );
1374 : : }
1375 : : #endif
1376 : : }
1377 : :
1378 : : // Auf die richtige Laenge bringen
1379 [ + - ]: 48 : pThis->maLastMethodSeq.realloc( iDest );
1380 : :
1381 : : // MethodConcept merken, dies entspricht maLastMethodSeq
1382 : 48 : pThis->mnLastMethodConcept = MethodConcepts;
1383 : :
1384 : : // Zusammengebastelte Sequence liefern
1385 [ + - ][ + - ]: 74 : return maLastMethodSeq;
1386 : : }
1387 : :
1388 : 0 : Sequence< Type > ImplIntrospectionAccess::getSupportedListeners(void)
1389 : : throw( RuntimeException )
1390 : : {
1391 : 0 : return mpStaticImpl->getSupportedListeners();
1392 : : }
1393 : :
1394 : 121715 : Reference<XInterface> SAL_CALL ImplIntrospectionAccess::queryAdapter( const Type& rType )
1395 : : throw( IllegalTypeException, RuntimeException )
1396 : : {
1397 : : // Gibt es schon einen Adapter?
1398 [ + - ]: 121715 : Reference< XInterface > xAdapter( maAdapter );
1399 [ + + ]: 121715 : if( !xAdapter.is() )
1400 : : {
1401 [ + - ][ + - ]: 115043 : xAdapter = *( new ImplIntrospectionAdapter( this, maInspectedObject, mpStaticImpl ) );
[ + - ]
1402 [ + - ]: 115043 : maAdapter = xAdapter;
1403 : : }
1404 : :
1405 : 121715 : Reference<XInterface> xRet;
1406 [ + - ][ + - ]: 121715 : xAdapter->queryInterface( rType ) >>= xRet;
[ + - ]
1407 : 121715 : return xRet;
1408 : : }
1409 : :
1410 : : // Methoden von XMaterialHolder
1411 : 18236 : Any ImplIntrospectionAccess::getMaterial(void) throw(RuntimeException)
1412 : : {
1413 : 18236 : return maInspectedObject;
1414 : : }
1415 : :
1416 : : // Hilfs-Funktion zur LowerCase-Wandlung eines ::rtl::OUString
1417 : 89206 : ::rtl::OUString toLower( ::rtl::OUString aUStr )
1418 : : {
1419 : : // Tabelle fuer XExactName pflegen
1420 : 89206 : ::rtl::OUString aOWStr( aUStr.getStr() );
1421 : 89206 : ::rtl::OUString aOWLowerStr = aOWStr.toAsciiLowerCase();
1422 : 89206 : ::rtl::OUString aLowerUStr( aOWLowerStr.getStr() );
1423 : 89206 : return aLowerUStr;
1424 : : }
1425 : :
1426 : : // Methoden von XExactName
1427 : 541 : ::rtl::OUString ImplIntrospectionAccess::getExactName( const ::rtl::OUString& rApproximateName ) throw( RuntimeException )
1428 : : {
1429 : 541 : ::rtl::OUString aRetStr;
1430 : : LowerToExactNameMap::iterator aIt =
1431 [ + - ]: 541 : mpStaticImpl->maLowerToExactNameMap.find( toLower( rApproximateName ) );
1432 [ + + ][ + - ]: 541 : if( !( aIt == mpStaticImpl->maLowerToExactNameMap.end() ) )
1433 [ + - ]: 541 : aRetStr = (*aIt).second;
1434 : 541 : return aRetStr;
1435 : : }
1436 : :
1437 : :
1438 : : //-----------------------------------------------------------------------------
1439 : :
1440 : 16601 : struct hashIntrospectionKey_Impl
1441 : : {
1442 : : Sequence< Reference<XIdlClass> > aIdlClasses;
1443 : : Reference<XPropertySetInfo> xPropInfo;
1444 : : Reference<XIdlClass> xImplClass;
1445 : : sal_Int32 nHitCount;
1446 : :
1447 : 15241 : void IncHitCount() const { ((hashIntrospectionKey_Impl*)this)->nHitCount++; }
1448 : : hashIntrospectionKey_Impl() : nHitCount( 0 ) {}
1449 : : hashIntrospectionKey_Impl( const Sequence< Reference<XIdlClass> > & rIdlClasses,
1450 : : const Reference<XPropertySetInfo> & rxPropInfo,
1451 : : const Reference<XIdlClass> & rxImplClass );
1452 : : };
1453 : :
1454 : 15513 : hashIntrospectionKey_Impl::hashIntrospectionKey_Impl
1455 : : (
1456 : : const Sequence< Reference<XIdlClass> > & rIdlClasses,
1457 : : const Reference<XPropertySetInfo> & rxPropInfo,
1458 : : const Reference<XIdlClass> & rxImplClass
1459 : : )
1460 : : : aIdlClasses( rIdlClasses )
1461 : : , xPropInfo( rxPropInfo )
1462 : : , xImplClass( rxImplClass )
1463 : 15513 : , nHitCount( 0 )
1464 : 15513 : {}
1465 : :
1466 : :
1467 : : struct hashIntrospectionAccessCache_Impl
1468 : : {
1469 : 15670 : size_t operator()(const hashIntrospectionKey_Impl & rObj ) const
1470 : : {
1471 : 15670 : return (size_t)rObj.xImplClass.get() ^ (size_t)rObj.xPropInfo.get();
1472 : : }
1473 : :
1474 : 15241 : bool operator()( const hashIntrospectionKey_Impl & rObj1,
1475 : : const hashIntrospectionKey_Impl & rObj2 ) const
1476 : : {
1477 [ + - - + ]: 30482 : if( rObj1.xPropInfo != rObj2.xPropInfo
[ - + ]
1478 : 15241 : || rObj1.xImplClass != rObj2.xImplClass )
1479 : 0 : return sal_False;
1480 : :
1481 : 15241 : sal_Int32 nCount1 = rObj1.aIdlClasses.getLength();
1482 : 15241 : sal_Int32 nCount2 = rObj2.aIdlClasses.getLength();
1483 [ - + ]: 15241 : if( nCount1 != nCount2 )
1484 : 0 : return sal_False;
1485 : :
1486 : 15241 : const Reference<XIdlClass>* pRefs1 = rObj1.aIdlClasses.getConstArray();
1487 : 15241 : const Reference<XIdlClass>* pRefs2 = rObj2.aIdlClasses.getConstArray();
1488 : 15241 : return memcmp( pRefs1, pRefs2, nCount1 * sizeof( Reference<XIdlClass> ) ) == 0;
1489 : : }
1490 : :
1491 : : };
1492 : :
1493 : : typedef boost::unordered_map
1494 : : <
1495 : : hashIntrospectionKey_Impl,
1496 : : rtl::Reference< IntrospectionAccessStatic_Impl >,
1497 : : hashIntrospectionAccessCache_Impl,
1498 : : hashIntrospectionAccessCache_Impl
1499 : : >
1500 : : IntrospectionAccessCacheMap;
1501 : :
1502 : : // For XTypeProvider
1503 [ + - ][ + - ]: 7523 : struct hashTypeProviderKey_Impl
1504 : : {
1505 : : Reference<XPropertySetInfo> xPropInfo;
1506 : : Sequence< sal_Int8 > maImpIdSeq;
1507 : : sal_Int32 nHitCount;
1508 : :
1509 : 3343 : void IncHitCount() const { ((hashTypeProviderKey_Impl*)this)->nHitCount++; }
1510 : : hashTypeProviderKey_Impl() : nHitCount( 0 ) {}
1511 : : hashTypeProviderKey_Impl( const Reference<XPropertySetInfo> & rxPropInfo, const Sequence< sal_Int8 > & aImpIdSeq_ );
1512 : : };
1513 : :
1514 : 4179 : hashTypeProviderKey_Impl::hashTypeProviderKey_Impl
1515 : : (
1516 : : const Reference<XPropertySetInfo> & rxPropInfo,
1517 : : const Sequence< sal_Int8 > & aImpIdSeq_
1518 : : )
1519 : : : xPropInfo( rxPropInfo )
1520 : : , maImpIdSeq( aImpIdSeq_ )
1521 [ + - ]: 4179 : , nHitCount( 0 )
1522 : 4179 : {}
1523 : :
1524 : :
1525 : : struct TypeProviderAccessCache_Impl
1526 : : {
1527 : : size_t operator()(const hashTypeProviderKey_Impl & rObj ) const;
1528 : :
1529 : 3863 : bool operator()( const hashTypeProviderKey_Impl & rObj1,
1530 : : const hashTypeProviderKey_Impl & rObj2 ) const
1531 : : {
1532 [ + + ]: 3863 : if( rObj1.xPropInfo != rObj2.xPropInfo )
1533 : 520 : return sal_False;
1534 : :
1535 : 3343 : bool bEqual = false;
1536 : 3343 : sal_Int32 nLen1 = rObj1.maImpIdSeq.getLength();
1537 : 3343 : sal_Int32 nLen2 = rObj2.maImpIdSeq.getLength();
1538 [ + - ][ + - ]: 3343 : if( nLen1 == nLen2 && nLen1 > 0 )
1539 : : {
1540 : 3343 : const sal_Int8* pId1 = rObj1.maImpIdSeq.getConstArray();
1541 : 3343 : const sal_Int8* pId2 = rObj2.maImpIdSeq.getConstArray();
1542 : 3343 : bEqual = (memcmp( pId1, pId2, nLen1 * sizeof( sal_Int8 ) ) == 0 );
1543 : : }
1544 : 3863 : return bEqual;
1545 : : }
1546 : : };
1547 : :
1548 : 4836 : size_t TypeProviderAccessCache_Impl::operator()(const hashTypeProviderKey_Impl & rObj ) const
1549 : : {
1550 : 4836 : const sal_Int32* pBytesAsInt32Array = (const sal_Int32*)rObj.maImpIdSeq.getConstArray();
1551 : 4836 : sal_Int32 nLen = rObj.maImpIdSeq.getLength();
1552 : 4836 : sal_Int32 nCount32 = nLen / 4;
1553 : 4836 : sal_Int32 nMod32 = nLen % 4;
1554 : :
1555 : : // XOR with full 32 bit values
1556 : 4836 : sal_Int32 nId32 = 0;
1557 : : sal_Int32 i;
1558 [ + + ]: 24344 : for( i = 0 ; i < nCount32 ; i++ )
1559 : 19508 : nId32 ^= *(pBytesAsInt32Array++);
1560 : :
1561 : : // XOR with remaining byte values
1562 [ + + ]: 4836 : if( nMod32 )
1563 : : {
1564 : 4 : const sal_Int8* pBytes = (const sal_Int8*)pBytesAsInt32Array;
1565 : 4 : sal_Int8* pInt8_Id32 = (sal_Int8*)&nId32;
1566 [ + + ]: 8 : for( i = 0 ; i < nMod32 ; i++ )
1567 : 4 : *(pInt8_Id32++) ^= *(pBytes++);
1568 : : }
1569 : :
1570 : 4836 : return (size_t)nId32;
1571 : : }
1572 : :
1573 : :
1574 : : typedef boost::unordered_map
1575 : : <
1576 : : hashTypeProviderKey_Impl,
1577 : : rtl::Reference< IntrospectionAccessStatic_Impl >,
1578 : : TypeProviderAccessCache_Impl,
1579 : : TypeProviderAccessCache_Impl
1580 : : >
1581 : : TypeProviderAccessCacheMap;
1582 : :
1583 : : //*************************
1584 : : //*** ImplIntrospection ***
1585 : : //*************************
1586 : :
1587 : 198 : struct OIntrospectionMutex
1588 : : {
1589 : : Mutex m_mutex;
1590 : : };
1591 : :
1592 [ + - ][ + - ]: 22 : class ImplIntrospection : public XIntrospection
[ - + ]
1593 : : , public XServiceInfo
1594 : : , public OIntrospectionMutex
1595 : : , public OComponentHelper
1596 : : {
1597 : : // Implementation der Introspection.
1598 : : rtl::Reference< IntrospectionAccessStatic_Impl > implInspect(const Any& aToInspectObj);
1599 : :
1600 : : // Save XMultiServiceFactory from createComponent
1601 : : Reference<XMultiServiceFactory> m_xSMgr;
1602 : :
1603 : : // CoreReflection halten
1604 : : Reference< XIdlReflection > mxCoreReflection;
1605 : :
1606 : : // Klassen, deren Methoden eine spezielle Rolle spielen
1607 : : Reference<XIdlClass> mxElementAccessClass;
1608 : : Reference<XIdlClass> mxNameContainerClass;
1609 : : Reference<XIdlClass> mxNameAccessClass;
1610 : : Reference<XIdlClass> mxIndexContainerClass;
1611 : : Reference<XIdlClass> mxIndexAccessClass;
1612 : : Reference<XIdlClass> mxEnumerationAccessClass;
1613 : : Reference<XIdlClass> mxInterfaceClass;
1614 : : Reference<XIdlClass> mxAggregationClass;
1615 : : sal_Bool mbDisposed;
1616 : :
1617 : : sal_uInt16 mnCacheEntryCount;
1618 : : sal_uInt16 mnTPCacheEntryCount;
1619 : : IntrospectionAccessCacheMap* mpCache;
1620 : : TypeProviderAccessCacheMap* mpTypeProviderCache;
1621 : :
1622 : : public:
1623 : : ImplIntrospection( const Reference<XMultiServiceFactory> & rXSMgr );
1624 : :
1625 : : // Methoden von XInterface
1626 : : virtual Any SAL_CALL queryInterface( const Type& rType ) throw( RuntimeException );
1627 : 24413 : virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
1628 : 23845 : virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
1629 : :
1630 : : // XTypeProvider
1631 : : Sequence< Type > SAL_CALL getTypes( ) throw( RuntimeException );
1632 : : Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw( RuntimeException );
1633 : :
1634 : : // XServiceInfo
1635 : : ::rtl::OUString SAL_CALL getImplementationName() throw();
1636 : : sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw();
1637 : : Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw();
1638 : : static ::rtl::OUString SAL_CALL getImplementationName_Static( );
1639 : : static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static(void) throw();
1640 : :
1641 : : // Methoden von XIntrospection
1642 : : virtual Reference<XIntrospectionAccess> SAL_CALL inspect(const Any& aToInspectObj)
1643 : : throw( RuntimeException );
1644 : :
1645 : : protected:
1646 : : // some XComponent part from OComponentHelper
1647 : : virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException);
1648 : : };
1649 : :
1650 : : enum MethodType
1651 : : {
1652 : : STANDARD_METHOD, // normale Methode, kein Bezug zu Properties oder Listenern
1653 : : GETSET_METHOD, // gehoert zu einer get/set-Property
1654 : : ADD_LISTENER_METHOD, // add-Methode einer Listener-Schnittstelle
1655 : : REMOVE_LISTENER_METHOD, // remove-Methode einer Listener-Schnittstelle
1656 : : INVALID_METHOD // Methode, deren Klasse nicht beruecksichtigt wird, z.B. XPropertySet
1657 : : };
1658 : :
1659 : : // Ctor
1660 : 187 : ImplIntrospection::ImplIntrospection( const Reference<XMultiServiceFactory> & rXSMgr )
1661 : : : OComponentHelper( m_mutex )
1662 [ + - ][ + - ]: 187 : , m_xSMgr( rXSMgr )
1663 : : {
1664 : 187 : mnCacheEntryCount = 0;
1665 : 187 : mnTPCacheEntryCount = 0;
1666 : 187 : mpCache = NULL;
1667 : 187 : mpTypeProviderCache = NULL;
1668 : :
1669 : : // Spezielle Klassen holen
1670 : : // Reference< XInterface > xServiceIface = m_xSMgr->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection")) );
1671 : : // if( xServiceIface.is() )
1672 : : // mxCoreReflection = Reference< XIdlReflection >::query( xServiceIface );
1673 [ + - ]: 187 : Reference< XPropertySet > xProps( rXSMgr, UNO_QUERY );
1674 : : OSL_ASSERT( xProps.is() );
1675 [ + - ]: 187 : if (xProps.is())
1676 : : {
1677 : 187 : Reference< XComponentContext > xContext;
1678 [ + - ]: 187 : xProps->getPropertyValue(
1679 [ + - ][ + - ]: 187 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext;
[ + - ]
1680 : : OSL_ASSERT( xContext.is() );
1681 [ + - ]: 187 : if (xContext.is())
1682 : : {
1683 [ + - ]: 187 : xContext->getValueByName(
1684 [ + - ][ + - ]: 187 : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.reflection.theCoreReflection") ) ) >>= mxCoreReflection;
[ + - ]
1685 : : OSL_ENSURE( mxCoreReflection.is(), "### CoreReflection singleton not accessible!?" );
1686 : 187 : }
1687 : : }
1688 [ - + ]: 187 : if (! mxCoreReflection.is())
1689 : : {
1690 : : throw DeploymentException(
1691 : : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.reflection.theCoreReflection singleton not accessible") ),
1692 [ # # ][ # # ]: 0 : Reference< XInterface >() );
1693 : : }
1694 : :
1695 [ + - ][ + - ]: 187 : mxElementAccessClass = mxCoreReflection->forName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XElementAccess")) );
[ + - ][ + - ]
1696 [ + - ][ + - ]: 187 : mxNameContainerClass = mxCoreReflection->forName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XNameContainer")) );
[ + - ][ + - ]
1697 [ + - ][ + - ]: 187 : mxNameAccessClass = mxCoreReflection->forName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XNameAccess")) );
[ + - ][ + - ]
1698 [ + - ][ + - ]: 187 : mxIndexContainerClass = mxCoreReflection->forName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XIndexContainer")) );
[ + - ][ + - ]
1699 [ + - ][ + - ]: 187 : mxIndexAccessClass = mxCoreReflection->forName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XIndexAccess")) );
[ + - ][ + - ]
1700 [ + - ][ + - ]: 187 : mxEnumerationAccessClass = mxCoreReflection->forName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.XEnumerationAccess")) );
[ + - ][ + - ]
1701 [ + - ][ + - ]: 187 : mxInterfaceClass = mxCoreReflection->forName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface")) );
[ + - ][ + - ]
1702 [ + - ][ + - ]: 187 : mxAggregationClass = mxCoreReflection->forName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XAggregation")) );
[ + - ][ + - ]
1703 : 187 : mbDisposed = sal_False;
1704 : 187 : }
1705 : :
1706 : : // XComponent
1707 : 187 : void ImplIntrospection::dispose() throw(::com::sun::star::uno::RuntimeException)
1708 : : {
1709 : 187 : OComponentHelper::dispose();
1710 : :
1711 : : // Cache loeschen
1712 [ + + ]: 187 : delete mpCache;
1713 : 187 : mpCache = NULL;
1714 [ + + ]: 187 : delete mpTypeProviderCache;
1715 : 187 : mpTypeProviderCache = NULL;
1716 : :
1717 : 187 : mxElementAccessClass = NULL;
1718 : 187 : mxNameContainerClass = NULL;
1719 : 187 : mxNameAccessClass = NULL;
1720 : 187 : mxIndexContainerClass = NULL;
1721 : 187 : mxIndexAccessClass = NULL;
1722 : 187 : mxEnumerationAccessClass = NULL;
1723 : 187 : mxInterfaceClass = NULL;
1724 : 187 : mxAggregationClass = NULL;
1725 : 187 : mbDisposed = sal_True;
1726 : 187 : }
1727 : :
1728 : :
1729 : : //-----------------------------------------------------------------------------
1730 : :
1731 : : // XInterface
1732 : 3082 : Any ImplIntrospection::queryInterface( const Type & rType )
1733 : : throw(::com::sun::star::uno::RuntimeException)
1734 : : {
1735 : : Any aRet( ::cppu::queryInterface(
1736 : : rType,
1737 : : static_cast< XIntrospection * >( this ),
1738 [ + - ]: 3082 : static_cast< XServiceInfo * >( this ) ) );
1739 : :
1740 [ + + ][ + - ]: 3082 : return (aRet.hasValue() ? aRet : OComponentHelper::queryInterface( rType ));
1741 : : }
1742 : :
1743 : : // XTypeProvider
1744 : 0 : Sequence< Type > ImplIntrospection::getTypes()
1745 : : throw( RuntimeException )
1746 : : {
1747 : : static OTypeCollection * s_pTypes = 0;
1748 [ # # ]: 0 : if (! s_pTypes)
1749 : : {
1750 [ # # ][ # # ]: 0 : MutexGuard aGuard( Mutex::getGlobalMutex() );
1751 [ # # ]: 0 : if (! s_pTypes)
1752 : : {
1753 : : static OTypeCollection s_aTypes(
1754 [ # # ]: 0 : ::getCppuType( (const Reference< XIntrospection > *)0 ),
1755 [ # # ]: 0 : ::getCppuType( (const Reference< XServiceInfo > *)0 ),
1756 [ # # ][ # # ]: 0 : OComponentHelper::getTypes() );
[ # # ][ # # ]
[ # # ][ # # ]
1757 : 0 : s_pTypes = &s_aTypes;
1758 [ # # ]: 0 : }
1759 : : }
1760 : 0 : return s_pTypes->getTypes();
1761 : : }
1762 : :
1763 : 0 : Sequence< sal_Int8 > ImplIntrospection::getImplementationId()
1764 : : throw( RuntimeException )
1765 : : {
1766 : : static OImplementationId * s_pId = 0;
1767 [ # # ]: 0 : if (! s_pId)
1768 : : {
1769 [ # # ][ # # ]: 0 : MutexGuard aGuard( Mutex::getGlobalMutex() );
1770 [ # # ]: 0 : if (! s_pId)
1771 : : {
1772 [ # # ][ # # ]: 0 : static OImplementationId s_aId;
1773 : 0 : s_pId = &s_aId;
1774 [ # # ]: 0 : }
1775 : : }
1776 : 0 : return s_pId->getImplementationId();
1777 : : }
1778 : :
1779 : :
1780 : : // XServiceInfo
1781 : 0 : ::rtl::OUString ImplIntrospection::getImplementationName() throw()
1782 : : {
1783 : 0 : return getImplementationName_Static();
1784 : : }
1785 : :
1786 : : // XServiceInfo
1787 : 0 : sal_Bool ImplIntrospection::supportsService(const ::rtl::OUString& ServiceName) throw()
1788 : : {
1789 : 0 : Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames();
1790 : 0 : const ::rtl::OUString * pArray = aSNL.getConstArray();
1791 [ # # ]: 0 : for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
1792 [ # # ]: 0 : if( pArray[i] == ServiceName )
1793 : 0 : return sal_True;
1794 [ # # ]: 0 : return sal_False;
1795 : : }
1796 : :
1797 : : // XServiceInfo
1798 : 0 : Sequence< ::rtl::OUString > ImplIntrospection::getSupportedServiceNames(void) throw()
1799 : : {
1800 : 0 : return getSupportedServiceNames_Static();
1801 : : }
1802 : :
1803 : : //*************************************************************************
1804 : : // Helper XServiceInfo
1805 : 0 : ::rtl::OUString ImplIntrospection::getImplementationName_Static( )
1806 : : {
1807 : 0 : return ::rtl::OUString::createFromAscii( IMPLEMENTATION_NAME );
1808 : : }
1809 : :
1810 : : // ORegistryServiceManager_Static
1811 : 187 : Sequence< ::rtl::OUString > ImplIntrospection::getSupportedServiceNames_Static(void) throw()
1812 : : {
1813 : 187 : Sequence< ::rtl::OUString > aSNS( 1 );
1814 [ + - ]: 187 : aSNS.getArray()[0] = ::rtl::OUString::createFromAscii( SERVICE_NAME );
1815 : 187 : return aSNS;
1816 : : }
1817 : :
1818 : : //*************************************************************************
1819 : :
1820 : : // Methoden von XIntrospection
1821 : 21641 : Reference<XIntrospectionAccess> ImplIntrospection::inspect(const Any& aToInspectObj)
1822 : : throw( RuntimeException )
1823 : : {
1824 : 21641 : Reference<XIntrospectionAccess> xAccess;
1825 : :
1826 [ - + ]: 21641 : if ( aToInspectObj.getValueType().getTypeClass() == TypeClass_TYPE )
1827 : : {
1828 : 0 : Type aType;
1829 : 0 : aToInspectObj >>= aType;
1830 : :
1831 [ # # ][ # # ]: 0 : Reference< XIdlClass > xIdlClass = mxCoreReflection->forName(((Type*)(aToInspectObj.getValue()))->getTypeName());
1832 : :
1833 [ # # ]: 0 : if ( xIdlClass.is() )
1834 : : {
1835 : 0 : Any aRealInspectObj;
1836 [ # # ]: 0 : aRealInspectObj <<= xIdlClass;
1837 : :
1838 [ # # ]: 0 : rtl::Reference< IntrospectionAccessStatic_Impl > pStaticImpl( implInspect( aRealInspectObj ) );
1839 [ # # ]: 0 : if( pStaticImpl.is() )
1840 [ # # ][ # # ]: 0 : xAccess = new ImplIntrospectionAccess( aRealInspectObj, pStaticImpl );
[ # # ][ # # ]
1841 : 0 : }
1842 : : }
1843 : : else
1844 : : {
1845 [ + - ]: 21641 : rtl::Reference< IntrospectionAccessStatic_Impl > pStaticImpl( implInspect( aToInspectObj ) );
1846 [ + + ]: 21641 : if( pStaticImpl.is() )
1847 [ + - ][ + - ]: 21641 : xAccess = new ImplIntrospectionAccess( aToInspectObj, pStaticImpl );
[ + - ][ + - ]
1848 : : }
1849 : :
1850 : 21641 : return xAccess;
1851 : : }
1852 : :
1853 : : //-----------------------------------------------------------------------------
1854 : :
1855 : : // Hashtable fuer Pruefung auf mehrfache Beruecksichtigung von Interfaces
1856 : : struct hashInterface_Impl
1857 : : {
1858 : 66771 : size_t operator()(const void* p) const
1859 : : {
1860 : 66771 : return (size_t)p;
1861 : : }
1862 : : };
1863 : :
1864 : : struct eqInterface_Impl
1865 : : {
1866 : 20893 : bool operator()(const void* p1, const void* p2) const
1867 : : {
1868 : 20893 : return ( p1 == p2 );
1869 : : }
1870 : : };
1871 : :
1872 : : typedef boost::unordered_map
1873 : : <
1874 : : void*,
1875 : : void*,
1876 : : hashInterface_Impl,
1877 : : eqInterface_Impl
1878 : : >
1879 : : CheckedInterfacesMap;
1880 : :
1881 : :
1882 : :
1883 : : // TODO: Spaeter auslagern
1884 : 167598 : Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XMultiServiceFactory > & xMgr )
1885 : : {
1886 [ + + ][ + - ]: 167598 : static Reference< XIdlReflection > xRefl;
1887 : :
1888 : : // void als Default-Klasse eintragen
1889 : 167598 : Reference<XIdlClass> xRetClass;
1890 : 167598 : typelib_TypeDescription * pTD = 0;
1891 : 167598 : rType.getDescription( &pTD );
1892 [ + - ]: 167598 : if( pTD )
1893 : : {
1894 : 167598 : ::rtl::OUString sOWName( pTD->pTypeName );
1895 [ + + ]: 167598 : if( !xRefl.is() )
1896 : : {
1897 [ + - ][ + - ]: 182 : xRefl = Reference< XIdlReflection >( xMgr->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.reflection.CoreReflection")) ), UNO_QUERY );
[ + - ][ + - ]
[ + - ]
1898 : : OSL_ENSURE( xRefl.is(), "### no corereflection!" );
1899 : : }
1900 [ + - ][ + - ]: 167598 : xRetClass = xRefl->forName( sOWName );
[ + - ]
1901 : : }
1902 : 167598 : return xRetClass;
1903 : : }
1904 : :
1905 : : // Implementation der Introspection.
1906 : 21641 : rtl::Reference< IntrospectionAccessStatic_Impl > ImplIntrospection::implInspect(const Any& aToInspectObj)
1907 : : {
1908 [ + - ]: 21641 : MutexGuard aGuard( m_mutex );
1909 : :
1910 : : // Wenn die Introspection schon disposed ist, wird nur ein leeres Ergebnis geliefert
1911 [ - + ]: 21641 : if( mbDisposed )
1912 [ # # ]: 0 : return NULL;
1913 : :
1914 : : // Objekt untersuchen
1915 : 21641 : TypeClass eType = aToInspectObj.getValueType().getTypeClass();
1916 [ + + ][ + + ]: 21641 : if( eType != TypeClass_INTERFACE && eType != TypeClass_STRUCT && eType != TypeClass_EXCEPTION )
[ + + ]
1917 [ + - ]: 1689 : return NULL;
1918 : :
1919 : 19952 : Reference<XInterface> x;
1920 [ + + ]: 19952 : if( eType == TypeClass_INTERFACE )
1921 : : {
1922 : : // Interface aus dem Any besorgen
1923 [ + - ]: 4451 : x = *(Reference<XInterface>*)aToInspectObj.getValue();
1924 [ - + ]: 4451 : if( !x.is() )
1925 [ # # ]: 0 : return NULL;
1926 : : }
1927 : :
1928 : : // Haben wir schon eine Cache-Instanz
1929 [ + + ]: 19952 : if( !mpCache )
1930 [ + - ][ + - ]: 182 : mpCache = new IntrospectionAccessCacheMap;
1931 [ + + ]: 19952 : if( !mpTypeProviderCache )
1932 [ + - ][ + - ]: 182 : mpTypeProviderCache = new TypeProviderAccessCacheMap;
1933 : 19952 : IntrospectionAccessCacheMap& aCache = *mpCache;
1934 : 19952 : TypeProviderAccessCacheMap& aTPCache = *mpTypeProviderCache;
1935 : :
1936 : : // Pointer auf ggf. noetige neue IntrospectionAccess-Instanz
1937 : 19952 : rtl::Reference< IntrospectionAccessStatic_Impl > pAccess;
1938 : :
1939 : : // Pruefen: Ist schon ein passendes Access-Objekt gecached?
1940 [ + - ]: 19952 : Sequence< Reference<XIdlClass> > SupportedClassSeq;
1941 [ + - ]: 19952 : Sequence< Type > SupportedTypesSeq;
1942 : 19952 : Reference<XTypeProvider> xTypeProvider;
1943 : 19952 : Reference<XIdlClass> xImplClass;
1944 : 19952 : Reference<XPropertySetInfo> xPropSetInfo;
1945 : 19952 : Reference<XPropertySet> xPropSet;
1946 : :
1947 : : // Look for interfaces XTypeProvider and PropertySet
1948 [ + + ]: 19952 : if( eType == TypeClass_INTERFACE )
1949 : : {
1950 [ + - ][ + - ]: 4451 : xTypeProvider = Reference<XTypeProvider>::query( x );
1951 [ + + ]: 4451 : if( xTypeProvider.is() )
1952 : : {
1953 [ + - ][ + - ]: 4439 : SupportedTypesSeq = xTypeProvider->getTypes();
[ + - ][ + - ]
1954 : 4439 : sal_Int32 nTypeCount = SupportedTypesSeq.getLength();
1955 [ + - ]: 4439 : if( nTypeCount )
1956 : : {
1957 [ + - ]: 4439 : SupportedClassSeq.realloc( nTypeCount );
1958 [ + - ]: 4439 : Reference<XIdlClass>* pClasses = SupportedClassSeq.getArray();
1959 : :
1960 : 4439 : const Type* pTypes = SupportedTypesSeq.getConstArray();
1961 [ + + ]: 146580 : for( sal_Int32 i = 0 ; i < nTypeCount ; i++ )
1962 : : {
1963 [ + - ][ + - ]: 142141 : pClasses[ i ] = TypeToIdlClass( pTypes[ i ], m_xSMgr );
1964 : : }
1965 : : // TODO: Caching!
1966 : : }
1967 : : }
1968 : : else
1969 : : {
1970 [ + - ][ + - ]: 12 : xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
1971 [ + - ]: 12 : SupportedClassSeq.realloc( 1 );
1972 [ + - ][ + - ]: 12 : SupportedClassSeq.getArray()[ 0 ] = xImplClass;
1973 : : }
1974 : :
1975 [ + - ][ + - ]: 4451 : xPropSet = Reference<XPropertySet>::query( x );
1976 : : // Jetzt versuchen, das PropertySetInfo zu bekommen
1977 [ + + ]: 4451 : if( xPropSet.is() )
1978 [ + - ][ + - ]: 2550 : xPropSetInfo = xPropSet->getPropertySetInfo();
[ + - ]
1979 : : }
1980 : : else
1981 : : {
1982 [ + - ][ + - ]: 15501 : xImplClass = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
1983 : : }
1984 : :
1985 [ + + ]: 19952 : if( xTypeProvider.is() )
1986 : : {
1987 [ + - ][ + - ]: 4439 : Sequence< sal_Int8 > aImpIdSeq = xTypeProvider->getImplementationId();
1988 : 4439 : sal_Int32 nIdLen = aImpIdSeq.getLength();
1989 : :
1990 [ + + ]: 4439 : if( nIdLen )
1991 : : {
1992 : : // cache only, if the descriptor class is set
1993 [ + - ]: 4179 : hashTypeProviderKey_Impl aKeySeq( xPropSetInfo, aImpIdSeq );
1994 : :
1995 [ + - ]: 4179 : TypeProviderAccessCacheMap::iterator aIt = aTPCache.find( aKeySeq );
1996 [ + - ][ + + ]: 4179 : if( aIt == aTPCache.end() )
1997 : : {
1998 : : // not found
1999 : : // Neue Instanz anlegen und unter dem gegebenen Key einfuegen
2000 [ + - ][ + - ]: 836 : pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
[ + - ]
2001 : :
2002 : : // Groesse begrenzen, alten Eintrag wieder rausschmeissen
2003 [ - + ]: 836 : if( mnTPCacheEntryCount > INTROSPECTION_CACHE_MAX_SIZE )
2004 : : {
2005 : : // Access mit dem kleinsten HitCount suchen
2006 [ # # ]: 0 : TypeProviderAccessCacheMap::iterator iter = aTPCache.begin();
2007 [ # # ]: 0 : TypeProviderAccessCacheMap::iterator end = aTPCache.end();
2008 : 0 : TypeProviderAccessCacheMap::iterator toDelete = iter;
2009 [ # # ]: 0 : while( iter != end )
2010 : : {
2011 [ # # ][ # # ]: 0 : if( (*iter).first.nHitCount < (*toDelete).first.nHitCount )
[ # # ]
2012 : 0 : toDelete = iter;
2013 : 0 : ++iter;
2014 : : }
2015 [ # # ]: 0 : aTPCache.erase( toDelete );
2016 : : }
2017 : : else
2018 : 836 : mnTPCacheEntryCount++;
2019 : :
2020 : : // Neuer Eintrage rein in die Table
2021 : 836 : aKeySeq.nHitCount = 1;
2022 [ + - ][ + - ]: 836 : aTPCache[ aKeySeq ] = pAccess;
2023 : :
2024 : : }
2025 : : else
2026 : : {
2027 : : // Hit-Count erhoehen
2028 [ + - ]: 3343 : (*aIt).first.IncHitCount();
2029 [ + - ][ + - ]: 4179 : return (*aIt).second;
2030 [ + - ][ + + ]: 4439 : }
2031 [ + - ][ + + ]: 4439 : }
2032 : : }
2033 [ + - ]: 15513 : else if( xImplClass.is() )
2034 : : {
2035 : : // cache only, if the descriptor class is set
2036 [ + - ]: 15513 : hashIntrospectionKey_Impl aKeySeq( SupportedClassSeq, xPropSetInfo, xImplClass );
2037 : :
2038 [ + - ]: 15513 : IntrospectionAccessCacheMap::iterator aIt = aCache.find( aKeySeq );
2039 [ + - ][ + + ]: 15513 : if( aIt == aCache.end() )
2040 : : {
2041 : : // not found
2042 : : // Neue Instanz anlegen und unter dem gegebenen Key einfuegen
2043 [ + - ][ + - ]: 272 : pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
[ + - ]
2044 : :
2045 : : // Groesse begrenzen, alten Eintrag wieder rausschmeissen
2046 [ - + ]: 272 : if( mnCacheEntryCount > INTROSPECTION_CACHE_MAX_SIZE )
2047 : : {
2048 : : // Access mit dem kleinsten HitCount suchen
2049 [ # # ]: 0 : IntrospectionAccessCacheMap::iterator iter = aCache.begin();
2050 [ # # ]: 0 : IntrospectionAccessCacheMap::iterator end = aCache.end();
2051 : 0 : IntrospectionAccessCacheMap::iterator toDelete = iter;
2052 [ # # ]: 0 : while( iter != end )
2053 : : {
2054 [ # # ][ # # ]: 0 : if( (*iter).first.nHitCount < (*toDelete).first.nHitCount )
[ # # ]
2055 : 0 : toDelete = iter;
2056 : 0 : ++iter;
2057 : : }
2058 [ # # ]: 0 : aCache.erase( toDelete );
2059 : : }
2060 : : else
2061 : 272 : mnCacheEntryCount++;
2062 : :
2063 : : // Neuer Eintrage rein in die Table
2064 : 272 : aKeySeq.nHitCount = 1;
2065 [ + - ][ + - ]: 272 : aCache[ aKeySeq ] = pAccess;
2066 : :
2067 : : }
2068 : : else
2069 : : {
2070 : : // Hit-Count erhoehen
2071 [ + - ]: 15241 : (*aIt).first.IncHitCount();
2072 [ + - ][ + - ]: 15513 : return (*aIt).second;
2073 [ + - ][ + + ]: 15513 : }
2074 : : }
2075 : :
2076 : : // Kein Access gecached -> neu anlegen
2077 : : Property* pAllPropArray;
2078 : : Reference<XInterface>* pInterfaces1;
2079 : : Reference<XInterface>* pInterfaces2;
2080 : : sal_Int16* pMapTypeArray;
2081 : : sal_Int32* pPropertyConceptArray;
2082 : : sal_Int32 i;
2083 : :
2084 [ + + ]: 1368 : if( !pAccess.is() )
2085 [ + - ][ + - ]: 260 : pAccess = new IntrospectionAccessStatic_Impl( mxCoreReflection );
[ + - ]
2086 : :
2087 : : // Referenzen auf wichtige Daten von pAccess
2088 : 1368 : sal_Int32& rPropCount = pAccess->mnPropCount;
2089 : 1368 : IntrospectionNameMap& rPropNameMap = pAccess->maPropertyNameMap;
2090 : 1368 : IntrospectionNameMap& rMethodNameMap = pAccess->maMethodNameMap;
2091 : 1368 : LowerToExactNameMap& rLowerToExactNameMap = pAccess->maLowerToExactNameMap;
2092 : :
2093 : : // Schon mal Pointer auf das eigene Property-Feld holen
2094 [ + - ]: 1368 : pAllPropArray = pAccess->maAllPropertySeq.getArray();
2095 [ + - ]: 1368 : pInterfaces1 = pAccess->aInterfaceSeq1.getArray();
2096 [ + - ]: 1368 : pInterfaces2 = pAccess->aInterfaceSeq2.getArray();
2097 [ + - ]: 1368 : pMapTypeArray = pAccess->maMapTypeSeq.getArray();
2098 [ + - ]: 1368 : pPropertyConceptArray = pAccess->maPropertyConceptSeq.getArray();
2099 : :
2100 : : //*************************
2101 : : //*** Analyse vornehmen ***
2102 : : //*************************
2103 [ + + ]: 1368 : if( eType == TypeClass_INTERFACE )
2104 : : {
2105 : : // Zunaechst nach speziellen Interfaces suchen, die fuer
2106 : : // die Introspection von besonderer Bedeutung sind.
2107 : :
2108 : : // XPropertySet vorhanden?
2109 [ + + ][ + - ]: 1098 : if( xPropSet.is() && xPropSetInfo.is() )
[ + + ]
2110 : : {
2111 : : // Gibt es auch ein FastPropertySet?
2112 [ + - ]: 612 : Reference<XFastPropertySet> xDummy = Reference<XFastPropertySet>::query( x );
2113 : 612 : sal_Bool bFast = pAccess->mbFastPropSet = xDummy.is();
2114 : :
2115 [ + - ][ + - ]: 612 : Sequence<Property> aPropSeq = xPropSetInfo->getProperties();
2116 : 612 : const Property* pProps = aPropSeq.getConstArray();
2117 : 612 : sal_Int32 nLen = aPropSeq.getLength();
2118 : :
2119 : : // Bei FastPropertySet muessen wir uns die Original-Handles merken
2120 [ + + ]: 612 : if( bFast )
2121 [ + - ]: 68 : pAccess->mpOrgPropertyHandleArray = new sal_Int32[ nLen ];
2122 : :
2123 [ + + ]: 12619 : for( i = 0 ; i < nLen ; i++ )
2124 : : {
2125 : : // Property in eigene Liste uebernehmen
2126 : : pAccess->checkPropertyArraysSize
2127 [ + - ]: 12007 : ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
2128 : 12007 : Property& rProp = pAllPropArray[ rPropCount ];
2129 : 12007 : rProp = pProps[ i ];
2130 : :
2131 [ + + ]: 12007 : if( bFast )
2132 : 1972 : pAccess->mpOrgPropertyHandleArray[ i ] = rProp.Handle;
2133 : :
2134 : : // PropCount als Handle fuer das eigene FastPropertySet eintragen
2135 : 12007 : rProp.Handle = rPropCount;
2136 : :
2137 : : // Art der Property merken
2138 : 12007 : pMapTypeArray[ rPropCount ] = MAP_PROPERTY_SET;
2139 : 12007 : pPropertyConceptArray[ rPropCount ] = PROPERTYSET;
2140 : 12007 : pAccess->mnPropertySetPropCount++;
2141 : :
2142 : : // Namen in Hashtable eintragen, wenn nicht schon bekannt
2143 : 12007 : ::rtl::OUString aPropName = rProp.Name;
2144 : :
2145 : : // Haben wir den Namen schon?
2146 [ + - ]: 12007 : IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
2147 [ + - ][ + - ]: 12007 : if( aIt == rPropNameMap.end() )
2148 : : {
2149 : : // Neuer Eintrag in die Hashtable
2150 [ + - ]: 12007 : rPropNameMap[ aPropName ] = rPropCount;
2151 : :
2152 : : // Tabelle fuer XExactName pflegen
2153 [ + - ]: 12007 : rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
2154 : : }
2155 : : else
2156 : : {
2157 : : OSL_FAIL(
2158 : : ( ::rtl::OString( "Introspection: Property \"" ) +
2159 : : ::rtl::OUStringToOString( aPropName, RTL_TEXTENCODING_UTF8 ) +
2160 : : ::rtl::OString( "\" found more than once in PropertySet" ) ).getStr() );
2161 : : }
2162 : :
2163 : : // Count pflegen
2164 : 12007 : rPropCount++;
2165 [ + - ]: 12619 : }
2166 : : }
2167 : :
2168 : : // Indizes in die Export-Tabellen
2169 : 1098 : sal_Int32 iAllExportedMethod = 0;
2170 : 1098 : sal_Int32 iAllSupportedListener = 0;
2171 : :
2172 : : // Hashtable fuer Pruefung auf mehrfache Beruecksichtigung von Interfaces
2173 [ + - ]: 1098 : CheckedInterfacesMap aCheckedInterfacesMap;
2174 : :
2175 : : // Flag, ob XInterface-Methoden erfasst werden sollen
2176 : : // (das darf nur einmal erfolgen, initial zulassen)
2177 : 1098 : sal_Bool bXInterfaceIsInvalid = sal_False;
2178 : :
2179 : : // Flag, ob die XInterface-Methoden schon erfasst wurden. Wenn sal_True,
2180 : : // wird bXInterfaceIsInvalid am Ende der Iface-Schleife aktiviert und
2181 : : // XInterface-Methoden werden danach abgeklemmt.
2182 : 1098 : sal_Bool bFoundXInterface = sal_False;
2183 : :
2184 : 1098 : sal_Int32 nClassCount = SupportedClassSeq.getLength();
2185 [ + + ]: 21531 : for( sal_Int32 nIdx = 0 ; nIdx < nClassCount; nIdx++ )
2186 : : {
2187 : 20433 : Reference<XIdlClass> xImplClass2 = SupportedClassSeq.getConstArray()[nIdx];
2188 [ + + ]: 64814 : while( xImplClass2.is() )
2189 : : {
2190 : : // Interfaces der Implementation holen
2191 [ + - ][ + - ]: 44381 : Sequence< Reference<XIdlClass> > aClassSeq = xImplClass2->getInterfaces();
2192 : 44381 : sal_Int32 nIfaceCount = aClassSeq.getLength();
2193 : :
2194 [ + - ]: 44381 : aClassSeq.realloc( nIfaceCount + 1 );
2195 [ + - ][ + - ]: 44381 : aClassSeq.getArray()[ nIfaceCount ] = xImplClass2;
2196 : 44381 : nIfaceCount++;
2197 : :
2198 : 44381 : const Reference<XIdlClass>* pParamArray = aClassSeq.getConstArray();
2199 : :
2200 [ + + ]: 88762 : for( sal_Int32 j = 0 ; j < nIfaceCount ; j++ )
2201 : : {
2202 : 44381 : const Reference<XIdlClass>& rxIfaceClass = pParamArray[j];
2203 : :
2204 : : // Pruefen, ob das Interface schon beruecksichtigt wurde.
2205 [ + - ]: 44381 : XInterface* pIface = ( static_cast< XInterface* >( rxIfaceClass.get() ) );
2206 [ + - ][ + + ]: 44381 : if( aCheckedInterfacesMap.count( pIface ) > 0 )
2207 : : {
2208 : : // Kennen wir schon
2209 : 20893 : continue;
2210 : : }
2211 : : else
2212 : : {
2213 : : // Sonst eintragen
2214 [ + - ]: 23488 : aCheckedInterfacesMap[ pIface ] = pIface;
2215 : : }
2216 : :
2217 : : //********************************************************************
2218 : :
2219 : : // 2. Fields als Properties registrieren
2220 : :
2221 : : // Felder holen
2222 [ + - ][ + - ]: 23488 : Sequence< Reference<XIdlField> > fields = rxIfaceClass->getFields();
2223 : 23488 : const Reference<XIdlField>* pFields = fields.getConstArray();
2224 : 23488 : sal_Int32 nLen = fields.getLength();
2225 : :
2226 [ + + ]: 25833 : for( i = 0 ; i < nLen ; i++ )
2227 : : {
2228 : 2345 : Reference<XIdlField> xField = pFields[i];
2229 [ + - ][ + - ]: 2345 : Reference<XIdlClass> xPropType = xField->getType();
2230 : :
2231 : : // Ist die PropertySequence gross genug?
2232 : : pAccess->checkPropertyArraysSize
2233 [ + - ]: 2345 : ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
2234 : :
2235 : : // In eigenes Property-Array eintragen
2236 : 2345 : Property& rProp = pAllPropArray[ rPropCount ];
2237 [ + - ][ + - ]: 2345 : ::rtl::OUString aFieldName = xField->getName();
2238 : 2345 : rProp.Name = aFieldName;
2239 : 2345 : rProp.Handle = rPropCount;
2240 [ + - ][ + - ]: 2345 : Type aFieldType( xPropType->getTypeClass(), xPropType->getName() );
[ + - ][ + - ]
2241 : 2345 : rProp.Type = aFieldType;
2242 [ + - ][ + - ]: 2345 : FieldAccessMode eAccessMode = xField->getAccessMode();
2243 : : rProp.Attributes = (eAccessMode == FieldAccessMode_READONLY ||
2244 : : eAccessMode == FieldAccessMode_CONST)
2245 [ + + ][ - + ]: 2345 : ? READONLY : 0;
2246 : :
2247 : : // Namen in Hashtable eintragen
2248 : 2345 : ::rtl::OUString aPropName = rProp.Name;
2249 : :
2250 : : // Haben wir den Namen schon?
2251 [ + - ]: 2345 : IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
2252 [ + - ][ + + ]: 2345 : if( !( aIt == rPropNameMap.end() ) )
2253 : 1158 : continue;
2254 : :
2255 : : // Neuer Eintrag in die Hashtable
2256 [ + - ]: 1187 : rPropNameMap[ aPropName ] = rPropCount;
2257 : :
2258 : : // Tabelle fuer XExactName pflegen
2259 [ + - ]: 1187 : rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
2260 : :
2261 : : // Field merken
2262 : 1187 : pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
2263 [ + - ]: 1187 : pInterfaces1, rPropCount );
2264 [ + - ]: 1187 : pInterfaces1[ rPropCount ] = xField;
2265 : :
2266 : : // Art der Property merken
2267 : 1187 : pMapTypeArray[ rPropCount ] = MAP_FIELD;
2268 : 1187 : pPropertyConceptArray[ rPropCount ] = ATTRIBUTES;
2269 : 1187 : pAccess->mnAttributePropCount++;
2270 : :
2271 : : // Count pflegen
2272 [ + + ]: 3532 : rPropCount++;
2273 [ + + ][ + + ]: 4690 : }
[ + + ][ + + ]
2274 : :
2275 : : //********************************************************************
2276 : :
2277 : : // 3. Methoden
2278 : :
2279 : : // Zaehler fuer die gefundenen Listener
2280 : 23488 : sal_Int32 nListenerCount = 0;
2281 : :
2282 : : // Alle Methoden holen und merken
2283 [ + - ][ + - ]: 23488 : Sequence< Reference<XIdlMethod> > methods = rxIfaceClass->getMethods();
2284 : 23488 : const Reference<XIdlMethod>* pSourceMethods = methods.getConstArray();
2285 : 23488 : sal_Int32 nSourceMethodCount = methods.getLength();
2286 : :
2287 : : // 3. a) get/set- und Listener-Methoden suchen
2288 : :
2289 : : // Feld fuer Infos ueber die Methoden anlegen, damit spaeter leicht die Methoden
2290 : : // gefunden werden koennen, die nicht im Zusammenhang mit Properties oder Listenern
2291 : : // stehen. NEU: auch MethodConceptArray initialisieren
2292 [ + - ]: 23488 : MethodType* pMethodTypes = new MethodType[ nSourceMethodCount ];
2293 [ + - ]: 23488 : sal_Int32* pLocalMethodConcepts = new sal_Int32[ nSourceMethodCount ];
2294 [ + + ]: 164226 : for( i = 0 ; i < nSourceMethodCount ; i++ )
2295 : : {
2296 : 140738 : pMethodTypes[ i ] = STANDARD_METHOD;
2297 : 140738 : pLocalMethodConcepts[ i ] = 0;
2298 : : }
2299 : :
2300 : 23488 : ::rtl::OUString aMethName;
2301 : 23488 : ::rtl::OUString aPropName;
2302 : 23488 : ::rtl::OUString aStartStr;
2303 [ + + ]: 164226 : for( i = 0 ; i < nSourceMethodCount ; i++ )
2304 : : {
2305 : : // Methode ansprechen
2306 : 140738 : const Reference<XIdlMethod>& rxMethod_i = pSourceMethods[i];
2307 : 140738 : sal_Int32& rMethodConcept_i = pLocalMethodConcepts[ i ];
2308 : :
2309 : : // Namen besorgen
2310 [ + - ][ + - ]: 140738 : aMethName = rxMethod_i->getName();
2311 : :
2312 : : // Methoden katalogisieren
2313 : : // Alle (?) Methoden von XInterface filtern, damit z.B. nicht
2314 : : // vom Scripting aus acquire oder release gerufen werden kann
2315 [ + - ][ + - ]: 140738 : if( rxMethod_i->getDeclaringClass()->equals( mxInterfaceClass ) )
[ + - ][ + + ]
[ + - ]
2316 : : {
2317 : : // XInterface-Methoden sind hiermit einmal beruecksichtigt
2318 : 70464 : bFoundXInterface = sal_True;
2319 : :
2320 [ + + ]: 70464 : if( bXInterfaceIsInvalid )
2321 : : {
2322 : 67170 : pMethodTypes[ i ] = INVALID_METHOD;
2323 : 67170 : continue;
2324 : : }
2325 : : else
2326 : : {
2327 [ + - ][ + + ]: 3294 : if( aMethName != ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("queryInterface")) )
2328 : : {
2329 : 2196 : rMethodConcept_i |= MethodConcept::DANGEROUS;
2330 : 2196 : continue;
2331 : : }
2332 : : }
2333 : : }
2334 [ + - ][ + - ]: 70274 : else if( rxMethod_i->getDeclaringClass()->equals( mxAggregationClass ) )
[ + - ][ + - ]
[ + + ]
2335 : : {
2336 [ + + ]: 264 : if( aMethName == "setDelegator" )
2337 : : {
2338 : 132 : rMethodConcept_i |= MethodConcept::DANGEROUS;
2339 : 132 : continue;
2340 : : }
2341 : : }
2342 [ + - ][ + - ]: 70010 : else if( rxMethod_i->getDeclaringClass()->equals( mxElementAccessClass ) )
[ + - ][ + - ]
[ + + ]
2343 : : {
2344 : : rMethodConcept_i |= ( NAMECONTAINER |
2345 : : INDEXCONTAINER |
2346 : 3644 : ENUMERATION );
2347 : : }
2348 [ + - ][ + - ]: 198846 : else if( rxMethod_i->getDeclaringClass()->equals( mxNameContainerClass ) ||
[ + - ][ + - ]
[ + + ][ + + ]
[ + - ]
[ + + # # ]
2349 [ + - ][ + - ]: 132480 : rxMethod_i->getDeclaringClass()->equals( mxNameAccessClass ) )
[ + - ][ + - ]
[ + + ][ # # ]
2350 : : {
2351 : 3384 : rMethodConcept_i |= NAMECONTAINER;
2352 : : }
2353 [ + - ][ + - ]: 188946 : else if( rxMethod_i->getDeclaringClass()->equals( mxIndexContainerClass ) ||
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ]
[ + + # # ]
2354 [ + - ][ + - ]: 125964 : rxMethod_i->getDeclaringClass()->equals( mxIndexAccessClass ) )
[ + - ][ + - ]
[ + - ][ # # ]
2355 : : {
2356 : 20 : rMethodConcept_i |= INDEXCONTAINER;
2357 : : }
2358 [ + - ][ + - ]: 62962 : else if( rxMethod_i->getDeclaringClass()->equals( mxEnumerationAccessClass ) )
[ + - ][ + - ]
[ + + ]
2359 : : {
2360 : 242 : rMethodConcept_i |= ENUMERATION;
2361 : : }
2362 : :
2363 : : // Wenn der Name zu kurz ist, wird's sowieso nichts
2364 [ + + ]: 71240 : if( aMethName.getLength() <= 3 )
2365 : 116 : continue;
2366 : :
2367 : : // Ist es eine get-Methode?
2368 : 71124 : aStartStr = aMethName.copy( 0, 3 );
2369 [ + + ]: 71124 : if( aStartStr == "get" )
2370 : : {
2371 : : // Namen der potentiellen Property
2372 : 27687 : aPropName = aMethName.copy( 3 );
2373 : :
2374 : : // get-Methode darf keinen Parameter haben
2375 [ + - ][ + - ]: 27687 : Sequence< Reference<XIdlClass> > getParams = rxMethod_i->getParameterTypes();
2376 [ + + ]: 27687 : if( getParams.getLength() > 0 )
2377 : : {
2378 : 8614 : continue;
2379 : : }
2380 : :
2381 : : // Haben wir den Namen schon?
2382 [ + - ]: 19073 : IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
2383 [ + - ][ + + ]: 19073 : if( !( aIt == rPropNameMap.end() ) )
2384 : : {
2385 : : /* TODO
2386 : : OSL_TRACE(
2387 : : String( "Introspection: Property \"" ) +
2388 : : OOUStringToString( aPropName, CHARSET_SYSTEM ) +
2389 : : String( "\" found more than once" ) );
2390 : : */
2391 : 4080 : continue;
2392 : : }
2393 : :
2394 : : // Eine readonly-Property ist es jetzt mindestens schon
2395 : 14993 : rMethodConcept_i |= PROPERTY;
2396 : :
2397 : 14993 : pMethodTypes[i] = GETSET_METHOD;
2398 [ + - ][ + - ]: 14993 : Reference<XIdlClass> xGetRetType = rxMethod_i->getReturnType();
2399 : :
2400 : : // Ist die PropertySequence gross genug?
2401 : : pAccess->checkPropertyArraysSize
2402 [ + - ]: 14993 : ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
2403 : :
2404 : : // In eigenes Property-Array eintragen
2405 : 14993 : Property& rProp = pAllPropArray[ rPropCount ];
2406 : 14993 : rProp.Name = aPropName;
2407 : 14993 : rProp.Handle = rPropCount;
2408 [ + - ][ + - ]: 14993 : rProp.Type = Type( xGetRetType->getTypeClass(), xGetRetType->getName() );
[ + - ][ + - ]
2409 : 14993 : rProp.Attributes = READONLY;
2410 : :
2411 : : // Neuer Eintrag in die Hashtable
2412 [ + - ]: 14993 : rPropNameMap[ aPropName ] = rPropCount;
2413 : :
2414 : : // Tabelle fuer XExactName pflegen
2415 [ + - ]: 14993 : rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
2416 : :
2417 : : // get-Methode merken
2418 : 14993 : pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
2419 [ + - ]: 14993 : pInterfaces1, rPropCount );
2420 [ + - ]: 14993 : pInterfaces1[ rPropCount ] = rxMethod_i;
2421 : :
2422 : : // Art der Property merken
2423 : 14993 : pMapTypeArray[ rPropCount ] = MAP_GETSET;
2424 : 14993 : pPropertyConceptArray[ rPropCount ] = METHODS;
2425 : 14993 : pAccess->mnMethodPropCount++;
2426 : :
2427 : : // Passende set-Methode suchen
2428 : : sal_Int32 k;
2429 [ + + ]: 139790 : for( k = 0 ; k < nSourceMethodCount ; k++ )
2430 : : {
2431 : : // Methode ansprechen
2432 : 124797 : const Reference<XIdlMethod>& rxMethod_k = pSourceMethods[k];
2433 : :
2434 : : // Nur Methoden nehmen, die nicht schon zugeordnet sind
2435 [ + + ][ + + ]: 124797 : if( k == i || pMethodTypes[k] != STANDARD_METHOD )
2436 : 68453 : continue;
2437 : :
2438 : : // Name holen und auswerten
2439 [ + - ][ + - ]: 56344 : ::rtl::OUString aMethName2 = rxMethod_k->getName();
2440 : 56344 : ::rtl::OUString aStartStr2 = aMethName2.copy( 0, 3 );
2441 : : // ACHTUNG: Wegen SDL-Bug NICHT != bei ::rtl::OUString verwenden !!!
2442 [ + + ]: 56344 : if( !( aStartStr2 == "set" ) )
2443 : 50414 : continue;
2444 : :
2445 : : // Ist es denn der gleiche Name?
2446 : 5930 : ::rtl::OUString aPropName2 = aMethName2.copy( 3 );
2447 : : // ACHTUNG: Wegen SDL-Bug NICHT != bei ::rtl::OUString verwenden !!!
2448 [ + + ]: 5930 : if( !( aPropName == aPropName2 ) )
2449 : 3741 : continue;
2450 : :
2451 : : // set-Methode muss void returnen
2452 [ + - ][ + - ]: 2189 : Reference<XIdlClass> xSetRetType = rxMethod_k->getReturnType();
2453 [ + - ][ + - ]: 2189 : if( xSetRetType->getTypeClass() != TypeClass_VOID )
[ + + ]
2454 : : {
2455 : 12 : continue;
2456 : : }
2457 : :
2458 : : // set-Methode darf nur einen Parameter haben
2459 [ + - ][ + - ]: 2177 : Sequence< Reference<XIdlClass> > setParams = rxMethod_k->getParameterTypes();
2460 : 2177 : sal_Int32 nParamCount = setParams.getLength();
2461 [ + + ]: 2177 : if( nParamCount != 1 )
2462 : : {
2463 : 6 : continue;
2464 : : }
2465 : :
2466 : : // Jetzt muss nur noch der return-Typ dem Parameter-Typ entsprechen
2467 : 2171 : const Reference<XIdlClass>* pParamArray2 = setParams.getConstArray();
2468 : 2171 : Reference<XIdlClass> xParamType = pParamArray2[ 0 ];
2469 [ + - ][ + - ]: 2171 : if( xParamType->equals( xGetRetType ) )
[ + - ]
2470 : : {
2471 : 2171 : pLocalMethodConcepts[ k ] = PROPERTY;
2472 : :
2473 : 2171 : pMethodTypes[k] = GETSET_METHOD;
2474 : :
2475 : : // ReadOnly-Flag wieder loschen
2476 : 2171 : rProp.Attributes &= ~READONLY;
2477 : :
2478 : : // set-Methode merken
2479 : 2171 : pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq2,
2480 [ + - ]: 2171 : pInterfaces2, rPropCount );
2481 [ + - ]: 2171 : pInterfaces2[ rPropCount ] = rxMethod_k;
2482 : : }
2483 [ + - ][ + + ]: 124797 : }
[ + + ][ + + ]
[ + + ][ + + ]
2484 : :
2485 : : // Count pflegen
2486 [ + - ][ + + ]: 27687 : rPropCount++;
2487 : : }
2488 : :
2489 : : // Ist es eine addListener-Methode?
2490 [ + + ]: 43437 : else if( aStartStr == "add" )
2491 : : {
2492 : 6206 : ::rtl::OUString aListenerStr( "Listener" );
2493 : :
2494 : : // Namen der potentiellen Property
2495 : 6206 : sal_Int32 nStrLen = aMethName.getLength();
2496 : 6206 : sal_Int32 nCopyLen = nStrLen - aListenerStr.getLength();
2497 : 6206 : ::rtl::OUString aEndStr = aMethName.copy( nCopyLen > 0 ? nCopyLen : 0 );
2498 : :
2499 : : // Endet das Teil auf Listener?
2500 : : // ACHTUNG: Wegen SDL-Bug NICHT != bei ::rtl::OUString verwenden !!!
2501 [ + + ]: 6206 : if( !( aEndStr == aListenerStr ) )
2502 : 727 : continue;
2503 : :
2504 : : // Welcher Listener?
2505 : 5479 : ::rtl::OUString aListenerName = aMethName.copy( 3, nStrLen - aListenerStr.getLength() - 3 );
2506 : :
2507 : : // TODO: Hier koennten noch genauere Pruefungen vorgenommen werden
2508 : : // - Rueckgabe-Typ
2509 : : // - Anzahl und Art der Parameter
2510 : :
2511 : :
2512 : : // Passende remove-Methode suchen, sonst gilt's nicht
2513 : : sal_Int32 k;
2514 [ + + ]: 52435 : for( k = 0 ; k < nSourceMethodCount ; k++ )
2515 : : {
2516 : : // Methode ansprechen
2517 : 46956 : const Reference<XIdlMethod>& rxMethod_k = pSourceMethods[k];
2518 : :
2519 : : // Nur Methoden nehmen, die nicht schon zugeordnet sind
2520 [ + + ][ + + ]: 46956 : if( k == i || pMethodTypes[k] != STANDARD_METHOD )
2521 : 24678 : continue;
2522 : :
2523 : : // Name holen und auswerten
2524 [ + - ][ + - ]: 22278 : ::rtl::OUString aMethName2 = rxMethod_k->getName();
2525 : 22278 : sal_Int32 nNameLen = aMethName2.getLength();
2526 : 22278 : sal_Int32 nCopyLen2 = (nNameLen < 6) ? nNameLen : 6;
2527 : 22278 : ::rtl::OUString aStartStr2 = aMethName2.copy( 0, nCopyLen2 );
2528 [ + - ]: 22278 : ::rtl::OUString aRemoveStr( RTL_CONSTASCII_USTRINGPARAM("remove" ) );
2529 : : // ACHTUNG: Wegen SDL-Bug NICHT != bei ::rtl::OUString verwenden !!!
2530 [ + + ]: 22278 : if( !( aStartStr2 == aRemoveStr ) )
2531 : 15859 : continue;
2532 : :
2533 : : // Ist es denn der gleiche Listener?
2534 [ + + ]: 6419 : if( aMethName2.getLength() - aRemoveStr.getLength() <= aListenerStr.getLength() )
2535 : 52 : continue;
2536 : : ::rtl::OUString aListenerName2 = aMethName2.copy
2537 : 6367 : ( 6, aMethName2.getLength() - aRemoveStr.getLength() - aListenerStr.getLength() );
2538 : : // ACHTUNG: Wegen SDL-Bug NICHT != bei ::rtl::OUString verwenden !!!
2539 [ + + ]: 6367 : if( !( aListenerName == aListenerName2 ) )
2540 : 888 : continue;
2541 : :
2542 : : // TODO: Hier koennten noch genauere Pruefungen vorgenommen werden
2543 : : // - Rueckgabe-Typ
2544 : : // - Anzahl und Art der Parameter
2545 : :
2546 : :
2547 : : // Methoden sind als Listener-Schnittstelle erkannt
2548 : 5479 : rMethodConcept_i |= LISTENER;
2549 : 5479 : pLocalMethodConcepts[ k ] |= LISTENER;
2550 : :
2551 : 5479 : pMethodTypes[i] = ADD_LISTENER_METHOD;
2552 : 5479 : pMethodTypes[k] = REMOVE_LISTENER_METHOD;
2553 [ + + ]: 11846 : nListenerCount++;
2554 [ + + ][ + + ]: 59529 : }
[ + + ][ + + ]
[ + + ]
2555 : : }
2556 : : }
2557 : :
2558 : :
2559 : : // Jetzt koennen noch SET-Methoden ohne zugehoerige GET-Methode existieren,
2560 : : // diese muessen zu Write-Only-Properties gemachte werden.
2561 [ + + ]: 164226 : for( i = 0 ; i < nSourceMethodCount ; i++ )
2562 : : {
2563 : : // Methode ansprechen
2564 : 140738 : const Reference<XIdlMethod>& rxMethod_i = pSourceMethods[i];
2565 : :
2566 : : // Nur Methoden nehmen, die nicht schon zugeordnet sind
2567 [ + + ]: 140738 : if( pMethodTypes[i] != STANDARD_METHOD )
2568 : 95292 : continue;
2569 : :
2570 : : // Namen besorgen
2571 [ + - ][ + - ]: 45446 : aMethName = rxMethod_i->getName();
2572 : :
2573 : : // Wenn der Name zu kurz ist, wird's sowieso nichts
2574 [ + + ]: 45446 : if( aMethName.getLength() <= 3 )
2575 : 116 : continue;
2576 : :
2577 : : // Ist es eine set-Methode ohne zugehoerige get-Methode?
2578 : 45330 : aStartStr = aMethName.copy( 0, 3 );
2579 [ + + ]: 45330 : if( aStartStr == "set" )
2580 : : {
2581 : : // Namen der potentiellen Property
2582 : 2907 : aPropName = aMethName.copy( 3 );
2583 : :
2584 : : // set-Methode muss void returnen
2585 [ + - ][ + - ]: 2907 : Reference<XIdlClass> xSetRetType = rxMethod_i->getReturnType();
2586 [ + - ][ + - ]: 2907 : if( xSetRetType->getTypeClass() != TypeClass_VOID )
[ + + ]
2587 : : {
2588 : 20 : continue;
2589 : : }
2590 : :
2591 : : // set-Methode darf nur einen Parameter haben
2592 [ + - ][ + - ]: 2887 : Sequence< Reference<XIdlClass> > setParams = rxMethod_i->getParameterTypes();
2593 : 2887 : sal_Int32 nParamCount = setParams.getLength();
2594 [ + + ]: 2887 : if( nParamCount != 1 )
2595 : : {
2596 : 1874 : continue;
2597 : : }
2598 : :
2599 : : // Haben wir den Namen schon?
2600 [ + - ]: 1013 : IntrospectionNameMap::iterator aIt = rPropNameMap.find( aPropName );
2601 [ + - ][ + + ]: 1013 : if( !( aIt == rPropNameMap.end() ) )
2602 : : {
2603 : : /* TODO:
2604 : : OSL_TRACE(
2605 : : String( "Introspection: Property \"" ) +
2606 : : OOUStringToString( aPropName, CHARSET_SYSTEM ) +
2607 : : String( "\" found more than once" ) );
2608 : : */
2609 : 523 : continue;
2610 : : }
2611 : :
2612 : : // Alles klar, es ist eine Write-Only-Property
2613 : 490 : pLocalMethodConcepts[ i ] = PROPERTY;
2614 : :
2615 : 490 : pMethodTypes[i] = GETSET_METHOD;
2616 : 490 : Reference<XIdlClass> xGetRetType = setParams.getConstArray()[0];
2617 : :
2618 : : // Ist die PropertySequence gross genug?
2619 : : pAccess->checkPropertyArraysSize
2620 [ + - ]: 490 : ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
2621 : :
2622 : : // In eigenes Property-Array eintragen
2623 : 490 : Property& rProp = pAllPropArray[ rPropCount ];
2624 : 490 : rProp.Name = aPropName;
2625 : 490 : rProp.Handle = rPropCount;
2626 [ + - ][ + - ]: 490 : rProp.Type = Type( xGetRetType->getTypeClass(), xGetRetType->getName() );
[ + - ][ + - ]
2627 : 490 : rProp.Attributes = 0; // PROPERTY_WRITEONLY ???
2628 : :
2629 : : // Neuer Eintrag in die Hashtable
2630 [ + - ]: 490 : rPropNameMap[ aPropName ] = rPropCount;
2631 : :
2632 : : // Tabelle fuer XExactName pflegen
2633 [ + - ]: 490 : rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
2634 : :
2635 : : // set-Methode merken
2636 : 490 : pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq2,
2637 [ + - ]: 490 : pInterfaces2, rPropCount );
2638 [ + - ]: 490 : pInterfaces2[ rPropCount ] = rxMethod_i;
2639 : :
2640 : : // Art der Property merken
2641 : 490 : pMapTypeArray[ rPropCount ] = MAP_SETONLY;
2642 : 490 : pPropertyConceptArray[ rPropCount ] = METHODS;
2643 : 490 : pAccess->mnMethodPropCount++;
2644 : :
2645 : : // Count pflegen
2646 [ + - ][ + + ]: 2907 : rPropCount++;
[ + + ]
2647 : : }
2648 : : }
2649 : :
2650 : :
2651 : : //********************************************************************
2652 : :
2653 : : // 4. Methoden in die Gesamt-Sequence uebernehmen
2654 : :
2655 : : // Wieviele Methoden muessen in die Method-Sequence?
2656 : 23488 : sal_Int32 nExportedMethodCount = 0;
2657 : 23488 : sal_Int32 nSupportedListenerCount = 0;
2658 [ + + ]: 164226 : for( i = 0 ; i < nSourceMethodCount ; i++ )
2659 : : {
2660 [ + + ]: 140738 : if( pMethodTypes[ i ] != INVALID_METHOD )
2661 : : {
2662 : 73568 : nExportedMethodCount++;
2663 : : }
2664 [ + + ]: 140738 : if( pMethodTypes[ i ] == ADD_LISTENER_METHOD )
2665 : : {
2666 : 5479 : nSupportedListenerCount++;
2667 : : }
2668 : : }
2669 : :
2670 : : // Sequences im Access-Objekt entsprechend aufbohren
2671 [ + - ]: 23488 : pAccess->maAllMethodSeq.realloc( nExportedMethodCount + iAllExportedMethod );
2672 [ + - ]: 23488 : pAccess->maMethodConceptSeq.realloc( nExportedMethodCount + iAllExportedMethod );
2673 [ + - ]: 23488 : pAccess->maSupportedListenerSeq.realloc( nSupportedListenerCount + iAllSupportedListener );
2674 : :
2675 : : // Methoden reinschreiben
2676 [ + - ]: 23488 : Reference<XIdlMethod>* pDestMethods = pAccess->maAllMethodSeq.getArray();
2677 [ + - ]: 23488 : sal_Int32* pMethodConceptArray = pAccess->maMethodConceptSeq.getArray();
2678 [ + - ]: 23488 : Type* pListenerClassRefs = pAccess->maSupportedListenerSeq.getArray();
2679 [ + + ]: 164226 : for( i = 0 ; i < nSourceMethodCount ; i++ )
2680 : : {
2681 [ + + ]: 140738 : if( pMethodTypes[ i ] != INVALID_METHOD )
2682 : : {
2683 : : // Methode ansprechen
2684 : 73568 : const Reference<XIdlMethod>& rxMethod = pSourceMethods[i];
2685 : :
2686 : : // Namen in Hashtable eintragen, wenn nicht schon bekannt
2687 [ + - ][ + - ]: 73568 : ::rtl::OUString aMethName2 = rxMethod->getName();
2688 [ + - ]: 73568 : IntrospectionNameMap::iterator aIt = rMethodNameMap.find( aMethName2 );
2689 [ + - ][ + + ]: 73568 : if( aIt == rMethodNameMap.end() )
2690 : : {
2691 : : // Eintragen
2692 [ + - ]: 58928 : rMethodNameMap[ aMethName2 ] = iAllExportedMethod;
2693 : :
2694 : : // Tabelle fuer XExactName pflegen
2695 [ + - ]: 58928 : rLowerToExactNameMap[ toLower( aMethName2 ) ] = aMethName2;
2696 : : }
2697 : : else
2698 : : {
2699 [ + - ]: 14640 : sal_Int32 iHashResult = (*aIt).second;
2700 : :
2701 : 14640 : Reference<XIdlMethod> xExistingMethod = pDestMethods[ iHashResult ];
2702 : :
2703 : : Reference< XIdlClass > xExistingMethClass =
2704 [ + - ][ + - ]: 14640 : xExistingMethod->getDeclaringClass();
2705 [ + - ][ + - ]: 14640 : Reference< XIdlClass > xNewMethClass = rxMethod->getDeclaringClass();
2706 [ + - ][ + - ]: 14640 : if( xExistingMethClass->equals( xNewMethClass ) )
[ + + ]
2707 [ + + ][ + + ]: 14640 : continue;
[ + + ]
2708 : : }
2709 : :
2710 [ + - ]: 60848 : pDestMethods[ iAllExportedMethod ] = rxMethod;
2711 : :
2712 : : // Wenn kein Concept gesetzt wurde, ist die Methode "normal"
2713 : 60848 : sal_Int32& rMethodConcept_i = pLocalMethodConcepts[ i ];
2714 [ + + ]: 60848 : if( !rMethodConcept_i )
2715 : 29608 : rMethodConcept_i = MethodConcept_NORMAL_IMPL;
2716 : 60848 : pMethodConceptArray[ iAllExportedMethod ] = rMethodConcept_i;
2717 [ + + ]: 73568 : iAllExportedMethod++;
2718 : : }
2719 [ + + ]: 128018 : if( pMethodTypes[ i ] == ADD_LISTENER_METHOD )
2720 : : {
2721 : : // Klasse des Listeners ermitteln
2722 : 4837 : const Reference<XIdlMethod>& rxMethod = pSourceMethods[i];
2723 : :
2724 : : // void als Default-Klasse eintragen
2725 [ + - ][ + - ]: 4837 : Reference<XIdlClass> xListenerClass = TypeToIdlClass( getCppuVoidType(), m_xSMgr );
2726 : : // ALT: Reference<XIdlClass> xListenerClass = Void_getReflection()->getIdlClass();
2727 : :
2728 : : // 1. Moeglichkeit: Parameter nach einer Listener-Klasse durchsuchen
2729 : : // Nachteil: Superklassen muessen rekursiv durchsucht werden
2730 [ + - ][ + - ]: 4837 : Sequence< Reference<XIdlClass> > aParams = rxMethod->getParameterTypes();
2731 : 4837 : const Reference<XIdlClass>* pParamArray2 = aParams.getConstArray();
2732 : :
2733 [ + - ][ + - ]: 4837 : Reference<XIdlClass> xEventListenerClass = TypeToIdlClass( getCppuType( (Reference<XEventListener>*) NULL ), m_xSMgr );
2734 : : // ALT: Reference<XIdlClass> xEventListenerClass = XEventListener_getReflection()->getIdlClass();
2735 : 4837 : sal_Int32 nParamCount = aParams.getLength();
2736 : : sal_Int32 k;
2737 [ + + ]: 6391 : for( k = 0 ; k < nParamCount ; k++ )
2738 : : {
2739 : 6389 : const Reference<XIdlClass>& rxClass = pParamArray2[k];
2740 : :
2741 : : // Sind wir von einem Listener abgeleitet?
2742 [ + - ][ + - ]: 17866 : if( rxClass->equals( xEventListenerClass ) ||
[ + + ][ + + ]
[ + + ]
2743 [ + - ][ + + ]: 11477 : isDerivedFrom( rxClass, xEventListenerClass ) )
[ + + ]
[ # # # # ]
2744 : : {
2745 [ + - ]: 4835 : xListenerClass = rxClass;
2746 : 4835 : break;
2747 : : }
2748 : : }
2749 : :
2750 : : // 2. Moeglichkeit: Namen der Methode auswerden
2751 : : // Nachteil: geht nicht bei Test-Listenern, die es nicht gibt
2752 : : //aMethName = rxMethod->getName();
2753 : : //aListenerName = aMethName.Copy( 3, aMethName.Len()-8-3 );
2754 : : //Reference<XIdlClass> xListenerClass = reflection->forName( aListenerName );
2755 [ + - ][ + - ]: 4837 : Type aListenerType( TypeClass_INTERFACE, xListenerClass->getName() );
2756 : 4837 : pListenerClassRefs[ iAllSupportedListener ] = aListenerType;
2757 [ + - ]: 4837 : iAllSupportedListener++;
2758 : : }
2759 : : }
2760 : :
2761 : : // Wenn in diesem Durchlauf XInterface-Methoden
2762 : : // dabei waren, diese zukuenftig ignorieren
2763 [ + - ]: 23488 : if( bFoundXInterface )
2764 : 23488 : bXInterfaceIsInvalid = sal_True;
2765 : :
2766 [ + - ]: 23488 : delete[] pMethodTypes;
2767 [ + - ]: 23488 : delete[] pLocalMethodConcepts;
2768 [ + - ][ + - ]: 23488 : }
2769 : :
2770 : : // Super-Klasse(n) vorhanden? Dann dort fortsetzen
2771 [ + - ][ + - ]: 44381 : Sequence< Reference<XIdlClass> > aSuperClassSeq = xImplClass2->getSuperclasses();
2772 : :
2773 : : // Zur Zeit wird nur von einer Superklasse ausgegangen
2774 [ + + ]: 44381 : if( aSuperClassSeq.getLength() >= 1 )
2775 : : {
2776 [ + - ]: 23948 : xImplClass2 = aSuperClassSeq.getConstArray()[0];
2777 : : OSL_ENSURE( xImplClass2.is(), "super class null" );
2778 : : }
2779 : : else
2780 : : {
2781 [ + - ]: 20433 : xImplClass2 = NULL;
2782 : : }
2783 [ + - ][ + - ]: 44381 : }
2784 : 20433 : }
2785 : :
2786 : : // Anzahl der exportierten Methoden uebernehmen und Sequences anpassen
2787 : : // (kann abweichen, weil doppelte Methoden erst nach der Ermittlung
2788 : : // von nExportedMethodCount herausgeworfen werden)
2789 : 1098 : sal_Int32& rMethCount = pAccess->mnMethCount;
2790 : 1098 : rMethCount = iAllExportedMethod;
2791 [ + - ]: 1098 : pAccess->maAllMethodSeq.realloc( rMethCount );
2792 [ + - ]: 1098 : pAccess->maMethodConceptSeq.realloc( rMethCount );
2793 : :
2794 : : // Groesse der Property-Sequences anpassen
2795 [ + - ]: 1098 : pAccess->maAllPropertySeq.realloc( rPropCount );
2796 [ + - ]: 1098 : pAccess->maPropertyConceptSeq.realloc( rPropCount );
2797 [ + - ][ + - ]: 1098 : pAccess->maMapTypeSeq.realloc( rPropCount );
2798 : : }
2799 : : // Bei structs Fields als Properties registrieren
2800 : : else //if( eType == TypeClass_STRUCT )
2801 : : {
2802 : : // Ist es ein Interface oder eine struct?
2803 : : //Reference<XIdlClass> xClassRef = aToInspectObj.getReflection()->getIdlClass();
2804 [ + - ]: 270 : Reference<XIdlClass> xClassRef = TypeToIdlClass( aToInspectObj.getValueType(), m_xSMgr );
2805 [ - + ]: 270 : if( !xClassRef.is() )
2806 : : {
2807 : : OSL_FAIL( "Can't get XIdlClass from Reflection" );
2808 [ # # ]: 0 : return pAccess;
2809 : : }
2810 : :
2811 : : // Felder holen
2812 [ + - ][ + - ]: 270 : Sequence< Reference<XIdlField> > fields = xClassRef->getFields();
2813 : 270 : const Reference<XIdlField>* pFields = fields.getConstArray();
2814 : 270 : sal_Int32 nLen = fields.getLength();
2815 : :
2816 [ + + ]: 1330 : for( i = 0 ; i < nLen ; i++ )
2817 : : {
2818 : 1060 : Reference<XIdlField> xField = pFields[i];
2819 [ + - ][ + - ]: 1060 : Reference<XIdlClass> xPropType = xField->getType();
2820 [ + - ][ + - ]: 1060 : ::rtl::OUString aPropName = xField->getName();
2821 : :
2822 : : // Ist die PropertySequence gross genug?
2823 : : pAccess->checkPropertyArraysSize
2824 [ + - ]: 1060 : ( pAllPropArray, pMapTypeArray, pPropertyConceptArray, rPropCount );
2825 : :
2826 : : // In eigenes Property-Array eintragen
2827 : 1060 : Property& rProp = pAllPropArray[ rPropCount ];
2828 : 1060 : rProp.Name = aPropName;
2829 : 1060 : rProp.Handle = rPropCount;
2830 [ + - ][ + - ]: 1060 : rProp.Type = Type( xPropType->getTypeClass(), xPropType->getName() );
[ + - ][ + - ]
2831 [ + - ][ + - ]: 1060 : FieldAccessMode eAccessMode = xField->getAccessMode();
2832 : : rProp.Attributes = (eAccessMode == FieldAccessMode_READONLY ||
2833 : : eAccessMode == FieldAccessMode_CONST)
2834 [ + - ][ - + ]: 1060 : ? READONLY : 0;
2835 : :
2836 : : //FieldAccessMode eAccessMode = xField->getAccessMode();
2837 : : //rProp.Attributes = (eAccessMode == FieldAccessMode::READONLY || eAccessMode == CONST)
2838 : : //? PropertyAttribute::READONLY : 0;
2839 : :
2840 : : // Namen in Hashtable eintragen
2841 [ + - ]: 1060 : rPropNameMap[ aPropName ] = rPropCount;
2842 : :
2843 : : // Tabelle fuer XExactName pflegen
2844 [ + - ]: 1060 : rLowerToExactNameMap[ toLower( aPropName ) ] = aPropName;
2845 : :
2846 : : // Field merken
2847 : 1060 : pAccess->checkInterfaceArraySize( pAccess->aInterfaceSeq1,
2848 [ + - ]: 1060 : pInterfaces1, rPropCount );
2849 [ + - ]: 1060 : pInterfaces1[ rPropCount ] = xField;
2850 : :
2851 : : // Art der Property merken
2852 : 1060 : pMapTypeArray[ rPropCount ] = MAP_FIELD;
2853 : 1060 : pPropertyConceptArray[ rPropCount ] = ATTRIBUTES;
2854 : 1060 : pAccess->mnAttributePropCount++;
2855 : :
2856 : : // Count pflegen
2857 : 1060 : rPropCount++;
2858 [ + - ][ + - ]: 1330 : }
2859 : : }
2860 : :
2861 : : // Property-Sequence auf die richtige Laenge bringen
2862 [ + - ]: 1368 : pAccess->maAllPropertySeq.realloc( pAccess->mnPropCount );
2863 : :
2864 [ + - ][ + - ]: 21641 : return pAccess;
[ + - ][ + - ]
[ + - ]
2865 : : }
2866 : :
2867 : : //*************************************************************************
2868 : 187 : Reference< XInterface > SAL_CALL ImplIntrospection_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr )
2869 : : throw( RuntimeException )
2870 : : {
2871 [ + - ][ + - ]: 187 : Reference< XInterface > xService = (OWeakObject*)(OComponentHelper*)new ImplIntrospection( rSMgr );
[ + - ]
2872 : 187 : return xService;
2873 : : }
2874 : :
2875 : : }
2876 : :
2877 : : #ifdef DISABLE_DYNLOADING
2878 : : #define component_getFactory introspection_component_getFactory
2879 : : #endif
2880 : :
2881 : : extern "C"
2882 : : {
2883 : 187 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
2884 : : const sal_Char * pImplName, void * pServiceManager,
2885 : : SAL_UNUSED_PARAMETER void * )
2886 : : {
2887 : 187 : void * pRet = 0;
2888 : :
2889 [ + - ][ + - ]: 187 : if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
[ + - ]
2890 : : {
2891 : : Reference< XSingleServiceFactory > xFactory( createOneInstanceFactory(
2892 : : reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
2893 : : ::rtl::OUString::createFromAscii( pImplName ),
2894 : : stoc_inspect::ImplIntrospection_CreateInstance,
2895 [ + - ][ + - ]: 187 : stoc_inspect::ImplIntrospection::getSupportedServiceNames_Static() ) );
[ + - ]
2896 : :
2897 [ + - ]: 187 : if (xFactory.is())
2898 : : {
2899 [ + - ]: 187 : xFactory->acquire();
2900 [ + - ]: 187 : pRet = xFactory.get();
2901 : 187 : }
2902 : : }
2903 : :
2904 : 187 : return pRet;
2905 : : }
2906 : : }
2907 : :
2908 : :
2909 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|