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