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