Update ooo320-m1
[ooovba.git] / extensions / test / ole / OleClient / clientTest.cxx
blob53056b9ca05f5357dddef335a70803282ba4b33d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: clientTest.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
34 #include <atlbase.h>
36 CComModule _Module;
37 #include<atlcom.h>
38 #include <comdef.h>
40 #include "axhost.hxx"
42 #include <stdio.h>
43 #include "typelib/typedescription.hxx"
44 #include <com/sun/star/bridge/oleautomation/Date.hpp>
45 #include <com/sun/star/bridge/oleautomation/Currency.hpp>
46 #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
47 #include <com/sun/star/bridge/oleautomation/SCode.hpp>
48 #include <com/sun/star/bridge/oleautomation/NamedArgument.hpp>
49 #include <com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp>
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #include <com/sun/star/script/XInvocation.hpp>
52 //#include <oletest/XCallback.hpp>
53 #include <com/sun/star/uno/Reference.h>
54 #include <cppuhelper/servicefactory.hxx>
55 #include <rtl/string.h>
57 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
58 BEGIN_OBJECT_MAP(ObjectMap)
59 END_OBJECT_MAP()
61 using namespace com::sun::star::lang;
62 using namespace com::sun::star::uno;
63 using namespace com::sun::star::script;
64 using namespace com::sun::star::bridge::oleautomation;
65 using namespace cppu;
66 using namespace rtl;
70 Reference<XInvocation> convertComObject( IUnknown* pUnk);
71 Reference<XInvocation> getComObject( OUString progId);
72 bool checkOutArgs(const Sequence<Any> & outArgs,
73 const Sequence<sal_Int16> & indices, const Sequence<Any> & values);
75 bool doSimpleTest(const Reference<XInvocation> & inv);
76 bool doSimpleSequenceTest(const Reference<XInvocation> & inv);
77 bool doParameterTest(const Reference<XInvocation> & inv);
78 bool doPropertyWithArgumentTest(const Reference<XInvocation> & inv);
79 bool equalSequences(const Any& orig, const Any& returned);
80 HRESULT doTest();
81 HRESULT doTest2( Reference<XInvocation> &);
82 Reference<XInvocation> getComObject(OUString& );
84 HRESULT InitializeParameter();
85 void printResultVariantArray( VARIANT & var);
86 void printVariant( VARIANT & var);
87 void printSequence( Sequence<Any>& val);
89 extern "C" int __cdecl main( int , char **)
91 HRESULT hr;
92 if( FAILED( hr=CoInitialize(NULL)))
94 _tprintf(_T("CoInitialize failed \n"));
95 return -1;
99 _Module.Init( ObjectMap, GetModuleHandle( NULL));
101 if( FAILED(hr=doTest()))
103 _com_error err( hr);
104 const TCHAR * errMsg= err.ErrorMessage();
105 MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
107 else
109 MessageBox( NULL,NULL , "Test succeeded", MB_ICONINFORMATION);
113 _Module.Term();
114 CoUninitialize();
115 return 0;
117 //Also supports named args
119 bool doParameterTest(const Reference<XInvocation> & inv)
121 Sequence< sal_Int16> seqIndices;
122 Sequence<Any> seqOut;
124 Any arArgs[2];
125 Any arValue[2];
126 Any arArgs1[4];
128 NamedArgument arg1(OUString(L"val1"), makeAny((sal_Int32) 123));
129 NamedArgument arg2(OUString(L"val2"), makeAny((sal_Int32) 456));
130 NamedArgument arg3(OUString(L"val3"), makeAny((sal_Int32) 0xff));
131 NamedArgument arg4(OUString(L"val4"), makeAny((sal_Int32) 0xffff));
133 NamedArgument argOut1(OUString(L"val1"), Any());
134 NamedArgument argOut2(OUString(L"val2"), Any());
135 Sequence<Any> seqNoArgs;
136 arArgs[0] <<= (sal_Int32) 0;
137 arArgs[1] <<= (sal_Int32) 0;
138 Sequence<Any> seqPositional0(arArgs, 2);
141 arArgs[0] <<= arg1;
142 arArgs[1] <<= arg2;
143 Sequence<Any> seqNamed(arArgs, 2);
144 arArgs[0] <<= arg2;
145 arArgs[1] <<= arg1;
146 Sequence<Any> seqNamed2(arArgs, 2);
147 arArgs[0] <<= argOut1;
148 arArgs[1] <<= argOut2;
149 Sequence<Any> seqNamed3(arArgs, 2);
150 arArgs[0] <<= argOut2;
151 arArgs[1] <<= argOut1;
152 Sequence<Any> seqNamed4(arArgs, 2);
154 arArgs[0] <<= arg1;
155 Sequence<Any> seqNamed5(arArgs, 1);
156 arArgs[0] <<= arg2;
157 Sequence<Any> seqNamed6(arArgs, 1);
159 arArgs[0] <<= (sal_Int32) 123;
160 arArgs[1] <<= (sal_Int32) 456;
161 Sequence<Any> seqPositional(arArgs, 2);
162 arArgs[0] <<= (sal_Int32) 123;
163 Sequence<Any> seqPositional2(arArgs, 1);
165 arArgs[0] <<= Any();
166 arArgs[1] <<= Any();
167 Sequence<Any> seqPositional3(arArgs, 2);
169 arArgs[0] <<= (sal_Int32) 123;
170 arArgs[1] <<= SCode(DISP_E_PARAMNOTFOUND);
171 Sequence<Any> seqOutOpt1(arArgs, 2);
173 arArgs[0] <<= SCode(DISP_E_PARAMNOTFOUND);
174 arArgs[1] <<= SCode(DISP_E_PARAMNOTFOUND);
175 Sequence<Any> seqOutOpt2(arArgs, 2);
177 arArgs[0] <<= SCode(DISP_E_PARAMNOTFOUND);
178 arArgs[1] <<= (sal_Int32) 456;
179 Sequence<Any> seqOutOpt3(arArgs, 2);
181 arArgs1[0] <<= (sal_Int32) 0;
182 arArgs1[1] <<= (sal_Int32) 0;
183 arArgs1[2] <<= (sal_Int32) 0;
184 arArgs1[3] <<= (sal_Int32) 0;
185 Sequence<Any> seqMix0(arArgs1, 4);
187 arArgs1[0] <<= (sal_Int32) 123;
188 arArgs1[1] <<= (sal_Int32) 456;
189 arArgs1[2] <<= arg3;
190 arArgs1[3] <<= arg4;
191 Sequence<Any> seqMix(arArgs1, 4);
193 arArgs1[0] <<= Any();
194 arArgs1[1] <<= (sal_Int32) 456;
195 arArgs1[2] <<= arg4;
196 Sequence<Any> seqMix2(arArgs1, 3);
198 arArgs1[0] <<= SCode(DISP_E_PARAMNOTFOUND);
199 arArgs1[1] <<= (sal_Int32) 456;
200 arArgs1[2] <<= SCode(DISP_E_PARAMNOTFOUND);
201 arArgs1[3] <<= arg4.Value;
202 Sequence<Any> seqMixOut(arArgs1, 4);
204 arArgs1[0] <<= SCode(DISP_E_PARAMNOTFOUND);
205 arArgs1[1] <<= Any();
206 arArgs1[2] <<= arg4;
207 Sequence<Any> seqMix2Out(arArgs1, 3);
211 //in args + out, optional, positional-----------------------------------------
212 //first general test
213 seqIndices.realloc(0);
214 seqOut.realloc(0);
215 inv->invoke(OUString(L"optional3"), seqPositional, seqIndices, seqOut);
216 seqIndices.realloc(0);
217 seqOut.realloc(0);
218 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
219 if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
220 return false;
222 //2 optional args, 1 provided
223 seqIndices.realloc(0);
224 seqOut.realloc(0);
225 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
226 seqIndices.realloc(0);
227 seqOut.realloc(0);
228 inv->invoke(OUString(L"optional3"), seqPositional2, seqIndices, seqOut);
229 seqIndices.realloc(0);
230 seqOut.realloc(0);
231 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
232 if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt1))
233 return false;
235 //2 optional args, 0 provided
236 seqIndices.realloc(0);
237 seqOut.realloc(0);
238 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
239 seqIndices.realloc(0);
240 seqOut.realloc(0);
241 inv->invoke(OUString(L"optional3"), seqNoArgs, seqIndices, seqOut);
242 seqIndices.realloc(0);
243 seqOut.realloc(0);
244 inv->invoke(OUString(L"optional5"), seqPositional3, seqIndices, seqOut);
245 if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt2))
246 return false;
248 //named args --------------------------------------------
250 // 2 named args, correct position
251 seqIndices.realloc(0);
252 seqOut.realloc(0);
253 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
254 seqIndices.realloc(0);
255 seqOut.realloc(0);
256 inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
257 seqIndices.realloc(0);
258 seqOut.realloc(0);
259 inv->invoke(OUString(L"optional5"), seqPositional0, seqIndices, seqOut);
260 if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
261 return false;
263 // 2named args, position differs
264 seqIndices.realloc(0);
265 seqOut.realloc(0);
266 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
267 seqIndices.realloc(0);
268 seqOut.realloc(0);
269 inv->invoke(OUString(L"optional3"), seqNamed2, seqIndices, seqOut);
270 seqIndices.realloc(0);
271 seqOut.realloc(0);
272 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
273 if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
274 return false;
276 //named out args, 2 named args with correct position
277 seqIndices.realloc(0);
278 seqOut.realloc(0);
279 inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
280 seqIndices.realloc(0);
281 seqIndices.realloc(0);
282 inv->invoke(OUString(L"optional5"), seqNamed3, seqIndices, seqOut);
283 if ( ! checkOutArgs(seqOut, seqIndices, seqNamed ))
284 return false;
286 //named out args, 2 named args with different position
287 seqIndices.realloc(0);
288 seqOut.realloc(0);
289 inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
290 seqIndices.realloc(0);
291 seqIndices.realloc(0);
292 inv->invoke(OUString(L"optional5"), seqNamed4, seqIndices, seqOut);
293 if ( ! checkOutArgs(seqOut, seqIndices, seqNamed2 ))
294 return false;
297 //2 args, 1 provided (correct order)
298 seqIndices.realloc(0);
299 seqOut.realloc(0);
300 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
301 seqIndices.realloc(0);
302 seqOut.realloc(0);
303 inv->invoke(OUString(L"optional3"), seqNamed5, seqIndices, seqOut);
304 seqIndices.realloc(0);
305 seqOut.realloc(0);
306 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
307 if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt1))
308 return false;
309 //2 args, 1 provided (incorrect order)
310 seqIndices.realloc(0);
311 seqOut.realloc(0);
312 inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
313 seqIndices.realloc(0);
314 seqOut.realloc(0);
315 inv->invoke(OUString(L"optional3"), seqNamed6, seqIndices, seqOut);
316 seqIndices.realloc(0);
317 seqOut.realloc(0);
318 inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
319 if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt3))
320 return false;
322 //2position + 2 2named args, correct order
323 seqIndices.realloc(0);
324 seqOut.realloc(0);
325 inv->invoke(OUString(L"optional6"), seqMix0, seqIndices, seqOut);
326 seqIndices.realloc(0);
327 seqOut.realloc(0);
328 inv->invoke(OUString(L"optional6"), seqMix, seqIndices, seqOut);
329 seqIndices.realloc(0);
330 seqOut.realloc(0);
331 inv->invoke(OUString(L"optional7"), seqMix, seqIndices, seqOut);
332 if ( ! checkOutArgs(seqOut, seqIndices, seqMix))
333 return false;
335 // 4 in args, 1 positional, 1 named, 1 positional omitted
336 seqIndices.realloc(0);
337 seqOut.realloc(0);
338 inv->invoke(OUString(L"optional6"), seqMix0, seqIndices, seqOut);
339 seqIndices.realloc(0);
340 seqOut.realloc(0);
341 inv->invoke(OUString(L"optional6"), seqMix2, seqIndices, seqOut);
342 seqIndices.realloc(0);
343 seqOut.realloc(0);
344 inv->invoke(OUString(L"optional7"), seqMix0, seqIndices, seqOut);
345 if ( ! checkOutArgs(seqOut, seqIndices, seqMixOut))
346 return false;
348 // 4 out args, 1 positional, 1 named, 1 positional omitted
349 seqIndices.realloc(0);
350 seqOut.realloc(0);
351 inv->invoke(OUString(L"optional6"), seqMix2, seqIndices, seqOut);
352 seqIndices.realloc(0);
353 seqOut.realloc(0);
354 inv->invoke(OUString(L"optional7"), seqMix2Out, seqIndices, seqOut);
355 if ( ! checkOutArgs(seqOut, seqIndices, seqMix2Out))
356 return false;
359 return true;
361 bool doPropertyTest(const Reference<XInvocation> & inv)
363 Sequence< sal_Int16> seqIndices;
364 Sequence<Any> seqOut;
366 Any inBool, outBool;
367 Any inByte, outByte;
368 Any inShort, outShort;
369 Any inLong, outLong;
370 Any inString, outString;
371 Any inFloat, outFloat;
372 Any inDouble, outDouble;
373 Any inVariant, outVariant;
374 Any inObject, outObject;
375 Any inUnknown, outUnknown;
376 Any inCY, outCY;
377 Any inDate, outDate;
378 Any inDecimal, outDecimal;
379 Any inSCode, outSCode;
380 Any inrefLong, outrefLong;
381 Any inrefVariant, outrefVariant;
382 Any inrefDecimal, outrefDecimal;
383 Any inParamsLong, outParamsLong;
384 Reference<XInterface> xintUnknown(getComObject(L"AxTestComponents.Foo"));
386 inBool <<= (sal_Bool) sal_True;
387 inv->setValue(OUString(L"prpBool"), inBool);
388 outBool = inv->getValue(OUString(L"prpBool"));
390 inByte <<= (sal_Int8) 100;
391 inv->setValue(OUString(L"prpByte"), inByte);
392 outByte = inv->getValue(OUString(L"prpByte"));
394 inShort <<= static_cast<sal_Int16>( -1);
395 inv->setValue(OUString(L"prpShort"), inShort);
396 outShort = inv->getValue(OUString(L"prpShort"));
398 inLong <<= ( sal_Int32) 1234567;
399 inv->setValue(OUString(L"prpLong"), inLong // TODO: Add your implementation code here
401 outLong = inv->getValue(OUString(L"prpLong"));
403 inString <<= OUString(L" this is clientTest.exe");
404 inv->setValue(OUString(L"prpString"), inString);
405 outString = inv->getValue(OUString(L"prpString"));
407 inFloat <<= 3.14f;
408 inv->setValue(OUString(L"prpFloat"), inFloat);
409 outFloat = inv->getValue(OUString(L"prpFloat"));
411 inDouble <<= ( double) 3.145;
412 inv->setValue(OUString(L"prpDouble"), inDouble);
413 outDouble = inv->getValue(OUString(L"prpDouble"));
415 inVariant <<= OUString(L"A string in an any");
416 inv->setValue(OUString(L"prpVariant"), inVariant);
417 outVariant = inv->getValue(OUString(L"prpVariant"));
419 inObject <<= inv;
420 inv->setValue(OUString(L"prpObject"), inObject);
421 outObject = inv->getValue(OUString(L"prpObject"));
423 inUnknown <<= xintUnknown;
424 inv->setValue(OUString(L"prpUnknown"), inUnknown);
425 outUnknown = inv->getValue(OUString(L"prpUnknown"));
427 Currency cur(99999);
428 inCY <<= cur;
429 inv->setValue(OUString(L"prpCurrency"), inCY);
430 outCY = inv->getValue(OUString(L"prpCurrency"));
432 Date d(37889.0);
433 inDate <<= d;
434 inv->setValue(OUString(L"prpDate"), inDate);
435 outDate = inv->getValue(OUString(L"prpDate"));
437 Decimal dec(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff);
438 inDecimal <<= dec;
439 inv->setValue(OUString(L"prpDecimal"), inDecimal);
440 outDecimal = inv->getValue(OUString(L"prpDecimal"));
442 SCode code(DISP_E_BADVARTYPE);
443 inSCode <<= code;
444 inv->setValue(OUString(L"prpSCode"), inSCode);
445 outSCode = inv->getValue(OUString(L"prpSCode"));
447 inrefLong <<= (sal_Int32) 123456;
448 inv->setValue(OUString(L"prprefLong"), inrefLong);
449 outrefLong = inv->getValue(OUString(L"prprefLong"));
451 inrefVariant <<= OUString(L"A string in an any");
452 inv->setValue(OUString(L"prprefVariant"), inrefVariant);
453 outrefVariant = inv->getValue(OUString(L"prprefVariant"));
455 Decimal decref(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff);
456 inrefDecimal <<= decref;
457 inv->setValue(OUString(L"prprefDecimal"), inrefDecimal);
458 outrefDecimal = inv->getValue(OUString(L"prprefDecimal"));
460 if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
461 || inFloat != outFloat || inDouble != outDouble || inString != outString
462 || inVariant != outVariant || inObject != outObject
463 || inUnknown != outUnknown || inCY != outCY
464 || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode
465 || inrefLong != outrefLong ||inrefVariant != outrefVariant
466 || inrefDecimal != outrefDecimal)
467 return false;
468 return true;
471 bool doPropertyWithArgumentTest(const Reference<XInvocation> & inv)
473 Sequence< sal_Int16> seqIndices;
474 Sequence<Any> seqOut;
476 Any arMultiArgs[3];
477 arMultiArgs[0] <<= makeAny((sal_Int32) 0);
478 arMultiArgs[1] <<= makeAny((sal_Int32) 0);
479 arMultiArgs[2] <<= PropertyPutArgument(makeAny((sal_Int32) 0));
480 Sequence<Any> seqMultiArgPut0(arMultiArgs, 3);
482 arMultiArgs[0] <<= makeAny((sal_Int32) 1);
483 arMultiArgs[1] <<= makeAny((sal_Int32) 2);
484 arMultiArgs[2] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
485 Sequence<Any> seqMultiArgPut1(arMultiArgs, 3);
487 arMultiArgs[0] <<= makeAny((sal_Int32) 1);
488 arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
489 Sequence<Any> seqMultiArgPut2(arMultiArgs, 2);
491 arMultiArgs[0] <<= NamedArgument(OUString(L"val2"), makeAny((sal_Int32) 1));
492 arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
493 Sequence<Any> seqMultiArgPut3(arMultiArgs, 2);
495 arMultiArgs[0] <<= NamedArgument(OUString(L"val2"), makeAny((sal_Int32) 1));
496 arMultiArgs[1] <<= NamedArgument(OUString(L"val3"), makeAny((sal_Int32) 3));
497 Sequence<Any> seqMultiArgPut4(arMultiArgs, 2);
499 arMultiArgs[0] <<= makeAny((sal_Int32) 0);
500 arMultiArgs[1] <<= makeAny((sal_Int32) 0);
501 Sequence<Any> seqMultiArgGet0(arMultiArgs, 2);
503 arMultiArgs[0] <<= makeAny((sal_Int32) 1);
504 arMultiArgs[1] <<= makeAny((sal_Int32) 2);
505 Sequence<Any> seqMultiArgGet1(arMultiArgs, 2);
506 Sequence<Any> seqMultiArgGet2(arMultiArgs, 1);
509 arMultiArgs[0] <<= makeAny((sal_Int32) 0);
510 arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 0));
511 Sequence<Any> seqMultiArgPut5(arMultiArgs, 2);
513 arMultiArgs[0] <<= makeAny((sal_Int32) 1);
514 arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 2));
515 Sequence<Any> seqMultiArgPut6(arMultiArgs, 2);
517 arMultiArgs[0] <<= Any();
518 arMultiArgs[1] <<= Any();
519 Sequence<Any> seqMultiVoid(arMultiArgs, 2);
521 arMultiArgs[0] = makeAny((sal_Int32) 0);
522 arMultiArgs[1] = makeAny((sal_Int32) 0);
523 Sequence<Any> seqMultiVoid2(arMultiArgs, 2);
525 //[propput, ...] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [in] VARIANT* newVal);
526 //[propget, ...] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [out, optional, retval] VARIANT* pVal);
527 seqIndices.realloc( 0);
528 seqOut.realloc(0);
529 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
530 seqIndices.realloc( 0);
531 seqOut.realloc(0);
532 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut1, seqIndices, seqOut);
533 //check in/out args
534 seqIndices.realloc( 0);
535 seqOut.realloc(0);
536 Any anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
537 seqIndices, seqOut);
539 if (anyRet != ((PropertyPutArgument const *)seqMultiArgPut1[2].getValue())->Value
540 || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(seqMultiArgPut1.getArray(), 2)))
542 return false;
544 // test optional (one arg omitted
545 seqIndices.realloc( 0);
546 seqOut.realloc(0);
547 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
548 seqIndices.realloc( 0);
549 seqOut.realloc(0);
550 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut2, seqIndices, seqOut);
551 seqIndices.realloc( 0);
552 seqOut.realloc(0);
553 anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
554 seqIndices, seqOut);
556 arMultiArgs[0] = makeAny((sal_Int32) 1);
557 arMultiArgs[1] = makeAny((SCode(DISP_E_PARAMNOTFOUND)));
559 if (anyRet != ((PropertyPutArgument const *) seqMultiArgPut2[1].getValue())->Value
560 || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(arMultiArgs, 2)))
562 return false;
565 //test one named arg and one omitted
566 seqIndices.realloc( 0);
567 seqOut.realloc(0);
568 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
569 seqIndices.realloc( 0);
570 seqOut.realloc(0);
571 inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut3, seqIndices, seqOut);
572 seqIndices.realloc( 0);
573 seqOut.realloc(0);
574 anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
575 seqIndices, seqOut);
577 arMultiArgs[0] = makeAny((SCode(DISP_E_PARAMNOTFOUND)));
578 arMultiArgs[1] = ((NamedArgument const*) seqMultiArgPut3[0].getValue())->Value;
579 if (anyRet != ((PropertyPutArgument const*) seqMultiArgPut3[1].getValue())->Value
580 || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(arMultiArgs, 2)))
582 return false;
585 // [propget,...] HRESULT prpMultiArg2([in] VARIANT val1, [out, retval] VARIANT* pVal);
586 // [propput,...] HRESULT prpMultiArg2([in] VARIANT val1, [in] VARIANT newVal);
587 seqIndices.realloc( 0);
588 seqOut.realloc(0);
589 inv->invoke(OUString(L"prpMultiArg2"), seqMultiArgPut5, seqIndices, seqOut);
590 seqIndices.realloc( 0);
591 seqOut.realloc(0);
592 inv->invoke(OUString(L"prpMultiArg2GetValues"), seqMultiVoid, seqIndices, seqOut);
594 if ( ! checkOutArgs(seqOut, seqIndices, seqMultiVoid2))
595 return false;
596 seqIndices.realloc( 0);
597 seqOut.realloc(0);
598 anyRet = inv->invoke(OUString(L"prpMultiArg2"), seqMultiArgPut6,
599 seqIndices, seqOut);
600 seqIndices.realloc( 0);
601 seqOut.realloc(0);
602 anyRet = inv->invoke(OUString(L"prpMultiArg2GetValues"), seqMultiVoid,
603 seqIndices, seqOut);
605 // [propget,...] HRESULT prpMultiArg3([in,out] LONG* val1, [out, retval] LONG* pVal);
606 // [propput,...] HRESULT prpMultiArg3([in,out] LONG* val1, [in] LONG newVal);
608 if ( ! checkOutArgs(seqOut, seqIndices, seqMultiArgGet1 ))
609 return false;
610 seqIndices.realloc( 0);
611 seqOut.realloc(0);
612 inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgPut5, seqIndices, seqOut);
613 seqIndices.realloc( 0);
614 seqOut.realloc(0);
615 inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgPut6, seqIndices, seqOut);
616 seqIndices.realloc( 0);
617 seqOut.realloc(0);
618 anyRet = inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgGet2, seqIndices, seqOut);
620 if ( anyRet != ((PropertyPutArgument const*) seqMultiArgPut6[1].getValue())->Value
621 || !checkOutArgs(seqOut, seqIndices, seqMultiArgGet2))
622 return false;
625 //hasProperty, hasMethod
626 if (inv->hasProperty(OUSTR("prpMultiArg1")))
627 return false;
628 if ( ! inv->hasMethod(OUSTR("prpMultiArg1")))
629 return false;
630 if ( ! inv->hasProperty(OUSTR("prprefLong")))
631 return false;
632 if (inv->hasMethod(OUSTR("prprefLong")))
633 return false;
634 if ( ! inv->hasMethod(OUSTR("inLong")))
635 return false;
637 return true;
639 bool doSimpleTest(const Reference<XInvocation> & inv)
641 Sequence< sal_Int16> seqIndices;
642 Sequence<Any> seqOut;
644 Any inBool, outBool;
645 Any inByte, outByte;
646 Any inShort, outShort;
647 Any inLong, outLong;
648 Any inString, outString;
649 Any inFloat, outFloat;
650 Any inDouble, outDouble;
651 Any inVariant, outVariant;
652 Any inObject, outObject;
653 Any inUnknown, outUnknown;
654 Any inCY, outCY;
655 Any inDate, outDate;
656 Any inDecimal, outDecimal;
657 Any inSCode, outSCode;
658 Any inrefLong, outrefLong;
659 Any inrefVariant, outrefVariant;
660 Any inrefDecimal, outrefDecimal;
662 Reference<XInterface> xIntFoo(getComObject(L"AxTestComponents.Foo"));
663 //###################################################################################
664 // in and out parameter
665 //###################################################################################
666 sal_Bool aBool = sal_True;
667 inBool.setValue(&aBool, getCppuBooleanType());
668 inv->invoke(OUString(L"inBool"), Sequence< Any > ( &inBool, 1), seqIndices, seqOut);
669 seqIndices.realloc(0);
670 seqOut.realloc(0);
671 inv->invoke(OUString(L"outBool"), Sequence< Any > ( & outBool, 1), seqIndices, seqOut);
672 outBool <<= seqOut[0];
674 inByte <<= (sal_Int8) 127;
675 inv->invoke(OUString(L"inByte"), Sequence< Any > ( & inByte, 1), seqIndices, seqOut);
676 seqIndices.realloc( 0);
677 seqOut.realloc(0);
678 inv->invoke(OUString(L"outByte"), Sequence< Any > ( & outByte, 1), seqIndices, seqOut);
679 outByte <<= seqOut[0];
681 inShort <<= static_cast<sal_Int16>(-1);
682 inv->invoke(OUString(L"inShort"), Sequence< Any > ( & inShort, 1), seqIndices, seqOut);
683 seqIndices.realloc( 0);
684 seqOut.realloc(0);
685 inv->invoke(OUString(L"outShort"), Sequence< Any > ( & outShort, 1), seqIndices, seqOut);
686 outShort <<= seqOut[0];
688 inLong <<= ( sal_Int32) 1234567;
689 inv->invoke(OUString(L"inLong"), Sequence< Any > ( & inLong, 1), seqIndices, seqOut);
690 seqIndices.realloc( 0);
691 seqOut.realloc(0);
692 inv->invoke(OUString(L"outLong"), Sequence< Any > ( & outLong, 1 ), seqIndices, seqOut);
693 outLong <<= seqOut[0];
695 inString <<= OUString(L" this is clientTest.exe");
696 inv->invoke(OUString(L"inString"), Sequence< Any > ( & inString, 1), seqIndices, seqOut);
697 seqIndices.realloc( 0);
698 seqOut.realloc(0);
699 inv->invoke(OUString(L"outString"), Sequence< Any > ( & outString, 1 ), seqIndices, seqOut);
700 outString <<= seqOut[0];
702 inFloat <<= 3.14f;
703 inv->invoke(OUString(L"inFloat"), Sequence< Any > ( & inFloat, 1), seqIndices, seqOut);
704 seqIndices.realloc( 0);
705 seqOut.realloc(0);
706 inv->invoke(OUString(L"outFloat"), Sequence< Any > ( & outFloat, 1 ), seqIndices, seqOut);
707 outFloat <<= seqOut[0];
709 inDouble <<= ( double) 3.145;
710 inv->invoke(OUString(L"inDouble"), Sequence< Any > ( & inDouble, 1), seqIndices, seqOut);
711 seqIndices.realloc( 0);
712 seqOut.realloc(0);
713 inv->invoke(OUString(L"outDouble"), Sequence< Any > ( & outDouble, 1 ), seqIndices, seqOut);
714 outDouble <<= seqOut[0];
716 inVariant <<= OUString(L" A string in an any");
717 inv->invoke(OUString(L"inVariant"), Sequence< Any > ( & inVariant, 1), seqIndices, seqOut);
718 seqIndices.realloc( 0);
719 seqOut.realloc(0);
720 inv->invoke(OUString(L"outVariant"), Sequence< Any > (&outVariant, 1), seqIndices, seqOut);
721 outVariant <<= seqOut[0];
723 inObject <<= inv;
724 inv->invoke(OUString(L"inObject"), Sequence< Any > ( & inObject, 1), seqIndices, seqOut);
725 seqIndices.realloc( 0);
726 seqOut.realloc(0);
727 inv->invoke(OUString(L"outObject"), Sequence< Any > (& outObject, 1), seqIndices, seqOut);
728 outObject <<= seqOut[0];
730 inUnknown <<= xIntFoo;
731 inv->invoke(OUString(L"inUnknown"), Sequence< Any > ( & inUnknown, 1), seqIndices, seqOut);
732 seqIndices.realloc( 0);
733 seqOut.realloc(0);
734 inv->invoke(OUString(L"outUnknown"), Sequence< Any > (& outUnknown, 1), seqIndices, seqOut);
735 outUnknown <<= seqOut[0];
737 Currency cur(999999);
738 inCY <<= cur;
739 inv->invoke(OUString(L"inCurrency"), Sequence<Any>( & inCY, 1), seqIndices, seqOut);
740 seqIndices.realloc( 0);
741 seqOut.realloc(0);
742 inv->invoke(OUString(L"outCurrency"), Sequence< Any > (& outCY, 1), seqIndices, seqOut);
743 outCY <<= seqOut[0];
745 Date dDate(37889.0);
746 inDate <<= dDate;
747 inv->invoke(OUString(L"inDate"), Sequence<Any>( & inDate, 1), seqIndices, seqOut);
748 seqIndices.realloc( 0);
749 seqOut.realloc(0);
750 inv->invoke(OUString(L"outDate"), Sequence< Any > (& outDate, 1), seqIndices, seqOut);
751 outDate <<= seqOut[0];
753 Decimal dec(3, 0, 0xffffffff, 0xffffffff, 0xfffffff0);
754 inDecimal <<= dec;
755 inv->invoke(OUString(L"inDecimal"), Sequence<Any>( & inDecimal, 1), seqIndices, seqOut);
756 seqIndices.realloc( 0);
757 seqOut.realloc(0);
758 inv->invoke(OUString(L"outDecimal"), Sequence< Any > (& outDecimal, 1), seqIndices, seqOut);
759 outDecimal <<= seqOut[0];
761 SCode code(DISP_E_BADVARTYPE);
762 inSCode <<= code;
763 inv->invoke(OUString(L"inSCode"), Sequence<Any>( & inSCode, 1), seqIndices, seqOut);
764 seqIndices.realloc( 0);
765 seqOut.realloc(0);
766 inv->invoke(OUString(L"outSCode"), Sequence< Any > (& outSCode, 1), seqIndices, seqOut);
767 outSCode <<= seqOut[0];
769 if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
770 || inFloat != outFloat || inDouble != outDouble || inString != outString
771 || inVariant != outVariant || inObject != outObject || inUnknown != outUnknown
772 || inCY != outCY
773 || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode)
774 return false;
775 //###################################################################################
776 // in/out parameter
777 //###################################################################################
778 outBool = Any();
779 seqIndices.realloc( 0);
780 seqOut.realloc(0);
781 inv->invoke(OUString(L"inoutBool"), Sequence< Any > ( & inBool, 1), seqIndices, seqOut);
782 outBool <<= seqOut[0];
784 outByte = Any();
785 seqIndices.realloc( 0);
786 seqOut.realloc(0);
787 inv->invoke(OUString(L"inoutByte"), Sequence< Any > ( & inByte, 1), seqIndices, seqOut);
788 outByte <<= seqOut[0];
790 outShort = Any();
791 seqIndices.realloc( 0);
792 seqOut.realloc(0);
793 inv->invoke(OUString(L"inoutShort"), Sequence< Any > ( & inShort, 1), seqIndices, seqOut);
794 outShort <<= seqOut[0];
796 outLong = Any();
797 seqIndices.realloc( 0);
798 seqOut.realloc(0);
799 inv->invoke(OUString(L"inoutLong"), Sequence< Any > ( & inLong, 1), seqIndices, seqOut);
800 outLong <<= seqOut[0];
802 outString = Any();
803 seqIndices.realloc( 0);
804 seqOut.realloc(0);
805 inv->invoke(OUString(L"inoutString"), Sequence< Any > ( & inString, 1), seqIndices, seqOut);
806 outString <<= seqOut[0];
808 outFloat = Any();
809 seqIndices.realloc( 0);
810 seqOut.realloc(0);
811 inv->invoke(OUString(L"inoutFloat"), Sequence< Any > ( & inFloat, 1), seqIndices, seqOut);
812 outFloat <<= seqOut[0];
814 outDouble = Any();
815 seqIndices.realloc( 0);
816 seqOut.realloc(0);
817 inv->invoke(OUString(L"inoutDouble"), Sequence< Any > ( &inDouble, 1), seqIndices, seqOut);
818 outDouble <<= seqOut[0];
820 outVariant = Any();
821 seqIndices.realloc( 0);
822 seqOut.realloc(0);
823 inv->invoke(OUString(L"inoutVariant"), Sequence< Any > ( & inVariant, 1), seqIndices, seqOut);
824 outVariant <<= seqOut[0];
826 outObject = Any();
827 seqIndices.realloc( 0);
828 seqOut.realloc(0);
829 inv->invoke(OUString(L"inoutObject"), Sequence< Any > ( & inObject, 1), seqIndices, seqOut);
830 outObject <<= seqOut[0];
832 outCY = Any();
833 seqIndices.realloc( 0);
834 seqOut.realloc(0);
835 inv->invoke(OUString(L"inoutCurrency"), Sequence< Any > ( & inCY, 1), seqIndices, seqOut);
836 outCY <<= seqOut[0];
838 outDate = Any();
839 seqIndices.realloc( 0);
840 seqOut.realloc(0);
841 inv->invoke(OUString(L"inoutDate"), Sequence< Any > ( & inDate, 1), seqIndices, seqOut);
842 outDate <<= seqOut[0];
844 outDecimal = Any();
845 seqIndices.realloc( 0);
846 seqOut.realloc(0);
847 inv->invoke(OUString(L"inoutDecimal"), Sequence< Any > (& inDecimal, 1), seqIndices, seqOut);
848 outDecimal <<= seqOut[0];
850 outSCode = Any();
851 seqIndices.realloc(0);
852 seqOut.realloc(0);
853 inv->invoke(OUString(L"inoutSCode"), Sequence< Any > (& inSCode, 1), seqIndices, seqOut);
854 outSCode <<= seqOut[0];
856 if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
857 || inFloat != outFloat || inDouble != outDouble || inString != outString
858 || inVariant != outVariant || inObject != outObject || inCY != outCY
859 || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode)
860 return false;
862 //###################################################################################
863 // in byref parameters
864 //###################################################################################
866 inrefLong <<= (sal_Int32) 1234;
867 inv->invoke(OUString(L"inrefLong"), Sequence<Any>( & inrefLong, 1), seqIndices, seqOut);
868 seqIndices.realloc( 0);
869 seqOut.realloc(0);
870 inv->invoke(OUString(L"outLong"), Sequence< Any > (& outrefLong, 1), seqIndices, seqOut);
871 outrefLong <<= seqOut[0];
873 inrefVariant <<= OUString(L" A string in an any");
874 inv->invoke(OUString(L"inrefVariant"), Sequence< Any > ( & inrefVariant, 1), seqIndices, seqOut);
875 seqIndices.realloc( 0);
876 seqOut.realloc(0);
877 inv->invoke(OUString(L"outVariant"), Sequence< Any > (&outrefVariant, 1), seqIndices, seqOut);
878 outrefVariant <<= seqOut[0];
880 Decimal refdec(5, 1, 0xffff, 0xff, 0x1);
881 inrefDecimal <<= refdec;
882 inv->invoke(OUString(L"inrefDecimal"), Sequence< Any > ( & inrefDecimal, 1), seqIndices, seqOut);
883 seqIndices.realloc( 0);
884 seqOut.realloc(0);
885 inv->invoke(OUString(L"outDecimal"), Sequence< Any > (&outrefDecimal, 1), seqIndices, seqOut);
886 outrefDecimal <<= seqOut[0];
888 if (inrefLong != outrefLong || inrefVariant != outrefVariant
889 || inrefDecimal != outrefDecimal)
890 return false;
893 //###################################################################################
894 // mixed parameter
895 //###################################################################################
896 // mixed1
897 seqIndices.realloc( 0);
898 seqOut.realloc(0);
899 Any param[3];
900 param[0] = inByte;
901 param[1] = inFloat;
902 param[2] = inVariant;
903 inv->invoke(OUString(L"mixed1"), Sequence< Any >(param, 3), seqIndices, seqOut);
905 if (seqOut.getLength() != 3 || inByte != seqOut[0] || inFloat != seqOut[1]
906 || inVariant != seqOut[2])
907 return false;
908 return true;
911 bool doSimpleSequenceTest(const Reference<XInvocation> & inv)
913 bool ret = true;
914 Sequence<sal_Int16> seqIndices;
915 Sequence<Any> seqOut;
916 Any voidAny;
917 Any inArAny;
918 Any outArray;
919 Any inArBool, outArBool;
920 Any inArByte, outArByte;
921 Any inArShort, outArShort;
922 Any inArLong, outArLong;
923 Any inArString, outArString;
924 Any inArFloat, outArFloat;
925 Any inArDouble, outArDouble;
926 Any inArObject, outArObject;
927 Any outVariant;
929 //Initialize arrays
930 OUString arStr[]= {L"string0", L"string1", L"string2"};
931 Sequence<OUString> seq( arStr, 3);
932 inArString <<= seq;
934 Any arAnyStrTmp[3];
935 arAnyStrTmp[0]<<= arStr[0];
936 arAnyStrTmp[1]<<= arStr[1];
937 arAnyStrTmp[2]<<= arStr[2];
938 Sequence<Any> seq_1( arAnyStrTmp, 3);
939 inArAny <<= seq_1;
940 //###################################################################################
941 // in, out Sequences
942 //###################################################################################
943 //Test sequence containing Anys of Strings
944 inv->invoke(OUString(L"inArray"), Sequence< Any > ( & inArAny, 1), seqIndices, seqOut);
945 seqIndices.realloc(0);
946 seqOut.realloc(0);
947 inv->invoke(OUString(L"outArray"), Sequence<Any>( & voidAny, 1), seqIndices, seqOut);
948 if (inArAny != seqOut[0])
949 return false;
951 seqIndices.realloc(0);
952 seqOut.realloc(0);
953 inv->invoke(OUString(L"inArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
954 inv->invoke(OUString(L"outArray"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
955 outArray <<= seqOut[0];
957 sal_Int8 arByte[]={1,2,3};
958 Sequence<sal_Int8> seqByte(arByte, 3);
959 inArByte <<= seqByte;
960 inv->invoke(OUString(L"inSequenceByte"),Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
961 seqIndices.realloc(0);
962 seqOut.realloc(0);
963 inv->invoke(OUString(L"outSequenceByte"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
964 outArByte <<= seqOut[0];
966 sal_Int16 arShort[]={4,5,6};
967 Sequence<sal_Int16> seqShort(arShort, 3);
968 inArShort<<= seqShort;
969 inv->invoke(OUString(L"inSequenceShort"),Sequence< Any >( & inArShort, 1), seqIndices, seqOut);
970 seqIndices.realloc(0);
971 seqOut.realloc(0);
972 inv->invoke(OUString(L"outSequenceShort"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
973 outArShort <<= seqOut[0];
975 sal_Int32 arLong[] = {7,8,9};
976 Sequence<sal_Int32> seqLong(arLong, 3);
977 inArLong <<= seqLong;
978 inv->invoke(OUString(L"inSequenceLong"),Sequence< Any > ( & inArLong, 1), seqIndices, seqOut);
979 seqIndices.realloc(0);
980 seqOut.realloc(0);
981 inv->invoke(OUString(L"outSequenceLong"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
982 outArLong <<= seqOut[0];
984 inv->invoke(OUString(L"inSequenceLong"),Sequence< Any > ( & inArLong, 1), seqIndices, seqOut);
985 seqIndices.realloc(0);
986 seqOut.realloc(0);
987 inv->invoke(OUString(L"outSequenceLong"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
988 outArLong <<= seqOut[0];
990 inv->invoke( OUString(L"inSequenceString"),Sequence< Any > ( & inArString, 1), seqIndices, seqOut);
991 seqIndices.realloc(0);
992 seqOut.realloc(0);
993 inv->invoke(OUString(L"outSequenceString"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
994 outArString <<= seqOut[0];
996 float arFloat[]={3.14f, 31.4f, 314.f};
997 Sequence<float> seqFloat( arFloat, 3);
998 inArFloat <<= seqFloat;
999 inv->invoke( OUString(L"inSequenceFloat"),Sequence< Any > ( & inArFloat, 1), seqIndices, seqOut);
1000 seqIndices.realloc(0);
1001 seqOut.realloc(0);
1002 inv->invoke(OUString(L"outSequenceFloat"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
1003 outArFloat <<= seqOut[0];
1005 double arDouble[]={3.145, 31.45, 3145.};
1006 Sequence<double> seqDouble( arDouble, 3);
1007 inArDouble <<= seqDouble;
1008 inv->invoke(OUString(L"inSequenceDouble"),Sequence< Any >( & inArDouble, 1), seqIndices, seqOut);
1009 seqIndices.realloc(0);
1010 seqOut.realloc(0);
1011 inv->invoke(OUString(L"outSequenceDouble"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
1012 outArDouble <<= seqOut[0];
1014 Sequence<Reference<XInvocation> > seqObj(2);
1015 seqObj[0]= getComObject(L"AxTestComponents.Basic");
1016 seqObj[1]= getComObject(L"AxTestComponents.Basic");
1017 inArObject <<= seqObj;
1018 inv->invoke(OUString(L"inSequenceObject"),Sequence< Any >( & inArObject, 1), seqIndices, seqOut);
1019 seqIndices.realloc(0);
1020 seqOut.realloc(0);
1021 inv->invoke(OUString(L"outSequenceObject"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
1022 outArObject <<= seqOut[0];
1024 if ( ! equalSequences(inArByte, outArByte) || ! equalSequences(inArShort, outArShort)
1025 || ! equalSequences(inArLong, outArLong) || ! equalSequences(inArString, outArray)
1026 || ! equalSequences(inArFloat, outArFloat) || ! equalSequences(inArDouble, outArDouble)
1027 || ! equalSequences(inArString, outArString) || ! equalSequences(inArObject, outArObject))
1028 return false;
1030 //###################################################################################
1031 // in/out Sequences
1032 //###################################################################################
1033 seqIndices.realloc(0);
1034 seqOut.realloc(0);
1035 inv->invoke(OUString(L"inoutArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
1036 inv->invoke(OUString(L"inoutArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
1037 outArray <<= seqOut[0];
1039 inv->invoke(OUString(L"inoutSequenceByte"), Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
1040 inv->invoke(OUString(L"inoutSequenceByte"), Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
1041 outArByte <<= seqOut[0];
1043 inv->invoke(OUString(L"inoutSequenceShort"), Sequence<Any>( & inArShort, 1), seqIndices, seqOut);
1044 inv->invoke(OUString(L"inoutSequenceShort"), Sequence<Any>( & inArShort, 1), seqIndices, seqOut);
1045 outArShort <<= seqOut[0];
1047 inv->invoke(OUString(L"inoutSequenceLong"), Sequence<Any>( & inArLong, 1), seqIndices, seqOut);
1048 inv->invoke(OUString(L"inoutSequenceLong"), Sequence< Any >( & inArLong, 1), seqIndices, seqOut);
1049 outArLong <<= seqOut[0];
1051 inv->invoke(OUString(L"inoutSequenceString"), Sequence<Any>( & inArString, 1), seqIndices, seqOut);
1052 inv->invoke(OUString(L"inoutSequenceString"), Sequence<Any>( & inArString, 1), seqIndices, seqOut);
1053 outArString <<= seqOut[0];
1055 inv->invoke(OUString(L"inoutSequenceFloat"), Sequence<Any>( & inArFloat, 1), seqIndices, seqOut);
1056 inv->invoke(OUString(L"inoutSequenceFloat"), Sequence<Any>( & inArFloat, 1), seqIndices, seqOut);
1057 outArFloat <<= seqOut[0];
1059 inv->invoke(OUString(L"inoutSequenceDouble"), Sequence<Any>( & inArDouble, 1), seqIndices, seqOut);
1060 inv->invoke(OUString(L"inoutSequenceDouble"), Sequence<Any>( & inArDouble, 1), seqIndices, seqOut);
1061 outArDouble <<= seqOut[0];
1063 inv->invoke(OUString(L"inoutSequenceObject"), Sequence<Any>( & inArObject, 1), seqIndices, seqOut);
1064 inv->invoke(OUString(L"inoutSequenceObject"), Sequence<Any>( & inArObject, 1), seqIndices, seqOut);
1065 outArObject <<= seqOut[0];
1067 if ( ! equalSequences(inArByte, outArByte) || ! equalSequences(inArShort, outArShort)
1068 || ! equalSequences(inArLong, outArLong) || ! equalSequences(inArString, outArray)
1069 || ! equalSequences(inArFloat, outArFloat) || ! equalSequences(inArDouble, outArDouble)
1070 || ! equalSequences(inArString, outArString) || ! equalSequences(inArObject, outArObject))
1071 return false;
1073 return ret;
1076 HRESULT doTest()
1078 HRESULT hr= S_OK;
1079 USES_CONVERSION;
1080 Reference<XInvocation> inv= getComObject( L"AxTestComponents.Basic");
1082 HostWin* pWin= new HostWin( L"MFCCONTROL.MfcControlCtrl.1");
1083 CComPtr<IUnknown> spUnk= pWin->GetHostedControl();
1084 Reference<XInvocation> invMfc= convertComObject( spUnk.p);
1086 Sequence< sal_Int16> seqIndices;
1087 Sequence<Any> seqOut;
1089 Any aAny;
1090 Any anyOut;
1091 char buff[1024];
1092 Any seqAny;
1094 if (! doSimpleTest(inv))
1096 fprintf(stdout, "### Test failed!\n");
1097 return E_FAIL;
1100 if (! doPropertyTest(inv))
1102 fprintf(stdout, "### Test failed!\n");
1103 return E_FAIL;
1106 if ( ! doSimpleSequenceTest(inv))
1108 fprintf(stdout, "### Test failed! \n");
1109 return E_FAIL;
1112 if ( ! doParameterTest(inv))
1114 fprintf(stdout, "### Test failed! \n");
1115 return E_FAIL;
1118 if ( ! doPropertyWithArgumentTest(inv))
1120 fprintf(stdout, "### Test failed! \n");
1121 return E_FAIL;
1129 // //###################################################################################
1130 // // in multi Sequences
1131 // //###################################################################################
1132 // // inMulDimArrayLong
1133 sal_Int32 arLongi[]={1,2,3};
1134 sal_Int32 arLongi2[]={4,5,6,7};
1135 sal_Int32 arLongi3[]={8,9,10,11,12};
1137 Sequence<sal_Int32> seqLongi1( arLongi, 3);
1138 Sequence<sal_Int32> seqLongi2( arLongi2, 4);
1139 Sequence<sal_Int32> seqLongi3( arLongi3, 5);
1141 Sequence< Sequence< sal_Int32 > > seq2i(3);
1142 seq2i[0]= seqLongi1;
1143 seq2i[1]= seqLongi2;
1144 seq2i[2]= seqLongi3;
1145 seqAny<<= seq2i;
1146 // dimension length 3,5
1147 inv->invoke( OUString(L"inMulDimArrayLong"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
1149 //inMulDimArrayVariant
1150 inv->invoke( OUString(L"inMulDimArrayVariant"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
1152 //inMulDimArrayLong2
1153 sal_Int32 arLongii1[]={1,2,3};
1154 sal_Int32 arLongii2[]={4,5,6,7};
1155 sal_Int32 arLongii3[]={8,9,10,11,12};
1156 sal_Int32 arLongii4[]={13,14,15,16};
1157 sal_Int32 arLongii5[]={17,18,19};
1159 Sequence<sal_Int32> seqLongii1( arLongii1, 3);
1160 Sequence<sal_Int32> seqLongii2( arLongii2, 4);
1161 Sequence<sal_Int32> seqLongii3( arLongii3, 5);
1162 Sequence<sal_Int32> seqLongii4( arLongii4, 4);
1163 Sequence<sal_Int32> seqLongii5( arLongii5, 3);
1165 Sequence< Sequence< sal_Int32 > > seq2ii(3);
1166 Sequence< Sequence< sal_Int32> > seq2ii2(2);
1167 seq2ii[0]= seqLongii1;
1168 seq2ii[1]= seqLongii2;
1169 seq2ii[2]= seqLongii3;
1171 seq2ii2[0]= seqLongii4;
1172 seq2ii2[1]= seqLongii5;
1174 Sequence< Sequence< Sequence< sal_Int32> > > seq3ii(2);
1175 seq3ii[0]=seq2ii;
1176 seq3ii[1]=seq2ii2;
1177 seqAny<<= seq3ii;
1178 inv->invoke( OUString(L"inMulDimArrayLong2"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
1180 // inMulDimArrayByte2
1181 sal_Int8 arByteii1[]={1,2,3};
1182 sal_Int8 arByteii2[]={4,5,6,7};
1183 sal_Int8 arByteii3[]={8,9,10,11,12};
1184 sal_Int8 arByteii4[]={13,14,15,16};
1185 sal_Int8 arByteii5[]={17,18,19};
1187 Sequence<sal_Int8> seqByteii1( arByteii1, 3);
1188 Sequence<sal_Int8> seqByteii2( arByteii2, 4);
1189 Sequence<sal_Int8> seqByteii3( arByteii3, 5);
1190 Sequence<sal_Int8> seqByteii4( arByteii4, 4);
1191 Sequence<sal_Int8> seqByteii5( arByteii5, 3);
1193 Sequence< Sequence< sal_Int8 > > seq2Byteii(3);
1194 Sequence< Sequence< sal_Int8> > seq2Byteii2(2);
1195 seq2Byteii[0]= seqByteii1;
1196 seq2Byteii[1]= seqByteii2;
1197 seq2Byteii[2]= seqByteii3;
1199 seq2Byteii2[0]= seqByteii4;
1200 seq2Byteii2[1]= seqByteii5;
1202 Sequence< Sequence< Sequence< sal_Int8> > > seq3Byteii(2);
1203 seq3Byteii[0]=seq2Byteii;
1204 seq3Byteii[1]=seq2Byteii2;
1205 seqAny<<= seq3Byteii;
1206 inv->invoke( OUString(L"inMulDimArrayByte2"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
1210 //###################################################################################
1211 //###################################################################################
1212 //###################################################################################
1213 // Tests with a MFC ActiveX control, ( pure dispinterface)
1214 //###################################################################################
1216 //###################################################################################
1217 // in parameter MFC ActiveX
1218 //###################################################################################
1219 // unsigned char is not supported by MFC
1220 // aAny <<= ( sal_Int8) 127;
1221 // invMfc->invoke( OUString(L"inByte"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1222 if ( ! invMfc.is())
1223 return hr;
1224 aAny <<= static_cast<sal_Int16>(-1);
1225 aAny= invMfc->invoke( OUString(L"inShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1228 aAny <<= ( sal_Int32) 1234567;
1229 aAny=invMfc->invoke( OUString(L"inLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1230 sal_Int32 retLong= *(sal_Int32*)aAny.getValue();
1232 OUString str_1(L" this is clientTest.exe");
1233 aAny <<= str_1;
1234 aAny=invMfc->invoke( OUString(L"inString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1235 aAny>>= str_1;
1237 aAny <<= ( float) 3.14;
1238 aAny=invMfc->invoke( OUString(L"inFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1240 aAny <<= ( double) 3.145;
1241 aAny=invMfc->invoke( OUString(L"inDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1243 aAny <<= OUString( L" A string in an any");
1244 aAny=invMfc->invoke( OUString(L"inVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1246 // Tests with Sequences later.
1247 // OUString arStr4[]= {L"string0", L"string1", L"string2"};
1248 // Sequence<OUString> seqStr4( arStr4, 3);
1249 // aAny <<= seqStr4;
1250 // invMfc->invoke( OUString(L"inArray"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1253 Reference < XInvocation > inv5= getComObject(L"AxTestComponents.Basic");
1254 Any anyVal4;
1255 anyVal4 <<= OUString(L"this is the value of prpString");
1256 inv5->setValue( OUString(L"prpString"), anyVal4);
1257 aAny <<= inv5;
1258 aAny=invMfc->invoke( OUString(L"inObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1260 // //###################################################################################
1261 // // out parameter MFC ActiveX
1262 // //###################################################################################
1264 // // outShort
1265 aAny= invMfc->invoke( OUString(L"outShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1266 anyOut<<= seqOut[0];
1267 sprintf(buff, "MFC outShort %d", *(sal_Int16*)anyOut.getValue());
1268 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1270 // outLong
1271 aAny= invMfc->invoke( OUString(L"outLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1272 anyOut<<= seqOut[0];
1273 sprintf(buff, "MFC outLong %d", *(sal_Int32*)anyOut.getValue());
1274 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1276 // outString
1277 aAny= invMfc->invoke( OUString(L"outString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1278 anyOut<<= seqOut[0];
1279 sprintf(buff, "MFC outString %S", ((OUString*)anyOut.getValue())->getStr());
1280 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1282 // outFloat
1283 aAny= invMfc->invoke( OUString(L"outFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1284 anyOut<<= seqOut[0];
1285 sprintf(buff, "MFC outFloat %f", *(float*)anyOut.getValue());
1286 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1288 // outDouble
1289 aAny= invMfc->invoke( OUString(L"outDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1290 anyOut<<= seqOut[0];
1291 sprintf(buff, "MFC outFloat %f", *(double*)anyOut.getValue());
1292 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1294 // outVariant
1295 // we expect a string!! ( VT_BSTR)
1296 aAny= invMfc->invoke( OUString(L"outVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1297 anyOut<<= seqOut[0];
1298 sprintf(buff, "MFC outVariant %S", ((OUString*)anyOut.getValue())->getStr());
1299 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1301 // outDouble
1302 aAny= invMfc->invoke( OUString(L"outObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
1303 Reference<XInvocation> invOut5;
1304 seqOut[0]>>= invOut5;
1305 // we assume that an object of AxTestControls.Basic is being returned.
1306 anyOut= invOut5->getValue( OUString(L"prpString"));
1307 OUString tmpStr;
1308 anyOut>>=tmpStr;
1309 sprintf(buff, "MFC outObject, property: %S", tmpStr.getStr());
1310 MessageBox( NULL, buff, _T("clientTest"), MB_OK);
1313 //###################################################################################
1314 // Sequence parameter MFC ActiveX
1315 //###################################################################################
1316 // Sequences are not directly supported.
1319 delete pWin;
1320 return hr;
1326 //VARIANT_TRUE VT_UI1