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 <stdio.h> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include <sal/main.h> 34*cdf0e10cSrcweir #include <osl/diagnose.h> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 37*cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include <test/XLanguageBindingTest.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/registry/XSimpleRegistry.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/registry/XImplementationRegistration.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/script/XInvocation.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/script/XInvocationAdapterFactory.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/script/XInvocationAdapterFactory2.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp> 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir using namespace test; 52*cdf0e10cSrcweir using namespace rtl; 53*cdf0e10cSrcweir using namespace cppu; 54*cdf0e10cSrcweir using namespace osl; 55*cdf0e10cSrcweir using namespace com::sun::star::uno; 56*cdf0e10cSrcweir using namespace com::sun::star::script; 57*cdf0e10cSrcweir using namespace com::sun::star::beans; 58*cdf0e10cSrcweir using namespace com::sun::star::lang; 59*cdf0e10cSrcweir using namespace com::sun::star::reflection; 60*cdf0e10cSrcweir using namespace com::sun::star::lang; 61*cdf0e10cSrcweir using namespace com::sun::star::registry; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir //================================================================================================== 65*cdf0e10cSrcweir sal_Bool equals( const test::TestElement & rData1, const test::TestElement & rData2 ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir OSL_ENSURE( rData1.Bool == rData2.Bool, "### bool does not match!" ); 68*cdf0e10cSrcweir OSL_ENSURE( rData1.Char == rData2.Char, "### char does not match!" ); 69*cdf0e10cSrcweir OSL_ENSURE( rData1.Byte == rData2.Byte, "### byte does not match!" ); 70*cdf0e10cSrcweir OSL_ENSURE( rData1.Short == rData2.Short, "### short does not match!" ); 71*cdf0e10cSrcweir OSL_ENSURE( rData1.UShort == rData2.UShort, "### unsigned short does not match!" ); 72*cdf0e10cSrcweir OSL_ENSURE( rData1.Long == rData2.Long, "### long does not match!" ); 73*cdf0e10cSrcweir OSL_ENSURE( rData1.ULong == rData2.ULong, "### unsigned long does not match!" ); 74*cdf0e10cSrcweir OSL_ENSURE( rData1.Hyper == rData2.Hyper, "### hyper does not match!" ); 75*cdf0e10cSrcweir OSL_ENSURE( rData1.UHyper == rData2.UHyper, "### unsigned hyper does not match!" ); 76*cdf0e10cSrcweir OSL_ENSURE( rData1.Float == rData2.Float, "### float does not match!" ); 77*cdf0e10cSrcweir OSL_ENSURE( rData1.Double == rData2.Double, "### double does not match!" ); 78*cdf0e10cSrcweir OSL_ENSURE( rData1.Enum == rData2.Enum, "### enum does not match!" ); 79*cdf0e10cSrcweir OSL_ENSURE( rData1.String == rData2.String, "### string does not match!" ); 80*cdf0e10cSrcweir OSL_ENSURE( rData1.Interface == rData2.Interface, "### interface does not match!" ); 81*cdf0e10cSrcweir OSL_ENSURE( rData1.Any == rData2.Any, "### any does not match!" ); 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir return (rData1.Bool == rData2.Bool && 84*cdf0e10cSrcweir rData1.Char == rData2.Char && 85*cdf0e10cSrcweir rData1.Byte == rData2.Byte && 86*cdf0e10cSrcweir rData1.Short == rData2.Short && 87*cdf0e10cSrcweir rData1.UShort == rData2.UShort && 88*cdf0e10cSrcweir rData1.Long == rData2.Long && 89*cdf0e10cSrcweir rData1.ULong == rData2.ULong && 90*cdf0e10cSrcweir rData1.Hyper == rData2.Hyper && 91*cdf0e10cSrcweir rData1.UHyper == rData2.UHyper && 92*cdf0e10cSrcweir rData1.Float == rData2.Float && 93*cdf0e10cSrcweir rData1.Double == rData2.Double && 94*cdf0e10cSrcweir rData1.Enum == rData2.Enum && 95*cdf0e10cSrcweir rData1.String == rData2.String && 96*cdf0e10cSrcweir rData1.Interface == rData2.Interface && 97*cdf0e10cSrcweir rData1.Any == rData2.Any); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir //================================================================================================== 100*cdf0e10cSrcweir sal_Bool equals( const test::TestData & rData1, const test::TestData & rData2 ) 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir sal_Int32 nLen; 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir if ((rData1.Sequence == rData2.Sequence) && 105*cdf0e10cSrcweir equals( (const test::TestElement &)rData1, (const test::TestElement &)rData2 ) && 106*cdf0e10cSrcweir (nLen = rData1.Sequence.getLength()) == rData2.Sequence.getLength()) 107*cdf0e10cSrcweir { 108*cdf0e10cSrcweir // once again by hand sequence == 109*cdf0e10cSrcweir const test::TestElement * pElements1 = rData1.Sequence.getConstArray(); 110*cdf0e10cSrcweir const test::TestElement * pElements2 = rData2.Sequence.getConstArray(); 111*cdf0e10cSrcweir for ( ; nLen--; ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir if (! equals( pElements1[nLen], pElements2[nLen] )) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir OSL_ENSURE( sal_False, "### sequence element did not match!" ); 116*cdf0e10cSrcweir return sal_False; 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir return sal_True; 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir return sal_False; 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir //================================================================================================== 124*cdf0e10cSrcweir void assign( test::TestElement & rData, 125*cdf0e10cSrcweir sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte, 126*cdf0e10cSrcweir sal_Int16 nShort, sal_uInt16 nUShort, 127*cdf0e10cSrcweir sal_Int32 nLong, sal_uInt32 nULong, 128*cdf0e10cSrcweir sal_Int64 nHyper, sal_uInt64 nUHyper, 129*cdf0e10cSrcweir float fFloat, double fDouble, 130*cdf0e10cSrcweir test::TestEnum eEnum, const ::rtl::OUString& rStr, 131*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest, 132*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rAny ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir rData.Bool = bBool; 135*cdf0e10cSrcweir rData.Char = cChar; 136*cdf0e10cSrcweir rData.Byte = nByte; 137*cdf0e10cSrcweir rData.Short = nShort; 138*cdf0e10cSrcweir rData.UShort = nUShort; 139*cdf0e10cSrcweir rData.Long = nLong; 140*cdf0e10cSrcweir rData.ULong = nULong; 141*cdf0e10cSrcweir rData.Hyper = nHyper; 142*cdf0e10cSrcweir rData.UHyper = nUHyper; 143*cdf0e10cSrcweir rData.Float = fFloat; 144*cdf0e10cSrcweir rData.Double = fDouble; 145*cdf0e10cSrcweir rData.Enum = eEnum; 146*cdf0e10cSrcweir rData.String = rStr; 147*cdf0e10cSrcweir rData.Interface = xTest; 148*cdf0e10cSrcweir rData.Any = rAny; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir //================================================================================================== 151*cdf0e10cSrcweir void assign( test::TestData & rData, 152*cdf0e10cSrcweir sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte, 153*cdf0e10cSrcweir sal_Int16 nShort, sal_uInt16 nUShort, 154*cdf0e10cSrcweir sal_Int32 nLong, sal_uInt32 nULong, 155*cdf0e10cSrcweir sal_Int64 nHyper, sal_uInt64 nUHyper, 156*cdf0e10cSrcweir float fFloat, double fDouble, 157*cdf0e10cSrcweir test::TestEnum eEnum, const ::rtl::OUString& rStr, 158*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest, 159*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rAny, 160*cdf0e10cSrcweir const com::sun::star::uno::Sequence< test::TestElement >& rSequence ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir assign( (test::TestElement &)rData, 163*cdf0e10cSrcweir bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble, 164*cdf0e10cSrcweir eEnum, rStr, xTest, rAny ); 165*cdf0e10cSrcweir rData.Sequence = rSequence; 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir //================================================================================================== 169*cdf0e10cSrcweir class Test_Impl : public WeakImplHelper1< XLanguageBindingTest > 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir test::TestData _aData, _aStructData; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir public: 174*cdf0e10cSrcweir virtual ~Test_Impl() 175*cdf0e10cSrcweir { OSL_TRACE( "> scalar Test_Impl dtor <\n" ); } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir // XLBTestBase 178*cdf0e10cSrcweir virtual void SAL_CALL setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte, 179*cdf0e10cSrcweir sal_Int16 nShort, sal_uInt16 nUShort, 180*cdf0e10cSrcweir sal_Int32 nLong, sal_uInt32 nULong, 181*cdf0e10cSrcweir sal_Int64 nHyper, sal_uInt64 nUHyper, 182*cdf0e10cSrcweir float fFloat, double fDouble, 183*cdf0e10cSrcweir test::TestEnum eEnum, const ::rtl::OUString& rStr, 184*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest, 185*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rAny, 186*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence, 187*cdf0e10cSrcweir const test::TestData& rStruct ) 188*cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException); 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir virtual test::TestData SAL_CALL setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, 191*cdf0e10cSrcweir sal_Int16& nShort, sal_uInt16& nUShort, 192*cdf0e10cSrcweir sal_Int32& nLong, sal_uInt32& nULong, 193*cdf0e10cSrcweir sal_Int64& nHyper, sal_uInt64& nUHyper, 194*cdf0e10cSrcweir float& fFloat, double& fDouble, 195*cdf0e10cSrcweir test::TestEnum& eEnum, rtl::OUString& rStr, 196*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest, 197*cdf0e10cSrcweir ::com::sun::star::uno::Any& rAny, 198*cdf0e10cSrcweir ::com::sun::star::uno::Sequence<test::TestElement >& rSequence, 199*cdf0e10cSrcweir test::TestData& rStruct ) 200*cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir virtual test::TestData SAL_CALL getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, 203*cdf0e10cSrcweir sal_Int16& nShort, sal_uInt16& nUShort, 204*cdf0e10cSrcweir sal_Int32& nLong, sal_uInt32& nULong, 205*cdf0e10cSrcweir sal_Int64& nHyper, sal_uInt64& nUHyper, 206*cdf0e10cSrcweir float& fFloat, double& fDouble, 207*cdf0e10cSrcweir test::TestEnum& eEnum, rtl::OUString& rStr, 208*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest, 209*cdf0e10cSrcweir ::com::sun::star::uno::Any& rAny, 210*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< test::TestElement >& rSequence, 211*cdf0e10cSrcweir test::TestData& rStruct ) 212*cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir virtual sal_Bool SAL_CALL getBool() throw(com::sun::star::uno::RuntimeException) 215*cdf0e10cSrcweir { return _aData.Bool; } 216*cdf0e10cSrcweir virtual sal_Int8 SAL_CALL getByte() throw(com::sun::star::uno::RuntimeException) 217*cdf0e10cSrcweir { return _aData.Byte; } 218*cdf0e10cSrcweir virtual sal_Unicode SAL_CALL getChar() throw(com::sun::star::uno::RuntimeException) 219*cdf0e10cSrcweir { return _aData.Char; } 220*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL getShort() throw(com::sun::star::uno::RuntimeException) 221*cdf0e10cSrcweir { return _aData.Short; } 222*cdf0e10cSrcweir virtual sal_uInt16 SAL_CALL getUShort() throw(com::sun::star::uno::RuntimeException) 223*cdf0e10cSrcweir { return _aData.UShort; } 224*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getLong() throw(com::sun::star::uno::RuntimeException) 225*cdf0e10cSrcweir { return _aData.Long; } 226*cdf0e10cSrcweir virtual sal_uInt32 SAL_CALL getULong() throw(com::sun::star::uno::RuntimeException) 227*cdf0e10cSrcweir { return _aData.ULong; } 228*cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getHyper() throw(com::sun::star::uno::RuntimeException) 229*cdf0e10cSrcweir { return _aData.Hyper; } 230*cdf0e10cSrcweir virtual sal_uInt64 SAL_CALL getUHyper() throw(com::sun::star::uno::RuntimeException) 231*cdf0e10cSrcweir { return _aData.UHyper; } 232*cdf0e10cSrcweir virtual float SAL_CALL getFloat() throw(com::sun::star::uno::RuntimeException) 233*cdf0e10cSrcweir { return _aData.Float; } 234*cdf0e10cSrcweir virtual double SAL_CALL getDouble() throw(com::sun::star::uno::RuntimeException) 235*cdf0e10cSrcweir { return _aData.Double; } 236*cdf0e10cSrcweir virtual test::TestEnum SAL_CALL getEnum() throw(com::sun::star::uno::RuntimeException) 237*cdf0e10cSrcweir { return _aData.Enum; } 238*cdf0e10cSrcweir virtual rtl::OUString SAL_CALL getString() throw(com::sun::star::uno::RuntimeException) 239*cdf0e10cSrcweir { return _aData.String; } 240*cdf0e10cSrcweir virtual com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getInterface( ) throw(com::sun::star::uno::RuntimeException) 241*cdf0e10cSrcweir { return _aData.Interface; } 242*cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL getAny() throw(com::sun::star::uno::RuntimeException) 243*cdf0e10cSrcweir { return _aData.Any; } 244*cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< test::TestElement > SAL_CALL getSequence() throw(com::sun::star::uno::RuntimeException) 245*cdf0e10cSrcweir { return _aData.Sequence; } 246*cdf0e10cSrcweir virtual test::TestData SAL_CALL getStruct() throw(com::sun::star::uno::RuntimeException) 247*cdf0e10cSrcweir { return _aStructData; } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir virtual void SAL_CALL setBool( sal_Bool _bool ) throw(::com::sun::star::uno::RuntimeException) 250*cdf0e10cSrcweir { _aData.Bool = _bool; } 251*cdf0e10cSrcweir virtual void SAL_CALL setByte( sal_Int8 _byte ) throw(::com::sun::star::uno::RuntimeException) 252*cdf0e10cSrcweir { _aData.Byte = _byte; } 253*cdf0e10cSrcweir virtual void SAL_CALL setChar( sal_Unicode _char ) throw(::com::sun::star::uno::RuntimeException) 254*cdf0e10cSrcweir { _aData.Char = _char; } 255*cdf0e10cSrcweir virtual void SAL_CALL setShort( sal_Int16 _short ) throw(::com::sun::star::uno::RuntimeException) 256*cdf0e10cSrcweir { _aData.Short = _short; } 257*cdf0e10cSrcweir virtual void SAL_CALL setUShort( sal_uInt16 _ushort ) throw(::com::sun::star::uno::RuntimeException) 258*cdf0e10cSrcweir { _aData.UShort = _ushort; } 259*cdf0e10cSrcweir virtual void SAL_CALL setLong( sal_Int32 _long ) throw(::com::sun::star::uno::RuntimeException) 260*cdf0e10cSrcweir { _aData.Long = _long; } 261*cdf0e10cSrcweir virtual void SAL_CALL setULong( sal_uInt32 _ulong ) throw(::com::sun::star::uno::RuntimeException) 262*cdf0e10cSrcweir { _aData.ULong = _ulong; } 263*cdf0e10cSrcweir virtual void SAL_CALL setHyper( sal_Int64 _hyper ) throw(::com::sun::star::uno::RuntimeException) 264*cdf0e10cSrcweir { _aData.Hyper = _hyper; } 265*cdf0e10cSrcweir virtual void SAL_CALL setUHyper( sal_uInt64 _uhyper ) throw(::com::sun::star::uno::RuntimeException) 266*cdf0e10cSrcweir { _aData.UHyper = _uhyper; } 267*cdf0e10cSrcweir virtual void SAL_CALL setFloat( float _float ) throw(::com::sun::star::uno::RuntimeException) 268*cdf0e10cSrcweir { _aData.Float = _float; } 269*cdf0e10cSrcweir virtual void SAL_CALL setDouble( double _double ) throw(::com::sun::star::uno::RuntimeException) 270*cdf0e10cSrcweir { _aData.Double = _double; } 271*cdf0e10cSrcweir virtual void SAL_CALL setEnum( test::TestEnum _enum ) throw(::com::sun::star::uno::RuntimeException) 272*cdf0e10cSrcweir { _aData.Enum = _enum; } 273*cdf0e10cSrcweir virtual void SAL_CALL setString( const ::rtl::OUString& _string ) throw(::com::sun::star::uno::RuntimeException) 274*cdf0e10cSrcweir { _aData.String = _string; } 275*cdf0e10cSrcweir virtual void SAL_CALL setInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _interface ) throw(::com::sun::star::uno::RuntimeException) 276*cdf0e10cSrcweir { _aData.Interface = _interface; } 277*cdf0e10cSrcweir virtual void SAL_CALL setAny( const ::com::sun::star::uno::Any& _any ) throw(::com::sun::star::uno::RuntimeException) 278*cdf0e10cSrcweir { _aData.Any = _any; } 279*cdf0e10cSrcweir virtual void SAL_CALL setSequence( const ::com::sun::star::uno::Sequence<test::TestElement >& _sequence ) throw(::com::sun::star::uno::RuntimeException) 280*cdf0e10cSrcweir { _aData.Sequence = _sequence; } 281*cdf0e10cSrcweir virtual void SAL_CALL setStruct( const test::TestData& _struct ) throw(::com::sun::star::uno::RuntimeException) 282*cdf0e10cSrcweir { _aStructData = _struct; } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir // XLanguageBindingTest 285*cdf0e10cSrcweir virtual test::TestData SAL_CALL raiseException( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, sal_Int16& nShort, sal_uInt16& nUShort, sal_Int32& nLong, sal_uInt32& nULong, sal_Int64& nHyper, sal_uInt64& nUHyper, float& fFloat, double& fDouble, test::TestEnum& eEnum, ::rtl::OUString& aString, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInterface, ::com::sun::star::uno::Any& aAny, ::com::sun::star::uno::Sequence<test::TestElement >& aSequence,test::TestData& aStruct ) 286*cdf0e10cSrcweir throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getRuntimeException() throw(::com::sun::star::uno::RuntimeException); 289*cdf0e10cSrcweir virtual void SAL_CALL setRuntimeException( sal_Int32 _runtimeexception ) throw(::com::sun::star::uno::RuntimeException); 290*cdf0e10cSrcweir }; 291*cdf0e10cSrcweir //================================================================================================== 292*cdf0e10cSrcweir class XLB_Invocation : public WeakImplHelper1< XInvocation > 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir Reference< XLanguageBindingTest > _xLBT; 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir public: 297*cdf0e10cSrcweir XLB_Invocation( const Reference< XMultiServiceFactory > & /*xMgr*/, 298*cdf0e10cSrcweir const Reference< XLanguageBindingTest > & xLBT ) 299*cdf0e10cSrcweir : _xLBT( xLBT ) 300*cdf0e10cSrcweir {} 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir // XInvocation 303*cdf0e10cSrcweir virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() throw(::com::sun::star::uno::RuntimeException) 304*cdf0e10cSrcweir { return Reference< XIntrospectionAccess >(); } 305*cdf0e10cSrcweir virtual Any SAL_CALL invoke( const OUString & rFunctionName, 306*cdf0e10cSrcweir const Sequence< Any > & rParams, 307*cdf0e10cSrcweir Sequence< sal_Int16 > & rOutParamIndex, 308*cdf0e10cSrcweir Sequence< Any > & rOutParam ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); 309*cdf0e10cSrcweir virtual void SAL_CALL setValue( const OUString & rPropertyName, const Any & rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); 310*cdf0e10cSrcweir virtual Any SAL_CALL getValue( const OUString & rPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); 311*cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasMethod( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException); 312*cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasProperty( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException); 313*cdf0e10cSrcweir }; 314*cdf0e10cSrcweir //__________________________________________________________________________________________________ 315*cdf0e10cSrcweir Any XLB_Invocation::invoke( const OUString & rFunctionName, 316*cdf0e10cSrcweir const Sequence< Any > & rParams, 317*cdf0e10cSrcweir Sequence< sal_Int16 > & rOutParamIndex, 318*cdf0e10cSrcweir Sequence< Any > & rOutParam ) 319*cdf0e10cSrcweir throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir bool bImplementedMethod = true; 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir Any aRet; 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir OSL_ASSERT( rOutParam.getLength() == 0 ); 326*cdf0e10cSrcweir OSL_ASSERT( rOutParamIndex.getLength() == 0 ); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir try 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir sal_Bool aBool; 331*cdf0e10cSrcweir sal_Unicode aChar; 332*cdf0e10cSrcweir sal_Int8 nByte; 333*cdf0e10cSrcweir sal_Int16 nShort; 334*cdf0e10cSrcweir sal_uInt16 nUShort; 335*cdf0e10cSrcweir sal_Int32 nLong; 336*cdf0e10cSrcweir sal_uInt32 nULong; 337*cdf0e10cSrcweir sal_Int64 nHyper; 338*cdf0e10cSrcweir sal_uInt64 nUHyper; 339*cdf0e10cSrcweir float fFloat; 340*cdf0e10cSrcweir double fDouble; 341*cdf0e10cSrcweir TestEnum eEnum; 342*cdf0e10cSrcweir OUString aString; 343*cdf0e10cSrcweir Reference< XInterface > xInterface; 344*cdf0e10cSrcweir Any aAny; 345*cdf0e10cSrcweir Sequence< TestElement > aSeq; 346*cdf0e10cSrcweir TestData aData; 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") )) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir OSL_ASSERT( rParams.getLength() == 17 ); 351*cdf0e10cSrcweir aBool = *(sal_Bool *)rParams[0].getValue(); 352*cdf0e10cSrcweir aChar = *(sal_Unicode *)rParams[1].getValue(); 353*cdf0e10cSrcweir rParams[2] >>= nByte; 354*cdf0e10cSrcweir rParams[3] >>= nShort; 355*cdf0e10cSrcweir rParams[4] >>= nUShort; 356*cdf0e10cSrcweir rParams[5] >>= nLong; 357*cdf0e10cSrcweir rParams[6] >>= nULong; 358*cdf0e10cSrcweir rParams[7] >>= nHyper; 359*cdf0e10cSrcweir rParams[8] >>= nUHyper; 360*cdf0e10cSrcweir rParams[9] >>= fFloat; 361*cdf0e10cSrcweir rParams[10] >>= fDouble; 362*cdf0e10cSrcweir rParams[11] >>= eEnum; 363*cdf0e10cSrcweir rParams[12] >>= aString; 364*cdf0e10cSrcweir rParams[13] >>= xInterface; 365*cdf0e10cSrcweir rParams[14] >>= aAny; 366*cdf0e10cSrcweir rParams[15] >>= aSeq; 367*cdf0e10cSrcweir rParams[16] >>= aData; 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir _xLBT->setValues( aBool, aChar, nByte, nShort, nUShort, nLong, nULong, 370*cdf0e10cSrcweir nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface, 371*cdf0e10cSrcweir aAny, aSeq, aData ); 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir rOutParamIndex.realloc( 0 ); 374*cdf0e10cSrcweir rOutParam.realloc( 0 ); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") )) 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir aBool = *(sal_Bool *)rParams[0].getValue(); 379*cdf0e10cSrcweir aChar = *(sal_Unicode *)rParams[1].getValue(); 380*cdf0e10cSrcweir rParams[2] >>= nByte; 381*cdf0e10cSrcweir rParams[3] >>= nShort; 382*cdf0e10cSrcweir rParams[4] >>= nUShort; 383*cdf0e10cSrcweir rParams[5] >>= nLong; 384*cdf0e10cSrcweir rParams[6] >>= nULong; 385*cdf0e10cSrcweir rParams[7] >>= nHyper; 386*cdf0e10cSrcweir rParams[8] >>= nUHyper; 387*cdf0e10cSrcweir rParams[9] >>= fFloat; 388*cdf0e10cSrcweir rParams[10] >>= fDouble; 389*cdf0e10cSrcweir rParams[11] >>= eEnum; 390*cdf0e10cSrcweir rParams[12] >>= aString; 391*cdf0e10cSrcweir rParams[13] >>= xInterface; 392*cdf0e10cSrcweir rParams[14] >>= aAny; 393*cdf0e10cSrcweir rParams[15] >>= aSeq; 394*cdf0e10cSrcweir rParams[16] >>= aData; 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir aRet <<= _xLBT->setValues2( aBool, aChar, nByte, nShort, nUShort, nLong, nULong, 397*cdf0e10cSrcweir nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface, 398*cdf0e10cSrcweir aAny, aSeq, aData ); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir rOutParamIndex.realloc( 17 ); 401*cdf0e10cSrcweir rOutParamIndex[0] = 0; 402*cdf0e10cSrcweir rOutParamIndex[1] = 1; 403*cdf0e10cSrcweir rOutParamIndex[2] = 2; 404*cdf0e10cSrcweir rOutParamIndex[3] = 3; 405*cdf0e10cSrcweir rOutParamIndex[4] = 4; 406*cdf0e10cSrcweir rOutParamIndex[5] = 5; 407*cdf0e10cSrcweir rOutParamIndex[6] = 6; 408*cdf0e10cSrcweir rOutParamIndex[7] = 7; 409*cdf0e10cSrcweir rOutParamIndex[8] = 8; 410*cdf0e10cSrcweir rOutParamIndex[9] = 9; 411*cdf0e10cSrcweir rOutParamIndex[10] = 10; 412*cdf0e10cSrcweir rOutParamIndex[11] = 11; 413*cdf0e10cSrcweir rOutParamIndex[12] = 12; 414*cdf0e10cSrcweir rOutParamIndex[13] = 13; 415*cdf0e10cSrcweir rOutParamIndex[14] = 14; 416*cdf0e10cSrcweir rOutParamIndex[15] = 15; 417*cdf0e10cSrcweir rOutParamIndex[16] = 16; 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir rOutParam.realloc( 17 ); 420*cdf0e10cSrcweir rOutParam[0].setValue( &aBool, ::getCppuBooleanType() ); 421*cdf0e10cSrcweir rOutParam[1].setValue( &aChar, ::getCppuCharType() ); 422*cdf0e10cSrcweir rOutParam[2] <<= nByte; 423*cdf0e10cSrcweir rOutParam[3] <<= nShort; 424*cdf0e10cSrcweir rOutParam[4] <<= nUShort; 425*cdf0e10cSrcweir rOutParam[5] <<= nLong; 426*cdf0e10cSrcweir rOutParam[6] <<= nULong; 427*cdf0e10cSrcweir rOutParam[7] <<= nHyper; 428*cdf0e10cSrcweir rOutParam[8] <<= nUHyper; 429*cdf0e10cSrcweir rOutParam[9] <<= fFloat; 430*cdf0e10cSrcweir rOutParam[10] <<= fDouble; 431*cdf0e10cSrcweir rOutParam[11] <<= eEnum; 432*cdf0e10cSrcweir rOutParam[12] <<= aString; 433*cdf0e10cSrcweir rOutParam[13] <<= xInterface; 434*cdf0e10cSrcweir rOutParam[14] <<= aAny; 435*cdf0e10cSrcweir rOutParam[15] <<= aSeq; 436*cdf0e10cSrcweir rOutParam[16] <<= aData; 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") )) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir aRet <<= _xLBT->getValues( aBool, aChar, nByte, nShort, nUShort, nLong, nULong, 441*cdf0e10cSrcweir nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface, 442*cdf0e10cSrcweir aAny, aSeq, aData ); 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir rOutParamIndex.realloc( 17 ); 445*cdf0e10cSrcweir rOutParamIndex[0] = 0; 446*cdf0e10cSrcweir rOutParamIndex[1] = 1; 447*cdf0e10cSrcweir rOutParamIndex[2] = 2; 448*cdf0e10cSrcweir rOutParamIndex[3] = 3; 449*cdf0e10cSrcweir rOutParamIndex[4] = 4; 450*cdf0e10cSrcweir rOutParamIndex[5] = 5; 451*cdf0e10cSrcweir rOutParamIndex[6] = 6; 452*cdf0e10cSrcweir rOutParamIndex[7] = 7; 453*cdf0e10cSrcweir rOutParamIndex[8] = 8; 454*cdf0e10cSrcweir rOutParamIndex[9] = 9; 455*cdf0e10cSrcweir rOutParamIndex[10] = 10; 456*cdf0e10cSrcweir rOutParamIndex[11] = 11; 457*cdf0e10cSrcweir rOutParamIndex[12] = 12; 458*cdf0e10cSrcweir rOutParamIndex[13] = 13; 459*cdf0e10cSrcweir rOutParamIndex[14] = 14; 460*cdf0e10cSrcweir rOutParamIndex[15] = 15; 461*cdf0e10cSrcweir rOutParamIndex[16] = 16; 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir rOutParam.realloc( 17 ); 464*cdf0e10cSrcweir rOutParam[0].setValue( &aBool, ::getCppuBooleanType() ); 465*cdf0e10cSrcweir rOutParam[1].setValue( &aChar, ::getCppuCharType() ); 466*cdf0e10cSrcweir rOutParam[2] <<= nByte; 467*cdf0e10cSrcweir rOutParam[3] <<= nShort; 468*cdf0e10cSrcweir rOutParam[4] <<= nUShort; 469*cdf0e10cSrcweir rOutParam[5] <<= nLong; 470*cdf0e10cSrcweir rOutParam[6] <<= nULong; 471*cdf0e10cSrcweir rOutParam[7] <<= nHyper; 472*cdf0e10cSrcweir rOutParam[8] <<= nUHyper; 473*cdf0e10cSrcweir rOutParam[9] <<= fFloat; 474*cdf0e10cSrcweir rOutParam[10] <<= fDouble; 475*cdf0e10cSrcweir rOutParam[11] <<= eEnum; 476*cdf0e10cSrcweir rOutParam[12] <<= aString; 477*cdf0e10cSrcweir rOutParam[13] <<= xInterface; 478*cdf0e10cSrcweir rOutParam[14] <<= aAny; 479*cdf0e10cSrcweir rOutParam[15] <<= aSeq; 480*cdf0e10cSrcweir rOutParam[16] <<= aData; 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir else if (rFunctionName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") )) 483*cdf0e10cSrcweir { 484*cdf0e10cSrcweir aRet <<= _xLBT->raiseException( aBool, aChar, nByte, nShort, nUShort, nLong, nULong, 485*cdf0e10cSrcweir nHyper, nUHyper, fFloat, fDouble, eEnum, aString, xInterface, 486*cdf0e10cSrcweir aAny, aSeq, aData ); 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir rOutParamIndex.realloc( 17 ); 489*cdf0e10cSrcweir rOutParamIndex[0] = 0; 490*cdf0e10cSrcweir rOutParamIndex[1] = 1; 491*cdf0e10cSrcweir rOutParamIndex[2] = 2; 492*cdf0e10cSrcweir rOutParamIndex[3] = 3; 493*cdf0e10cSrcweir rOutParamIndex[4] = 4; 494*cdf0e10cSrcweir rOutParamIndex[5] = 5; 495*cdf0e10cSrcweir rOutParamIndex[6] = 6; 496*cdf0e10cSrcweir rOutParamIndex[7] = 7; 497*cdf0e10cSrcweir rOutParamIndex[8] = 8; 498*cdf0e10cSrcweir rOutParamIndex[9] = 9; 499*cdf0e10cSrcweir rOutParamIndex[10] = 10; 500*cdf0e10cSrcweir rOutParamIndex[11] = 11; 501*cdf0e10cSrcweir rOutParamIndex[12] = 12; 502*cdf0e10cSrcweir rOutParamIndex[13] = 13; 503*cdf0e10cSrcweir rOutParamIndex[14] = 14; 504*cdf0e10cSrcweir rOutParamIndex[15] = 15; 505*cdf0e10cSrcweir rOutParamIndex[16] = 16; 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir rOutParam.realloc( 17 ); 508*cdf0e10cSrcweir rOutParam[0].setValue( &aBool, ::getCppuBooleanType() ); 509*cdf0e10cSrcweir rOutParam[1].setValue( &aChar, ::getCppuCharType() ); 510*cdf0e10cSrcweir rOutParam[2] <<= nByte; 511*cdf0e10cSrcweir rOutParam[3] <<= nShort; 512*cdf0e10cSrcweir rOutParam[4] <<= nUShort; 513*cdf0e10cSrcweir rOutParam[5] <<= nLong; 514*cdf0e10cSrcweir rOutParam[6] <<= nULong; 515*cdf0e10cSrcweir rOutParam[7] <<= nHyper; 516*cdf0e10cSrcweir rOutParam[8] <<= nUHyper; 517*cdf0e10cSrcweir rOutParam[9] <<= fFloat; 518*cdf0e10cSrcweir rOutParam[10] <<= fDouble; 519*cdf0e10cSrcweir rOutParam[11] <<= eEnum; 520*cdf0e10cSrcweir rOutParam[12] <<= aString; 521*cdf0e10cSrcweir rOutParam[13] <<= xInterface; 522*cdf0e10cSrcweir rOutParam[14] <<= aAny; 523*cdf0e10cSrcweir rOutParam[15] <<= aSeq; 524*cdf0e10cSrcweir rOutParam[16] <<= aData; 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir else 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir bImplementedMethod = false; 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir catch (IllegalArgumentException & rExc) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir // thrown by raiseException() call 534*cdf0e10cSrcweir InvocationTargetException aExc; 535*cdf0e10cSrcweir aExc.TargetException <<= rExc; 536*cdf0e10cSrcweir throw aExc; 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir catch (Exception &) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir OSL_ENSURE( sal_False, "### unexpected exception caught!" ); 541*cdf0e10cSrcweir throw; 542*cdf0e10cSrcweir } 543*cdf0e10cSrcweir 544*cdf0e10cSrcweir if (! bImplementedMethod) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir throw IllegalArgumentException( 547*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("not an implemented method!") ), 548*cdf0e10cSrcweir (OWeakObject *)this, 0 ); 549*cdf0e10cSrcweir } 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir return aRet; 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir //__________________________________________________________________________________________________ 554*cdf0e10cSrcweir void XLB_Invocation::setValue( const OUString & rName, const Any & rValue ) 555*cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") )) 558*cdf0e10cSrcweir _xLBT->setBool( *(const sal_Bool *)rValue.getValue() ); 559*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") )) 560*cdf0e10cSrcweir _xLBT->setByte( *(const sal_Int8 *)rValue.getValue() ); 561*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") )) 562*cdf0e10cSrcweir _xLBT->setChar( *(const sal_Unicode *)rValue.getValue() ); 563*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") )) 564*cdf0e10cSrcweir _xLBT->setShort( *(const sal_Int16 *)rValue.getValue() ); 565*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") )) 566*cdf0e10cSrcweir _xLBT->setUShort( *(const sal_uInt16 *)rValue.getValue() ); 567*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") )) 568*cdf0e10cSrcweir _xLBT->setLong( *(const sal_Int32 *)rValue.getValue() ); 569*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") )) 570*cdf0e10cSrcweir _xLBT->setULong( *(const sal_uInt32 *)rValue.getValue() ); 571*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") )) 572*cdf0e10cSrcweir _xLBT->setHyper( *(const sal_Int64 *)rValue.getValue() ); 573*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") )) 574*cdf0e10cSrcweir _xLBT->setUHyper( *(const sal_uInt64 *)rValue.getValue() ); 575*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") )) 576*cdf0e10cSrcweir _xLBT->setFloat( *(const float *)rValue.getValue() ); 577*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") )) 578*cdf0e10cSrcweir _xLBT->setDouble( *(const double *)rValue.getValue() ); 579*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") )) 580*cdf0e10cSrcweir _xLBT->setEnum( *(const TestEnum *)rValue.getValue() ); 581*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") )) 582*cdf0e10cSrcweir _xLBT->setString( *(const OUString *)rValue.getValue() ); 583*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") )) 584*cdf0e10cSrcweir _xLBT->setInterface( *(const Reference< XInterface > *)rValue.getValue() ); 585*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") )) 586*cdf0e10cSrcweir _xLBT->setAny( rValue ); 587*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") )) 588*cdf0e10cSrcweir _xLBT->setSequence( *(const Sequence< TestElement > *)rValue.getValue() ); 589*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") )) 590*cdf0e10cSrcweir _xLBT->setStruct( *(const TestData *)rValue.getValue() ); 591*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") )) 592*cdf0e10cSrcweir _xLBT->setRuntimeException( *(const sal_Int32 *)rValue.getValue() ); 593*cdf0e10cSrcweir } 594*cdf0e10cSrcweir //__________________________________________________________________________________________________ 595*cdf0e10cSrcweir Any XLB_Invocation::getValue( const OUString & rName ) 596*cdf0e10cSrcweir throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) 597*cdf0e10cSrcweir { 598*cdf0e10cSrcweir Any aRet; 599*cdf0e10cSrcweir if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") )) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir sal_Bool aBool = _xLBT->getBool(); 602*cdf0e10cSrcweir aRet.setValue( &aBool, ::getCppuBooleanType() ); 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") )) 605*cdf0e10cSrcweir aRet <<= _xLBT->getByte(); 606*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") )) 607*cdf0e10cSrcweir { 608*cdf0e10cSrcweir sal_Unicode aChar = _xLBT->getChar(); 609*cdf0e10cSrcweir aRet.setValue( &aChar, ::getCppuCharType() ); 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") )) 612*cdf0e10cSrcweir aRet <<= _xLBT->getShort(); 613*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") )) 614*cdf0e10cSrcweir aRet <<= _xLBT->getUShort(); 615*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") )) 616*cdf0e10cSrcweir aRet <<= _xLBT->getLong(); 617*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") )) 618*cdf0e10cSrcweir aRet <<= _xLBT->getULong(); 619*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") )) 620*cdf0e10cSrcweir aRet <<= _xLBT->getHyper(); 621*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") )) 622*cdf0e10cSrcweir aRet <<= _xLBT->getUHyper(); 623*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") )) 624*cdf0e10cSrcweir aRet <<= _xLBT->getFloat(); 625*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") )) 626*cdf0e10cSrcweir aRet <<= _xLBT->getDouble(); 627*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") )) 628*cdf0e10cSrcweir aRet <<= _xLBT->getEnum(); 629*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") )) 630*cdf0e10cSrcweir aRet <<= _xLBT->getString(); 631*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") )) 632*cdf0e10cSrcweir aRet <<= _xLBT->getInterface(); 633*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") )) 634*cdf0e10cSrcweir aRet <<= _xLBT->getAny(); 635*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") )) 636*cdf0e10cSrcweir aRet <<= _xLBT->getSequence(); 637*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") )) 638*cdf0e10cSrcweir aRet <<= _xLBT->getStruct(); 639*cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") )) 640*cdf0e10cSrcweir aRet <<= _xLBT->getRuntimeException(); 641*cdf0e10cSrcweir return aRet; 642*cdf0e10cSrcweir } 643*cdf0e10cSrcweir //__________________________________________________________________________________________________ 644*cdf0e10cSrcweir sal_Bool XLB_Invocation::hasMethod( const OUString & rName ) 645*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir return (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("raiseException") ) || 648*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("getValues") ) || 649*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues2") ) || 650*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("setValues") ) || 651*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("acquire") ) || 652*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("release") ) || 653*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("queryInterface") )); 654*cdf0e10cSrcweir } 655*cdf0e10cSrcweir //__________________________________________________________________________________________________ 656*cdf0e10cSrcweir sal_Bool XLB_Invocation::hasProperty( const OUString & rName ) 657*cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir return (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Bool") ) || 660*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Byte") ) || 661*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Char") ) || 662*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Short") ) || 663*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UShort") ) || 664*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Long") ) || 665*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ULong") ) || 666*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Hyper") ) || 667*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("UHyper") ) || 668*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Float") ) || 669*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Double") ) || 670*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Enum") ) || 671*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("String") ) || 672*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Interface") ) || 673*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Any") ) || 674*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Sequence") ) || 675*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("Struct") ) || 676*cdf0e10cSrcweir rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("RuntimeException") ) ); 677*cdf0e10cSrcweir } 678*cdf0e10cSrcweir 679*cdf0e10cSrcweir //################################################################################################## 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir //__________________________________________________________________________________________________ 682*cdf0e10cSrcweir void Test_Impl::setValues( sal_Bool bBool, sal_Unicode cChar, sal_Int8 nByte, 683*cdf0e10cSrcweir sal_Int16 nShort, sal_uInt16 nUShort, 684*cdf0e10cSrcweir sal_Int32 nLong, sal_uInt32 nULong, 685*cdf0e10cSrcweir sal_Int64 nHyper, sal_uInt64 nUHyper, 686*cdf0e10cSrcweir float fFloat, double fDouble, 687*cdf0e10cSrcweir test::TestEnum eEnum, const ::rtl::OUString& rStr, 688*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest, 689*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rAny, 690*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence<test::TestElement >& rSequence, 691*cdf0e10cSrcweir const test::TestData& rStruct ) 692*cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir assign( _aData, 695*cdf0e10cSrcweir bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble, 696*cdf0e10cSrcweir eEnum, rStr, xTest, rAny, rSequence ); 697*cdf0e10cSrcweir _aStructData = rStruct; 698*cdf0e10cSrcweir } 699*cdf0e10cSrcweir //__________________________________________________________________________________________________ 700*cdf0e10cSrcweir test::TestData Test_Impl::setValues2( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, 701*cdf0e10cSrcweir sal_Int16& nShort, sal_uInt16& nUShort, 702*cdf0e10cSrcweir sal_Int32& nLong, sal_uInt32& nULong, 703*cdf0e10cSrcweir sal_Int64& nHyper, sal_uInt64& nUHyper, 704*cdf0e10cSrcweir float& fFloat, double& fDouble, 705*cdf0e10cSrcweir test::TestEnum& eEnum, rtl::OUString& rStr, 706*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest, 707*cdf0e10cSrcweir ::com::sun::star::uno::Any& rAny, 708*cdf0e10cSrcweir ::com::sun::star::uno::Sequence<test::TestElement >& rSequence, 709*cdf0e10cSrcweir test::TestData& rStruct ) 710*cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException) 711*cdf0e10cSrcweir { 712*cdf0e10cSrcweir assign( _aData, 713*cdf0e10cSrcweir bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, fFloat, fDouble, 714*cdf0e10cSrcweir eEnum, rStr, xTest, rAny, rSequence ); 715*cdf0e10cSrcweir _aStructData = rStruct; 716*cdf0e10cSrcweir return _aStructData; 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir //__________________________________________________________________________________________________ 719*cdf0e10cSrcweir test::TestData Test_Impl::getValues( sal_Bool& bBool, sal_Unicode& cChar, sal_Int8& nByte, 720*cdf0e10cSrcweir sal_Int16& nShort, sal_uInt16& nUShort, 721*cdf0e10cSrcweir sal_Int32& nLong, sal_uInt32& nULong, 722*cdf0e10cSrcweir sal_Int64& nHyper, sal_uInt64& nUHyper, 723*cdf0e10cSrcweir float& fFloat, double& fDouble, 724*cdf0e10cSrcweir test::TestEnum& eEnum, rtl::OUString& rStr, 725*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xTest, 726*cdf0e10cSrcweir ::com::sun::star::uno::Any& rAny, 727*cdf0e10cSrcweir ::com::sun::star::uno::Sequence<test::TestElement >& rSequence, 728*cdf0e10cSrcweir test::TestData& rStruct ) 729*cdf0e10cSrcweir throw(com::sun::star::uno::RuntimeException) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir bBool = _aData.Bool; 732*cdf0e10cSrcweir cChar = _aData.Char; 733*cdf0e10cSrcweir nByte = _aData.Byte; 734*cdf0e10cSrcweir nShort = _aData.Short; 735*cdf0e10cSrcweir nUShort = _aData.UShort; 736*cdf0e10cSrcweir nLong = _aData.Long; 737*cdf0e10cSrcweir nULong = _aData.ULong; 738*cdf0e10cSrcweir nHyper = _aData.Hyper; 739*cdf0e10cSrcweir nUHyper = _aData.UHyper; 740*cdf0e10cSrcweir fFloat = _aData.Float; 741*cdf0e10cSrcweir fDouble = _aData.Double; 742*cdf0e10cSrcweir eEnum = _aData.Enum; 743*cdf0e10cSrcweir rStr = _aData.String; 744*cdf0e10cSrcweir xTest = _aData.Interface; 745*cdf0e10cSrcweir rAny = _aData.Any; 746*cdf0e10cSrcweir rSequence = _aData.Sequence; 747*cdf0e10cSrcweir rStruct = _aStructData; 748*cdf0e10cSrcweir return _aStructData; 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir //================================================================================================== 752*cdf0e10cSrcweir sal_Bool performTest( const Reference<XLanguageBindingTest > & xLBT ) 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir OSL_ENSURE( xLBT.is(), "### no test interface!" ); 755*cdf0e10cSrcweir if (xLBT.is()) 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir // this data is never ever granted access to by calls other than equals(), assign()! 758*cdf0e10cSrcweir test::TestData aData; // test against this data 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir Reference<XInterface > xI( *new OWeakObject() ); 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir assign( (test::TestElement &)aData, 763*cdf0e10cSrcweir sal_True, '@', 17, 0x1234, 0xfedc, 0x12345678, 0xfedcba98, 764*cdf0e10cSrcweir SAL_CONST_INT64(0x123456789abcdef0), 765*cdf0e10cSrcweir SAL_CONST_UINT64(0xfedcba9876543210), 766*cdf0e10cSrcweir (float)17.0815, 3.1415926359, TestEnum_LOLA, OUString::createFromAscii("dumdidum"), xI, 767*cdf0e10cSrcweir Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) ); 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir OSL_ENSURE( aData.Any == xI, "### unexpected any!" ); 770*cdf0e10cSrcweir OSL_ENSURE( !(aData.Any != xI), "### unexpected any!" ); 771*cdf0e10cSrcweir 772*cdf0e10cSrcweir aData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aData, 1 ); 773*cdf0e10cSrcweir // aData complete 774*cdf0e10cSrcweir //================================================================================ 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir // this is a manually copy of aData for first setting... 777*cdf0e10cSrcweir test::TestData aSetData; 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir assign( (test::TestElement &)aSetData, 780*cdf0e10cSrcweir aData.Bool, aData.Char, aData.Byte, aData.Short, aData.UShort, 781*cdf0e10cSrcweir aData.Long, aData.ULong, aData.Hyper, aData.UHyper, aData.Float, aData.Double, 782*cdf0e10cSrcweir aData.Enum, aData.String, xI, 783*cdf0e10cSrcweir Any( &xI, ::getCppuType( (const Reference<XInterface > *)0 ) ) ); 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir aSetData.Sequence = Sequence<test::TestElement >( (const test::TestElement *)&aSetData, 1 ); 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir xLBT->setValues( 788*cdf0e10cSrcweir aSetData.Bool, aSetData.Char, aSetData.Byte, aSetData.Short, aSetData.UShort, 789*cdf0e10cSrcweir aSetData.Long, aSetData.ULong, aSetData.Hyper, aSetData.UHyper, aSetData.Float, aSetData.Double, 790*cdf0e10cSrcweir aSetData.Enum, aSetData.String, aSetData.Interface, aSetData.Any, aSetData.Sequence, aSetData ); 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir test::TestData aRet, aRet2; 794*cdf0e10cSrcweir xLBT->getValues( 795*cdf0e10cSrcweir aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort, 796*cdf0e10cSrcweir aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double, 797*cdf0e10cSrcweir aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 ); 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) ); 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir // set last retrieved values 802*cdf0e10cSrcweir test::TestData aSV2ret = xLBT->setValues2( 803*cdf0e10cSrcweir aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort, 804*cdf0e10cSrcweir aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double, 805*cdf0e10cSrcweir aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 ); 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir OSL_ASSERT( equals( aData, aSV2ret ) && equals( aData, aRet2 ) ); 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir test::TestData aRet, aRet2; 811*cdf0e10cSrcweir test::TestData aGVret = xLBT->getValues( 812*cdf0e10cSrcweir aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort, 813*cdf0e10cSrcweir aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double, 814*cdf0e10cSrcweir aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 ); 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir OSL_ASSERT( equals( aData, aRet ) && equals( aData, aRet2 ) && equals( aData, aGVret ) ); 817*cdf0e10cSrcweir 818*cdf0e10cSrcweir // set last retrieved values 819*cdf0e10cSrcweir xLBT->setBool( aRet.Bool ); 820*cdf0e10cSrcweir xLBT->setChar( aRet.Char ); 821*cdf0e10cSrcweir xLBT->setByte( aRet.Byte ); 822*cdf0e10cSrcweir xLBT->setShort( aRet.Short ); 823*cdf0e10cSrcweir xLBT->setUShort( aRet.UShort ); 824*cdf0e10cSrcweir xLBT->setLong( aRet.Long ); 825*cdf0e10cSrcweir xLBT->setULong( aRet.ULong ); 826*cdf0e10cSrcweir xLBT->setHyper( aRet.Hyper ); 827*cdf0e10cSrcweir xLBT->setUHyper( aRet.UHyper ); 828*cdf0e10cSrcweir xLBT->setFloat( aRet.Float ); 829*cdf0e10cSrcweir xLBT->setDouble( aRet.Double ); 830*cdf0e10cSrcweir xLBT->setEnum( aRet.Enum ); 831*cdf0e10cSrcweir xLBT->setString( aRet.String ); 832*cdf0e10cSrcweir xLBT->setInterface( aRet.Interface ); 833*cdf0e10cSrcweir xLBT->setAny( aRet.Any ); 834*cdf0e10cSrcweir xLBT->setSequence( aRet.Sequence ); 835*cdf0e10cSrcweir xLBT->setStruct( aRet2 ); 836*cdf0e10cSrcweir } 837*cdf0e10cSrcweir { 838*cdf0e10cSrcweir test::TestData aRet, aRet2; 839*cdf0e10cSrcweir aRet.Hyper = xLBT->getHyper(); 840*cdf0e10cSrcweir aRet.UHyper = xLBT->getUHyper(); 841*cdf0e10cSrcweir aRet.Float = xLBT->getFloat(); 842*cdf0e10cSrcweir aRet.Double = xLBT->getDouble(); 843*cdf0e10cSrcweir aRet.Byte = xLBT->getByte(); 844*cdf0e10cSrcweir aRet.Char = xLBT->getChar(); 845*cdf0e10cSrcweir aRet.Bool = xLBT->getBool(); 846*cdf0e10cSrcweir aRet.Short = xLBT->getShort(); 847*cdf0e10cSrcweir aRet.UShort = xLBT->getUShort(); 848*cdf0e10cSrcweir aRet.Long = xLBT->getLong(); 849*cdf0e10cSrcweir aRet.ULong = xLBT->getULong(); 850*cdf0e10cSrcweir aRet.Enum = xLBT->getEnum(); 851*cdf0e10cSrcweir aRet.String = xLBT->getString(); 852*cdf0e10cSrcweir aRet.Interface = xLBT->getInterface(); 853*cdf0e10cSrcweir aRet.Any = xLBT->getAny(); 854*cdf0e10cSrcweir aRet.Sequence = xLBT->getSequence(); 855*cdf0e10cSrcweir aRet2 = xLBT->getStruct(); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir return (equals( aData, aRet ) && equals( aData, aRet2 )); 858*cdf0e10cSrcweir } 859*cdf0e10cSrcweir } 860*cdf0e10cSrcweir return sal_False; 861*cdf0e10cSrcweir } 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir //__________________________________________________________________________________________________ 864*cdf0e10cSrcweir test::TestData Test_Impl::raiseException( sal_Bool& /*bBool*/, sal_Unicode& /*cChar*/, sal_Int8& /*nByte*/, sal_Int16& /*nShort*/, sal_uInt16& /*nUShort*/, sal_Int32& /*nLong*/, sal_uInt32& /*nULong*/, sal_Int64& /*nHyper*/, sal_uInt64& /*nUHyper*/, float& /*fFloat*/, double& /*fDouble*/, test::TestEnum& /*eEnum*/, ::rtl::OUString& /*aString*/, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& /*xInterface*/, ::com::sun::star::uno::Any& /*aAny*/, ::com::sun::star::uno::Sequence< test::TestElement >& /*aSequence*/, test::TestData& /*aStruct*/ ) 865*cdf0e10cSrcweir throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 866*cdf0e10cSrcweir { 867*cdf0e10cSrcweir IllegalArgumentException aExc; 868*cdf0e10cSrcweir aExc.ArgumentPosition = 5; 869*cdf0e10cSrcweir aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum..."); 870*cdf0e10cSrcweir aExc.Context = *this; 871*cdf0e10cSrcweir throw aExc; 872*cdf0e10cSrcweir } 873*cdf0e10cSrcweir //__________________________________________________________________________________________________ 874*cdf0e10cSrcweir sal_Int32 Test_Impl::getRuntimeException() throw(::com::sun::star::uno::RuntimeException) 875*cdf0e10cSrcweir { 876*cdf0e10cSrcweir RuntimeException aExc; 877*cdf0e10cSrcweir aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum..."); 878*cdf0e10cSrcweir aExc.Context = *this; 879*cdf0e10cSrcweir throw aExc; 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir //__________________________________________________________________________________________________ 882*cdf0e10cSrcweir void Test_Impl::setRuntimeException( sal_Int32 /*_runtimeexception*/ ) throw(::com::sun::star::uno::RuntimeException) 883*cdf0e10cSrcweir { 884*cdf0e10cSrcweir RuntimeException aExc; 885*cdf0e10cSrcweir aExc.Message = OUString::createFromAscii("dum dum dum ich tanz im kreis herum..."); 886*cdf0e10cSrcweir aExc.Context = *this; 887*cdf0e10cSrcweir throw aExc; 888*cdf0e10cSrcweir } 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir //================================================================================================== 891*cdf0e10cSrcweir sal_Bool raiseException( const Reference<XLanguageBindingTest > & xLBT ) 892*cdf0e10cSrcweir { 893*cdf0e10cSrcweir try 894*cdf0e10cSrcweir { 895*cdf0e10cSrcweir try 896*cdf0e10cSrcweir { 897*cdf0e10cSrcweir try 898*cdf0e10cSrcweir { 899*cdf0e10cSrcweir test::TestData aRet, aRet2; 900*cdf0e10cSrcweir xLBT->raiseException( 901*cdf0e10cSrcweir aRet.Bool, aRet.Char, aRet.Byte, aRet.Short, aRet.UShort, 902*cdf0e10cSrcweir aRet.Long, aRet.ULong, aRet.Hyper, aRet.UHyper, aRet.Float, aRet.Double, 903*cdf0e10cSrcweir aRet.Enum, aRet.String, aRet.Interface, aRet.Any, aRet.Sequence, aRet2 ); 904*cdf0e10cSrcweir return sal_False; 905*cdf0e10cSrcweir } 906*cdf0e10cSrcweir catch (IllegalArgumentException aExc) 907*cdf0e10cSrcweir { 908*cdf0e10cSrcweir OSL_ENSURE( aExc.ArgumentPosition == 5 && 909*cdf0e10cSrcweir // aExc.Context == xLBT && 910*cdf0e10cSrcweir aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")), 911*cdf0e10cSrcweir "### unexpected exception content!" ); 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir Reference<XLanguageBindingTest > xLBT2( 914*cdf0e10cSrcweir Reference<XLanguageBindingTest >::query( aExc.Context ) ); 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir OSL_ENSURE( xLBT2.is(), "### unexpected source of exception!" ); 917*cdf0e10cSrcweir if (xLBT2.is()) 918*cdf0e10cSrcweir xLBT2->getRuntimeException(); 919*cdf0e10cSrcweir else 920*cdf0e10cSrcweir return sal_False; 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir } 923*cdf0e10cSrcweir catch (const RuntimeException & rExc) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir OSL_ENSURE(//rExc.Context == xLBT && 926*cdf0e10cSrcweir rExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")), 927*cdf0e10cSrcweir "### unexpected exception content!" ); 928*cdf0e10cSrcweir 929*cdf0e10cSrcweir Reference<XLanguageBindingTest > xLBT2( 930*cdf0e10cSrcweir Reference<XLanguageBindingTest >::query( rExc.Context ) ); 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir OSL_ENSURE( xLBT2.is(), "### unexpected source of exception!" ); 933*cdf0e10cSrcweir if (xLBT2.is()) 934*cdf0e10cSrcweir xLBT2->setRuntimeException( 0xcafebabe ); 935*cdf0e10cSrcweir else 936*cdf0e10cSrcweir return sal_False; 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir catch (Exception & aExc) 940*cdf0e10cSrcweir { 941*cdf0e10cSrcweir OSL_ENSURE( //aExc.Context == xLBT && 942*cdf0e10cSrcweir aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum...")), 943*cdf0e10cSrcweir "### unexpected exception content!" ); 944*cdf0e10cSrcweir return (//aExc.Context == xLBT && 945*cdf0e10cSrcweir aExc.Message.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("dum dum dum ich tanz im kreis herum..."))); 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir return sal_False; 948*cdf0e10cSrcweir } 949*cdf0e10cSrcweir 950*cdf0e10cSrcweir //================================================================================================== 951*cdf0e10cSrcweir static sal_Bool test_adapter( const Reference< XMultiServiceFactory > & xMgr ) 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir Reference< XInvocationAdapterFactory > xAdapFac( 954*cdf0e10cSrcweir xMgr->createInstance( OUString::createFromAscii("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY ); 955*cdf0e10cSrcweir Reference< XInvocationAdapterFactory2 > xAdapFac2( xAdapFac, UNO_QUERY_THROW ); 956*cdf0e10cSrcweir 957*cdf0e10cSrcweir Reference< XLanguageBindingTest > xOriginal( (XLanguageBindingTest *)new Test_Impl() ); 958*cdf0e10cSrcweir Reference< XInvocation > xInvok( new XLB_Invocation( xMgr, xOriginal ) ); 959*cdf0e10cSrcweir Reference< XLanguageBindingTest > xLBT( xAdapFac->createAdapter( 960*cdf0e10cSrcweir xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY ); 961*cdf0e10cSrcweir Reference< XLanguageBindingTest > xLBT2( 962*cdf0e10cSrcweir xAdapFac->createAdapter( 963*cdf0e10cSrcweir xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY ); 964*cdf0e10cSrcweir if (xLBT != xLBT2) 965*cdf0e10cSrcweir return sal_False; 966*cdf0e10cSrcweir Reference< XInterface > xLBT3( 967*cdf0e10cSrcweir xAdapFac->createAdapter( 968*cdf0e10cSrcweir xInvok, ::getCppuType( (const Reference< XInterface > *)0 ) ), UNO_QUERY ); 969*cdf0e10cSrcweir if (xLBT != xLBT3) 970*cdf0e10cSrcweir return sal_False; 971*cdf0e10cSrcweir Type ar[ 2 ] = { 972*cdf0e10cSrcweir ::getCppuType( (const Reference< XLBTestBase > *)0 ), 973*cdf0e10cSrcweir ::getCppuType( (const Reference< XInterface > *)0 ) }; 974*cdf0e10cSrcweir Reference< XInterface > xLBT4( 975*cdf0e10cSrcweir xAdapFac2->createAdapter( xInvok, Sequence< Type >( ar, 2 ) ), UNO_QUERY ); 976*cdf0e10cSrcweir if (xLBT != xLBT4) 977*cdf0e10cSrcweir return sal_False; 978*cdf0e10cSrcweir Reference< XSimpleRegistry > xInvalidAdapter( 979*cdf0e10cSrcweir xAdapFac->createAdapter( 980*cdf0e10cSrcweir xInvok, ::getCppuType( (const Reference< XSimpleRegistry > *)0 ) ), UNO_QUERY ); 981*cdf0e10cSrcweir if (xLBT == xInvalidAdapter) 982*cdf0e10cSrcweir return sal_False; 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir try 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir xInvalidAdapter->isValid(); 987*cdf0e10cSrcweir return sal_False; 988*cdf0e10cSrcweir } 989*cdf0e10cSrcweir catch (RuntimeException &) 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir } 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir return (performTest( xLBT ) && raiseException( xLBT )); 994*cdf0e10cSrcweir } 995*cdf0e10cSrcweir //================================================================================================== 996*cdf0e10cSrcweir static sal_Bool test_invocation( const Reference< XMultiServiceFactory > & xMgr ) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir Reference< XInvocationAdapterFactory > xAdapFac( 999*cdf0e10cSrcweir xMgr->createInstance( OUString::createFromAscii("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY ); 1000*cdf0e10cSrcweir Reference< XSingleServiceFactory > xInvocFac( 1001*cdf0e10cSrcweir xMgr->createInstance( OUString::createFromAscii("com.sun.star.script.Invocation") ), UNO_QUERY ); 1002*cdf0e10cSrcweir 1003*cdf0e10cSrcweir Reference< XLanguageBindingTest > xOriginal( (XLanguageBindingTest *)new Test_Impl() ); 1004*cdf0e10cSrcweir Any aOriginal( &xOriginal, ::getCppuType( &xOriginal ) ); 1005*cdf0e10cSrcweir Reference< XInvocation > xInvok( 1006*cdf0e10cSrcweir xInvocFac->createInstanceWithArguments( Sequence< Any >( &aOriginal, 1 ) ), UNO_REF_QUERY ); 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir Reference< XLanguageBindingTest > xLBT( xAdapFac->createAdapter( 1009*cdf0e10cSrcweir xInvok, ::getCppuType( (const Reference< XLanguageBindingTest > *)0 ) ), UNO_QUERY ); 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir return (performTest( xLBT ) && raiseException( xLBT )); 1012*cdf0e10cSrcweir } 1013*cdf0e10cSrcweir 1014*cdf0e10cSrcweir SAL_IMPLEMENT_MAIN() 1015*cdf0e10cSrcweir { 1016*cdf0e10cSrcweir Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory( 1017*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("stoctest.rdb") ) ) ); 1018*cdf0e10cSrcweir 1019*cdf0e10cSrcweir try 1020*cdf0e10cSrcweir { 1021*cdf0e10cSrcweir Reference< XImplementationRegistration > xImplReg( 1022*cdf0e10cSrcweir xMgr->createInstance( 1023*cdf0e10cSrcweir OUString( 1024*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM( 1025*cdf0e10cSrcweir "com.sun.star.registry.ImplementationRegistration") ) ), 1026*cdf0e10cSrcweir UNO_QUERY ); 1027*cdf0e10cSrcweir OSL_ENSURE( xImplReg.is(), "### no impl reg!" ); 1028*cdf0e10cSrcweir 1029*cdf0e10cSrcweir xImplReg->registerImplementation( 1030*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), 1031*cdf0e10cSrcweir OUString::createFromAscii("invocadapt.uno" SAL_DLLEXTENSION), 1032*cdf0e10cSrcweir Reference< XSimpleRegistry >() ); 1033*cdf0e10cSrcweir xImplReg->registerImplementation( 1034*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), 1035*cdf0e10cSrcweir OUString::createFromAscii("stocservices.uno" SAL_DLLEXTENSION), 1036*cdf0e10cSrcweir Reference< XSimpleRegistry >() ); 1037*cdf0e10cSrcweir xImplReg->registerImplementation( 1038*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), 1039*cdf0e10cSrcweir OUString::createFromAscii("invocation.uno" SAL_DLLEXTENSION), 1040*cdf0e10cSrcweir Reference< XSimpleRegistry >() ); 1041*cdf0e10cSrcweir xImplReg->registerImplementation( 1042*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), 1043*cdf0e10cSrcweir OUString::createFromAscii("reflection.uno" SAL_DLLEXTENSION), 1044*cdf0e10cSrcweir Reference< XSimpleRegistry >() ); 1045*cdf0e10cSrcweir xImplReg->registerImplementation( 1046*cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), 1047*cdf0e10cSrcweir OUString::createFromAscii("introspection.uno" SAL_DLLEXTENSION), 1048*cdf0e10cSrcweir Reference< XSimpleRegistry >() ); 1049*cdf0e10cSrcweir 1050*cdf0e10cSrcweir if (test_adapter( xMgr )) 1051*cdf0e10cSrcweir { 1052*cdf0e10cSrcweir fprintf( stderr, "> test_iadapter() succeeded.\n" ); 1053*cdf0e10cSrcweir if (test_invocation( xMgr )) 1054*cdf0e10cSrcweir { 1055*cdf0e10cSrcweir fprintf( stderr, "> test_invocation() succeeded.\n" ); 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir } 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir catch (Exception & rExc) 1060*cdf0e10cSrcweir { 1061*cdf0e10cSrcweir fprintf( stderr, "> exception occured: " ); 1062*cdf0e10cSrcweir OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); 1063*cdf0e10cSrcweir fprintf( stderr, "%s\n", aMsg.getStr() ); 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir 1066*cdf0e10cSrcweir Reference< XComponent >( xMgr, UNO_QUERY )->dispose(); 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir return 0; 1069*cdf0e10cSrcweir } 1070