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<HTML> 22<HEAD> 23<META NAME="GENERATOR" Content="Microsoft Developer Studio"> 24<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> 25<TITLE>Document Title</TITLE> 26</HEAD> 27<BODY id=theBody> 28 29<script language="JScript"> 30 31function runJScriptTest( Log) 32{ 33document.writeln("================================================================================<br>"); 34document.writeln("JScript<br>"); 35document.writeln("================================================================================<p>"); 36 37//var name : String = "Fred"; 38//print(name); 39var arr= new Array( 1, 2, 3, 4, 0); 40var arrInt= new Array( 1,2,3,4,5); 41var arrDouble= new Array( 1.2345, 12.345, 123.45, 1234.5, 12345); 42var arrBool= new Array( true, false, true, false, true); 43var arrChar= new Array( '1', 'A'," ", 55); 44 45var arrString= new Array("hamburger","cheeseburger", "chicken nuggets", "chicken wings" , "pizza"); 46var arrAny= new Array( 100, 100.1235,"hallo"); 47var arrSeq= new Array( arr, arr, arr); 48var arrSeq2= new Array( ); 49 50var arEventListener= new Array( new XEventListener_Impl(), new XEventListener_Impl(), 51 new XEventListener_Impl()); 52var arEventListener2= new Array( new XEventListener_Impl(), new XEventListener_Impl(), 53 new XEventListener_Impl()); 54var arArEventListener= new Array( arEventListener, arEventListener2); 55 56var arObj= new Array(); 57for( i=0; i< 3; i++) 58{ 59 arObj[i]= new Object(); 60} 61var outVal= new Array(); 62var outVal2= new Array(); 63var outVal3= new Array(); 64 65for( i=0; i < 3; i++) 66{ 67 arrSeq2[i]= new Array(); 68 for( j= 0; j < 3; j++) 69 { 70 arrSeq2[i][j]= new Array(); 71 for( k= 0; k < 5; k++) 72 { 73 arrSeq2[i][j][k]= (i * 3 * 5) + (j * 5) + k; 74// document.write(arrSeq2[i][j][k] + " "); 75 } 76// document.write("<br>"); 77 } 78} 79 80 81ret= oletest.methodByte( arr); 82_ret= new VBArray( ret).toArray(); 83Log.print( isEqualAr( arr, _ret), "methodByte"); 84 85ret= oletest.methodFloat( arrDouble); 86_ret= new VBArray( ret).toArray(); 87bOk= false; 88if( (arrDouble.length == _ret.length) 89 && (_ret[0] > 1.2344 && _ret[0] < 1.2346) 90 && (_ret[1] > 12.344 && _ret[1] < 12.346) 91 && (_ret[2] > 123.44 && _ret[2] < 123.46) 92 && (_ret[3] > 1234.4 && _ret[3] < 1234.6) 93 && (_ret[4] > 12344 && _ret[4] < 12346)) 94 bOk= true; 95Log.print( bOk, "methodFloat"); 96 97ret= oletest.methodDouble( arrDouble); 98_ret= new VBArray( ret).toArray(); 99Log.print( isEqualAr( arrDouble, _ret), "methodDouble"); 100 101ret= oletest.methodBool( arrBool); 102_ret= new VBArray( ret).toArray(); 103Log.print( isEqualAr( arrBool, _ret), "methodBool"); 104 105ret= oletest.methodShort( arr); 106_ret= new VBArray( ret).toArray(); 107Log.print( isEqualAr( arr, _ret), "methodShort"); 108 109ret= oletest.methodUShort( arr); 110_ret= new VBArray( ret).toArray(); 111Log.print( isEqualAr( arr, _ret), "methodUShort"); 112 113ret= oletest.methodLong( arr); 114_ret= new VBArray( ret).toArray(); 115Log.print( isEqualAr( arr, _ret), "methodLong"); 116 117ret= oletest.methodULong( arr); 118_ret= new VBArray( ret).toArray(); 119Log.print( isEqualAr( arr, _ret), "methodULong"); 120 121ret= oletest.methodChar( arrChar); 122_ret= new VBArray( ret).toArray(); 123bOk= false; 124if( _ret.length == arrChar.length && _ret[0] == 49 && _ret[1] == 65 && _ret[2] == 32 && _ret[3] == 55) 125 bOk= true; 126Log.print( bOk, "methodChar"); 127 128ret= oletest.methodString( arrString); 129_ret= new VBArray( ret).toArray(); 130Log.print( isEqualAr( arrString, _ret), "methodString"); 131 132ret= oletest.methodAny( arrAny); 133_ret= new VBArray( ret).toArray(); 134Log.print( isEqualAr( arrAny, _ret), "methodAny"); 135 136ret= oletest.methodSequence( arrSeq); 137_ret= new VBArray( ret).toArray(); 138for( i=0; i < _ret.length; i++) 139{ 140 sfarray2= new VBArray( _ret[i]); 141 var arr2= sfarray2.toArray(); 142 if( ! isEqualAr(arrSeq[i], arr2)) 143 { 144 bOk= false; 145 break; 146 } 147} 148Log.print( bOk, "methodSequence"); 149 150ret= oletest.methodSequence2( arrSeq2); 151arr1= new VBArray( ret).toArray(); 152for( i=0; i < arr1.length; i++) 153{ 154 var ar2Dim= arrSeq2[i]; 155 sfarray2= new VBArray( arr1[i]); 156 arr2= sfarray2.toArray(); 157 for ( j=0; j < arr2.length; j++) 158 { 159 var ar1Dim= ar2Dim[j]; 160 sfarray3= new VBArray( arr2[j]); 161 arr3= sfarray3.toArray(); 162// document.write(arr3[j].toString()); 163 if( ! isEqualAr( arrSeq2[i][j], arr3)) 164 { 165 bOk= false; 166 break; 167 } 168 } 169} 170Log.print( bOk, "methodSequence2"); 171 172ret= oletest.methodXInterface( arObj); 173_ret= new VBArray( ret).toArray(); 174bOk= true; 175for(i in _ret) 176{ 177 if( _ret[i] !== arObj[i]) 178 { 179 bOk= false; 180 break; 181 } 182} 183Log.print( bOk, "methodXInterface"); 184 185 186ret= oletest.methodXEventListeners( arEventListener); 187_ret= new VBArray(ret).toArray(); 188bOk= true; 189for ( key in _ret) 190{ 191 if( ! _ret[key].disposingCalled()) 192 { 193 bOk= false; 194 break; 195 } 196} 197Log.print( bOk, "methodXEventListeners"); 198 199ret= oletest.methodXEventListenersMul( arArEventListener); 200_ret= new VBArray(ret).toArray(); 201bOk= true; 202for( key in _ret) 203{ 204 _ret2= new VBArray(_ret[key]).toArray(); 205 for( key2 in _ret2) 206 { 207 if( ! _ret2[key2].disposingCalled()) 208 { 209 bOk= false; 210 break; 211 } 212 } 213} 214Log.print( bOk, "methodXEventListenersMul"); 215 216document.writeln("<br>"); 217oletest.AttrByte = arr; 218ret= oletest.AttrByte; 219_ret= new VBArray( ret).toArray(); 220Log.print( isEqualAr( arr, _ret), "AttrByte"); 221 222oletest.AttrFloat= arrDouble; 223ret= oletest.AttrFloat; 224_ret= new VBArray( ret).toArray(); 225bOk= false; 226if( (arrDouble.length == _ret.length) 227 && (_ret[0] > 1.2344 && _ret[0] < 1.2346) 228 && (_ret[1] > 12.344 && _ret[1] < 12.346) 229 && (_ret[2] > 123.44 && _ret[2] < 123.46) 230 && (_ret[3] > 1234.4 && _ret[3] < 1234.6) 231 && (_ret[4] > 12344 && _ret[4] < 12346)) 232 bOk= true; 233Log.print( bOk, "AttrFloat"); 234 235oletest.AttrDouble= arrDouble; 236ret= oletest.AttrDouble; 237_ret= new VBArray( ret).toArray(); 238Log.print( isEqualAr( arrDouble, _ret), "AttrDouble"); 239 240oletest.AttrBool= arrBool; 241ret= oletest.AttrBool; 242_ret= new VBArray( ret).toArray(); 243Log.print( isEqualAr( arrBool, _ret), "AttrBool"); 244 245oletest.AttrShort= arr; 246ret= oletest.AttrShort; 247_ret= new VBArray( ret).toArray(); 248Log.print( isEqualAr( arr, _ret), "AttrShort"); 249 250oletest.AttrUShort= arr; 251ret= oletest.AttrUShort; 252_ret= new VBArray( ret).toArray(); 253Log.print( isEqualAr( arr, _ret), "AttrUShort"); 254 255oletest.AttrLong= arr; 256ret= oletest.AttrLong; 257_ret= new VBArray( ret).toArray(); 258Log.print( isEqualAr( arr, _ret), "AttrLong"); 259 260oletest.AttrULong= arr; 261ret= oletest.AttrULong; 262_ret= new VBArray( ret).toArray(); 263Log.print( isEqualAr( arr, _ret), "AttrULong"); 264 265oletest.AttrChar= arrChar; 266ret= oletest.AttrChar; 267_ret= new VBArray(ret).toArray(); 268bOk= false; 269if( _ret.length == arrChar.length && _ret[0] == 49 && _ret[1] == 65 && _ret[2] == 32 && _ret[3] == 55) 270 bOk= true; 271Log.print( bOk, "AttrChar"); 272 273oletest.AttrString= arrString; 274ret= oletest.AttrString; 275_ret= new VBArray( ret).toArray(); 276Log.print( isEqualAr( arrString, _ret), "AttrString"); 277 278oletest.AttrAny= arrAny; 279ret= oletest.AttrAny; 280_ret= new VBArray( ret).toArray(); 281Log.print( isEqualAr( arrAny, _ret), "AttrAny"); 282 283oletest.AttrSequence= arrSeq; 284ret= oletest.AttrSequence; 285_ret= new VBArray( ret).toArray(); 286for( i=0; i < _ret.length; i++) 287{ 288 sfarray2= new VBArray( _ret[i]); 289 var arr2= sfarray2.toArray(); 290 if( ! isEqualAr(arrSeq[i], arr2)) 291 { 292 bOk= false; 293 break; 294 } 295} 296Log.print( bOk, "AttrSequence"); 297 298oletest.AttrSequence2= arrSeq2; 299ret= oletest.AttrSequence2; 300arr1= new VBArray( ret).toArray(); 301for( i=0; i < arr1.length; i++) 302{ 303 var ar2Dim= arrSeq2[i]; 304 sfarray2= new VBArray( arr1[i]); 305 arr2= sfarray2.toArray(); 306 for ( j=0; j < arr2.length; j++) 307 { 308 var ar1Dim= ar2Dim[j]; 309 sfarray3= new VBArray( arr2[j]); 310 arr3= sfarray3.toArray(); 311 if( ! isEqualAr( arrSeq2[i][j], arr3)) 312 { 313 bOk= false; 314 break; 315 } 316 } 317} 318Log.print( bOk, "AttrSequence2"); 319 320oletest.AttrXInterface= arObj; 321ret= oletest.AttrXInterface; 322_ret= new VBArray( ret).toArray(); 323bOk= true; 324for(i in _ret) 325{ 326 if( _ret[i] !== arObj[i]) 327 { 328 bOk= false; 329 break; 330 } 331} 332Log.print( bOk, "AttrXInterface"); 333 334ret= oletest.methodXInterface( arObj); 335_ret= new VBArray( ret); 336_ret= _ret.toArray(); 337bOk= true; 338for(i in _ret) 339{ 340 if( _ret[i] !== arObj[i]) 341 { 342 bOk= false; 343 break; 344 } 345} 346Log.print( bOk, "methodXInterface"); 347//====================================================================================== 348document.writeln("<br>"); 349var inVal, outVal, retVal; 350outVal = new Array(); 351 352inVal = 77; 353retVal = oletest.in_methodByte(inVal) 354oletest.testout_methodByte( outVal ); 355Log.print( retVal == inVal, "in_methodByte"); 356Log.print( outVal[0] == inVal, "testout_methodByte"); 357 358inVal = 3.14 359retVal = oletest.in_methodFloat(inVal); 360oletest.testout_methodFloat( outVal ); 361Log.print( retVal > 3.14 && retVal < 3.15, "in_methodFloat"); 362Log.print( outVal[0] > 3.13 && outVal[0] < 3.15, "testout_methodFloat"); 363//Log.print( outVal[0] == inVal, "testout_methodFloat"); 364 365retVal = oletest.in_methodDouble(inVal) 366oletest.testout_methodDouble( outVal ); 367Log.print( retVal == inVal, "in_methodDouble"); 368Log.print( outVal[0] == 3.14, "testout_methodDouble" ); 369 370inVal = true; 371retVal = oletest.in_methodBool(inVal); 372oletest.testout_methodBool( outVal ); 373Log.print(retVal == inVal, "in_methodBool"); 374Log.print( outVal[0] == true, "testout_methodBool"); 375 376inVal = 111 377retVal = oletest.in_methodShort(inVal); 378oletest.testout_methodShort( outVal ); 379Log.print(retVal == inVal, "in_methodShort"); 380Log.print( outVal[0] == inVal, "testout_methodShort"); 381 382retVal = oletest.in_methodUShort(inVal); 383oletest.testout_methodUShort( outVal ); 384Log.print(retVal == inVal, "in_methodUShort"); 385Log.print( outVal[0] == inVal, "testout_methodUShort"); 386 387retVal = oletest.in_methodLong(inVal); 388oletest.testout_methodLong( outVal ); 389Log.print(retVal == inVal, "in_methodLong"); 390Log.print( outVal[0] == inVal, "testout_methodLong"); 391 392retVal = oletest.in_methodULong(inVal); 393oletest.testout_methodULong( outVal ); 394Log.print(retVal == inVal, "in_methodULong"); 395Log.print( outVal[0] == inVal, "testout_methodULong"); 396 397retVal = oletest.in_methodChar(inVal); 398oletest.testout_methodChar( outVal ); 399Log.print(retVal == inVal, "in_methodChar"); 400Log.print( outVal[0] == inVal, "testout_methodChar"); 401 402inVal = "Hello World"; 403retVal = oletest.in_methodString(inVal); 404oletest.testout_methodString( outVal ); 405Log.print(retVal == inVal, "in_methodString"); 406Log.print( outVal[0] == inVal, "testout_methodString"); 407 408retVal = oletest.in_methodAny(inVal); 409oletest.testout_methodAny( outVal ); 410Log.print(retVal == inVal, "in_methodAny"); 411Log.print( outVal[0] == inVal, "testout_methodAny"); 412 413inVal = new Object(); 414retVal = oletest.in_methodXInterface(inVal); 415oletest.testout_methodXInterface(outVal); 416Log.print(retVal === inVal, "in_methodXInterface"); 417Log.print(outVal[0] === inVal, "testout_methodXInterface"); 418 419inVal = oletest; 420retVal = oletest.in_methodXInterface(inVal); 421oletest.testout_methodXInterface(outVal); 422Log.print(retVal === inVal, "in_methodXInterface"); 423Log.print(outVal[0] === inVal, "testout_methodXInterface"); 424 425 426oletest.testout_methodSequence( outVal ); 427var arr= new VBArray( outVal[0]).toArray(); 428Log.print( isEqualAr(arr, new Array( 0,1,2,3,4,5,6,7,8,9)), "testout_methodSequence"); 429 430oletest.testout_methodSequence2( outVal ); 431var arr= new VBArray( outVal[0]).toArray(); 432bOk= true; 433if( arr.length= 10) 434{ 435 for( i=0; i < arr.length; i++) 436 { 437 var arr2= new VBArray( arr[i]).toArray(); 438 if( ! isEqualAr( arr2, new Array( 0,1,2,3,4,5,6,7,8,9))) 439 { 440 bOk= false; 441 break; 442 } 443 } 444} 445Log.print( bOk, "testout_methodSequence2"); 446 447oletest.testout_methodMulParams1( outVal, outVal2 ); 448Log.print( outVal[0] == 999 && outVal2[0] == 1111, "testout_methodMulParams1"); 449 450oletest.testout_methodMulParams2( outVal, outVal2, outVal3 ); 451Log.print( outVal[0] == 1111 && outVal2[0] == 1222 && outVal3[0] == " another string", 452 "testout_methodMulParams2"); 453 454oletest.testout_methodMulParams3( "hallo", outVal ); 455Log.print( outVal[0] == "Out Hallo!", "testout_methodMulParams3"); 456 457var in1= 3.14; 458var in2= 1111; 459var in3= -2222; 460oletest.testout_methodMulParams4( in1, outVal, in2, outVal2, in3 ); 461Log.print( (outVal[0] > 4.13 && outVal[0] < 4.15) && (outVal2[0] == 1112), "testout_methodMulParams4"); 462 463document.writeln("<p>"); 464 465inVal = 100; 466outVal[0]= inVal; 467oletest.testinout_methodByte( outVal ); 468oletest.testinout_methodByte( outVal ); 469Log.print( outVal[0] == inVal, "testinout_methodByte"); 470 471inVal = 3.14; 472outVal[0]= inVal; 473oletest.testinout_methodFloat( outVal ); 474oletest.testinout_methodFloat( outVal ); 475Log.print( outVal[0] > 3.13 && outVal[0] < 3.15, "testinout_methodFloat"); 476 477inVal = 3.14 478outVal[0]= inVal; 479oletest.testinout_methodDouble( outVal ); 480oletest.testinout_methodDouble( outVal ); 481Log.print( outVal[0] == inVal, "testinout_methodDouble"); 482 483inVal = true; 484outVal[0]= inVal; 485oletest.testinout_methodBool( outVal ); 486oletest.testinout_methodBool( outVal ); 487Log.print( outVal[0] == inVal, "testinout_methodBool"); 488 489inVal = 200; 490outVal[0]= inVal; 491oletest.testinout_methodShort( outVal ); 492oletest.testinout_methodShort( outVal ); 493Log.print( outVal[0] == inVal, "testinout_methodShort"); 494 495inVal = 300; 496outVal[0]= inVal; 497oletest.testinout_methodUShort( outVal ); 498oletest.testinout_methodUShort( outVal ); 499Log.print( outVal[0] == inVal, "testinout_methodUShort"); 500 501inVal = 400 502outVal[0]= inVal; 503oletest.testinout_methodLong( outVal ); 504oletest.testinout_methodLong( outVal ); 505Log.print( outVal[0] == inVal, "testinout_methodLong"); 506 507inVal = 500; 508outVal[0]= inVal; 509oletest.testinout_methodULong( outVal ); 510oletest.testinout_methodULong( outVal ); 511Log.print( outVal[0] == inVal, "testinout_methodULong"); 512 513inVal = "B"; 514outVal[0]= inVal; 515oletest.testinout_methodChar( outVal ); 516oletest.testinout_methodChar( outVal ); 517 518Log.print( outVal[0] == 66, "testinout_methodChar"); 519 520inVal = "Hello World 2!"; 521outVal[0]= inVal; 522oletest.testinout_methodString( outVal ); 523oletest.testinout_methodString( outVal ); 524Log.print( outVal[0] == inVal, "testinout_methodString"); 525 526inVal = new Object(); 527outVal[0]= inVal; 528oletest.testinout_methodAny( outVal ); 529oletest.testinout_methodAny( outVal ); 530Log.print( outVal[0] === inVal, "testinout_methodAny"); 531 532inVal = arrInt; 533outVal[0] = inVal; 534oletest.testinout_methodSequence( outVal ); 535oletest.testinout_methodSequence( outVal ); 536retVal = new VBArray(outVal[0]).toArray(); 537 538Log.print( isEqualAr(retVal, new Array(3,4,5,6,7)), "testinout_methodSequence"); 539 540 541outVal[0]= arrSeq; 542oletest.testinout_methodSequence2( outVal ); 543var arr= new VBArray( outVal[0]).toArray(); 544var i; 545bOk= true; 546if( arr.length == 3) 547{ 548 var tmpArr= new Array(2,4,6,8,0); 549 for( i=0; i < arr.length; i++) 550 { 551 var arr2= new VBArray( arr[i]).toArray(); 552 if( ! isEqualAr( arr2, tmpArr)) 553 { 554 bOk= false; 555 break; 556 } 557 } 558} 559Log.print( bOk, "testinout_methodSequence2"); 560 561 562var ob= new Object(); 563var sInVal= "this is a string" 564ob.value= sInVal; 565outVal[0]= ob; 566oletest.testinout_methodXInterface( outVal); 567Log.print( outVal[0].value == "out", "testinout_methodXInterface"); 568document.writeln("<p>"); 569 570i= 100; 571ret= oletest.methodAnyTest1( i); 572Log.print( i == ret, "methodAnyTest1"); 573 574i= 3.14; 575ret= oletest.methodAnyTest1( i); 576Log.print( i == ret, "methodAnyTest1"); 577 578i= "Hallo" 579ret= oletest.methodAnyTest1( i); 580Log.print( i == ret, "methodAnyTest1"); 581 582i= arrInt; 583ret= oletest.methodAnyTest1( i); 584var arr= new VBArray( ret).toArray(); 585Log.print( isEqualAr(arr, arrInt), "methodAnyTest1"); 586 587var obj= new Object(); 588ret= oletest.methodAnyTest1( obj); 589Log.print( obj == ret, "methodAnyTest1"); 590 591 592document.writeln("<p>"); 593 594i= 100; 595oletest.AttrAny2= i; 596ret= oletest.AttrAny2; 597Log.print( i == ret, "AttrAny2"); 598 599i= 3.14; 600oletest.AttrAny2= i; 601ret= oletest.AttrAny2; 602Log.print( i == ret, "AttrAny2"); 603 604i= "Hallo" 605oletest.AttrAny2= i; 606ret= oletest.AttrAny2; 607Log.print( i == ret, "AttrAny2"); 608 609i= arrInt; 610oletest.AttrAny2= i; 611ret= oletest.AttrAny2; 612var arr= new VBArray( ret).toArray(); 613Log.print( isEqualAr(arr, arrInt), "AttrAny2"); 614 615var obj= new Object(); 616oletest.AttrAny2= obj; 617ret= oletest.AttrAny2; 618Log.print( obj == ret, "AttrAny2"); 619 620 621document.writeln("<p>"); 622// Structs ---------------------------------------------- 623 624/* var struct= oletest._GetStruct("com.sun.star.beans.Property"); */ 625/* struct.Attributes= 1; */ 626/* struct.Handle= 2; */ 627/* struct.Name= "some Property" */ 628/* oletest.methodStruct( struct); */ 629 630var ret= oletest.retMethodStruct(); 631Log.print( ret.Attributes == 127 && ret.Handle == 255 && ret.Name == "OleTest_Property", "retMethodStruct"); 632 633var astruct= oletest._GetStruct("com.sun.star.beans.Property"); 634astruct.Attributes= 1; 635astruct.Handle= 2; 636astruct.Name= "some Property" 637oletest.AttrStruct= astruct; 638 639var ret= oletest.AttrStruct; 640Log.print( ret.Attributes == 127 && ret.Handle == 255 && ret.Name == "OleTest_Property", "AttrStruct"); 641 642// The function returns the struct. Since structs are passed by value the returned struct 643// will be wrapped in another IDispatch object 644astruct.Attributes= 1; 645astruct.Handle= 2; 646astruct.Name= "Property"; 647ret= oletest.methodStruct2( astruct); 648Log.print( ret.Attributes == 1 && ret.Handle == 2 && ret.Name == "Property", "methodStruct2"); 649 650 651document.writeln("<p>"); 652// Test Identity from COM objects in UNO 653var listener1= new XEventListener_Impl(); 654oletest.setObject(listener1); 655ret= oletest.isSame(listener1); 656Log.print2( ret, "Ok Testing identity of COM objects<br>","Failed Testing identity of COM objects<br>"); 657 658var oletest2= oletest.getThis(); 659ret= oletest === oletest2; 660Log.print2(ret, "Ok Testing identity of UNO objects<br>","Failed Testing identity of UNO objects<br>"); 661} 662 663 664 665 666function isEqualAr( ar1, ar2) 667{ 668 var bOk= false; 669 if( ar1.length == ar2.length) 670 { 671 bOk= true; 672 for( x in ar1) 673 { 674// document.writeln( ar1[x] + " "); 675// document.writeln( ar2[x] + " "); 676 if( ar1[x] != ar2[x]) 677 { 678 bOk= false; 679 break; 680 } 681 } 682 } 683 return bOk; 684} 685 686/* function isEqualAr2( ar1, ar2) */ 687/* { */ 688 689/* var bOk= false; */ 690/* if( ar1.length == ar2.length) */ 691/* { */ 692/* bOk= true; */ 693/* for( x in ar1) */ 694/* { */ 695/* document.write( ar1[x]); */ 696/* document.write( ar2[x]); */ 697/* if( ! isEqualAr( ar1[x], ar2[x])) */ 698/* { */ 699/* bOk= false; */ 700/* break; */ 701/* } */ 702/* } */ 703/* } */ 704/* return bOk; */ 705 706/* } */ 707 708function XEventListener_Impl() 709{ 710 this._environment= "JScript"; 711 this._implementedInterfaces= new Array( "com.sun.star.lang.XEventListener"); 712 713 //XEventListener 714 this.disposing= XEventListener_disposing; 715 716 this.bdisposingCalled= false; 717 this.bQuiet= true; 718 this.resetDisposing= XEventListener_resetDisposing; 719 this.disposingCalled= XEventListener_disposingCalled; 720} 721 722function XEventListener_disposing( source) 723{ 724 if( !this.bQuiet) 725 alert("JScript Event Listener \n disposing is being called"); 726 this.bdisposingCalled= true; 727} 728 729function XEventListener_resetDisposing() 730{ 731 this.bdisposingCalled= false; 732} 733 734function XEventListener_disposingCalled() 735{ 736 return this.bdisposingCalled; 737} 738</script> 739 740<script language="VBScript"> 741Function runVBTest( Log) 742document.writeln("================================================================================<br>") 743document.writeln("VB Script<br>") 744document.writeln("================================================================================<p>") 745 746Dim arrInt 747arrInt= Array(1,2,3,-4,-5, 0) 748arrUInt= Array(1,2,3,4,5) 749arrDouble= Array( 1.2345, 12.345, 123.45, 1234.5, 12345) 750arrBool= Array( true, false, true, false, true) 751arrChar= Array("A","B",67) 752arrString= Array("hamburger","cheeseburger", "chicken nuggets", "chicken wings" , "pizza") 753arrAny= Array( 100, 100.1235,"hallo") 754 755 756Dim arrDim2Int(2,1) 757Dim i,j,k 758For i= 0 To 1 759 For j= 0 To 2 760 arrDim2Int(j,i) = i*3 + j 761 Next 762Next 763 764 765Dim arrDim3Int(3,2,1) 766For i= 0 To 1 767 For j= 0 To 2 768 For k= 0 To 3 769 arrDim3Int(k,j,i)= i* 3 + j* 4 + k 770 Next 771 Next 772Next 773 774Dim arrXEvent(2) 775For i= 0 To 2 776 Set arrXEvent(i)= new VBEventListener 777Next 778 779Dim arrXEvent2(2,1) 780For i= 0 To 1 781 For j= 0 To 2 782 Set arrXEvent2(j,i)= new VBEventListener 783 Next 784Next 785 786 787 788ret= oletest.methodByte( arrUInt) 789Log.print isEqualVBAr( ret, arrUInt), "methodByte" 790 791ret= oletest.methodFloat( arrDouble) 792Log.print isEqualVBAr( ret, arrDouble), "methodFloat" 793 794ret= oletest.methodDouble( arrDouble) 795Log.print isEqualVBAr( ret, arrDouble), "methodDouble" 796 797ret= oletest.methodBool( arrBool) 798Log.print isEqualVBAr( ret, arrBool), "methodBool" 799 800ret= oletest.methodShort( arrInt) 801Log.print isEqualVBAr( ret, arrInt), "methodShort" 802 803ret= oletest.methodUShort( arrUInt) 804Log.print isEqualVBAr( ret, arrUInt), "methodUShort" 805 806ret= oletest.methodLong( arrInt) 807Log.print isEqualVBAr( ret, arrInt), "methodLong" 808 809ret= oletest.methodULong( arrUInt) 810Log.print isEqualVBAr( ret, arrUInt), "methodULong" 811 812ret= oletest.methodChar( arrChar) 813bOk= false 814if ret(0) = 65 AND ret(1) = 66 AND ret(2) = 67 then 815 bOk= true 816end if 817Log.print bOk, "methodChar" 818 819ret= oletest.methodString( arrString) 820Log.print isEqualVBAr( ret, arrString), "methodString" 821 822ret= oletest.methodAny( arrAny) 823Log.print isEqualVBAr( ret, arrAny), "methodAny" 824 825 826ret= oletest.methodSequence( arrDim2Int) 827bOk= true 828 829For i= 0 To 1 830 Dim arr1 831 arr1= ret(i) 832 For j= 0 To 2 833 if arr1(j) <> arrDim2Int(j,i) then 834 bOk= false 835 exit for 836 end if 837 Next 838Next 839Log.print bOk, "methodSequence" 840 841ret= oletest.methodSequence2( arrDim3Int) 842'arrDim3Int(3,2,1) 843bOk= true 844For i= 0 To 1 845 arr1= ret(i) 846 For j= 0 To 2 847 arr2= arr1(j) 848 For k= 0 To 3 849 If arr2(k) <> arrDim3Int(k,j,i) then 850 bOk= false 851 exit for 852 End If 853 Next 854 Next 855Next 856Log.print bOk, "methodSequence2" 857 858ret= oletest.methodXInterface(arrXEvent) 859bOk= true 860numArg= UBound( arrXEvent) - LBound( arrXEvent) + 1 861numRet= UBound( ret) - LBound( ret) + 1 862If numArg = numRet then 863 For i= 0 To numArg - 1 864 If NOT (arrXEvent(i) Is ret(i)) then 865 bOk= false 866 Exit For 867 End if 868 Next 869End If 870Log.print bOk, "methodXInterface" 871 872ret= oletest.methodXEventListeners( arrXEvent) 873bOk= true 874For i= 0 To 2 875 If arrXEvent(i).disposingCalled = false then 876 bOk= false 877 Exit For 878 End If 879Next 880Log.print bOk, "methodXEventListeners" 881 882ret= oletest.methodXEventListenersMul(arrXEvent2) 883bOk= true 884For i= 0 To 1 885 For j= 0 To 2 886 If arrXEvent2(j,i).disposingCalled = false then 887 bOk= false 888 Exit For 889 End If 890 Next 891Next 892Log.print bOk, "methodXEventListenersMul" 893 894' Attributes ------------------------------------------------------ 895document.writeln( "<br>" ) 896oletest.AttrByte= arrUInt 897ret= oletest.AttrByte 898Log.print isEqualVBAr( arrUInt, ret), "AttrByte" 899 900oletest.AttrFloat= arrDouble 901ret= oletest.AttrFloat 902Log.print isEqualVBAr( arrDouble, ret), "AttrFloat" 903 904oletest.AttrDouble= arrDouble 905ret= oletest.AttrDouble 906Log.print isEqualVBAr( arrDouble, ret), "AttrDouble" 907 908oletest.AttrBool= arrBool 909ret= oletest.AttrBool 910Log.print isEqualVBAr( arrBool, ret), "AttrBool" 911 912oletest.AttrShort= arrInt 913ret= oletest.AttrShort 914Log.print isEqualVBAr( arrInt, ret), "AttrShort" 915 916oletest.AttrUShort= arrUInt 917ret= oletest.AttrUShort 918Log.print isEqualVBAr( arrUInt, ret), "AttrUShort" 919 920oletest.AttrLong= arrInt 921ret= oletest.AttrLong 922Log.print isEqualVBAr( arrInt, ret), "AttrLong" 923 924oletest.AttrULong= arrUInt 925ret= oletest.AttrULong 926Log.print isEqualVBAr( arrUInt, ret), "AttrULong" 927 928oletest.AttrChar= arrChar 929ret= oletest.AttrChar 930bOk= false 931if ret(0) = 65 AND ret(1) = 66 AND ret(2) = 67 then 932 bOk= true 933end if 934Log.print bOk, "AttrChar" 935 936oletest.AttrString= arrString 937ret= oletest.AttrString 938Log.print isEqualVBAr( arrString, ret), "AttrString" 939 940oletest.AttrSequence= arrDim2Int 941ret= oletest.AttrSequence 942bOk= true 943For i= 0 To 1 944 arr1= ret(i) 945 For j= 0 To 2 946 if arr1(j) <> arrDim2Int(j,i) then 947 bOk= false 948 exit for 949 end if 950 Next 951Next 952Log.print bOk, "AttrSequence" 953 954oletest.AttrSequence2= arrDim3Int 955ret= oletest.AttrSequence2 956'arrDim3Int(3,2,1) 957bOk= true 958For i= 0 To 1 959 arr1= ret(i) 960 For j= 0 To 2 961 arr2= arr1(j) 962 For k= 0 To 3 963 If arr2(k) <> arrDim3Int(k,j,i) then 964 bOk= false 965 exit for 966 End If 967 Next 968 Next 969Next 970Log.print bOk, "AttrSequence2" 971 972oletest.AttrXInterface= arrXEvent 973ret= oletest.AttrXInterface 974bOk= true 975numArg= UBound( arrXEvent) - LBound( arrXEvent) + 1 976numRet= UBound( ret) - LBound( ret) + 1 977If numArg = numRet then 978 For i= 0 To numArg - 1 979 If NOT (arrXEvent(i) Is ret(i)) then 980 bOk= false 981 Exit For 982 End if 983 Next 984End If 985Log.print bOk, "AttrXInterface" 986 987'out params ================================================================================ 988document.writeln("<p>") 989Dim inVal, outVal, retVal 990 991inVal = 111 992retVal = oletest.in_methodByte(inVal) 993oletest.testout_methodByte outVal 994Log.print inVal = retVal, "in_methodByte" 995Log.print outVal = inVal, "testout_methodByte" 996 997inVal = 3.14 998retVal = oletest.in_methodFloat(inVal) 999oletest.testout_methodFloat outVal 1000Log.print inVal = retVal, "in_methodFloat" 1001Log.print outVal > 3.13 AND outVal < 3.15, "testout_methodFloat" 1002 1003inVal = 3.14 1004retVal = oletest.in_methodDouble(inVal) 1005oletest.testout_methodDouble outVal 1006Log.print inVal = retVal, "in_methodDouble" 1007Log.print outVal = 3.14, "testout_methodDouble" 1008 1009inVal = true 1010retVal = oletest.in_methodBool(inVal) 1011oletest.testout_methodBool outVal 1012Log.print inVal = retVal, "in_methodBool" 1013Log.print outVal = inVal, "testout_methodBool" 1014 1015inVal = 222 1016retVal = oletest.in_methodShort(inVal) 1017oletest.testout_methodShort outVal 1018Log.print inVal = retVal, "in_methodShort" 1019Log.print outVal = inVAl, "testout_methodShort" 1020 1021inVal = 333 1022retVal = oletest.in_methodUShort(inVal) 1023oletest.testout_methodUShort outVal 1024Log.print inVal = retVal, "in_methodUShort" 1025Log.print outVal = inVal, "testout_methodUShort" 1026 1027inVal = 4444 1028retVal = oletest.in_methodLong(inVal) 1029oletest.testout_methodLong outVal 1030Log.print inVal = retVal, "in_methodLong" 1031Log.print outVal = inVal, "testout_methodLong" 1032 1033inVal = 5555 1034retVal = oletest.in_methodULong(inVal) 1035oletest.testout_methodULong outVal 1036Log.print inVal = retVal, "in_methodULong" 1037Log.print outVal = inVal, "testout_methodULong" 1038 1039inVal = 65 1040retVal = oletest.in_methodChar(inVal) 1041oletest.testout_methodChar outVal 1042Log.print inVal = retVal, "in_methodChar" 1043Log.print outVal = 65, "testout_methodChar" 1044 1045inVal = "Hello World 3!" 1046retVal = oletest.in_methodString(inVal) 1047oletest.testout_methodString outVal 1048Log.print inVal = retVal, "in_methodString" 1049Log.print outVal = inVal, "testout_methodString" 1050 1051inVal = "Hello World 4!" 1052retVal = oletest.in_methodAny(inVal) 1053oletest.testout_methodAny outVal 1054Log.print outVal = inVal, "testout_methodAny" 1055 1056oletest.testout_methodSequence outVal 1057Log.print isEqualVBAr(outVal, Array( 0,1,2,3,4,5,6,7,8,9)), "testout_methodSequence" 1058 1059oletest.testout_methodSequence2 outVal 1060count= UBound( outVal) - LBound( outVal) + 1 1061ret= False 1062If count = 10 Then 1063 For Each ar In outVal 1064 ret= isEqualVBAr(ar, Array( 0,1,2,3,4,5,6,7,8,9)) 1065 If ret = false Then 1066 Exit For 1067 End If 1068 Next 1069End If 1070Log.print ret, "testout_methodSequence2" 1071 1072outVal= Empty 1073outVal2= Empty 1074oletest.testout_methodMulParams1 outVal, outVal2 1075ret= false 1076If outVal = 999 AND outVal2 = 1111 Then 1077 ret= true 1078End If 1079Log.print ret, "testout_methodMulParams1" 1080 1081outVal= Empty 1082outVal2= Empty 1083outVal3= Empty 1084oletest.testout_methodMulParams2 outVal, outVal2, outVal3 1085ret = false 1086If outVal = 1111 AND outVal2 = 1222 AND outVal3 = " another string" Then 1087 ret= true 1088End If 1089Log.print ret, "testout_methodMulParams2" 1090 1091document.writeln("missing: testout_methodMulParams3 <br>") 1092document.writeln("missing: testout_methodMulParams4 <br>") 1093 1094outVal= Empty 1095oletest.testout_methodXInterface outVal 1096ret= false 1097If outVal Is oletest Then 1098 ret= true 1099End If 1100Log.print ret, "testout_methodXInterface" 1101 1102Set outVal= Nothing 1103document.writeln("missing: testout_methodXInterface <br>") 1104 1105inVal = 1 1106outVal= inVal 1107oletest.testinout_methodByte outVal 1108oletest.testinout_methodByte outVal 1109Log.print inVal = outVal, "testinout_methodByte" 1110 1111 1112document.writeln("missing: testinout_methodFloat <br>") 1113document.writeln("missing: testinout_methodDouble <br>") 1114document.writeln("missing: testinout_methodBool <br>") 1115document.writeln("missing: testinout_methodShort <br>") 1116document.writeln("missing: testinout_methodUShort <br>") 1117document.writeln("missing: testinout_methodLong <br>") 1118document.writeln("missing: testinout_methodULong <br>") 1119document.writeln("missing: testinout_methodChar <br>") 1120document.writeln("missing: testinout_methodString <br>") 1121document.writeln("missing: testinout_methodAny <br>") 1122document.writeln("missing: testinout_methodSequence <br>") 1123document.writeln("missing: testinout_methodSequence2 <br>") 1124document.writeln("missing: testinout_methodXInterface <br>") 1125document.writeln("missing: methodAnyTest1 <br>") 1126document.writeln("missing: methodAnyTest1 <br>") 1127document.writeln("missing: methodAnyTest1 <br>") 1128document.writeln("missing: methodAnyTest1 <br>") 1129document.writeln("missing: methodAnyTest1 <br>") 1130document.writeln("missing: AttrAny2 <br>") 1131document.writeln("missing: methodAnyTest1 <br>") 1132document.writeln("missing: methodAnyTest1 <br>") 1133document.writeln("missing: methodAnyTest1 <br>") 1134document.writeln("missing: methodAnyTest1 <br>") 1135document.writeln("missing: methodAnyTest1 <br>") 1136document.writeln("missing: retMethodStruct <br>") 1137document.writeln("missing: AttrStruct <br>") 1138document.writeln("missing: methodStruct2 <br>") 1139 1140' Test Identity from COM objects in UNO 1141Dim listener1 1142Set listener1= new VBEventListener 1143call oletest.setObject( listener1) 1144ret= oletest.isSame(listener1) 1145Log.print2 ret, "Ok Testing identity of COM objects <br>","Failed Testing identity of COM objects<br>" 1146' Test identity of UNO objects 1147 1148set oletest2= oletest.getThis() 1149ret= oletest Is oletest2 1150Log.print2 ret, "Ok Testing identity of UNO objects<br>","Failed Testing identity of UNO objects<br>" 1151 1152End Function 1153 1154 1155Function isEqualVBAr( arr1, arr2) 1156 ret = false 1157 s1= UBound( arr1) - LBound( arr1) + 1 1158 s2= UBound( arr2) - LBound( arr2) + 1 1159 1160 if s1 = s2 then 1161 ret= true 1162 Dim i 1163 for i= 0 To s1 - 1 1164 if arr1(i) <> arr2(i) then 1165 ret= false 1166 exit for 1167 end if 1168 next 1169 end if 1170 isEqualVBar= ret 1171End Function 1172 1173 1174'The listener object 1175 1176Class VBEventListener 1177 Dim Bridge_ImplementedInterfaces(0) 1178 Dim bDisposingCalled 1179 1180'XEventListener::disposing 1181 Function disposing( source) 1182 bDisposingCalled= true 1183 End Function 1184 1185 Sub Class_Initialize() 1186 bDisposingCalled= false 1187 Bridge_ImplementedInterfaces(0)= "com.sun.star.lang.XEventListener" 1188 End Sub 1189 1190 Function resetDisposing() 1191 bDisposingCalled= false 1192 End Function 1193 1194 Function disposingCalled() 1195 disposingCalled= bDisposingCalled 1196 End Function 1197End Class 1198 1199 1200sub callBasic(id) 1201 1202 Dim factory 1203 Set factory= GetObject("", "com.sun.star.ServiceManager") 1204 1205 Set oletest= factory.createInstance("oletest.OleTest") 1206 1207 1208 arrInt= Array(1,2,3,4,5) 1209 arrInt2= Array( -1, -2, 127, 128, 0) 1210 arrDouble= Array(1.1, 2.2, 3.3, 4.4, 5.5) 1211 arrBool= Array(0,1,0,2,0) 1212 arrLong= Array( &Hff, &Hffff, &Hffffff, &Hffffffff) 1213 arrString= Array("Chicken Wings", "Cheeseburger", "Hamburger") 1214 arrChar= Array("a",65, "M") 1215 arrAny= Array("Mickey", 3.14, 100, "A") 1216 1217 Dim arrDim2Int(1,2) 1218 For i= 0 To 1 1219 For j= 0 To 1 1220 arrDim2Int(i,j) = i*2 + j 1221 Next 1222 Next 1223 1224 Dim arrDim3Int(1,1,1) 1225 For i= 0 To 1 1226 For j= 0 To 1 1227 For k=0 To 1 1228 arrDim3Int(i,j,k) = i*2 + j*2 + k 1229 Next 1230 Next 1231 Next 1232 1233 1234 select case id 1235 1236 // Out Parameter 1237 1238 1239 1240 // In Out Parameter -------------------------------------------------- 1241 case 100 1242 a= 100 1243 document.write "param: " & CStr( a) & "<br>" 1244 oletest.testinout_methodByte a 1245 document.write a 1246 case 101 1247 a= 1.11 1248 document.write "param: " & CStr( a) & "<br>" 1249 oletest.testinout_methodDouble a 1250 document.write a 1251 case 102 1252 a= 5 1253 document.write "param: "& CStr( a) & "<br>" 1254 oletest.testinout_methodBool a 1255 document.write a 1256 case 103 1257 a= -10 1258 document.write "param: "& CStr( a) & "<br>" 1259 oletest.testinout_methodShort a 1260 document.write a 1261 case 104 1262 a= 128 1263 document.write "param: "& CStr( a) & "<br>" 1264 oletest.testinout_methodUShort a 1265 document.write a 1266 case 105 1267 a= 65556 1268 document.write "param: "& CStr( a) & "<br>" 1269 oletest.testinout_methodLong a 1270 document.write a 1271 case 106 1272 a= 65556 1273 document.write "param: "& CStr( a) & "<br>" 1274 oletest.testinout_methodULong a 1275 document.write a 1276 case 107 1277 a= "ein test string" 1278 document.write "param: "& CStr( a) & "<br>" 1279 oletest.testinout_methodString a 1280 document.write a 1281 case 108 1282 a= "W" 1283 document.write "param: "& CStr( a) & "<br>" 1284 oletest.testinout_methodChar a 1285 document.write a 1286 case 109 1287 a= "Ein String im Any" 1288 document.write "param: "& CStr( a) & "<br>" 1289 oletest.other_methodAnyIn a 1290 document.write a 1291 1292 case 150 1293 dim a 1294 document.write "param: "& CStr( a) & "<br>" 1295 oletest.testout_methodByte( a) 1296 document.write a 1297// Attributes ----------------------------------------------------------------- 1298 case 200 1299 document.write "set: " 1300 printArray arrInt 1301 oletest.AttrByte= arrInt 1302 b= oletest.AttrByte 1303 call printArrayEx( "<br> get: ", "<br>", b) 1304 case 201 1305 document.write "set: " 1306 printArray arrDouble 1307 oletest.AttrDouble= arrDouble 1308 b= oletest.AttrDouble 1309 call printArrayEx( "<br> get: ", "<br>", b) 1310 case 202 1311 document.write "set: " 1312 printArray arrBool : 1313 oletest.AttrBool= arrBool 1314 b= oletest.AttrBool 1315 call printArrayEx( "<br> get: ", "<br>", b) 1316 case 203 1317 document.write "set: " 1318 printArray arrInt2 : 1319 oletest.AttrShort= arrInt2 1320 b= oletest.AttrShort 1321 call printArrayEx( "<br> get: ", "<br>", b) 1322 case 204 1323 document.write "set: " 1324 printArray arrInt 1325 oletest.AttrUShort= arrInt 1326 b= oletest.AttrUShort 1327 call printArrayEx( "<br> get: ", "<br>", b) 1328 case 205 1329 document.write "set: " 1330 printArray arrInt2 1331 oletest.AttrLong= arrInt2 1332 b= oletest.AttrLong 1333 call printArrayEx( "<br> get: ", "<br>", b) 1334 case 206 1335 document.write "set: " 1336 printArray arrInt 1337 oletest.AttrULong= arrInt 1338 b= oletest.AttrULong 1339 call printArrayEx( "<br> get: ", "<br>", b) 1340 case 207 1341 document.write "set: " 1342 printArray arrString 1343 oletest.AttrString= arrString 1344 b= oletest.AttrString 1345 call printArrayEx( "<br> get: ", "<br>", b) 1346 case 208 1347 document.write "set: " 1348 printArray arrChar 1349 oletest.AttrChar= arrChar 1350 b= oletest.AttrChar 1351 call printArrayEx( "<br> get: ", "<br>", b) 1352 case 209 1353 document.write "set: " 1354 printArray arrAny 1355 oletest.AttrAny= arrAny 1356 b= oletest.AttrAny 1357 call printArrayEx( "<br> get: ", "<br>", b) 1358 1359 case 210 1360 document.write "set: <br>" 1361 printArray2 arrDim2Int : 1362 oletest.AttrSequence= arrDim2Int 1363 ret= oletest.AttrSequence 1364 document.write "get: " 1365 for each val in ret 1366 document.write "<br> array: " 1367 for each val2 in val 1368 document.write val2 1369 next 1370 next 1371 1372 case 300 1373 dim aByte 1374 aByte= 100 1375 call oletest.testinout_methodByte( aByte) 1376 MsgBox aByte 1377 1378 1379 case 400 1380 1381 set struct= oletest.Bridge_GetStruct("com.sun.star.beans.Property") 1382 struct.Attributes= 1 1383 struct.Handle= 2 1384 struct.Name= "some Property" 1385 oletest.methodStruct struct 1386 1387 case 401 1388 set struct= oletest.retMethodStruct() 1389 alert( "Property::Attributes : " & struct.Attributes & vblf & " Property::Handle : " _ 1390 & struct.Handle & vblf & " Property::Name : " & struct.Name) 1391 1392 case 402 1393 set struct= oletest.Bridge_GetStruct("com.sun.star.beans.Property") 1394 struct.Attributes= 1 1395 struct.Handle= 2 1396 struct.Name= "some Property" 1397 oletest.AttrStruct= struct 1398 1399 set struct2= oletest.AttrStruct 1400 alert( "property get: " & vblf & "Property::Attributes : " & struct2.Attributes & _ 1401 vblf & " Property::Handle : " & struct2.Handle & vblf & " Property::Name : " _ 1402 & struct2.Name) 1403 end select 1404end sub 1405 1406sub printArray( arr) 1407 document.write "array: " 1408 For Each val In arr 1409 document.write CStr(val) & " " 1410 Next 1411end sub 1412 1413// print a 2 dimensional Array 1414 1415sub printArray2( arr) 1416 elements1= UBound( arr, 1) - LBound( arr, 1) +1 1417 elements2= UBound( arr, 2) - LBound( arr, 2) +1 1418 1419 For i=0 To elements1 -1 1420 document.write( "array " & CStr( i) & ": " ) 1421 For j=0 To elements2 -1 1422 document.write CStr( arr(i,j)) 1423 Next 1424 document.write( "<br>") 1425 Next 1426end sub 1427 1428sub printArrayEx( pre, post, array) 1429 document.write pre 1430 printArray array 1431 document.write post 1432end sub 1433</script> 1434 1435<script language="JScript"> 1436var arFunctions= new Array(); 1437arFunctions["methodByte"]= "sequence<byte> methodByte( [in] sequence<byte> aSeq )"; 1438arFunctions["methodFloat"]= "sequence<float> methodFloat( [in] sequence<float> aSeq)"; 1439arFunctions["methodDouble"]= "sequence<double> methodDouble( [in] sequence<double> aSeq)"; 1440arFunctions["methodBool"]= "sequence<boolean> methodBool( [in] sequence<boolean> aSeq)"; 1441arFunctions["methodShort"]= "sequence<short> methodShort( [in] sequence<short> aSeq)"; 1442arFunctions["methodUShort"]= "sequence<unsigned short> methodUShort( [in] sequence<unsigned short> aSeq)"; 1443arFunctions["methodLong"]= "sequence<long> methodLong( [in] sequence<long> aSeq)"; 1444arFunctions["methodULong"]= "sequence<unsigned long> methodULong( [in] sequence<unsigned long> aSeq)"; 1445arFunctions["methodString"]= "sequence<string> methodString( [in] sequence<string> aSeq)"; 1446arFunctions["methodChar"]= "sequence<char> methodChar( [in] sequence<char> aSeq)"; 1447arFunctions["methodAny"]= "sequence<any> methodAny ( [in] sequence<any> aSeq)"; 1448arFunctions["methodXInterface"]= "sequence<XInterface> methodXInterface ( [in] sequence<XInterface> aSeq)"; 1449arFunctions["methodSequence"]= "sequence< sequence <long> > methodSequence( [in] sequence< sequence< long > > aSeq)"; 1450arFunctions["methodSequence2"]= "sequence< sequence <sequence <long> > > methodSequence2( [in] sequence< sequence< sequence<long> > > aSeq)"; 1451arFunctions["methodXEventListeners"]= "sequence< com::sun::star::lang::XEventListener > methodXEventListeners( [in] sequence<com::sun::star::lang::XEventListener> aSeq)"; 1452arFunctions["methodXEventListenersMul"]= "sequence< sequence< com::sun::star::lang::XEventListener > > methodXEventListenersMul( [in] sequence< sequence< com::sun::star::lang::XEventListener> > aSeq)"; 1453arFunctions["AttrByte"]="[attribute] sequence<byte> AttrByte"; 1454arFunctions["AttrFloat"]="[attribute] sequence<float> AttrFloat"; 1455arFunctions["AttrDouble"]="[attribute] sequence<double> AttrDouble"; 1456arFunctions["AttrBool"]="[attribute] sequence<boolean> AttrBool"; 1457arFunctions["AttrShort"]="[attribute] sequence<short> AttrShort"; 1458arFunctions["AttrUShort"]="[attribute] sequence<unsigned short> AttrUShort"; 1459arFunctions["AttrLong"]="[attribute] sequence<long> AttrLong"; 1460arFunctions["AttrULong"]="[attribute] sequence<unsigned long> AttrULong"; 1461arFunctions["AttrString"]="[attribute] sequence<string> AttrString"; 1462arFunctions["AttrChar"]="[attribute] sequence<char> AttrChar"; 1463arFunctions["AttrAny"]="[attribute] sequence<any> AttrAny"; 1464arFunctions["AttrSequence"]="[attribute] sequence< sequence<long> > AttrSequence"; 1465arFunctions["AttrSequence2"]="[attribute] sequence< sequence< sequence <long> > > AttrSequence2"; 1466arFunctions["AttrXInterface"]="[attribute] sequence< com::sun::star::uno::XInterface > AttrXInterface"; 1467 1468arFunctions["testout_methodByte"]= " void testout_methodByte( [out] byte rOut )"; 1469arFunctions["testout_methodFloat"]= "void testout_methodFloat( [out] float rOut)"; 1470arFunctions["testout_methodDouble"]= "void testout_methodDouble( [out] double rOut)"; 1471arFunctions["testout_methodBool"]= "void testout_methodBool( [out] boolean rOut)"; 1472arFunctions["testout_methodShort"]= "void testout_methodShort( [out] short rOut)"; 1473arFunctions["testout_methodUShort"]= "void testout_methodUShort( [out] unsigned short rOut)"; 1474arFunctions["testout_methodLong"]= "void testout_methodLong( [out] long rOut)"; 1475arFunctions["testout_methodULong"]= "void testout_methodULong( [out] unsigned long rOut)"; 1476arFunctions["testout_methodString"]= "void testout_methodString( [out] string rOut)"; 1477arFunctions["testout_methodChar"]= "void testout_methodChar( [out] char rOut)"; 1478arFunctions["testout_methodAny"]= "void testout_methodAny( [out] any rOut)"; 1479arFunctions["testout_methodSequence"]= "void testout_methodSequence( [out] sequence< long > rOut)"; 1480arFunctions["testout_methodSequence2"]= "void testout_methodSequence2( [out] sequence < sequence< long > > rOut)"; 1481arFunctions["testout_methodXInterface"]= "void testout_methodXInterface( [out] com::sun::star::uno::XInterface rOut)"; 1482arFunctions["testout_methodMulParams1"]= "void testout_methodMulParams1( [out] long rout1, [out] long rout2)"; 1483arFunctions["testout_methodMulParams2"]= "void testout_methodMulParams2( [out] long rout1, [out] long rout2, [out] string rout3)"; 1484arFunctions["testout_methodMulParams3"]= "void testout_methodMulParams3( [in] string sin, [out] string sout)"; 1485arFunctions["testout_methodMulParams4"]= "void testout_methodMulParams4( [in] float in1, [out] float out1, [in] long in2, [out] long out2, [in] long in3)"; 1486arFunctions["testinout_methodByte"]="void testinout_methodByte( [inout] byte rOut )"; 1487arFunctions["testinout_methodFloat"]="void testinout_methodFloat( [inout] float rOut)"; 1488arFunctions["testinout_methodDouble"]="void testinout_methodDouble( [inout] double rOut)"; 1489arFunctions["testinout_methodBool"]="void testinout_methodBool( [inout] boolean rOut)"; 1490arFunctions["testinout_methodShort"]="void testinout_methodShort( [inout] short rOut)"; 1491arFunctions["testinout_methodUShort"]="void testinout_methodUShort( [inout] unsigned short rOut)"; 1492arFunctions["testinout_methodLong"]="void testinout_methodLong( [inout] long rOut)"; 1493arFunctions["testinout_methodULong"]="void testinout_methodULong( [inout] unsigned long rOut)"; 1494arFunctions["testinout_methodString"]="void testinout_methodString( [inout] string rOut)"; 1495arFunctions["testinout_methodChar"]="void testinout_methodChar( [inout] char rOut)"; 1496arFunctions["testinout_methodAny"]="void testinout_methodAny( [inout] any rOut)"; 1497arFunctions["testinout_methodSequence"]="void testinout_methodSequence( [inout] sequence< long > rOut)"; 1498arFunctions["testinout_methodSequence2"]="void testinout_methodSequence2( [inout] sequence < sequence< long > > rOut)"; 1499arFunctions["testinout_methodXInterface"]="void testinout_methodXInterface( [inout] com::sun::star::script::XInvocation rOut)"; 1500arFunctions["testinout_methodXInterface2"]="void testinout_methodXInterface2( [inout] com::sun::star::uno::XInterface rOut)"; 1501 1502arFunctions["in_methodByte"]= "byte in_methodByte( [in] byte rIn )"; 1503arFunctions["in_methodFloat"]= "float in_methodFloat( [in] float rIn);" 1504arFunctions["in_methodDouble"]= "double in_methodDouble( [in] double rIn)"; 1505arFunctions["in_methodBool"]= "boolean in_methodBool( [in] boolean rIn)"; 1506arFunctions["in_methodShort"]= "short in_methodShort( [in] short rIn)"; 1507arFunctions["in_methodUShort"]= "unsigned short in_methodUShort( [in] unsigned short rIn)"; 1508arFunctions["in_methodLong"]= "long in_methodLong( [in] long rIn)"; 1509arFunctions["in_methodULong"]= "unsigned long in_methodULong( [in] unsigned long rIn)"; 1510arFunctions["in_methodHyper"]= "hyper in_methodHyper( [in] hyper rIn)"; 1511arFunctions["in_methodUHyper"]= "unsigned hyper in_methodHyper( [in] unsigned hyper rIn)"; 1512arFunctions["in_methodString"]= "string in_methodString( [in] string rIn)"; 1513arFunctions["in_methodChar"]= "char in_methodChar( [in] char rIn)"; 1514arFunctions["in_methodAny"]= "any in_methodAny ( [in] any rIn)"; 1515arFunctions["in_methodXInterface"]= "XInterface in_methodXInterface([in] XInterface rIn)"; 1516 1517 1518arFunctions["methodAnyTest1"]="any methodAnyTest1( [in] any rIn)"; 1519arFunctions["AttrAny2"]= "[attribute] any AttrAny2"; 1520arFunctions["retMethodStruct"]= "com::sun::star::beans::Property retMethodStruct()"; 1521arFunctions["AttrStruct"]= "[attribute] com::sun::star::beans::Property AttrStruct"; 1522arFunctions["methodStruct2"]= "com::sun::star::beans::Property methodStruct2( [in] com::sun::star::beans::Property aProp)"; 1523 1524 1525var factory= new ActiveXObject("com.sun.star.ServiceManager"); 1526var oletest= factory.createInstance("oletest.OleTest"); 1527 1528Log= new Logger(); 1529 1530 1531runJScriptTest(Log); 1532runVBTest(Log); 1533Log.summarize(); 1534 1535 1536function Logger() 1537{ 1538 this.print= logger_print; 1539 this.print2= logger_print2; 1540 this.summarize= logger_summarize; 1541 this.bAllOk= true; 1542} 1543function logger_print( bool, method) 1544{ 1545 this.print2(bool, "Ok " + arFunctions[method] + "<br>", 1546 "Failed " + arFunctions[method] + "<br>"); 1547} 1548 1549function logger_print2( bool, okString, failedString) 1550{ 1551 if( bool) 1552 document.writeln( okString); 1553 else 1554 { 1555 document.writeln( failedString); 1556 this.bAllOk= this.bAllOk && false; 1557 } 1558} 1559 1560function logger_summarize() 1561{ 1562 document.writeln("<p> ==============================================================================<br>"); 1563 if(this.bAllOk) 1564 document.writeln("No errors <br>"); 1565 else 1566 document.writeln("Error ! The test failed! <br>"); 1567} 1568 1569 1570</script> 1571 1572</body> 1573</html> 1574 1575 1576