xref: /trunk/main/stoc/test/testintrosp.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1647a425cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3647a425cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4647a425cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5647a425cSAndrew Rist  * distributed with this work for additional information
6647a425cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7647a425cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8647a425cSAndrew Rist  * "License"); you may not use this file except in compliance
9647a425cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11647a425cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13647a425cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14647a425cSAndrew Rist  * software distributed under the License is distributed on an
15647a425cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16647a425cSAndrew Rist  * KIND, either express or implied.  See the License for the
17647a425cSAndrew Rist  * specific language governing permissions and limitations
18647a425cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20647a425cSAndrew Rist  *************************************************************/
21647a425cSAndrew Rist 
22647a425cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_stoc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/main.h>
28cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
29cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx>
30cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
31cdf0e10cSrcweir #include <osl/diagnose.h>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //#include <vos/dynload.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <ModuleA/XIntroTest.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/XIntrospection.hpp>
38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
39cdf0e10cSrcweir #include <com/sun/star/beans/PropertyConcept.hpp>
40cdf0e10cSrcweir #include <com/sun/star/beans/MethodConcept.hpp>
41cdf0e10cSrcweir #include <com/sun/star/beans/XExactName.hpp>
42cdf0e10cSrcweir #include <com/sun/star/container/XElementAccess.hpp>
43cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
44cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
45cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
46cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlReflection.hpp>
47cdf0e10cSrcweir //#include <com/sun/star/registry/XSimpleRegistry.hpp>
48cdf0e10cSrcweir #include <com/sun/star/registry/XImplementationRegistration.hpp>
49cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
50cdf0e10cSrcweir 
51cdf0e10cSrcweir #include <stdio.h>
52cdf0e10cSrcweir #include <string.h>
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir using namespace rtl;
56cdf0e10cSrcweir using namespace cppu;
57cdf0e10cSrcweir //using namespace vos;
58cdf0e10cSrcweir using namespace ModuleA;
59cdf0e10cSrcweir //using namespace ModuleB;
60cdf0e10cSrcweir //using namespace ModuleC;
61cdf0e10cSrcweir //using namespace ModuleA::ModuleB;
62cdf0e10cSrcweir using namespace com::sun::star::uno;
63cdf0e10cSrcweir using namespace com::sun::star::lang;
64cdf0e10cSrcweir using namespace com::sun::star::beans;
65cdf0e10cSrcweir using namespace com::sun::star::registry;
66cdf0e10cSrcweir using namespace com::sun::star::reflection;
67cdf0e10cSrcweir using namespace com::sun::star::container;
68cdf0e10cSrcweir using namespace com::sun::star::beans::PropertyAttribute;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 
71cdf0e10cSrcweir typedef WeakImplHelper4< XIntroTest, XPropertySet, XNameAccess, XIndexAccess > ImplIntroTestHelper;
72cdf0e10cSrcweir typedef WeakImplHelper1< XPropertySetInfo > ImplPropertySetInfoHelper;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 
75cdf0e10cSrcweir #define DEFAULT_INDEX_ACCESS_COUNT  10
76cdf0e10cSrcweir #define DEFAULT_NAME_ACCESS_COUNT   5
77cdf0e10cSrcweir 
78cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
79cdf0e10cSrcweir #define TEST_ENSHURE(c, m)   OSL_ENSURE(c, m)
80cdf0e10cSrcweir #else
81cdf0e10cSrcweir #define TEST_ENSHURE(c, m)   OSL_VERIFY(c)
82cdf0e10cSrcweir #endif
83cdf0e10cSrcweir 
84cdf0e10cSrcweir //class IntroTestWritelnOutput;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir //**************************************************************
89cdf0e10cSrcweir //*** Hilfs-Funktion, um vom Type eine XIdlClass zu bekommen ***
90cdf0e10cSrcweir //**************************************************************
TypeToIdlClass(const Type & rType,const Reference<XMultiServiceFactory> & xMgr)91cdf0e10cSrcweir Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XMultiServiceFactory > & xMgr )
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     static Reference< XIdlReflection > xRefl;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     // void als Default-Klasse eintragen
96cdf0e10cSrcweir     Reference<XIdlClass> xRetClass;
97cdf0e10cSrcweir     typelib_TypeDescription * pTD = 0;
98cdf0e10cSrcweir     rType.getDescription( &pTD );
99cdf0e10cSrcweir     if( pTD )
100cdf0e10cSrcweir     {
101cdf0e10cSrcweir         OUString sOWName( pTD->pTypeName );
102cdf0e10cSrcweir         if( !xRefl.is() )
103cdf0e10cSrcweir         {
104cdf0e10cSrcweir             xRefl = Reference< XIdlReflection >( xMgr->createInstance(
105cdf0e10cSrcweir                 OUString::createFromAscii("com.sun.star.reflection.CoreReflection") ), UNO_QUERY );
106cdf0e10cSrcweir             OSL_ENSURE( xRefl.is(), "### no corereflection!" );
107cdf0e10cSrcweir         }
108cdf0e10cSrcweir         xRetClass = xRefl->forName( sOWName );
109cdf0e10cSrcweir     }
110cdf0e10cSrcweir     return xRetClass;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 
114cdf0e10cSrcweir //****************************************************
115cdf0e10cSrcweir //*** Hilfs-Funktion, um Any als UString auszugeben ***
116cdf0e10cSrcweir //****************************************************
117cdf0e10cSrcweir // ACHTUNG: Kann mal an eine zentrale Stelle uebernommen werden
118cdf0e10cSrcweir // Wird zunaechst nur fuer einfache Datentypen ausgefuehrt
119cdf0e10cSrcweir 
AnyToString(const Any & aValue,sal_Bool bIncludeType,const Reference<XMultiServiceFactory> & xMgr)120cdf0e10cSrcweir OUString AnyToString( const Any& aValue, sal_Bool bIncludeType, const Reference< XMultiServiceFactory > & xMgr )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     Type aValType = aValue.getValueType();
123cdf0e10cSrcweir     TypeClass eType = aValType.getTypeClass();
124cdf0e10cSrcweir     char pBuffer[50];
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     OUString aRetStr;
127cdf0e10cSrcweir     switch( eType )
128cdf0e10cSrcweir     {
129cdf0e10cSrcweir         case TypeClass_TYPE:            aRetStr = OUString::createFromAscii("TYPE TYPE");               break;
130cdf0e10cSrcweir         case TypeClass_INTERFACE:       aRetStr = OUString::createFromAscii("TYPE INTERFACE");      break;
131cdf0e10cSrcweir         case TypeClass_SERVICE:         aRetStr = OUString::createFromAscii("TYPE SERVICE");            break;
132cdf0e10cSrcweir         case TypeClass_STRUCT:          aRetStr = OUString::createFromAscii("TYPE STRUCT");         break;
133cdf0e10cSrcweir         case TypeClass_TYPEDEF:         aRetStr = OUString::createFromAscii("TYPE TYPEDEF");            break;
134cdf0e10cSrcweir         case TypeClass_UNION:           aRetStr = OUString::createFromAscii("TYPE UNION");          break;
135cdf0e10cSrcweir         case TypeClass_ENUM:            aRetStr = OUString::createFromAscii("TYPE ENUM");               break;
136cdf0e10cSrcweir         case TypeClass_EXCEPTION:       aRetStr = OUString::createFromAscii("TYPE EXCEPTION");      break;
137cdf0e10cSrcweir         case TypeClass_ARRAY:           aRetStr = OUString::createFromAscii("TYPE ARRAY");          break;
138cdf0e10cSrcweir         case TypeClass_SEQUENCE:        aRetStr = OUString::createFromAscii("TYPE SEQUENCE");           break;
139cdf0e10cSrcweir         case TypeClass_VOID:            aRetStr = OUString::createFromAscii("TYPE void");               break;
140cdf0e10cSrcweir         case TypeClass_ANY:             aRetStr = OUString::createFromAscii("TYPE any");                break;
141cdf0e10cSrcweir         case TypeClass_UNKNOWN:         aRetStr = OUString::createFromAscii("TYPE unknown");            break;
142cdf0e10cSrcweir         case TypeClass_BOOLEAN:
143cdf0e10cSrcweir         {
144cdf0e10cSrcweir             sal_Bool b = *(sal_Bool*)aValue.getValue();
145cdf0e10cSrcweir             //aRet.setValue( &b, getCppuBooleanType() );
146cdf0e10cSrcweir             //aValue >>= b;
147cdf0e10cSrcweir             aRetStr = OUString::valueOf( b );
148cdf0e10cSrcweir             break;
149cdf0e10cSrcweir         }
150cdf0e10cSrcweir         case TypeClass_CHAR:
151cdf0e10cSrcweir         {
152cdf0e10cSrcweir             sal_Unicode c = *(sal_Unicode*)aValue.getValue();
153cdf0e10cSrcweir             //aValue >>= c;
154cdf0e10cSrcweir             //getCppuCharType()
155cdf0e10cSrcweir             aRetStr = OUString::valueOf( c );
156cdf0e10cSrcweir             break;
157cdf0e10cSrcweir         }
158cdf0e10cSrcweir         case TypeClass_STRING:
159cdf0e10cSrcweir         {
160cdf0e10cSrcweir             aValue >>= aRetStr;
161cdf0e10cSrcweir             break;
162cdf0e10cSrcweir         }
163cdf0e10cSrcweir         case TypeClass_FLOAT:
164cdf0e10cSrcweir         {
165cdf0e10cSrcweir             float f(0.0);
166cdf0e10cSrcweir             aValue >>= f;
167cdf0e10cSrcweir             snprintf( pBuffer, sizeof( pBuffer ), "%f", f );
168cdf0e10cSrcweir             aRetStr = OUString( pBuffer, strlen( pBuffer ), RTL_TEXTENCODING_ASCII_US );
169cdf0e10cSrcweir             break;
170cdf0e10cSrcweir         }
171cdf0e10cSrcweir         case TypeClass_DOUBLE:
172cdf0e10cSrcweir         {
173cdf0e10cSrcweir             double d(0.0);
174cdf0e10cSrcweir             aValue >>= d;
175cdf0e10cSrcweir             snprintf( pBuffer, sizeof( pBuffer ), "%f", d );
176cdf0e10cSrcweir             aRetStr = OUString( pBuffer, strlen( pBuffer ), RTL_TEXTENCODING_ASCII_US );
177cdf0e10cSrcweir             break;
178cdf0e10cSrcweir         }
179cdf0e10cSrcweir         case TypeClass_BYTE:
180cdf0e10cSrcweir         {
181cdf0e10cSrcweir             sal_Int8 n(0);
182cdf0e10cSrcweir             aValue >>= n;
183cdf0e10cSrcweir             aRetStr = OUString::valueOf( (sal_Int32) n );
184cdf0e10cSrcweir             break;
185cdf0e10cSrcweir         }
186cdf0e10cSrcweir         case TypeClass_SHORT:
187cdf0e10cSrcweir         {
188cdf0e10cSrcweir             sal_Int16 n(0);
189cdf0e10cSrcweir             aValue >>= n;
190cdf0e10cSrcweir             aRetStr = OUString::valueOf( (sal_Int32) n );
191cdf0e10cSrcweir             break;
192cdf0e10cSrcweir         }
193cdf0e10cSrcweir         case TypeClass_LONG:
194cdf0e10cSrcweir         {
195cdf0e10cSrcweir             sal_Int32 n(0);
196cdf0e10cSrcweir             aValue >>= n;
197cdf0e10cSrcweir             aRetStr = OUString::valueOf( n );
198cdf0e10cSrcweir             break;
199cdf0e10cSrcweir         }
200cdf0e10cSrcweir         /*
201cdf0e10cSrcweir         case TypeClass_HYPER:
202cdf0e10cSrcweir         {
203cdf0e10cSrcweir             aRetStr = L"TYPE HYPER";
204cdf0e10cSrcweir             break;
205cdf0e10cSrcweir         }
206cdf0e10cSrcweir         case TypeClass_UNSIGNED_SHORT:
207cdf0e10cSrcweir         {
208cdf0e10cSrcweir             aRetStr = StringToUString(WSString(aValue.getUINT16()), CHARSET_SYSTEM);
209cdf0e10cSrcweir             break;
210cdf0e10cSrcweir         }
211cdf0e10cSrcweir         case TypeClass_UNSIGNED_LONG:
212cdf0e10cSrcweir         {
213cdf0e10cSrcweir             aRetStr = StringToUString(WSString(aValue.getUINT32()), CHARSET_SYSTEM);
214cdf0e10cSrcweir             break;
215cdf0e10cSrcweir         }
216cdf0e10cSrcweir         case TypeClass_UNSIGNED_HYPER:
217cdf0e10cSrcweir         {
218cdf0e10cSrcweir             aRetStr = L"TYPE UNSIGNED_HYPER";
219cdf0e10cSrcweir             break;
220cdf0e10cSrcweir         }
221cdf0e10cSrcweir         */
222cdf0e10cSrcweir     default: ;
223cdf0e10cSrcweir     }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir     if( bIncludeType )
226cdf0e10cSrcweir     {
227cdf0e10cSrcweir         Reference< XIdlClass > xIdlClass = TypeToIdlClass( aValType, xMgr );
228cdf0e10cSrcweir         aRetStr = aRetStr + OUString( OUString::createFromAscii(" (Typ: ") ) + xIdlClass->getName() + OUString::createFromAscii(")");
229cdf0e10cSrcweir     }
230cdf0e10cSrcweir     return aRetStr;
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir /*
234cdf0e10cSrcweir // Hilfs-Funktion, um ein UString in einen Any zu konvertieren
235cdf0e10cSrcweir UsrAny StringToAny( UString aStr, TypeClass eTargetType )
236cdf0e10cSrcweir {
237cdf0e10cSrcweir     UsrAny aRetAny;
238cdf0e10cSrcweir     switch( eTargetType )
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         case TypeClass_INTERFACE:       break;
241cdf0e10cSrcweir         case TypeClass_SERVICE:         break;
242cdf0e10cSrcweir         case TypeClass_STRUCT:          break;
243cdf0e10cSrcweir         case TypeClass_TYPEDEF:         break;
244cdf0e10cSrcweir         case TypeClass_UNION:           break;
245cdf0e10cSrcweir         case TypeClass_ENUM:            break;
246cdf0e10cSrcweir         case TypeClass_EXCEPTION:       break;
247cdf0e10cSrcweir         case TypeClass_ARRAY:           break;
248cdf0e10cSrcweir         case TypeClass_SEQUENCE:        break;
249cdf0e10cSrcweir         case TypeClass_VOID:            break;
250cdf0e10cSrcweir         case TypeClass_ANY:             break;
251cdf0e10cSrcweir         case TypeClass_UNKNOWN:         break;
252cdf0e10cSrcweir         case TypeClass_BOOLEAN:         aRetAny.setBOOL( short(aStr)!=0 );  break;
253cdf0e10cSrcweir         case TypeClass_CHAR:            aRetAny.setChar( char(aStr) );      break;
254cdf0e10cSrcweir         case TypeClass_STRING:          aRetAny.setString( aStr );          break;
255cdf0e10cSrcweir         case TypeClass_FLOAT:           aRetAny.setFloat( (float)strtod( aStr.GetStr(), NULL ) );   break;
256cdf0e10cSrcweir         case TypeClass_DOUBLE:          aRetAny.setDouble( strtod( aStr.GetStr(), NULL ) ); break;
257cdf0e10cSrcweir         case TypeClass_BYTE:            aRetAny.setBYTE( BYTE(short(aStr)) );   break;
258cdf0e10cSrcweir         case TypeClass_SHORT:           aRetAny.setINT16( short(aStr) );    break;
259cdf0e10cSrcweir         case TypeClass_LONG:            aRetAny.setINT32( long(aStr) );     break;
260cdf0e10cSrcweir         case TypeClass_HYPER:           break;
261cdf0e10cSrcweir         case TypeClass_UNSIGNED_SHORT:  aRetAny.setUINT16( USHORT(aStr) );  break;
262cdf0e10cSrcweir         case TypeClass_UNSIGNED_LONG:   aRetAny.setUINT32( ULONG(aStr) );   break;
263cdf0e10cSrcweir         case TypeClass_UNSIGNED_HYPER:  break;
264cdf0e10cSrcweir     }
265cdf0e10cSrcweir     return aRetAny;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir */
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 
270cdf0e10cSrcweir //*****************************************
271cdf0e10cSrcweir //*** XPropertySetInfo fuer Test-Klasse ***
272cdf0e10cSrcweir //*****************************************
273cdf0e10cSrcweir 
274cdf0e10cSrcweir class ImplPropertySetInfo : public ImplPropertySetInfoHelper
275cdf0e10cSrcweir {
276cdf0e10cSrcweir     friend class ImplIntroTest;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     Reference< XMultiServiceFactory > mxMgr;
279cdf0e10cSrcweir 
280cdf0e10cSrcweir public:
ImplPropertySetInfo(const Reference<XMultiServiceFactory> & xMgr)281cdf0e10cSrcweir     ImplPropertySetInfo( const Reference< XMultiServiceFactory > & xMgr )
282cdf0e10cSrcweir         : mxMgr( xMgr ) {}
283cdf0e10cSrcweir         //: mxMgr( xMgr ), ImplPropertySetInfoHelper( xMgr ) {}
284cdf0e10cSrcweir 
285cdf0e10cSrcweir /*
286cdf0e10cSrcweir     // Methoden von XInterface
287cdf0e10cSrcweir     virtual sal_Bool    SAL_CALL queryInterface( const Uik & rUik, Any & ifc ) throw( RuntimeException );
288cdf0e10cSrcweir     virtual void        SAL_CALL acquire() throw() { OWeakObject::acquire(); }
289cdf0e10cSrcweir     virtual void        SAL_CALL release() throw() { OWeakObject::release(); }
290cdf0e10cSrcweir     //ALT: sal_Bool queryInterface( Uik aUik, Reference<XInterface> & rOut );
291cdf0e10cSrcweir */
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     // Methods of XPropertySetInfo
294cdf0e10cSrcweir     virtual Sequence< Property > SAL_CALL getProperties(  )
295cdf0e10cSrcweir         throw(RuntimeException);
296cdf0e10cSrcweir     virtual Property SAL_CALL getPropertyByName( const OUString& aName )
297cdf0e10cSrcweir         throw(UnknownPropertyException, RuntimeException);
298cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name )
299cdf0e10cSrcweir         throw(RuntimeException);
300cdf0e10cSrcweir     //virtual Sequence< Property > SAL_CALL getProperties(void) throw( RuntimeException );
301cdf0e10cSrcweir     //virtual Property SAL_CALL getPropertyByName(const OUString& Name) throw( RuntimeException );
302cdf0e10cSrcweir     //virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& Name) throw( RuntimeException );
303cdf0e10cSrcweir };
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 
306cdf0e10cSrcweir /*
307cdf0e10cSrcweir // Methoden von XInterface
308cdf0e10cSrcweir sal_Bool SAL_CALL ImplPropertySetInfo::queryInterface( const Uik & rUik, Any & ifc )
309cdf0e10cSrcweir     throw( RuntimeException )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir     // PropertySet-Implementation
312cdf0e10cSrcweir     if( com::sun::star::uno::queryInterface( rUik, ifc,
313cdf0e10cSrcweir                                              SAL_STATIC_CAST(XPropertySetInfo*, this) ) )
314cdf0e10cSrcweir         return sal_True;
315cdf0e10cSrcweir 
316cdf0e10cSrcweir     return OWeakObject::queryInterface( rUik, ifc );
317cdf0e10cSrcweir }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir sal_Bool ImplPropertySetInfo::queryInterface( Uik aUik, Reference<XInterface> & rOut )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir     if( aUik == XPropertySetInfo::getSmartUik() )
322cdf0e10cSrcweir         rOut = (XPropertySetInfo *)this;
323cdf0e10cSrcweir     else
324cdf0e10cSrcweir         UsrObject::queryInterface( aUik, rOut );
325cdf0e10cSrcweir     return rOut.is();
326cdf0e10cSrcweir }
327cdf0e10cSrcweir */
328cdf0e10cSrcweir 
getProperties(void)329cdf0e10cSrcweir Sequence< Property > ImplPropertySetInfo::getProperties(void)
330cdf0e10cSrcweir     throw( RuntimeException )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir     static Sequence<Property> * pSeq = NULL;
333cdf0e10cSrcweir 
334cdf0e10cSrcweir     if( !pSeq )
335cdf0e10cSrcweir     {
336cdf0e10cSrcweir         // die Informationen f�r die Properties "Width", "Height" und "Name" anlegen
337cdf0e10cSrcweir         pSeq = new Sequence<Property>( 3 );
338cdf0e10cSrcweir         Property * pAry = pSeq->getArray();
339cdf0e10cSrcweir 
340cdf0e10cSrcweir         pAry[0].Name = OUString::createFromAscii("Factor");
341cdf0e10cSrcweir         pAry[0].Handle = -1;
342cdf0e10cSrcweir         pAry[0].Type = getCppuType( (double*) NULL );
343cdf0e10cSrcweir         //pAry[0].Type = TypeToIdlClass( getCppuType( (double*) NULL ), mxMgr );
344cdf0e10cSrcweir         //pAry[0].Type = Double_getReflection()->getIdlClass();
345cdf0e10cSrcweir         pAry[0].Attributes = BOUND | TRANSIENT;
346cdf0e10cSrcweir 
347cdf0e10cSrcweir         pAry[1].Name = OUString::createFromAscii("MyCount");
348cdf0e10cSrcweir         pAry[1].Handle = -1;
349cdf0e10cSrcweir         pAry[1].Type = getCppuType( (sal_Int32*) NULL );
350cdf0e10cSrcweir         //pAry[1].Type = TypeToIdlClass( getCppuType( (sal_Int32*) NULL ), mxMgr );
351cdf0e10cSrcweir         //pAry[1].Type = INT32_getReflection()->getIdlClass();
352cdf0e10cSrcweir         pAry[1].Attributes = BOUND | TRANSIENT;
353cdf0e10cSrcweir 
354cdf0e10cSrcweir         pAry[2].Name = OUString::createFromAscii("Info");
355cdf0e10cSrcweir         pAry[2].Handle = -1;
356cdf0e10cSrcweir         pAry[2].Type = getCppuType( (OUString*) NULL );
357cdf0e10cSrcweir         //pAry[2].Type = TypeToIdlClass( getCppuType( (OUString*) NULL ), mxMgr );
358cdf0e10cSrcweir         //pAry[2].Type = OUString_getReflection()->getIdlClass();
359cdf0e10cSrcweir         pAry[2].Attributes = TRANSIENT;
360cdf0e10cSrcweir     }
361cdf0e10cSrcweir     // Die Information �ber alle drei Properties liefern.
362cdf0e10cSrcweir     return *pSeq;
363cdf0e10cSrcweir }
364cdf0e10cSrcweir 
getPropertyByName(const OUString & Name)365cdf0e10cSrcweir Property ImplPropertySetInfo::getPropertyByName(const OUString& Name)
366cdf0e10cSrcweir     throw( UnknownPropertyException, RuntimeException )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir     Sequence<Property> aSeq = getProperties();
369cdf0e10cSrcweir     const Property * pAry = aSeq.getConstArray();
370cdf0e10cSrcweir 
371cdf0e10cSrcweir     for( sal_Int32 i = aSeq.getLength(); i--; )
372cdf0e10cSrcweir     {
373cdf0e10cSrcweir         if( pAry[i].Name == Name )
374cdf0e10cSrcweir             return pAry[i];
375cdf0e10cSrcweir     }
376cdf0e10cSrcweir     // Property unbekannt, also leere liefern
377cdf0e10cSrcweir     return Property();
378cdf0e10cSrcweir }
379cdf0e10cSrcweir 
hasPropertyByName(const OUString & Name)380cdf0e10cSrcweir sal_Bool ImplPropertySetInfo::hasPropertyByName(const OUString& Name)
381cdf0e10cSrcweir     throw( RuntimeException )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir     Sequence<Property> aSeq = getProperties();
384cdf0e10cSrcweir     const Property * pAry = aSeq.getConstArray();
385cdf0e10cSrcweir 
386cdf0e10cSrcweir     for( sal_Int32 i = aSeq.getLength(); i--; )
387cdf0e10cSrcweir     {
388cdf0e10cSrcweir         if( pAry[i].Name == Name )
389cdf0e10cSrcweir             return sal_True;
390cdf0e10cSrcweir     }
391cdf0e10cSrcweir     // Property unbekannt, also leere liefern
392cdf0e10cSrcweir     return sal_False;
393cdf0e10cSrcweir }
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 
398cdf0e10cSrcweir //*****************************************************************
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 
402cdf0e10cSrcweir class ImplIntroTest : public ImplIntroTestHelper
403cdf0e10cSrcweir {
404cdf0e10cSrcweir     Reference< XMultiServiceFactory > mxMgr;
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     friend class ImplPropertySetInfo;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir     // Properties fuer das PropertySet
409cdf0e10cSrcweir     Any aAnyArray[10];
410cdf0e10cSrcweir 
411cdf0e10cSrcweir     // Optionale Schnittstelle fuer die writeln-Ausgabe
412cdf0e10cSrcweir     //IntroTestWritelnOutput* m_pOutput;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir     Reference< XPropertySetInfo > m_xMyInfo;
415cdf0e10cSrcweir 
416cdf0e10cSrcweir     OUString m_ObjectName;
417cdf0e10cSrcweir 
418cdf0e10cSrcweir     sal_Int16 m_nMarkusAge;
419cdf0e10cSrcweir     sal_Int16 m_nMarkusChildrenCount;
420cdf0e10cSrcweir 
421cdf0e10cSrcweir     long m_lDroenk;
422cdf0e10cSrcweir     sal_Int16 m_nBla;
423cdf0e10cSrcweir     sal_Int16 m_nBlub;
424cdf0e10cSrcweir     sal_Int16 m_nGulp;
425cdf0e10cSrcweir     sal_Int16 m_nLaber;
426cdf0e10cSrcweir     TypeClass eTypeClass;
427cdf0e10cSrcweir     Sequence< OUString > aStringSeq;
428cdf0e10cSrcweir     Sequence< Sequence< Sequence< sal_Int16 > > > aMultSeq;
429cdf0e10cSrcweir     Reference< XIntroTest > m_xIntroTest;
430cdf0e10cSrcweir 
431cdf0e10cSrcweir     // Daten fuer NameAccess
432cdf0e10cSrcweir     Reference< XIntroTest >* pNameAccessTab;
433cdf0e10cSrcweir 
434cdf0e10cSrcweir     // Daten fuer IndexAccess
435cdf0e10cSrcweir     Reference< XIntroTest >* pIndexAccessTab;
436cdf0e10cSrcweir     sal_Int16 iIndexAccessCount;
437cdf0e10cSrcweir 
438cdf0e10cSrcweir     // struct-Properties
439cdf0e10cSrcweir     Property m_aFirstStruct;
440cdf0e10cSrcweir     PropertyValue m_aSecondStruct;
441cdf0e10cSrcweir 
442cdf0e10cSrcweir     // Listener merken (zunaechst einfach, nur einen pro Property)
443cdf0e10cSrcweir     Reference< XPropertyChangeListener > aPropChangeListener;
444cdf0e10cSrcweir     OUString aPropChangeListenerStr;
445cdf0e10cSrcweir     Reference< XVetoableChangeListener > aVetoPropChangeListener;
446cdf0e10cSrcweir     OUString aVetoPropChangeListenerStr;
447cdf0e10cSrcweir 
448cdf0e10cSrcweir     void Init( void );
449cdf0e10cSrcweir 
450cdf0e10cSrcweir public:
ImplIntroTest(const Reference<XMultiServiceFactory> & xMgr)451cdf0e10cSrcweir     ImplIntroTest( const Reference< XMultiServiceFactory > & xMgr )
452cdf0e10cSrcweir         : mxMgr( xMgr )
453cdf0e10cSrcweir         //: mxMgr( xMgr ), ImplIntroTestHelper( xMgr )
454cdf0e10cSrcweir     {
455cdf0e10cSrcweir         Init();
456cdf0e10cSrcweir     }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir     /*
459cdf0e10cSrcweir     ImplIntroTest( IntroTestWritelnOutput* pOutput_ )
460cdf0e10cSrcweir     {
461cdf0e10cSrcweir         Init();
462cdf0e10cSrcweir         m_pOutput = pOutput_;
463cdf0e10cSrcweir     }
464cdf0e10cSrcweir     */
465cdf0e10cSrcweir 
466cdf0e10cSrcweir     //SMART_UNO_DECLARATION(ImplIntroTest,UsrObject);
467cdf0e10cSrcweir 
468cdf0e10cSrcweir     //BOOL queryInterface( Uik aUik, Reference< XInterface > & rOut );
469cdf0e10cSrcweir     //Reference< XIdlClass > getIdlClass();
470cdf0e10cSrcweir 
471cdf0e10cSrcweir     // Trotz virtual inline, um Schreibarbeit zu sparen (nur fuer Testzwecke)
472cdf0e10cSrcweir     // XPropertySet
473cdf0e10cSrcweir     virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo(  )
474cdf0e10cSrcweir         throw(RuntimeException);
475cdf0e10cSrcweir     virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue )
476cdf0e10cSrcweir         throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException);
477cdf0e10cSrcweir     virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName )
478cdf0e10cSrcweir         throw(UnknownPropertyException, WrappedTargetException, RuntimeException);
addPropertyChangeListener(const OUString &,const Reference<XPropertyChangeListener> &)479cdf0e10cSrcweir     virtual void SAL_CALL addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ )
480cdf0e10cSrcweir         throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
481cdf0e10cSrcweir             {}
removePropertyChangeListener(const OUString &,const Reference<XPropertyChangeListener> &)482cdf0e10cSrcweir     virtual void SAL_CALL removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*aListener*/ )
483cdf0e10cSrcweir         throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
484cdf0e10cSrcweir             {}
addVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)485cdf0e10cSrcweir     virtual void SAL_CALL addVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ )
486cdf0e10cSrcweir         throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
487cdf0e10cSrcweir             {}
removeVetoableChangeListener(const OUString &,const Reference<XVetoableChangeListener> &)488cdf0e10cSrcweir     virtual void SAL_CALL removeVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ )
489cdf0e10cSrcweir         throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
490cdf0e10cSrcweir             {}
491cdf0e10cSrcweir 
492cdf0e10cSrcweir     /*
493cdf0e10cSrcweir     virtual void setIndexedPropertyValue(const OUString& aPropertyName, INT32 nIndex, const Any& aValue) {}
494cdf0e10cSrcweir     virtual Any getIndexedPropertyValue(const UString& aPropertyName, INT32 nIndex) const { return Any(); }
495cdf0e10cSrcweir     virtual void addPropertyChangeListener(const UString& aPropertyName, const XPropertyChangeListenerRef& aListener)
496cdf0e10cSrcweir         THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
497cdf0e10cSrcweir     virtual void removePropertyChangeListener(const UString& aPropertyName, const XPropertyChangeListenerRef& aListener)
498cdf0e10cSrcweir         THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
499cdf0e10cSrcweir     virtual void addVetoableChangeListener(const UString& aPropertyName, const XVetoableChangeListenerRef& aListener)
500cdf0e10cSrcweir         THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
501cdf0e10cSrcweir     virtual void removeVetoableChangeListener(const UString& aPropertyName, const XVetoableChangeListenerRef& aListener)
502cdf0e10cSrcweir         THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) ) {}
503cdf0e10cSrcweir         */
504cdf0e10cSrcweir 
505cdf0e10cSrcweir     // XIntroTest-Methoden
506cdf0e10cSrcweir     // Attributes
getObjectName()507cdf0e10cSrcweir     virtual OUString SAL_CALL getObjectName() throw(RuntimeException)
508cdf0e10cSrcweir         { return m_ObjectName; }
setObjectName(const OUString & _objectname)509cdf0e10cSrcweir     virtual void SAL_CALL setObjectName( const OUString& _objectname ) throw(RuntimeException)
510cdf0e10cSrcweir         { m_ObjectName = _objectname; }
511cdf0e10cSrcweir     virtual OUString SAL_CALL getFirstName()
512cdf0e10cSrcweir         throw(RuntimeException);
getLastName()513cdf0e10cSrcweir     virtual OUString SAL_CALL getLastName() throw(RuntimeException)
514cdf0e10cSrcweir         { return OUString( OUString::createFromAscii("Meyer") ); }
getAge()515cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL getAge() throw(RuntimeException)
516cdf0e10cSrcweir         { return m_nMarkusAge; }
getChildrenCount()517cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL getChildrenCount() throw(RuntimeException)
518cdf0e10cSrcweir         { return m_nMarkusChildrenCount; }
setChildrenCount(sal_Int16 _childrencount)519cdf0e10cSrcweir     virtual void SAL_CALL setChildrenCount( sal_Int16 _childrencount ) throw(RuntimeException)
520cdf0e10cSrcweir         { m_nMarkusChildrenCount = _childrencount; }
getFirstStruct()521cdf0e10cSrcweir     virtual Property SAL_CALL getFirstStruct() throw(RuntimeException)
522cdf0e10cSrcweir         { return m_aFirstStruct; }
setFirstStruct(const Property & _firststruct)523cdf0e10cSrcweir     virtual void SAL_CALL setFirstStruct( const Property& _firststruct ) throw(RuntimeException)
524cdf0e10cSrcweir         { m_aFirstStruct = _firststruct; }
getSecondStruct()525cdf0e10cSrcweir     virtual PropertyValue SAL_CALL getSecondStruct() throw(RuntimeException)
526cdf0e10cSrcweir         { return m_aSecondStruct; }
setSecondStruct(const PropertyValue & _secondstruct)527cdf0e10cSrcweir     virtual void SAL_CALL setSecondStruct( const PropertyValue& _secondstruct ) throw(RuntimeException)
528cdf0e10cSrcweir         { m_aSecondStruct = _secondstruct; }
529cdf0e10cSrcweir 
530cdf0e10cSrcweir     // Methods
531cdf0e10cSrcweir     virtual void SAL_CALL writeln( const OUString& Text )
532cdf0e10cSrcweir         throw(RuntimeException);
getDroenk()533cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getDroenk(  ) throw(RuntimeException)
534cdf0e10cSrcweir         { return m_lDroenk; }
535cdf0e10cSrcweir     virtual Reference< ::ModuleA::XIntroTest > SAL_CALL getIntroTest(  ) throw(RuntimeException);
getUps(sal_Int32 l)536cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getUps( sal_Int32 l ) throw(RuntimeException)
537cdf0e10cSrcweir         { return 2*l; }
setDroenk(sal_Int32 l)538cdf0e10cSrcweir     virtual void SAL_CALL setDroenk( sal_Int32 l ) throw(RuntimeException)
539cdf0e10cSrcweir         { m_lDroenk = l; }
getBla()540cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL getBla(  ) throw(RuntimeException)
541cdf0e10cSrcweir         { return m_nBla; }
setBla(sal_Int32 n)542cdf0e10cSrcweir     virtual void SAL_CALL setBla( sal_Int32 n ) throw(RuntimeException)
543cdf0e10cSrcweir         { m_nBla = (sal_Int16)n; }
getBlub()544cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL getBlub(  ) throw(RuntimeException)
545cdf0e10cSrcweir         { return m_nBlub; }
setBlub(sal_Int16 n)546cdf0e10cSrcweir     virtual void SAL_CALL setBlub( sal_Int16 n ) throw(RuntimeException)
547cdf0e10cSrcweir         { m_nBlub = n; }
getGulp()548cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL getGulp(  ) throw(RuntimeException)
549cdf0e10cSrcweir         { return m_nGulp; }
setGulp(sal_Int16 n)550cdf0e10cSrcweir     virtual sal_Int16 SAL_CALL setGulp( sal_Int16 n ) throw(RuntimeException)
551cdf0e10cSrcweir         { m_nGulp = n; return 1; }
getTypeClass(sal_Int16)552cdf0e10cSrcweir     virtual TypeClass SAL_CALL getTypeClass( sal_Int16 /*n*/ ) throw(RuntimeException)
553cdf0e10cSrcweir         { return eTypeClass; }
setTypeClass(TypeClass t,double,double)554cdf0e10cSrcweir     virtual void SAL_CALL setTypeClass( TypeClass t, double /*d1*/, double /*d2*/ ) throw(RuntimeException)
555cdf0e10cSrcweir         { eTypeClass = t; }
getStrings()556cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getStrings(  ) throw(RuntimeException)
557cdf0e10cSrcweir         { return aStringSeq; }
setStrings(const Sequence<OUString> & Strings)558cdf0e10cSrcweir     virtual void SAL_CALL setStrings( const Sequence< OUString >& Strings ) throw(RuntimeException)
559cdf0e10cSrcweir         { aStringSeq = Strings; }
setStringsPerMethod(const Sequence<OUString> & Strings,sal_Int16)560cdf0e10cSrcweir     virtual void SAL_CALL setStringsPerMethod( const Sequence< OUString >& Strings, sal_Int16 /*n*/ ) throw(RuntimeException)
561cdf0e10cSrcweir         { aStringSeq = Strings; }
getMultiSequence()562cdf0e10cSrcweir     virtual Sequence< Sequence< Sequence< sal_Int16 > > > SAL_CALL getMultiSequence(  ) throw(RuntimeException)
563cdf0e10cSrcweir         { return aMultSeq; }
setMultiSequence(const Sequence<Sequence<Sequence<sal_Int16>>> & Seq)564cdf0e10cSrcweir     virtual void SAL_CALL setMultiSequence( const Sequence< Sequence< Sequence< sal_Int16 > > >& Seq ) throw(RuntimeException)
565cdf0e10cSrcweir         { aMultSeq = Seq; }
566cdf0e10cSrcweir     virtual void SAL_CALL addPropertiesChangeListener( const Sequence< OUString >& PropertyNames, const Reference< XPropertiesChangeListener >& Listener )
567cdf0e10cSrcweir         throw(RuntimeException);
568cdf0e10cSrcweir     virtual void SAL_CALL removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& Listener )
569cdf0e10cSrcweir         throw(RuntimeException);
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 
572cdf0e10cSrcweir     // Methods of XElementAccess
573cdf0e10cSrcweir     virtual Type SAL_CALL getElementType(  )
574cdf0e10cSrcweir         throw(RuntimeException);
575cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasElements(  )
576cdf0e10cSrcweir         throw(RuntimeException);
577cdf0e10cSrcweir     //virtual XIdlClassRef getElementType(void) constTHROWS( (UsrSystemException) );
578cdf0e10cSrcweir     //virtual BOOL hasElements(void) const THROWS( (UsrSystemException) );
579cdf0e10cSrcweir 
580cdf0e10cSrcweir     // XNameAccess-Methoden
581cdf0e10cSrcweir     // Methods
582cdf0e10cSrcweir     virtual Any SAL_CALL getByName( const OUString& aName )
583cdf0e10cSrcweir         throw(NoSuchElementException, WrappedTargetException, RuntimeException);
584cdf0e10cSrcweir     virtual Sequence< OUString > SAL_CALL getElementNames(  )
585cdf0e10cSrcweir         throw(RuntimeException);
586cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasByName( const OUString& aName )
587cdf0e10cSrcweir         throw(RuntimeException);
588cdf0e10cSrcweir     //virtual Any getByName(const UString& Name) const
589cdf0e10cSrcweir         //THROWS( (NoSuchElementException, WrappedTargetException, UsrSystemException) );
590cdf0e10cSrcweir     //virtual Sequence<UString> getElementNames(void) const THROWS( (UsrSystemException) );
591cdf0e10cSrcweir     //virtual BOOL hasByName(const UString& Name) const THROWS( (UsrSystemException) );
592cdf0e10cSrcweir 
593cdf0e10cSrcweir     // XIndexAccess-Methoden
594cdf0e10cSrcweir     // Methods
595cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getCount(  )
596cdf0e10cSrcweir         throw(RuntimeException);
597cdf0e10cSrcweir     virtual Any SAL_CALL getByIndex( sal_Int32 Index )
598cdf0e10cSrcweir         throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
599cdf0e10cSrcweir     //virtual INT32 getCount(void) const THROWS( (UsrSystemException) );
600cdf0e10cSrcweir     //virtual Any getByIndex(INT32 Index) const
601cdf0e10cSrcweir         //THROWS( (IndexOutOfBoundsException, WrappedTargetException, UsrSystemException) );
602cdf0e10cSrcweir };
603cdf0e10cSrcweir 
604cdf0e10cSrcweir //SMART_UNO_IMPLEMENTATION(ImplIntroTest,UsrObject)
605cdf0e10cSrcweir 
Init(void)606cdf0e10cSrcweir void ImplIntroTest::Init( void )
607cdf0e10cSrcweir {
608cdf0e10cSrcweir     // Eindeutigen Namen verpassen
609cdf0e10cSrcweir     static sal_Int32 nObjCount = 0;
610cdf0e10cSrcweir     OUString aName( OUString::createFromAscii("IntroTest-Obj Nr. ") );
611cdf0e10cSrcweir     aName += OUString::valueOf( nObjCount );
612cdf0e10cSrcweir     setObjectName( aName );
613cdf0e10cSrcweir 
614cdf0e10cSrcweir     // Properties initialisieren
615cdf0e10cSrcweir     aAnyArray[0] <<= 3.14;
616cdf0e10cSrcweir     aAnyArray[1] <<= (sal_Int32)42;
617cdf0e10cSrcweir     aAnyArray[2] <<= OUString( OUString::createFromAscii("Hallo") );
618cdf0e10cSrcweir 
619cdf0e10cSrcweir     // Output-Interface
620cdf0e10cSrcweir     //m_pOutput = NULL;
621cdf0e10cSrcweir 
622cdf0e10cSrcweir     // Einmal fuer den internen Gebrauch die PropertySetInfo abholen
623cdf0e10cSrcweir     m_xMyInfo = getPropertySetInfo();
624cdf0e10cSrcweir     m_xMyInfo->acquire();       // sonst raucht es am Programm-Ende ab
625cdf0e10cSrcweir 
626cdf0e10cSrcweir     m_nMarkusAge = 33;
627cdf0e10cSrcweir     m_nMarkusChildrenCount = 2;
628cdf0e10cSrcweir 
629cdf0e10cSrcweir     m_lDroenk = 314;
630cdf0e10cSrcweir     m_nBla = 42;
631cdf0e10cSrcweir     m_nBlub = 111;
632cdf0e10cSrcweir     m_nGulp = 99;
633cdf0e10cSrcweir     m_nLaber = 1;
634cdf0e10cSrcweir     eTypeClass = TypeClass_INTERFACE;
635cdf0e10cSrcweir 
636cdf0e10cSrcweir     // String-Sequence intitialisieren
637cdf0e10cSrcweir     aStringSeq.realloc( 3 );
638cdf0e10cSrcweir     OUString* pStr = aStringSeq.getArray();
639cdf0e10cSrcweir     pStr[ 0 ] = OUString( OUString::createFromAscii("String 0") );
640cdf0e10cSrcweir     pStr[ 1 ] = OUString( OUString::createFromAscii("String 1") );
641cdf0e10cSrcweir     pStr[ 2 ] = OUString( OUString::createFromAscii("String 2") );
642cdf0e10cSrcweir 
643cdf0e10cSrcweir     // structs initialisieren
644cdf0e10cSrcweir     m_aFirstStruct.Name = OUString::createFromAscii("FirstStruct-Name");
645cdf0e10cSrcweir     m_aFirstStruct.Handle = 77777;
646cdf0e10cSrcweir     //XIdlClassRef Type;
647cdf0e10cSrcweir     m_aFirstStruct.Attributes = -222;
648cdf0e10cSrcweir 
649cdf0e10cSrcweir     //XInterfaceRef Source;
650cdf0e10cSrcweir     Any Value;
651cdf0e10cSrcweir     Value <<= 2.718281828459;
652cdf0e10cSrcweir     m_aSecondStruct.Value = Value;
653cdf0e10cSrcweir     //XIdlClassRef ListenerType;
654cdf0e10cSrcweir     m_aSecondStruct.State = PropertyState_DIRECT_VALUE;
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     // IndexAccess
657cdf0e10cSrcweir     iIndexAccessCount = DEFAULT_INDEX_ACCESS_COUNT;
658cdf0e10cSrcweir     pIndexAccessTab = NULL;
659cdf0e10cSrcweir     pNameAccessTab = NULL;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir 
662cdf0e10cSrcweir /*
663cdf0e10cSrcweir BOOL ImplIntroTest::queryInterface( Uik aUik, XInterfaceRef & rOut )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir     if( aUik == XIntroTest::getSmartUik() )
666cdf0e10cSrcweir         rOut = (XIntroTest*)this;
667cdf0e10cSrcweir     else if( aUik == XPropertySet::getSmartUik() )
668cdf0e10cSrcweir         rOut = (XPropertySet*)this;
669cdf0e10cSrcweir     else if( aUik == XNameAccess::getSmartUik() )
670cdf0e10cSrcweir         rOut = (XNameAccess*)this;
671cdf0e10cSrcweir     else if( aUik == XIndexAccess::getSmartUik() )
672cdf0e10cSrcweir         rOut = (XIndexAccess*)this;
673cdf0e10cSrcweir     else if( aUik == ((XElementAccess*)NULL)->getSmartUik() )
674cdf0e10cSrcweir         rOut = (XElementAccess*)(XIndexAccess *)this;
675cdf0e10cSrcweir     else
676cdf0e10cSrcweir         UsrObject::queryInterface( aUik, rOut );
677cdf0e10cSrcweir     return rOut.is();
678cdf0e10cSrcweir }
679cdf0e10cSrcweir 
680cdf0e10cSrcweir XIdlClassRef ImplIntroTest::getIdlClass()
681cdf0e10cSrcweir {
682cdf0e10cSrcweir     static XIdlClassRef xClass = createStandardClass( L"ImplIntroTest",
683cdf0e10cSrcweir         UsrObject::getUsrObjectIdlClass(), 4,
684cdf0e10cSrcweir             XIntroTest_getReflection(),
685cdf0e10cSrcweir             XPropertySet_getReflection(),
686cdf0e10cSrcweir             XNameAccess_getReflection(),
687cdf0e10cSrcweir             XIndexAccess_getReflection() );
688cdf0e10cSrcweir     return xClass;
689cdf0e10cSrcweir }
690cdf0e10cSrcweir */
691cdf0e10cSrcweir 
getPropertySetInfo()692cdf0e10cSrcweir Reference< XPropertySetInfo > ImplIntroTest::getPropertySetInfo()
693cdf0e10cSrcweir     throw(RuntimeException)
694cdf0e10cSrcweir {
695cdf0e10cSrcweir     static ImplPropertySetInfo aInfo( mxMgr );
696cdf0e10cSrcweir     // Alle Objekt haben die gleichen Properties, deshalb kann
697cdf0e10cSrcweir     // die Info f�r alle gleich sein
698cdf0e10cSrcweir     return &aInfo;
699cdf0e10cSrcweir 
700cdf0e10cSrcweir     //if( m_xMyInfo == NULL )
701cdf0e10cSrcweir     //  ((ImplIntroTest*)this)->m_xMyInfo = new ImplPropertySetInfo( this );
702cdf0e10cSrcweir     //return m_xMyInfo;
703cdf0e10cSrcweir }
704cdf0e10cSrcweir 
setPropertyValue(const OUString & aPropertyName,const Any & aValue)705cdf0e10cSrcweir void ImplIntroTest::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
706cdf0e10cSrcweir     throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
707cdf0e10cSrcweir //void ImplIntroTest::setPropertyValue( const UString& aPropertyName, const Any& aValue )
708cdf0e10cSrcweir //  THROWS( (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, UsrSystemException) )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir     if( aPropChangeListener.is() && aPropertyName == aPropChangeListenerStr )
711cdf0e10cSrcweir     {
712cdf0e10cSrcweir         PropertyChangeEvent aEvt;
713cdf0e10cSrcweir         aEvt.Source = (OWeakObject*)this;
714cdf0e10cSrcweir         aEvt.PropertyName = aPropertyName;
715cdf0e10cSrcweir         aEvt.PropertyHandle = 0L;
716cdf0e10cSrcweir         //aEvt.OldValue;
717cdf0e10cSrcweir         //aEvt.NewValue;
718cdf0e10cSrcweir         //aEvt.PropagationId;
719cdf0e10cSrcweir         aPropChangeListener->propertyChange( aEvt );
720cdf0e10cSrcweir     }
721cdf0e10cSrcweir     if( aVetoPropChangeListener.is() && aPropertyName == aVetoPropChangeListenerStr )
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir         PropertyChangeEvent aEvt;
724cdf0e10cSrcweir         aEvt.Source = (OWeakObject*)this;
725cdf0e10cSrcweir         aEvt.PropertyName = aVetoPropChangeListenerStr;
726cdf0e10cSrcweir         aEvt.PropertyHandle = 0L;
727cdf0e10cSrcweir         //aEvt.OldValue;
728cdf0e10cSrcweir         //aEvt.NewValue;
729cdf0e10cSrcweir         //aEvt.PropagationId;
730cdf0e10cSrcweir         aVetoPropChangeListener->vetoableChange( aEvt );
731cdf0e10cSrcweir     }
732cdf0e10cSrcweir 
733cdf0e10cSrcweir     Sequence<Property> aPropSeq = m_xMyInfo->getProperties();
734cdf0e10cSrcweir     sal_Int32 nLen = aPropSeq.getLength();
735cdf0e10cSrcweir     for( sal_Int32 i = 0 ; i < nLen ; i++ )
736cdf0e10cSrcweir     {
737cdf0e10cSrcweir         Property aProp = aPropSeq.getArray()[ i ];
738cdf0e10cSrcweir         if( aProp.Name == aPropertyName )
739cdf0e10cSrcweir             aAnyArray[i] = aValue;
740cdf0e10cSrcweir     }
741cdf0e10cSrcweir }
742cdf0e10cSrcweir 
getPropertyValue(const OUString & PropertyName)743cdf0e10cSrcweir Any ImplIntroTest::getPropertyValue( const OUString& PropertyName )
744cdf0e10cSrcweir     throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
745cdf0e10cSrcweir //Any ImplIntroTest::getPropertyValue(const UString& aPropertyName) const
746cdf0e10cSrcweir     //THROWS( (UnknownPropertyException, WrappedTargetException, UsrSystemException) )
747cdf0e10cSrcweir {
748cdf0e10cSrcweir     Sequence<Property> aPropSeq = m_xMyInfo->getProperties();
749cdf0e10cSrcweir     sal_Int32 nLen = aPropSeq.getLength();
750cdf0e10cSrcweir     for( sal_Int32 i = 0 ; i < nLen ; i++ )
751cdf0e10cSrcweir     {
752cdf0e10cSrcweir         Property aProp = aPropSeq.getArray()[ i ];
753cdf0e10cSrcweir         if( aProp.Name == PropertyName )
754cdf0e10cSrcweir             return aAnyArray[i];
755cdf0e10cSrcweir     }
756cdf0e10cSrcweir     return Any();
757cdf0e10cSrcweir }
758cdf0e10cSrcweir 
getFirstName(void)759cdf0e10cSrcweir OUString ImplIntroTest::getFirstName(void)
760cdf0e10cSrcweir     throw(RuntimeException)
761cdf0e10cSrcweir {
762cdf0e10cSrcweir     return OUString( OUString::createFromAscii("Markus") );
763cdf0e10cSrcweir }
764cdf0e10cSrcweir 
writeln(const OUString & Text)765cdf0e10cSrcweir void ImplIntroTest::writeln( const OUString& Text )
766cdf0e10cSrcweir     throw(RuntimeException)
767cdf0e10cSrcweir {
768cdf0e10cSrcweir     OString aStr( Text.getStr(), Text.getLength(), RTL_TEXTENCODING_ASCII_US );
769cdf0e10cSrcweir 
770cdf0e10cSrcweir     // Haben wir ein Output?
771cdf0e10cSrcweir     //if( m_pOutput )
772cdf0e10cSrcweir     //{
773cdf0e10cSrcweir         //m_pOutput->doWriteln( TextStr );
774cdf0e10cSrcweir     //}
775cdf0e10cSrcweir     // Sonst einfach rausbraten
776cdf0e10cSrcweir     //else
777cdf0e10cSrcweir     {
778cdf0e10cSrcweir         printf( "%s", aStr.getStr() );
779cdf0e10cSrcweir     }
780cdf0e10cSrcweir }
781cdf0e10cSrcweir 
getIntroTest()782cdf0e10cSrcweir Reference< XIntroTest > ImplIntroTest::getIntroTest()
783cdf0e10cSrcweir     throw(RuntimeException)
784cdf0e10cSrcweir //XIntroTestRef ImplIntroTest::getIntroTest(void) THROWS( (UsrSystemException) )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir     if( !m_xIntroTest.is() )
787cdf0e10cSrcweir         m_xIntroTest = new ImplIntroTest( mxMgr );
788cdf0e10cSrcweir     return m_xIntroTest;
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
791cdf0e10cSrcweir // Methoden von XElementAccess
getElementType()792cdf0e10cSrcweir Type ImplIntroTest::getElementType(  )
793cdf0e10cSrcweir     throw(RuntimeException)
794cdf0e10cSrcweir //XIdlClassRef ImplIntroTest::getElementType(void) const THROWS( (UsrSystemException) )
795cdf0e10cSrcweir {
796cdf0e10cSrcweir     // TODO
797cdf0e10cSrcweir     Type aRetType;
798cdf0e10cSrcweir     return aRetType;
799cdf0e10cSrcweir     //return Reference< XIdlClass >();
800cdf0e10cSrcweir     //return Void_getReflection()->getIdlClass();
801cdf0e10cSrcweir }
802cdf0e10cSrcweir 
hasElements()803cdf0e10cSrcweir sal_Bool ImplIntroTest::hasElements(  )
804cdf0e10cSrcweir     throw(RuntimeException)
805cdf0e10cSrcweir //BOOL ImplIntroTest::hasElements(void) const THROWS( (UsrSystemException) )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir     return sal_True;
808cdf0e10cSrcweir }
809cdf0e10cSrcweir 
810cdf0e10cSrcweir // XNameAccess-Methoden
getIndexForName(const OUString & ItemName)811cdf0e10cSrcweir sal_Int32 getIndexForName( const OUString& ItemName )
812cdf0e10cSrcweir {
813cdf0e10cSrcweir     OUString aLeftStr = ItemName.copy( 0, 4 );
814cdf0e10cSrcweir     if( aLeftStr == OUString::createFromAscii("Item") )
815cdf0e10cSrcweir     {
816cdf0e10cSrcweir         // TODO
817cdf0e10cSrcweir         OUString aNumStr = ItemName.copy( 4 );
818cdf0e10cSrcweir         //sal_Int32 iIndex = (INT32)UStringToString( aNumStr, CHARSET_SYSTEM );
819cdf0e10cSrcweir         //if( iIndex < DEFAULT_NAME_ACCESS_COUNT )
820cdf0e10cSrcweir             //return iIndex;
821cdf0e10cSrcweir     }
822cdf0e10cSrcweir     return -1;
823cdf0e10cSrcweir }
824cdf0e10cSrcweir 
825cdf0e10cSrcweir 
getByName(const OUString & aName)826cdf0e10cSrcweir Any ImplIntroTest::getByName( const OUString& aName )
827cdf0e10cSrcweir     throw(NoSuchElementException, WrappedTargetException, RuntimeException)
828cdf0e10cSrcweir //Any ImplIntroTest::getByName(const UString& Name) const
829cdf0e10cSrcweir     //THROWS( (NoSuchElementException, WrappedTargetException, UsrSystemException) )
830cdf0e10cSrcweir {
831cdf0e10cSrcweir     Any aRetAny;
832cdf0e10cSrcweir 
833cdf0e10cSrcweir     if( !pNameAccessTab  )
834cdf0e10cSrcweir         ((ImplIntroTest*)this)->pNameAccessTab  = new Reference< XIntroTest >[ DEFAULT_NAME_ACCESS_COUNT ];
835cdf0e10cSrcweir 
836cdf0e10cSrcweir     sal_Int32 iIndex = getIndexForName( aName );
837cdf0e10cSrcweir     if( iIndex != -1 )
838cdf0e10cSrcweir     {
839cdf0e10cSrcweir         if( !pNameAccessTab[iIndex].is() )
840cdf0e10cSrcweir         {
841cdf0e10cSrcweir             ImplIntroTest* p = new ImplIntroTest( mxMgr );
842cdf0e10cSrcweir             OUString aName2( OUString::createFromAscii("IntroTest by Name-Access, Index = ") );
843cdf0e10cSrcweir             aName2 += OUString::valueOf( iIndex );
844cdf0e10cSrcweir             //aName2 = aName2 + StringToUString( String( iIndex ), CHARSET_SYSTEM );
845cdf0e10cSrcweir             p->setObjectName( aName2 );
846cdf0e10cSrcweir             pNameAccessTab[iIndex] = p;
847cdf0e10cSrcweir         }
848cdf0e10cSrcweir 
849cdf0e10cSrcweir         Reference< XIntroTest > xRet = pNameAccessTab[iIndex];
850cdf0e10cSrcweir         aRetAny = makeAny( xRet );
851cdf0e10cSrcweir 
852cdf0e10cSrcweir         //aRetAny.set( &xRet, XIntroTest_getReflection() );
853cdf0e10cSrcweir         //return (UsrObject*)(XIntroTest*)pNameAccessTab[iIndex];
854cdf0e10cSrcweir     }
855cdf0e10cSrcweir     return aRetAny;
856cdf0e10cSrcweir }
857cdf0e10cSrcweir 
getElementNames()858cdf0e10cSrcweir Sequence< OUString > ImplIntroTest::getElementNames(  )
859cdf0e10cSrcweir     throw(RuntimeException)
860cdf0e10cSrcweir //Sequence<UString> ImplIntroTest::getElementNames(void) const THROWS( (UsrSystemException) )
861cdf0e10cSrcweir {
862cdf0e10cSrcweir     Sequence<OUString> aStrSeq( DEFAULT_NAME_ACCESS_COUNT );
863cdf0e10cSrcweir     OUString* pStr = aStrSeq.getArray();
864cdf0e10cSrcweir     for( sal_Int32 i = 0 ; i < DEFAULT_NAME_ACCESS_COUNT ; i++ )
865cdf0e10cSrcweir     {
866cdf0e10cSrcweir         OUString aName( OUString::createFromAscii("Item") );
867cdf0e10cSrcweir         aName += OUString::valueOf( i );
868cdf0e10cSrcweir         //aName = aName + StringToUString( i, CHARSET_SYSTEM );
869cdf0e10cSrcweir         pStr[i] = aName;
870cdf0e10cSrcweir     }
871cdf0e10cSrcweir     return aStrSeq;
872cdf0e10cSrcweir }
873cdf0e10cSrcweir 
hasByName(const OUString & aName)874cdf0e10cSrcweir sal_Bool ImplIntroTest::hasByName( const OUString& aName )
875cdf0e10cSrcweir     throw(RuntimeException)
876cdf0e10cSrcweir //BOOL ImplIntroTest::hasByName(const UString& Name) const THROWS( (UsrSystemException) )
877cdf0e10cSrcweir {
878cdf0e10cSrcweir     return ( getIndexForName( aName ) != -1 );
879cdf0e10cSrcweir }
880cdf0e10cSrcweir 
881cdf0e10cSrcweir // XIndexAccess-Methoden
getCount()882cdf0e10cSrcweir sal_Int32 ImplIntroTest::getCount(  )
883cdf0e10cSrcweir     throw(RuntimeException)
884cdf0e10cSrcweir //sal_Int32 ImplIntroTest::getCount(void) const THROWS( (UsrSystemException) )
885cdf0e10cSrcweir {
886cdf0e10cSrcweir     return iIndexAccessCount;
887cdf0e10cSrcweir }
888cdf0e10cSrcweir 
getByIndex(sal_Int32 Index)889cdf0e10cSrcweir Any ImplIntroTest::getByIndex( sal_Int32 Index )
890cdf0e10cSrcweir     throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
891cdf0e10cSrcweir //Any ImplIntroTest::getByIndex( sal_Int32 Index ) const
892cdf0e10cSrcweir     //THROWS( (IndexOutOfBoundsException, WrappedTargetException, UsrSystemException) )
893cdf0e10cSrcweir {
894cdf0e10cSrcweir     Any aRetAny;
895cdf0e10cSrcweir 
896cdf0e10cSrcweir     if( !pIndexAccessTab )
897cdf0e10cSrcweir         ((ImplIntroTest*)this)->pIndexAccessTab = new Reference< XIntroTest >[ iIndexAccessCount ];
898cdf0e10cSrcweir 
899cdf0e10cSrcweir     if( Index < iIndexAccessCount )
900cdf0e10cSrcweir     {
901cdf0e10cSrcweir         if( !pNameAccessTab[Index].is() )
902cdf0e10cSrcweir         {
903cdf0e10cSrcweir             ImplIntroTest* p = new ImplIntroTest( mxMgr );
904cdf0e10cSrcweir             OUString aName( OUString::createFromAscii("IntroTest by Index-Access, Index = ") );
905cdf0e10cSrcweir             aName += OUString::valueOf( Index );
906cdf0e10cSrcweir             //aName = aName + StringToUString( String( iIndex ), CHARSET_SYSTEM );
907cdf0e10cSrcweir             p->setObjectName( aName );
908cdf0e10cSrcweir             pIndexAccessTab[Index] = p;
909cdf0e10cSrcweir         }
910cdf0e10cSrcweir         Reference< XIntroTest > xRet = pIndexAccessTab[Index];
911cdf0e10cSrcweir         aRetAny = makeAny( xRet );
912cdf0e10cSrcweir     }
913cdf0e10cSrcweir     return aRetAny;
914cdf0e10cSrcweir }
915cdf0e10cSrcweir 
addPropertiesChangeListener(const Sequence<OUString> &,const Reference<XPropertiesChangeListener> &)916cdf0e10cSrcweir void ImplIntroTest::addPropertiesChangeListener( const Sequence< OUString >& /*PropertyNames*/,
917cdf0e10cSrcweir                                                  const Reference< XPropertiesChangeListener >& /*Listener*/ )
918cdf0e10cSrcweir         throw(RuntimeException)
919cdf0e10cSrcweir //void ImplIntroTest::addPropertiesChangeListener
920cdf0e10cSrcweir //(const Sequence< UString >& PropertyNames, const XPropertiesChangeListenerRef& Listener)
921cdf0e10cSrcweir     //THROWS( (UsrSystemException) )
922cdf0e10cSrcweir {
923cdf0e10cSrcweir }
924cdf0e10cSrcweir 
removePropertiesChangeListener(const Reference<XPropertiesChangeListener> &)925cdf0e10cSrcweir void ImplIntroTest::removePropertiesChangeListener
926cdf0e10cSrcweir ( const Reference< XPropertiesChangeListener >& /*Listener*/ )
927cdf0e10cSrcweir         throw(RuntimeException)
928cdf0e10cSrcweir //void ImplIntroTest::removePropertiesChangeListener(const XPropertiesChangeListenerRef& Listener)
929cdf0e10cSrcweir     //THROWS( (UsrSystemException) )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir }
932cdf0e10cSrcweir 
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 
935cdf0e10cSrcweir struct DefItem
936cdf0e10cSrcweir {
937cdf0e10cSrcweir     char const * pName;
938cdf0e10cSrcweir     sal_Int32 nConcept;
939cdf0e10cSrcweir };
940cdf0e10cSrcweir 
941cdf0e10cSrcweir // Spezial-Wert fuer Method-Concept, um "normale" Funktionen kennzeichnen zu koennen
942cdf0e10cSrcweir #define  MethodConcept_NORMAL_IMPL      0x80000000
943cdf0e10cSrcweir 
944cdf0e10cSrcweir 
945cdf0e10cSrcweir // Test-Objekt liefern
getIntrospectionTestObject(const Reference<XMultiServiceFactory> & xMgr)946cdf0e10cSrcweir Any getIntrospectionTestObject( const Reference< XMultiServiceFactory > & xMgr )
947cdf0e10cSrcweir {
948cdf0e10cSrcweir     Any aObjAny;
949cdf0e10cSrcweir     Reference< XIntroTest > xTestObj = new ImplIntroTest( xMgr );
950cdf0e10cSrcweir     aObjAny.setValue( &xTestObj, ::getCppuType( (const Reference< XIntroTest > *)0 ) );
951cdf0e10cSrcweir     return aObjAny;
952cdf0e10cSrcweir }
953cdf0e10cSrcweir 
test_introsp(Reference<XMultiServiceFactory> xMgr,Reference<XIdlReflection>,Reference<XIntrospection> xIntrospection)954cdf0e10cSrcweir static sal_Bool test_introsp( Reference< XMultiServiceFactory > xMgr,
955cdf0e10cSrcweir                               Reference< XIdlReflection > /*xRefl*/, Reference< XIntrospection > xIntrospection )
956cdf0e10cSrcweir {
957cdf0e10cSrcweir     DefItem pPropertyDefs[] =
958cdf0e10cSrcweir     {
959cdf0e10cSrcweir         { "Factor", PropertyConcept::PROPERTYSET },
960cdf0e10cSrcweir         { "MyCount", PropertyConcept::PROPERTYSET },
961cdf0e10cSrcweir         { "Info", PropertyConcept::PROPERTYSET },
962cdf0e10cSrcweir         { "ObjectName", PropertyConcept::ATTRIBUTES },
963cdf0e10cSrcweir         { "FirstName", PropertyConcept::ATTRIBUTES },
964cdf0e10cSrcweir         { "LastName", PropertyConcept::ATTRIBUTES },
965cdf0e10cSrcweir         { "Age", PropertyConcept::ATTRIBUTES },
966cdf0e10cSrcweir         { "ChildrenCount", PropertyConcept::ATTRIBUTES },
967cdf0e10cSrcweir         { "FirstStruct", PropertyConcept::ATTRIBUTES },
968cdf0e10cSrcweir         { "SecondStruct", PropertyConcept::ATTRIBUTES },
969cdf0e10cSrcweir         { "Droenk", PropertyConcept::METHODS },
970cdf0e10cSrcweir         { "IntroTest", PropertyConcept::METHODS },
971cdf0e10cSrcweir         { "Bla", PropertyConcept::METHODS },
972cdf0e10cSrcweir         { "Blub", PropertyConcept::METHODS },
973cdf0e10cSrcweir         { "Gulp", PropertyConcept::METHODS },
974cdf0e10cSrcweir         { "Strings", PropertyConcept::METHODS },
975cdf0e10cSrcweir         { "MultiSequence", PropertyConcept::METHODS },
976cdf0e10cSrcweir         { "PropertySetInfo", PropertyConcept::METHODS },
977cdf0e10cSrcweir         { "ElementType", PropertyConcept::METHODS },
978cdf0e10cSrcweir         { "ElementNames", PropertyConcept::METHODS },
979cdf0e10cSrcweir         { "Count", PropertyConcept::METHODS },
980cdf0e10cSrcweir         { "Types", PropertyConcept::METHODS },
981cdf0e10cSrcweir         { "ImplementationId", PropertyConcept::METHODS },
982cdf0e10cSrcweir         { NULL, 0 }
983cdf0e10cSrcweir     };
984cdf0e10cSrcweir 
985cdf0e10cSrcweir     // Tabelle der Property-Namen, die gefunden werden muessen
986cdf0e10cSrcweir //  char* pDemandedPropNames[] =
987cdf0e10cSrcweir //  {
988cdf0e10cSrcweir //      "Factor",
989cdf0e10cSrcweir //      "MyCount",
990cdf0e10cSrcweir //      "Info",
991cdf0e10cSrcweir //      "ObjectName",
992cdf0e10cSrcweir //      "FirstName",
993cdf0e10cSrcweir //      "LastName",
994cdf0e10cSrcweir //      "Age",
995cdf0e10cSrcweir //      "ChildrenCount",
996cdf0e10cSrcweir //      "FirstStruct",
997cdf0e10cSrcweir //      "SecondStruct",
998cdf0e10cSrcweir //      "Droenk",
999cdf0e10cSrcweir //      "IntroTest",
1000cdf0e10cSrcweir //      "Bla",
1001cdf0e10cSrcweir //      "Blub",
1002cdf0e10cSrcweir //      "Gulp",
1003cdf0e10cSrcweir //      "Strings",
1004cdf0e10cSrcweir //      "MultiSequence",
1005cdf0e10cSrcweir //      "PropertySetInfo",
1006cdf0e10cSrcweir //      "ElementType",
1007cdf0e10cSrcweir //      "ElementNames",
1008cdf0e10cSrcweir //      "Count",
1009cdf0e10cSrcweir //      "Types"
1010cdf0e10cSrcweir //      "ImplementationId"
1011cdf0e10cSrcweir //  };
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir     char const * pDemandedPropVals[] =
1014cdf0e10cSrcweir     {
1015cdf0e10cSrcweir         "3.140000",
1016cdf0e10cSrcweir         "42",
1017cdf0e10cSrcweir         "Hallo",
1018cdf0e10cSrcweir         "IntroTest-Obj Nr. 0",
1019cdf0e10cSrcweir         "Markus",
1020cdf0e10cSrcweir         "Meyer",
1021cdf0e10cSrcweir         "33",
1022cdf0e10cSrcweir         "2",
1023cdf0e10cSrcweir         "TYPE STRUCT",
1024cdf0e10cSrcweir         "TYPE STRUCT",
1025cdf0e10cSrcweir         "314",
1026cdf0e10cSrcweir         "TYPE INTERFACE",
1027cdf0e10cSrcweir         "42",
1028cdf0e10cSrcweir         "111",
1029cdf0e10cSrcweir         "99",
1030cdf0e10cSrcweir         "TYPE SEQUENCE",
1031cdf0e10cSrcweir         "TYPE SEQUENCE",
1032cdf0e10cSrcweir         "TYPE INTERFACE",
1033cdf0e10cSrcweir         "TYPE TYPE",
1034cdf0e10cSrcweir         "TYPE SEQUENCE",
1035cdf0e10cSrcweir         "10",
1036cdf0e10cSrcweir         "TYPE SEQUENCE",
1037cdf0e10cSrcweir         "TYPE SEQUENCE",
1038cdf0e10cSrcweir     };
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir     char const * pDemandedModifiedPropVals[] =
1041cdf0e10cSrcweir     {
1042cdf0e10cSrcweir         "4.140000",
1043cdf0e10cSrcweir         "43",
1044cdf0e10cSrcweir         "Hallo (Modified!)",
1045cdf0e10cSrcweir         "IntroTest-Obj Nr. 0 (Modified!)",
1046cdf0e10cSrcweir         "Markus",
1047cdf0e10cSrcweir         "Meyer",
1048cdf0e10cSrcweir         "33",
1049cdf0e10cSrcweir         "3",
1050cdf0e10cSrcweir         "Wert wurde nicht modifiziert",
1051cdf0e10cSrcweir         "Wert wurde nicht modifiziert",
1052cdf0e10cSrcweir         "315",
1053cdf0e10cSrcweir         "Wert wurde nicht modifiziert",
1054cdf0e10cSrcweir         "42",
1055cdf0e10cSrcweir         "112",
1056cdf0e10cSrcweir         "99",
1057cdf0e10cSrcweir         "Wert wurde nicht modifiziert",
1058cdf0e10cSrcweir         "Wert wurde nicht modifiziert",
1059cdf0e10cSrcweir         "Wert wurde nicht modifiziert",
1060cdf0e10cSrcweir         "Wert wurde nicht modifiziert",
1061cdf0e10cSrcweir         "Wert wurde nicht modifiziert",
1062cdf0e10cSrcweir         "10",
1063cdf0e10cSrcweir         "Wert wurde nicht modifiziert"
1064cdf0e10cSrcweir         "Wert wurde nicht modifiziert"
1065cdf0e10cSrcweir     };
1066cdf0e10cSrcweir 
1067cdf0e10cSrcweir     char const * pDemandedPropTypes[] =
1068cdf0e10cSrcweir     {
1069cdf0e10cSrcweir         "double",
1070cdf0e10cSrcweir         "long",
1071cdf0e10cSrcweir         "string",
1072cdf0e10cSrcweir         "string",
1073cdf0e10cSrcweir         "string",
1074cdf0e10cSrcweir         "string",
1075cdf0e10cSrcweir         "short",
1076cdf0e10cSrcweir         "short",
1077cdf0e10cSrcweir         "com.sun.star.beans.Property",
1078cdf0e10cSrcweir         "com.sun.star.beans.PropertyValue",
1079cdf0e10cSrcweir         "long",
1080cdf0e10cSrcweir         "ModuleA.XIntroTest",
1081cdf0e10cSrcweir         "short",
1082cdf0e10cSrcweir         "short",
1083cdf0e10cSrcweir         "short",
1084cdf0e10cSrcweir         "[]string",
1085cdf0e10cSrcweir         "[][][]short",
1086cdf0e10cSrcweir         "com.sun.star.beans.XPropertySetInfo",
1087cdf0e10cSrcweir         "type",
1088cdf0e10cSrcweir         "[]string",
1089cdf0e10cSrcweir         "long",
1090cdf0e10cSrcweir         "[]type",
1091cdf0e10cSrcweir         "[]byte",
1092cdf0e10cSrcweir     };
1093cdf0e10cSrcweir     //is() nDemandedPropCount = 22;
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir     DefItem pMethodDefs[] =
1097cdf0e10cSrcweir     {
1098cdf0e10cSrcweir         { "queryInterface", MethodConcept_NORMAL_IMPL },
1099cdf0e10cSrcweir         { "acquire", MethodConcept::DANGEROUS },
1100cdf0e10cSrcweir         { "release", MethodConcept::DANGEROUS },
1101cdf0e10cSrcweir         { "writeln", MethodConcept_NORMAL_IMPL },
1102cdf0e10cSrcweir         { "getDroenk", MethodConcept::PROPERTY },
1103cdf0e10cSrcweir         { "getIntroTest", MethodConcept::PROPERTY },
1104cdf0e10cSrcweir         { "getUps", MethodConcept_NORMAL_IMPL },
1105cdf0e10cSrcweir         { "setDroenk", MethodConcept::PROPERTY },
1106cdf0e10cSrcweir         { "getBla", MethodConcept::PROPERTY },
1107cdf0e10cSrcweir         { "setBla", MethodConcept_NORMAL_IMPL },
1108cdf0e10cSrcweir         { "getBlub", MethodConcept::PROPERTY },
1109cdf0e10cSrcweir         { "setBlub", MethodConcept::PROPERTY },
1110cdf0e10cSrcweir         { "getGulp", MethodConcept::PROPERTY },
1111cdf0e10cSrcweir         { "setGulp", MethodConcept_NORMAL_IMPL },
1112cdf0e10cSrcweir         { "getTypeClass", MethodConcept_NORMAL_IMPL },
1113cdf0e10cSrcweir         { "setTypeClass", MethodConcept_NORMAL_IMPL },
1114cdf0e10cSrcweir         { "getStrings", MethodConcept::PROPERTY },
1115cdf0e10cSrcweir         { "setStrings", MethodConcept::PROPERTY },
1116cdf0e10cSrcweir         { "setStringsPerMethod", MethodConcept_NORMAL_IMPL },
1117cdf0e10cSrcweir         { "getMultiSequence", MethodConcept::PROPERTY },
1118cdf0e10cSrcweir         { "setMultiSequence", MethodConcept::PROPERTY },
1119cdf0e10cSrcweir         { "addPropertiesChangeListener", MethodConcept::LISTENER },
1120cdf0e10cSrcweir         { "removePropertiesChangeListener", MethodConcept::LISTENER },
1121cdf0e10cSrcweir         { "getPropertySetInfo", MethodConcept::PROPERTY },
1122cdf0e10cSrcweir         { "setPropertyValue", MethodConcept_NORMAL_IMPL },
1123cdf0e10cSrcweir         { "getPropertyValue", MethodConcept_NORMAL_IMPL },
1124cdf0e10cSrcweir         { "addPropertyChangeListener", MethodConcept::LISTENER },
1125cdf0e10cSrcweir         { "removePropertyChangeListener", MethodConcept::LISTENER },
1126cdf0e10cSrcweir         { "addVetoableChangeListener", MethodConcept::LISTENER },
1127cdf0e10cSrcweir         { "removeVetoableChangeListener", MethodConcept::LISTENER },
1128cdf0e10cSrcweir         { "getElementType", MethodConcept::PROPERTY | MethodConcept::NAMECONTAINER| MethodConcept::INDEXCONTAINER | MethodConcept::ENUMERATION  },
1129cdf0e10cSrcweir         { "hasElements", MethodConcept::NAMECONTAINER | MethodConcept::INDEXCONTAINER | MethodConcept::ENUMERATION },
1130cdf0e10cSrcweir         { "getByName", MethodConcept::NAMECONTAINER },
1131cdf0e10cSrcweir         { "getElementNames", MethodConcept::PROPERTY | MethodConcept::NAMECONTAINER },
1132cdf0e10cSrcweir         { "hasByName", MethodConcept::NAMECONTAINER },
1133cdf0e10cSrcweir         { "getCount", MethodConcept::PROPERTY | MethodConcept::INDEXCONTAINER },
1134cdf0e10cSrcweir         { "getByIndex", MethodConcept::INDEXCONTAINER },
1135cdf0e10cSrcweir         { "getTypes", MethodConcept::PROPERTY },
1136cdf0e10cSrcweir         { "getImplementationId", MethodConcept::PROPERTY },
1137cdf0e10cSrcweir         { "queryAdapter", MethodConcept_NORMAL_IMPL },
1138cdf0e10cSrcweir         { NULL, 0 }
1139cdf0e10cSrcweir     };
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir     OString aErrorStr;
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir     //******************************************************
1144cdf0e10cSrcweir 
1145cdf0e10cSrcweir     // Test-Objekt anlegen
1146cdf0e10cSrcweir     Any aObjAny = getIntrospectionTestObject( xMgr );
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir     // Introspection-Service holen
1149cdf0e10cSrcweir     //Reference< XMultiServiceFactory > xServiceManager(getProcessServiceManager(), USR_QUERY);
1150cdf0e10cSrcweir     //Reference< XIntrospection > xIntrospection( xMgr->createInstance(L"com.sun.star.beans.Introspection"), UNO_QUERY );
1151cdf0e10cSrcweir     //TEST_ENSHURE( xIntrospection.is(), "Creation of introspection instance failed" );
1152cdf0e10cSrcweir     //if( !xIntrospection.is() )
1153cdf0e10cSrcweir         //return sal_False;
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir     // und unspecten
1156cdf0e10cSrcweir     Reference< XIntrospectionAccess > xAccess = xIntrospection->inspect( aObjAny );
1157cdf0e10cSrcweir     xAccess = xIntrospection->inspect( aObjAny );
1158cdf0e10cSrcweir     xAccess = xIntrospection->inspect( aObjAny );
1159cdf0e10cSrcweir     TEST_ENSHURE( xAccess.is(), "introspection failed, no XIntrospectionAccess returned" );
1160cdf0e10cSrcweir     if( !xAccess.is() )
1161cdf0e10cSrcweir         return sal_False;
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir     // Ergebnis der Introspection pruefen
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir     // XPropertySet-UIK ermitteln
1166cdf0e10cSrcweir     Type aType = getCppuType( (Reference< XPropertySet >*) NULL );
1167cdf0e10cSrcweir     //typelib_InterfaceTypeDescription* pTypeDesc = NULL;
1168cdf0e10cSrcweir     //aType.getDescription( (typelib_TypeDescription**)&pTypeDesc );
1169cdf0e10cSrcweir     //Uik aPropertySetUik = *(Uik*)&pTypeDesc->aUik;
1170cdf0e10cSrcweir     //typelib_typedescription_release( (typelib_TypeDescription*)pTypeDesc );
1171cdf0e10cSrcweir 
1172cdf0e10cSrcweir     Reference< XInterface > xPropSetIface = xAccess->queryAdapter( aType );
1173cdf0e10cSrcweir     //Reference< XInterface > xPropSetIface = xAccess->queryAdapter( aPropertySetUik );
1174cdf0e10cSrcweir     Reference< XPropertySet > xPropSet( xPropSetIface, UNO_QUERY );
1175cdf0e10cSrcweir     //XPropertySetRef xPropSet = (XPropertySet*)xPropSetIface->
1176cdf0e10cSrcweir     //  queryInterface( XPropertySet::getSmartUik() );
1177cdf0e10cSrcweir     TEST_ENSHURE( xPropSet.is(), "Could not get XPropertySet by queryAdapter()" );
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir     // XExactName
1180cdf0e10cSrcweir     Reference< XExactName > xExactName( xAccess, UNO_QUERY );
1181cdf0e10cSrcweir     TEST_ENSHURE( xExactName.is(), "Introspection unterstuetzt kein ExactName" );
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir     // Schleife ueber alle Kombinationen von Concepts
1184cdf0e10cSrcweir     for( sal_Int32 nConcepts = 0 ; nConcepts < 16 ; nConcepts++ )
1185cdf0e10cSrcweir     {
1186cdf0e10cSrcweir //printf( "*******************************************************\n" );
1187cdf0e10cSrcweir //printf( "nConcepts = %ld\n", nConcepts );
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir         // Wieviele Properties sollten es sein
1190cdf0e10cSrcweir         sal_Int32 nDemandedPropCount = 0;
1191cdf0e10cSrcweir         sal_Int32 iList = 0;
1192cdf0e10cSrcweir         while( pPropertyDefs[ iList ].pName )
1193cdf0e10cSrcweir         {
1194cdf0e10cSrcweir             if( pPropertyDefs[ iList ].nConcept & nConcepts )
1195cdf0e10cSrcweir                 nDemandedPropCount++;
1196cdf0e10cSrcweir             iList++;
1197cdf0e10cSrcweir         }
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir         if( xPropSet.is() )
1200cdf0e10cSrcweir         {
1201cdf0e10cSrcweir             Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1202cdf0e10cSrcweir             //Sequence<Property> aRetSeq = xPropSetInfo->getProperties();
1203cdf0e10cSrcweir             Sequence<Property> aRetSeq = xAccess->getProperties( nConcepts );
1204cdf0e10cSrcweir 
1205cdf0e10cSrcweir             sal_Int32 nLen = aRetSeq.getLength();
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir             aErrorStr  = "Expected to find ";
1208cdf0e10cSrcweir             aErrorStr += OString::valueOf( nDemandedPropCount );
1209cdf0e10cSrcweir             aErrorStr += " properties but found ";
1210cdf0e10cSrcweir             aErrorStr += OString::valueOf( nLen );
1211cdf0e10cSrcweir             TEST_ENSHURE( nLen == nDemandedPropCount, aErrorStr.getStr() );
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir             // cout << "**********************************\n";
1214cdf0e10cSrcweir             // cout << "*** Ergebnis der Introspection ***\n";
1215cdf0e10cSrcweir             // cout << "**********************************\n";
1216cdf0e10cSrcweir             // cout << "\nIntrospection hat " << nLen << " Properties gefunden:\n";
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir             const Property* pProps = aRetSeq.getConstArray();
1219cdf0e10cSrcweir             Any aPropVal;
1220cdf0e10cSrcweir             sal_Int32 i;
1221cdf0e10cSrcweir             iList = 0;
1222cdf0e10cSrcweir             for( i = 0 ; i < nLen ; i++ )
1223cdf0e10cSrcweir             {
1224cdf0e10cSrcweir                 const Property aProp = pProps[ i ];
1225cdf0e10cSrcweir 
1226cdf0e10cSrcweir                 // Naechste Passende Methode in der Liste suchen
1227cdf0e10cSrcweir                 while( pPropertyDefs[ iList ].pName )
1228cdf0e10cSrcweir                 {
1229cdf0e10cSrcweir                     if( pPropertyDefs[ iList ].nConcept & nConcepts )
1230cdf0e10cSrcweir                         break;
1231cdf0e10cSrcweir                     iList++;
1232cdf0e10cSrcweir                 }
1233cdf0e10cSrcweir                 sal_Int32 iDemanded = iList;
1234cdf0e10cSrcweir                 iList++;
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir                 OUString aPropName = aProp.Name;
1237cdf0e10cSrcweir                 OString aNameStr( aPropName.getStr(), aPropName.getLength(), RTL_TEXTENCODING_ASCII_US );
1238cdf0e10cSrcweir                     //UStringToString(aPropName, CHARSET_SYSTEM);
1239cdf0e10cSrcweir 
1240cdf0e10cSrcweir //printf( "Property = %s\n", aNameStr.getStr() );
1241cdf0e10cSrcweir 
1242cdf0e10cSrcweir                 OString aDemandedName = pPropertyDefs[ iDemanded ].pName;
1243cdf0e10cSrcweir                 //OString aDemandedName = pDemandedPropNames[ i ];
1244cdf0e10cSrcweir                 aErrorStr  = "Expected property \"";
1245cdf0e10cSrcweir                 aErrorStr += aDemandedName;
1246cdf0e10cSrcweir                 aErrorStr += "\", found \"";
1247cdf0e10cSrcweir                 aErrorStr += aNameStr;
1248cdf0e10cSrcweir                 aErrorStr += "\"";
1249cdf0e10cSrcweir                 TEST_ENSHURE( aNameStr == aDemandedName, aErrorStr.getStr() );
1250cdf0e10cSrcweir                 // cout << "Property " << (i+1) << ": \"" << (const char*)UStringToString(aPropName, CHARSET_SYSTEM) << "\"";
1251cdf0e10cSrcweir 
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir                 Type aPropType = aProp.Type;
1254cdf0e10cSrcweir                 OString aTypeNameStr( OUStringToOString(aPropType.getTypeName(), RTL_TEXTENCODING_ASCII_US) );
1255cdf0e10cSrcweir                 //Reference< XIdlClass > xPropType = aProp.Type;
1256cdf0e10cSrcweir                 //OString aTypeNameStr( xPropType->getName(), xPropType->getName().getLength(), RTL_TEXTENCODING_ASCII_US );
1257cdf0e10cSrcweir                 OString aDemandedTypeNameStr = pDemandedPropTypes[ iDemanded ];
1258cdf0e10cSrcweir                 //OString aDemandedTypeNameStr = pDemandedPropTypes[ i ];
1259cdf0e10cSrcweir                 aErrorStr  = "Property \"";
1260cdf0e10cSrcweir                 aErrorStr += aDemandedName;
1261cdf0e10cSrcweir                 aErrorStr += "\", expected type >";
1262cdf0e10cSrcweir                 aErrorStr += aDemandedTypeNameStr;
1263cdf0e10cSrcweir                 aErrorStr += "< found type >";
1264cdf0e10cSrcweir                 aErrorStr += aTypeNameStr;
1265cdf0e10cSrcweir                 aErrorStr += "<";
1266cdf0e10cSrcweir                 TEST_ENSHURE( aTypeNameStr == aDemandedTypeNameStr, aErrorStr.getStr() );
1267cdf0e10cSrcweir                 // cout << " (Prop-Typ: " << (const char*)UStringToString(xPropType->getName(), CHARSET_SYSTEM) << ")";
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir                 // Wert des Property lesen und ausgeben
1270cdf0e10cSrcweir                 aPropVal = xPropSet->getPropertyValue( aPropName );
1271cdf0e10cSrcweir                 // cout << "\n\tWert = " << (const char*)UStringToString(AnyToString( aPropVal, sal_True ), CHARSET_SYSTEM);
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir                 OString aValStr = OUStringToOString( AnyToString( aPropVal, sal_False, xMgr ), RTL_TEXTENCODING_ASCII_US );
1274cdf0e10cSrcweir                 OString aDemandedValStr = pDemandedPropVals[ iDemanded ];
1275cdf0e10cSrcweir                 //OString aDemandedValStr = pDemandedPropVals[ i ];
1276cdf0e10cSrcweir                 aErrorStr  = "Property \"";
1277cdf0e10cSrcweir                 aErrorStr += aDemandedName;
1278cdf0e10cSrcweir                 aErrorStr += "\", expected val >";
1279cdf0e10cSrcweir                 aErrorStr += aDemandedValStr;
1280cdf0e10cSrcweir                 aErrorStr += "< found val >";
1281cdf0e10cSrcweir                 aErrorStr += aValStr;
1282cdf0e10cSrcweir                 aErrorStr += "<";
1283cdf0e10cSrcweir                 TEST_ENSHURE( aValStr == aDemandedValStr, aErrorStr.getStr() );
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir                 // Wert pruefen und typgerecht modifizieren
1286cdf0e10cSrcweir                 TypeClass eType = aPropVal.getValueType().getTypeClass();
1287cdf0e10cSrcweir                 //Reference< XIdlClass > xIdlClass = aPropVal.getReflection()->getIdlClass();
1288cdf0e10cSrcweir                 //TypeClass eType = xIdlClass->getTypeClass();
1289cdf0e10cSrcweir                 Any aNewVal;
1290cdf0e10cSrcweir                 sal_Bool bModify = sal_True;
1291cdf0e10cSrcweir                 switch( eType )
1292cdf0e10cSrcweir                 {
1293cdf0e10cSrcweir                     case TypeClass_STRING:
1294cdf0e10cSrcweir                     {
1295cdf0e10cSrcweir                         OUString aStr;
1296cdf0e10cSrcweir                         aPropVal >>= aStr;
1297cdf0e10cSrcweir                         //OString aStr = aPropVal.getString();
1298cdf0e10cSrcweir                         aStr = aStr + OUString::createFromAscii(" (Modified!)");
1299cdf0e10cSrcweir                         aNewVal <<= aStr;
1300cdf0e10cSrcweir                         break;
1301cdf0e10cSrcweir                     }
1302cdf0e10cSrcweir                     case TypeClass_DOUBLE:
1303cdf0e10cSrcweir                     {
1304cdf0e10cSrcweir                         double d(0.0);
1305cdf0e10cSrcweir                         aPropVal >>= d;
1306cdf0e10cSrcweir                         aNewVal <<= d + 1.0;
1307cdf0e10cSrcweir                         break;
1308cdf0e10cSrcweir                     }
1309cdf0e10cSrcweir                     case TypeClass_SHORT:
1310cdf0e10cSrcweir                     {
1311cdf0e10cSrcweir                         sal_Int16 n(0);
1312cdf0e10cSrcweir                         aPropVal >>= n;
1313cdf0e10cSrcweir                         aNewVal <<= sal_Int16( n + 1 );
1314cdf0e10cSrcweir                         break;
1315cdf0e10cSrcweir                     }
1316cdf0e10cSrcweir                     case TypeClass_LONG:
1317cdf0e10cSrcweir                     {
1318cdf0e10cSrcweir                         sal_Int32 n(0);
1319cdf0e10cSrcweir                         aPropVal >>= n;
1320cdf0e10cSrcweir                         aNewVal <<= sal_Int32( n + 1 );
1321cdf0e10cSrcweir                         break;
1322cdf0e10cSrcweir                     }
1323cdf0e10cSrcweir                     default:
1324cdf0e10cSrcweir                         bModify = sal_False;
1325cdf0e10cSrcweir                         break;
1326cdf0e10cSrcweir                 }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir                 // Modifizieren nur beim letzten Durchlauf
1329cdf0e10cSrcweir                 if( nConcepts == 15 )
1330cdf0e10cSrcweir                 {
1331cdf0e10cSrcweir                     // XExactName pruefen, dafuer alles gross machen
1332cdf0e10cSrcweir                     // (Introspection ist mit LowerCase implementiert, also anders machen)
1333cdf0e10cSrcweir                     OUString aUpperUStr = aPropName.toAsciiUpperCase();
1334cdf0e10cSrcweir                     OUString aExactName = xExactName->getExactName( aUpperUStr );
1335cdf0e10cSrcweir                     if( aExactName != aPropName )
1336cdf0e10cSrcweir                     {
1337cdf0e10cSrcweir                         aErrorStr  = "Property \"";
1338cdf0e10cSrcweir                         aErrorStr += OUStringToOString( aPropName, RTL_TEXTENCODING_ASCII_US );
1339cdf0e10cSrcweir                         aErrorStr += "\", not found as \"";
1340cdf0e10cSrcweir                         aErrorStr += OUStringToOString(aUpperUStr, RTL_TEXTENCODING_ASCII_US );
1341cdf0e10cSrcweir                         aErrorStr += "\" using XExactName";
1342cdf0e10cSrcweir                         TEST_ENSHURE( sal_False, aErrorStr.getStr() );
1343cdf0e10cSrcweir                     }
1344cdf0e10cSrcweir                 }
1345cdf0e10cSrcweir                 else
1346cdf0e10cSrcweir                 {
1347cdf0e10cSrcweir                     bModify = sal_False;
1348cdf0e10cSrcweir                 }
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir                 // Neuen Wert setzen, wieder lesen und ausgeben
1351cdf0e10cSrcweir                 if( bModify )
1352cdf0e10cSrcweir                 {
1353cdf0e10cSrcweir                     // cout.flush();
1354cdf0e10cSrcweir 
1355cdf0e10cSrcweir                     // 1.7.1999, UnknownPropertyException bei ReadOnly-Properties abfangen
1356cdf0e10cSrcweir                     try
1357cdf0e10cSrcweir                     {
1358cdf0e10cSrcweir                         xPropSet->setPropertyValue( aPropName, aNewVal );
1359cdf0e10cSrcweir                     }
1360cdf0e10cSrcweir                     catch(UnknownPropertyException e1)
1361cdf0e10cSrcweir                     {
1362cdf0e10cSrcweir                     }
1363cdf0e10cSrcweir 
1364cdf0e10cSrcweir                     aPropVal = xPropSet->getPropertyValue( aPropName );
1365cdf0e10cSrcweir                     // cout << "\n\tModifizierter Wert = " << (const char*) UStringToString(AnyToString( aPropVal, sal_True ), CHARSET_SYSTEM) << "\n";
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir                     OUString aStr = AnyToString( aPropVal, sal_False, xMgr );
1368cdf0e10cSrcweir                     OString aModifiedValStr = OUStringToOString( aStr, RTL_TEXTENCODING_ASCII_US );
1369cdf0e10cSrcweir                     OString aDemandedModifiedValStr = pDemandedModifiedPropVals[ i ];
1370cdf0e10cSrcweir                     aErrorStr  = "Property \"";
1371cdf0e10cSrcweir                     aErrorStr += aDemandedName;
1372cdf0e10cSrcweir                     aErrorStr += "\", expected modified val >";
1373cdf0e10cSrcweir                     aErrorStr += aDemandedModifiedValStr;
1374cdf0e10cSrcweir                     aErrorStr += "< found val >";
1375cdf0e10cSrcweir                     aErrorStr += aModifiedValStr;
1376cdf0e10cSrcweir                     aErrorStr += "<";
1377cdf0e10cSrcweir                     TEST_ENSHURE( aModifiedValStr == aDemandedModifiedValStr, aErrorStr.getStr() );
1378cdf0e10cSrcweir                 }
1379cdf0e10cSrcweir                 else
1380cdf0e10cSrcweir                 {
1381cdf0e10cSrcweir                     // cout << "\n\tWert wurde nicht modifiziert\n";
1382cdf0e10cSrcweir                 }
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir                 // Checken, ob alle Properties auch einzeln gefunden werden
1385cdf0e10cSrcweir                 aErrorStr  = "property \"";
1386cdf0e10cSrcweir                 aErrorStr += aDemandedName;
1387cdf0e10cSrcweir                 aErrorStr += "\" not found with hasProperty()";
1388cdf0e10cSrcweir                 OUString aWDemandedName = OStringToOUString(aDemandedName, RTL_TEXTENCODING_ASCII_US );
1389cdf0e10cSrcweir                 sal_Bool bProperty = xAccess->hasProperty( aWDemandedName, nConcepts );
1390cdf0e10cSrcweir                 //sal_Bool bProperty = xAccess->hasProperty( aWDemandedName, PropertyConcept::ALL - PropertyConcept::DANGEROUS );
1391cdf0e10cSrcweir                 TEST_ENSHURE( bProperty, aErrorStr.getStr() );
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir                 aErrorStr  = "property \"";
1394cdf0e10cSrcweir                 aErrorStr += aDemandedName;
1395cdf0e10cSrcweir                 aErrorStr += "\" not equal to same Property in sequence returned by getProperties()";
1396cdf0e10cSrcweir                 try
1397cdf0e10cSrcweir                 {
1398cdf0e10cSrcweir                     Property aGetProp = xAccess->getProperty( aWDemandedName, nConcepts );
1399cdf0e10cSrcweir                     //Property aGetProp = xAccess->getProperty( aWDemandedName, PropertyConcept::ALL );
1400cdf0e10cSrcweir                     //TEST_ENSHURE( aGetProp == aProp , aErrorStr.getStr() );
1401cdf0e10cSrcweir                 }
1402cdf0e10cSrcweir                 catch (RuntimeException e1)
1403cdf0e10cSrcweir                 {
1404cdf0e10cSrcweir                     aErrorStr  = "property \"";
1405cdf0e10cSrcweir                     aErrorStr += aDemandedName;
1406cdf0e10cSrcweir                     aErrorStr += "\", exception was thrown when trying getProperty()";
1407cdf0e10cSrcweir                     TEST_ENSHURE( sal_False, aErrorStr.getStr() );
1408cdf0e10cSrcweir                 }
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir             }
1411cdf0e10cSrcweir         }
1412cdf0e10cSrcweir     }
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir     // Schleife ueber alle Kombinationen von Concepts
1415cdf0e10cSrcweir     for( sal_Int32 nConcepts = 0 ; nConcepts < 128 ; nConcepts++ )
1416cdf0e10cSrcweir     {
1417cdf0e10cSrcweir //printf( "*******************************************************\n" );
1418cdf0e10cSrcweir //printf( "nConcepts = %ld\n", nConcepts );
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir         // Das 2^6-Bit steht fuer "den Rest"
1421cdf0e10cSrcweir         sal_Int32 nRealConcepts = nConcepts;
1422cdf0e10cSrcweir         if( nConcepts & 0x40 )
1423cdf0e10cSrcweir             nRealConcepts |= (0xFFFFFFFF - 0x3F);
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir         // Wieviele Methoden sollten es sein
1426cdf0e10cSrcweir         sal_Int32 nDemandedMethCount = 0;
1427cdf0e10cSrcweir         sal_Int32 iList = 0;
1428cdf0e10cSrcweir         while( pMethodDefs[ iList ].pName )
1429cdf0e10cSrcweir         {
1430cdf0e10cSrcweir             if( pMethodDefs[ iList ].nConcept & nRealConcepts )
1431cdf0e10cSrcweir                 nDemandedMethCount++;
1432cdf0e10cSrcweir             iList++;
1433cdf0e10cSrcweir         }
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir         // Methoden-Array ausgeben
1436cdf0e10cSrcweir         //aMethodSeq = xAccess->getMethods
1437cdf0e10cSrcweir         Sequence< Reference< XIdlMethod > > aMethodSeq = xAccess->getMethods( nRealConcepts );
1438cdf0e10cSrcweir         //Sequence<XIdlMethodRef> aMethodSeq = xAccess->getMethods
1439cdf0e10cSrcweir         //  ( MethodConcept::ALL - MethodConcept::DANGEROUS - MethodConcept::PROPERTY );
1440cdf0e10cSrcweir         sal_Int32 nLen = aMethodSeq.getLength();
1441cdf0e10cSrcweir         // cout << "\n\n*** Methoden ***\n";
1442cdf0e10cSrcweir         // cout << "Introspection hat " << nLen << " Methoden gefunden:\n";
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir         aErrorStr  = "Expected to find ";
1445cdf0e10cSrcweir         aErrorStr += OString::valueOf( nDemandedMethCount );
1446cdf0e10cSrcweir         aErrorStr += " methods but found ";
1447cdf0e10cSrcweir         aErrorStr += OString::valueOf( nLen );
1448cdf0e10cSrcweir         TEST_ENSHURE( nLen == nDemandedMethCount, aErrorStr.getStr() );
1449cdf0e10cSrcweir 
1450cdf0e10cSrcweir         const Reference< XIdlMethod >* pMethods = aMethodSeq.getConstArray();
1451cdf0e10cSrcweir         sal_Int32 i;
1452cdf0e10cSrcweir         iList = 0;
1453cdf0e10cSrcweir 
1454cdf0e10cSrcweir         for( i = 0 ; i < nLen ; i++ )
1455cdf0e10cSrcweir         {
1456cdf0e10cSrcweir             // Methode ansprechen
1457cdf0e10cSrcweir             const Reference< XIdlMethod >& rxMethod = pMethods[i];
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir             // Methode ausgeben
1460cdf0e10cSrcweir             OUString aMethName = rxMethod->getName();
1461cdf0e10cSrcweir             OString aNameStr = OUStringToOString(aMethName, RTL_TEXTENCODING_ASCII_US );
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir //printf( "Method = %s\n", aNameStr.getStr() );
1464cdf0e10cSrcweir 
1465cdf0e10cSrcweir             // Naechste Passende Methode in der Liste suchen
1466cdf0e10cSrcweir             while( pMethodDefs[ iList ].pName )
1467cdf0e10cSrcweir             {
1468cdf0e10cSrcweir                 if( pMethodDefs[ iList ].nConcept & nRealConcepts )
1469cdf0e10cSrcweir                     break;
1470cdf0e10cSrcweir                 iList++;
1471cdf0e10cSrcweir             }
1472cdf0e10cSrcweir             OString aDemandedName = pMethodDefs[ iList ].pName;
1473cdf0e10cSrcweir             iList++;
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir             //OString aDemandedName = pDemandedMethNames[ i ];
1476cdf0e10cSrcweir             aErrorStr  = "Expected method \"";
1477cdf0e10cSrcweir             aErrorStr += aDemandedName;
1478cdf0e10cSrcweir             aErrorStr += "\", found \"";
1479cdf0e10cSrcweir             aErrorStr += aNameStr;
1480cdf0e10cSrcweir             aErrorStr += "\"";
1481cdf0e10cSrcweir             TEST_ENSHURE( aNameStr == aDemandedName, aErrorStr.getStr() );
1482cdf0e10cSrcweir             // cout << "Methode " << (i+1) << ": " << (const char*) UStringToString(rxMethod->getReturnType()->getName(), CHARSET_SYSTEM)
1483cdf0e10cSrcweir             //   << " " << (const char*) UStringToString(rxMethod->getName(), CHARSET_SYSTEM) << "( ";
1484cdf0e10cSrcweir 
1485cdf0e10cSrcweir             // Checken, ob alle Methoden auch einzeln gefunden werden
1486cdf0e10cSrcweir             aErrorStr  = "method \"";
1487cdf0e10cSrcweir             aErrorStr += aDemandedName;
1488cdf0e10cSrcweir             aErrorStr += "\" not found with hasMethod()";
1489cdf0e10cSrcweir             OUString aWDemandedName = OStringToOUString(aDemandedName, RTL_TEXTENCODING_ASCII_US );
1490cdf0e10cSrcweir             sal_Bool bMethod = xAccess->hasMethod( aWDemandedName, nRealConcepts );
1491cdf0e10cSrcweir             //sal_Bool bMethod = xAccess->hasMethod( aWDemandedName, MethodConcept::ALL );
1492cdf0e10cSrcweir             TEST_ENSHURE( bMethod, aErrorStr.getStr() );
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir             aErrorStr  = "method \"";
1495cdf0e10cSrcweir             aErrorStr += aDemandedName;
1496cdf0e10cSrcweir             aErrorStr += "\" not equal to same method in sequence returned by getMethods()";
1497cdf0e10cSrcweir             try
1498cdf0e10cSrcweir             {
1499cdf0e10cSrcweir                 Reference< XIdlMethod > xGetMethod = xAccess->getMethod( aWDemandedName, nRealConcepts );
1500cdf0e10cSrcweir                 //XIdlMethodRef xGetMethod = xAccess->getMethod( aWDemandedName, MethodConcept::ALL );
1501cdf0e10cSrcweir                 TEST_ENSHURE( xGetMethod == rxMethod , aErrorStr.getStr() );
1502cdf0e10cSrcweir             }
1503cdf0e10cSrcweir             catch (RuntimeException e1)
1504cdf0e10cSrcweir             {
1505cdf0e10cSrcweir                 aErrorStr  = "method \"";
1506cdf0e10cSrcweir                 aErrorStr += aDemandedName;
1507cdf0e10cSrcweir                 aErrorStr += "\", exception was thrown when trying getMethod()";
1508cdf0e10cSrcweir                 TEST_ENSHURE( sal_False, aErrorStr.getStr() );
1509cdf0e10cSrcweir             }
1510cdf0e10cSrcweir         }
1511cdf0e10cSrcweir     }
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir     // Listener-Klassen ausgeben
1514cdf0e10cSrcweir     Sequence< Type > aClassSeq = xAccess->getSupportedListeners();
1515cdf0e10cSrcweir     sal_Int32 nLen = aClassSeq.getLength();
1516cdf0e10cSrcweir     // cout << "\n\n*** Anmeldbare Listener ***\n";
1517cdf0e10cSrcweir     // cout << "Introspection hat " << nLen << " Listener gefunden:\n";
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir     const Type* pListeners = aClassSeq.getConstArray();
1520cdf0e10cSrcweir     for( sal_Int32 i = 0 ; i < nLen ; i++ )
1521cdf0e10cSrcweir     {
1522cdf0e10cSrcweir         // Methode ansprechen
1523cdf0e10cSrcweir         const Type& aListenerType = pListeners[i];
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir         // Namen besorgen
1526cdf0e10cSrcweir         OUString aListenerClassName = aListenerType.getTypeName();
1527cdf0e10cSrcweir         // cout << "Listener " << (i+1) << ": " << (const char*)UStringToString(aListenerClassName, CHARSET_SYSTEM) << "\n";
1528cdf0e10cSrcweir     }
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir     // Performance bei hasMethod testen.
1532cdf0e10cSrcweir     //CheckMethodPerformance( xAccess, "queryInterface", 100000 );
1533cdf0e10cSrcweir     //CheckMethodPerformance( xAccess, "getIdlClasses", 100000 );
1534cdf0e10cSrcweir 
1535cdf0e10cSrcweir     // cout.flush();
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir 
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir     return sal_True;
1541cdf0e10cSrcweir }
1542cdf0e10cSrcweir 
1543cdf0e10cSrcweir 
SAL_IMPLEMENT_MAIN()1544cdf0e10cSrcweir SAL_IMPLEMENT_MAIN()
1545cdf0e10cSrcweir {
1546cdf0e10cSrcweir     Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory( OUString::createFromAscii("stoctest.rdb") ) );
1547cdf0e10cSrcweir 
1548cdf0e10cSrcweir     sal_Bool bSucc = sal_False;
1549cdf0e10cSrcweir     try
1550cdf0e10cSrcweir     {
1551cdf0e10cSrcweir         Reference< XImplementationRegistration > xImplReg(
1552cdf0e10cSrcweir             xMgr->createInstance( OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration") ), UNO_QUERY );
1553cdf0e10cSrcweir         OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir         // Register services
1556cdf0e10cSrcweir         OUString libName( RTL_CONSTASCII_USTRINGPARAM(
1557cdf0e10cSrcweir                               "reflection.uno" SAL_DLLEXTENSION) );
1558cdf0e10cSrcweir //          ORealDynamicLoader::computeLibraryName( OUString::createFromAscii("corefl"), libName);
1559cdf0e10cSrcweir         fprintf(stderr, "1\n" );
1560cdf0e10cSrcweir         xImplReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
1561cdf0e10cSrcweir                                          libName, Reference< XSimpleRegistry >() );
1562cdf0e10cSrcweir         fprintf(stderr, "2\n" );
1563cdf0e10cSrcweir         Reference< XIdlReflection > xRefl( xMgr->createInstance( OUString::createFromAscii("com.sun.star.reflection.CoreReflection") ), UNO_QUERY );
1564cdf0e10cSrcweir         OSL_ENSURE( xRefl.is(), "### no corereflection!" );
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir         // Introspection
1567cdf0e10cSrcweir         libName = OUString::createFromAscii(
1568cdf0e10cSrcweir             "introspection.uno" SAL_DLLEXTENSION);
1569cdf0e10cSrcweir //          ORealDynamicLoader::computeLibraryName( OUString::createFromAscii("insp"), libName);
1570cdf0e10cSrcweir         fprintf(stderr, "3\n" );
1571cdf0e10cSrcweir         xImplReg->registerImplementation(OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
1572cdf0e10cSrcweir                                          libName, Reference< XSimpleRegistry >() );
1573cdf0e10cSrcweir         fprintf(stderr, "4\n" );
1574cdf0e10cSrcweir         Reference< XIntrospection > xIntrosp( xMgr->createInstance( OUString::createFromAscii("com.sun.star.beans.Introspection") ), UNO_QUERY );
1575cdf0e10cSrcweir         OSL_ENSURE( xRefl.is(), "### no corereflection!" );
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir         fprintf(stderr, "before test_introsp\n" );
1578cdf0e10cSrcweir         bSucc = test_introsp( xMgr, xRefl, xIntrosp );
1579cdf0e10cSrcweir         fprintf(stderr, "after test_introsp\n" );
1580cdf0e10cSrcweir         //bSucc = test_corefl( xRefl );
1581cdf0e10cSrcweir     }
1582cdf0e10cSrcweir     catch (Exception & rExc)
1583cdf0e10cSrcweir     {
1584*86e1cf34SPedro Giffuni         OSL_ENSURE( sal_False, "### exception occurred!" );
1585cdf0e10cSrcweir         OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
1586*86e1cf34SPedro Giffuni         OSL_TRACE( "### exception occurred: " );
1587cdf0e10cSrcweir         OSL_TRACE( aMsg.getStr() );
1588cdf0e10cSrcweir         OSL_TRACE( "\n" );
1589cdf0e10cSrcweir     }
1590cdf0e10cSrcweir 
1591cdf0e10cSrcweir     Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir     printf( "testintrosp %s !\n", (bSucc ? "succeeded" : "failed") );
1594cdf0e10cSrcweir     return (bSucc ? 0 : -1);
1595cdf0e10cSrcweir }
1596cdf0e10cSrcweir 
1597cdf0e10cSrcweir 
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir 
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir 
1603cdf0e10cSrcweir //*****************************
1604cdf0e10cSrcweir //*** TEST-Implementationen ***
1605cdf0e10cSrcweir //*****************************
1606cdf0e10cSrcweir // Bleibt auf Dauer nicht drin, dient als exportierbare Test-Klasse
1607cdf0e10cSrcweir // z.B. fuer Basic-Anbindung
1608