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