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