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