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 package com.sun.star.comp.bridge; 25 26 import com.sun.star.comp.loader.FactoryHelper; 27 28 import com.sun.star.lang.XServiceInfo; 29 import com.sun.star.lang.XTypeProvider; 30 31 import com.sun.star.test.performance.ComplexTypes; 32 import com.sun.star.test.performance.XPerformanceTest; 33 34 import test.testtools.bridgetest.BadConstructorArguments; 35 import test.testtools.bridgetest.Constructors; 36 import test.testtools.bridgetest.Constructors2; 37 import test.testtools.bridgetest.TestDataElements; 38 import test.testtools.bridgetest.TestElement; 39 import test.testtools.bridgetest.TestEnum; 40 import test.testtools.bridgetest.TestPolyStruct; 41 import test.testtools.bridgetest.TestPolyStruct2; 42 import test.testtools.bridgetest.TestStruct; 43 import test.testtools.bridgetest.SmallStruct; 44 import test.testtools.bridgetest.MediumStruct; 45 import test.testtools.bridgetest.BigStruct; 46 import test.testtools.bridgetest.AllFloats; 47 import test.testtools.bridgetest.XBridgeTest; 48 import test.testtools.bridgetest.XBridgeTest2; 49 import test.testtools.bridgetest.XCurrentContextChecker; 50 import test.testtools.bridgetest.XMulti; 51 import test.testtools.bridgetest.XRecursiveCall; 52 53 54 import com.sun.star.lang.IllegalArgumentException; 55 import com.sun.star.lang.XMultiServiceFactory; 56 import com.sun.star.lang.XSingleServiceFactory; 57 58 import com.sun.star.registry.XRegistryKey; 59 60 import com.sun.star.uno.Any; 61 import com.sun.star.uno.Type; 62 import com.sun.star.uno.XComponentContext; 63 import com.sun.star.uno.XInterface; 64 65 public class TestComponent { 66 static public final boolean DEBUG = false; 67 68 static public class _PerformancTestObject implements XPerformanceTest, XServiceInfo, XTypeProvider { 69 static private final String __serviceName = "com.sun.star.comp.benchmark.JavaTestObject"; 70 71 private boolean _bool; 72 private char _char; 73 private byte _byte; 74 private short _short; 75 private int _long; 76 private int _ulong; 77 private long _hyper; 78 private float _float; 79 private double _double; 80 private String _string = ""; 81 private Object _xInterface; 82 private Object _any; 83 private Object _interface_sequence[] = new Object[0]; 84 private ComplexTypes _complexTypes = new ComplexTypes(); 85 86 // Attributes 87 public int getLong_attr() throws com.sun.star.uno.RuntimeException { 88 return _long; 89 } 90 91 public void setLong_attr( int _long_attr ) throws com.sun.star.uno.RuntimeException { 92 _long = _long_attr; 93 } 94 95 public long getHyper_attr() throws com.sun.star.uno.RuntimeException { 96 return _hyper; 97 } 98 99 public void setHyper_attr( long _hyper_attr ) throws com.sun.star.uno.RuntimeException { 100 _hyper = _hyper_attr; 101 } 102 103 public float getFloat_attr() throws com.sun.star.uno.RuntimeException { 104 return _float; 105 } 106 107 public void setFloat_attr( float _float_attr ) throws com.sun.star.uno.RuntimeException { 108 _float = _float; 109 } 110 111 public double getDouble_attr() throws com.sun.star.uno.RuntimeException { 112 return _double; 113 } 114 115 public void setDouble_attr( double _double_attr ) throws com.sun.star.uno.RuntimeException { 116 _double = _double_attr; 117 } 118 119 public String getString_attr() throws com.sun.star.uno.RuntimeException { 120 return _string; 121 } 122 123 public void setString_attr( String _string_attr ) throws com.sun.star.uno.RuntimeException { 124 _string = _string_attr; 125 } 126 127 public Object getInterface_attr() throws com.sun.star.uno.RuntimeException { 128 return _xInterface; 129 } 130 131 public void setInterface_attr( java.lang.Object _interface_attr ) throws com.sun.star.uno.RuntimeException { 132 _xInterface = _interface_attr; 133 } 134 135 public Object getAny_attr() throws com.sun.star.uno.RuntimeException { 136 return _any; 137 } 138 139 public void setAny_attr(Object _any_attr ) throws com.sun.star.uno.RuntimeException { 140 _any = _any_attr; 141 } 142 143 public Object[] getSequence_attr() throws com.sun.star.uno.RuntimeException { 144 return _interface_sequence; 145 } 146 147 public void setSequence_attr(Object[] _sequence_attr ) throws com.sun.star.uno.RuntimeException { 148 _interface_sequence = _sequence_attr; 149 } 150 151 public ComplexTypes getStruct_attr() throws com.sun.star.uno.RuntimeException { 152 return _complexTypes; 153 } 154 155 public void setStruct_attr( ComplexTypes _struct_attr ) throws com.sun.star.uno.RuntimeException { 156 _complexTypes = _struct_attr; 157 } 158 159 160 // Methods 161 public void async() throws com.sun.star.uno.RuntimeException { 162 } 163 164 public void sync( ) throws com.sun.star.uno.RuntimeException { 165 } 166 167 public ComplexTypes complex_in( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException { 168 return aVal; 169 } 170 171 public ComplexTypes complex_inout( /*INOUT*/ComplexTypes[] aVal ) throws com.sun.star.uno.RuntimeException { 172 return aVal[0]; 173 } 174 175 public void complex_oneway( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException { 176 } 177 178 public void complex_noreturn( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException { 179 } 180 181 public XPerformanceTest createObject( ) throws com.sun.star.uno.RuntimeException { 182 return new _PerformancTestObject(); 183 } 184 185 public int getLong() throws com.sun.star.uno.RuntimeException { 186 return _long; 187 } 188 189 public void setLong(/*IN*/int n) throws com.sun.star.uno.RuntimeException { 190 _long = n; 191 } 192 193 public long getHyper() throws com.sun.star.uno.RuntimeException { 194 return _hyper; 195 } 196 197 public void setHyper(/*IN*/long n) throws com.sun.star.uno.RuntimeException { 198 _hyper = n; 199 } 200 201 public float getFloat() throws com.sun.star.uno.RuntimeException { 202 return _float; 203 } 204 205 public void setFloat( /*IN*/float f ) throws com.sun.star.uno.RuntimeException { 206 _float = f; 207 } 208 209 public double getDouble( ) throws com.sun.star.uno.RuntimeException { 210 return _double; 211 } 212 213 public void setDouble( /*IN*/double f ) throws com.sun.star.uno.RuntimeException { 214 _double = f; 215 } 216 217 public String getString( ) throws com.sun.star.uno.RuntimeException { 218 return _string; 219 } 220 221 public void setString( /*IN*/String s ) throws com.sun.star.uno.RuntimeException { 222 _string = s; 223 } 224 225 public Object getInterface( ) throws com.sun.star.uno.RuntimeException { 226 return _xInterface; 227 } 228 229 public void setInterface( /*IN*/Object x ) throws com.sun.star.uno.RuntimeException { 230 _xInterface = x; 231 } 232 233 public Object getAny( ) throws com.sun.star.uno.RuntimeException { 234 return _any; 235 } 236 237 public void setAny( /*IN*/java.lang.Object a ) throws com.sun.star.uno.RuntimeException { 238 _any = a; 239 } 240 241 public Object[] getSequence( ) throws com.sun.star.uno.RuntimeException { 242 return _interface_sequence; 243 } 244 245 public void setSequence( /*IN*/Object[] seq ) throws com.sun.star.uno.RuntimeException { 246 if(DEBUG) System.err.println("#### " + getClass().getName() + ".setSequence:" + seq); 247 248 _interface_sequence = seq; 249 } 250 251 public ComplexTypes getStruct( ) throws com.sun.star.uno.RuntimeException { 252 return _complexTypes; 253 } 254 255 public void setStruct( /*IN*/ComplexTypes c ) throws com.sun.star.uno.RuntimeException { 256 _complexTypes = c; 257 } 258 259 public void raiseRuntimeException( ) throws com.sun.star.uno.RuntimeException { 260 throw new com.sun.star.uno.RuntimeException(); 261 } 262 263 // XServiceInfo 264 public String getImplementationName() throws com.sun.star.uno.RuntimeException { 265 return __serviceName; 266 } 267 268 public boolean supportsService(String rServiceName) throws com.sun.star.uno.RuntimeException { 269 String rSNL[] = getSupportedServiceNames(); 270 271 for(int nPos = rSNL.length; (nPos--) != 0;) { 272 if (rSNL[nPos].equals(rServiceName)) 273 return true; 274 } 275 276 return false; 277 } 278 279 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException { 280 return new String[]{__serviceName}; 281 } 282 283 // XTypeProvider 284 public Type[] getTypes() throws com.sun.star.uno.RuntimeException { 285 try { 286 return new Type[]{new Type(XPerformanceTest.class), new Type(XServiceInfo.class), new Type(XTypeProvider.class)}; 287 } 288 catch(Exception exception) { 289 throw new com.sun.star.uno.RuntimeException(exception.getMessage()); 290 } 291 } 292 293 public byte[] getImplementationId() throws com.sun.star.uno.RuntimeException { 294 return toString().getBytes(); 295 } 296 } 297 298 static public class _TestObject implements XBridgeTest2, XRecursiveCall, XServiceInfo, XTypeProvider { 299 static private final String __serviceName = "com.sun.star.test.bridge.JavaTestObject"; 300 301 private boolean _bool; 302 private char _char; 303 private byte _byte; 304 private short _short; 305 private short _ushort; 306 private int _long; 307 private int _ulong; 308 private long _hyper; 309 private long _uhyper; 310 private float _float; 311 private double _double; 312 private String _string; 313 private Object _xInterface; 314 private Object _any; 315 private TestEnum _testEnum = TestEnum.TEST; 316 private TestElement _testElements[] = new TestElement[0]; 317 private TestDataElements _testDataElements = new TestDataElements(); 318 319 private int _nLastCallId; 320 private boolean _bFirstCall; 321 private boolean _bSequenceOfCallTestPassed; 322 323 private boolean[] arBool; 324 private char[] arChar; 325 private byte[] arByte; 326 private short[] arShort; 327 private short[] arUShort; 328 private int[] arLong; 329 private int[] arULong; 330 private long[] arHyper; 331 private long[] arUHyper; 332 private float[] arFloat; 333 private double[] arDouble; 334 private String[] arString; 335 private Object[] arObject; 336 private Object[] arAny; 337 private TestEnum[] arEnum; 338 private int[][] arLong2; 339 private int[][][] arLong3; 340 public _TestObject(XMultiServiceFactory xMultiServiceFactory) { 341 if(DEBUG) System.err.println("##### " + getClass().getName() + ".<init> " + xMultiServiceFactory); 342 343 _nLastCallId = 0; 344 _bFirstCall = true; 345 _bSequenceOfCallTestPassed = true; 346 } 347 348 349 public void setValues(boolean bBool, 350 char cChar, 351 byte nByte, 352 short nShort, 353 short nUShort, 354 int nLong, 355 int nULong, 356 long nHyper, 357 long nUHyper, 358 float fFloat, 359 double fDouble, 360 TestEnum testEnum, 361 String string, 362 Object xInterface, 363 Object any, 364 TestElement testElements[], 365 TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException 366 { 367 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setValues:" + any); 368 369 _bool = bBool; 370 _char = cChar; 371 _byte = nByte; 372 _short = nShort; 373 _ushort = nUShort; 374 _long = nLong; 375 _ulong = nULong; 376 _hyper = nHyper; 377 _uhyper = nUHyper; 378 _float = fFloat; 379 _double = fDouble; 380 _testEnum = testEnum; 381 _string = string; 382 _xInterface = xInterface; 383 _any = any; 384 _testElements = testElements; 385 _testDataElements = testDataElements; 386 } 387 388 389 390 public TestDataElements setValues2(/*INOUT*/boolean[] io_bool, 391 /*INOUT*/char[] io_char, 392 /*INOUT*/byte[] io_byte, 393 /*INOUT*/short[] io_short, 394 /*INOUT*/short[] io_ushort, 395 /*INOUT*/int[] io_long, 396 /*INOUT*/int[] io_ulong, 397 /*INOUT*/long[] io_hyper, 398 /*INOUT*/long[] io_uhyper, 399 /*INOUT*/float[] io_float, 400 /*INOUT*/double[] io_double, 401 /*INOUT*/TestEnum[] io_testEnum, 402 /*INOUT*/String[] io_string, 403 /*INOUT*/Object[] io_xInterface, 404 /*INOUT*/Object[] io_any, 405 /*INOUT*/TestElement[][] io_testElements, 406 /*INOUT*/TestDataElements[] io_testDataElements) throws com.sun.star.uno.RuntimeException 407 { 408 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setValues2:" + io_any[0]); 409 410 _bool = io_bool[0]; 411 _char = io_char[0]; 412 _byte = io_byte[0]; 413 _short = io_short[0]; 414 _ushort = io_ushort[0]; 415 _long = io_long[0]; 416 _ulong = io_ulong[0]; 417 _hyper = io_hyper[0]; 418 _uhyper = io_uhyper[0]; 419 _float = io_float[0]; 420 _double = io_double[0]; 421 _testEnum = io_testEnum[0]; 422 _string = io_string[0]; 423 _xInterface = io_xInterface[0]; 424 _any = io_any[0]; 425 _testElements = io_testElements[0]; 426 _testDataElements = io_testDataElements[0]; 427 428 io_testElements[ 0 ] = 429 new TestElement [] { io_testElements[ 0 ][ 1 ], io_testElements[ 0 ][ 0 ] }; 430 431 return _testDataElements; 432 } 433 434 public TestDataElements getValues(/*OUT*/boolean[] o_bool, 435 /*OUT*/char[] o_char, 436 /*OUT*/byte[] o_byte, 437 /*OUT*/short[] o_short, 438 /*OUT*/short[] o_ushort, 439 /*OUT*/int[] o_long, 440 /*OUT*/int[] o_ulong, 441 /*OUT*/long[] o_hyper, 442 /*OUT*/long[] o_uhyper, 443 /*OUT*/float[] o_float, 444 /*OUT*/double[] o_double, 445 /*OUT*/TestEnum[] o_testEnum, 446 /*OUT*/String[] o_string, 447 /*OUT*/Object[] o_xInterface, 448 /*OUT*/Object[] o_any, 449 /*OUT*/TestElement[][] o_testElements, 450 /*OUT*/TestDataElements[] o_testDataElements) throws com.sun.star.uno.RuntimeException 451 { 452 if(DEBUG) System.err.println("##### " + getClass().getName() + ".getValues:" + _any); 453 454 o_bool[0] = _bool; 455 o_char[0] = _char; 456 o_byte[0] = _byte; 457 o_short[0] = _short; 458 o_ushort[0] = _ushort; 459 o_long[0] = _long; 460 o_ulong[0] = _ulong; 461 o_hyper[0] = _hyper; 462 o_uhyper[0] = _uhyper; 463 o_float[0] = _float; 464 o_double[0] = _double; 465 o_testEnum[0] = _testEnum; 466 o_string[0] = _string; 467 o_xInterface[0] = _xInterface; 468 o_any[0] = _any; 469 o_testElements[0] = _testElements; 470 o_testDataElements[0] = _testDataElements; 471 472 return _testDataElements; 473 } 474 475 public SmallStruct echoSmallStruct( SmallStruct i_Struct) throws com.sun.star.uno.RuntimeException { 476 return i_Struct; 477 } 478 479 public MediumStruct echoMediumStruct( MediumStruct i_Struct) throws com.sun.star.uno.RuntimeException { 480 return i_Struct; 481 } 482 483 public BigStruct echoBigStruct( BigStruct i_Struct) throws com.sun.star.uno.RuntimeException { 484 return i_Struct; 485 } 486 487 public AllFloats echoAllFloats( AllFloats i_Struct) throws com.sun.star.uno.RuntimeException { 488 return i_Struct; 489 } 490 491 public int testPPCAlignment( long l1, long l2, int i1, long l3, int i2 ) throws com.sun.star.uno.RuntimeException { 492 return i2; 493 } 494 495 // Attributes 496 public boolean getBool() throws com.sun.star.uno.RuntimeException { 497 return _bool; 498 } 499 500 public void setBool(boolean bool) throws com.sun.star.uno.RuntimeException { 501 _bool = bool; 502 } 503 504 public byte getByte() throws com.sun.star.uno.RuntimeException { 505 return _byte; 506 } 507 508 public void setByte(byte zbyte) throws com.sun.star.uno.RuntimeException { 509 _byte = zbyte; 510 } 511 512 public char getChar() throws com.sun.star.uno.RuntimeException { 513 return _char; 514 } 515 516 public void setChar(char zchar) throws com.sun.star.uno.RuntimeException { 517 _char = zchar; 518 } 519 520 public short getShort() throws com.sun.star.uno.RuntimeException { 521 return _short; 522 } 523 524 public void setShort(short zshort) throws com.sun.star.uno.RuntimeException { 525 _short = zshort; 526 } 527 528 public short getUShort() throws com.sun.star.uno.RuntimeException { 529 return _ushort; 530 } 531 532 public void setUShort(short ushort) throws com.sun.star.uno.RuntimeException { 533 _ushort = ushort; 534 } 535 536 public int getLong() throws com.sun.star.uno.RuntimeException { 537 return _long; 538 } 539 540 public void setLong(int zint) throws com.sun.star.uno.RuntimeException { 541 _long = zint; 542 } 543 544 public int getULong() throws com.sun.star.uno.RuntimeException { 545 return _ulong; 546 } 547 548 public void setULong(int uint) throws com.sun.star.uno.RuntimeException { 549 _ulong = uint; 550 } 551 552 public long getHyper() throws com.sun.star.uno.RuntimeException { 553 return _hyper; 554 } 555 556 public void setHyper(long hyper) throws com.sun.star.uno.RuntimeException { 557 _hyper = hyper; 558 } 559 560 public long getUHyper() throws com.sun.star.uno.RuntimeException { 561 return _uhyper; 562 } 563 564 public void setUHyper(long uhyper) throws com.sun.star.uno.RuntimeException { 565 _uhyper = uhyper; 566 } 567 568 public float getFloat() throws com.sun.star.uno.RuntimeException { 569 return _float; 570 } 571 572 public void setFloat(float zfloat) throws com.sun.star.uno.RuntimeException { 573 _float = zfloat; 574 } 575 576 public double getDouble() throws com.sun.star.uno.RuntimeException { 577 return _double; 578 } 579 580 public void setDouble(double zdouble) throws com.sun.star.uno.RuntimeException { 581 _double = zdouble; 582 } 583 584 public TestEnum getEnum() throws com.sun.star.uno.RuntimeException { 585 return _testEnum; 586 } 587 588 public void setEnum(TestEnum testEnum) throws com.sun.star.uno.RuntimeException { 589 _testEnum = testEnum; 590 } 591 592 public String getString() throws com.sun.star.uno.RuntimeException { 593 return _string; 594 } 595 596 public void setString(String string) throws com.sun.star.uno.RuntimeException { 597 _string = string; 598 } 599 600 public Object getInterface() throws com.sun.star.uno.RuntimeException { 601 return _xInterface; 602 } 603 604 public void setInterface(Object zinterface) throws com.sun.star.uno.RuntimeException { 605 _xInterface = zinterface; 606 } 607 608 public Object getAny() throws com.sun.star.uno.RuntimeException { 609 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + _any); 610 611 return _any; 612 } 613 614 public void setAny(Object any) throws com.sun.star.uno.RuntimeException { 615 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + any); 616 617 _any = any; 618 } 619 620 public TestElement[] getSequence() throws com.sun.star.uno.RuntimeException { 621 return _testElements; 622 } 623 624 public void setSequence(TestElement testElements[]) throws com.sun.star.uno.RuntimeException { 625 _testElements = testElements; 626 } 627 628 public TestDataElements getStruct() throws com.sun.star.uno.RuntimeException { 629 return _testDataElements; 630 } 631 632 public void setStruct(TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException { 633 _testDataElements = testDataElements; 634 } 635 636 public int getRaiseAttr1() { 637 throw new com.sun.star.uno.RuntimeException(); 638 } 639 640 public void setRaiseAttr1(int n) throws IllegalArgumentException { 641 throw new IllegalArgumentException(); 642 } 643 644 public int getRaiseAttr2() throws IllegalArgumentException { 645 throw new IllegalArgumentException(); 646 } 647 648 public TestPolyStruct transportPolyBoolean(TestPolyStruct arg) { 649 Boolean dummy = (Boolean) arg.member; 650 return arg; 651 } 652 653 public void transportPolyHyper(TestPolyStruct[] arg) { 654 Long dummy = (Long) arg[0].member; 655 } 656 657 public void transportPolySequence( 658 TestPolyStruct arg1, TestPolyStruct[] arg2) 659 { 660 Object[] dummy = (Object[]) arg1.member; 661 arg2[0] = arg1; 662 } 663 664 public TestPolyStruct getNullPolyLong() { 665 return new TestPolyStruct(); 666 } 667 668 public TestPolyStruct getNullPolyString() { 669 return new TestPolyStruct(); 670 } 671 672 public TestPolyStruct getNullPolyType() { 673 return new TestPolyStruct(); 674 } 675 676 public TestPolyStruct getNullPolyAny() { 677 return new TestPolyStruct(); 678 } 679 680 public TestPolyStruct getNullPolySequence() { 681 return new TestPolyStruct(); 682 } 683 684 public TestPolyStruct getNullPolyEnum() { 685 return new TestPolyStruct(); 686 } 687 688 public TestPolyStruct getNullPolyBadEnum() { 689 return new TestPolyStruct(); 690 } 691 692 public TestPolyStruct getNullPolyStruct() { 693 return new TestPolyStruct(); 694 } 695 696 public TestPolyStruct getNullPolyInterface() { 697 return new TestPolyStruct(); 698 } 699 700 public Object transportAny(Object value) throws com.sun.star.uno.RuntimeException { 701 return value; 702 } 703 704 public void call(int nCallId , int nWaitMUSEC) throws com.sun.star.uno.RuntimeException { 705 // TimeValue value = { nWaitMUSEC / 1000000 , nWaitMUSEC * 1000 }; 706 // osl_waitThread( &value ); 707 try { 708 Thread.sleep(nWaitMUSEC / 10000); 709 } 710 catch(InterruptedException interruptedException) { 711 throw new com.sun.star.uno.RuntimeException(interruptedException.getMessage()); 712 } 713 714 if(_bFirstCall) 715 _bFirstCall = false; 716 717 else 718 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId); 719 720 _nLastCallId = nCallId; 721 } 722 723 public void callOneway( int nCallId , int nWaitMUSEC ) throws com.sun.star.uno.RuntimeException { 724 // TimeValue value = { nWaitMUSEC / 1000000 , nWaitMUSEC * 1000 }; 725 // osl_waitThread( &value ); 726 try { 727 Thread.sleep(nWaitMUSEC / 10000); 728 } 729 catch(InterruptedException interruptedException) { 730 throw new com.sun.star.uno.RuntimeException(interruptedException.getMessage()); 731 } 732 733 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId); 734 _nLastCallId = nCallId; 735 } 736 737 public boolean sequenceOfCallTestPassed() throws com.sun.star.uno.RuntimeException { 738 return _bSequenceOfCallTestPassed; 739 } 740 741 public synchronized void callRecursivly(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException { 742 if(nToCall != 0) 743 { 744 nToCall --; 745 xCall.callRecursivly(this , nToCall); 746 } 747 } 748 749 public synchronized void startRecursiveCall(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException { 750 if(nToCall != 0) 751 { 752 nToCall --; 753 xCall.callRecursivly( this , nToCall ); 754 } 755 } 756 757 public XMulti getMulti() { 758 return new XMulti() { 759 public double getatt1() { 760 return attribute1; 761 } 762 763 public void setatt1(double value) { 764 attribute1 = value; 765 } 766 767 public int fn11(int arg) { 768 return 11 * arg; 769 } 770 771 public String fn12(String arg) { 772 return "12" + arg; 773 } 774 775 public int fn21(int arg) { 776 return 21 * arg; 777 } 778 779 public String fn22(String arg) { 780 return "22" + arg; 781 } 782 783 public double getatt3() { 784 return attribute3; 785 } 786 787 public void setatt3(double value) { 788 attribute3 = value; 789 } 790 791 public int fn31(int arg) { 792 return 31 * arg; 793 } 794 795 public String fn32(String arg) { 796 return "32" + arg; 797 } 798 799 public int fn33() { 800 return 33; 801 } 802 803 public int fn41(int arg) { 804 return 41 * arg; 805 } 806 807 public int fn61(int arg) { 808 return 61 * arg; 809 } 810 811 public String fn62(String arg) { 812 return "62" + arg; 813 } 814 815 public int fn71(int arg) { 816 return 71 * arg; 817 } 818 819 public String fn72(String arg) { 820 return "72" + arg; 821 } 822 823 public int fn73() { 824 return 73; 825 } 826 827 private double attribute1 = 0.0; 828 private double attribute3 = 0.0; 829 }; 830 } 831 832 private static final class CheckFailed extends Exception { 833 CheckFailed(String message) { 834 super(message); 835 } 836 } 837 838 private static void checkEqual(int value, int argument) 839 throws CheckFailed 840 { 841 if (argument != value) { 842 throw new CheckFailed(value + " != " + argument); 843 } 844 } 845 846 private static void checkEqual(double value, double argument) 847 throws CheckFailed 848 { 849 if (argument != value) { 850 throw new CheckFailed(value + " != " + argument); 851 } 852 } 853 854 private static void checkEqual(String value, String argument) 855 throws CheckFailed 856 { 857 if (!argument.equals(value)) { 858 throw new CheckFailed(value + " != " + argument); 859 } 860 } 861 862 public String testMulti(XMulti multi) { 863 try { 864 checkEqual(0.0, multi.getatt1()); 865 multi.setatt1(0.1); 866 checkEqual(0.1, multi.getatt1()); 867 checkEqual(11 * 1, multi.fn11(1)); 868 checkEqual("12" + "abc", multi.fn12("abc")); 869 checkEqual(21 * 2, multi.fn21(2)); 870 checkEqual("22" + "de", multi.fn22("de")); 871 checkEqual(0.0, multi.getatt3()); 872 multi.setatt3(0.3); 873 checkEqual(0.3, multi.getatt3()); 874 checkEqual(31 * 3, multi.fn31(3)); 875 checkEqual("32" + "f", multi.fn32("f")); 876 checkEqual(33, multi.fn33()); 877 checkEqual(41 * 4, multi.fn41(4)); 878 checkEqual(61 * 6, multi.fn61(6)); 879 checkEqual("62" + "", multi.fn62("")); 880 checkEqual(71 * 7, multi.fn71(7)); 881 checkEqual("72" + "g", multi.fn72("g")); 882 checkEqual(73, multi.fn73()); 883 } catch (CheckFailed f) { 884 return f.getMessage(); 885 } 886 return ""; 887 } 888 889 // XBridgeTest 890 public TestDataElements raiseException(short nArgumentPos, String rMsg, Object xContext) 891 throws com.sun.star.lang.IllegalArgumentException, 892 com.sun.star.uno.RuntimeException 893 { 894 throw new com.sun.star.lang.IllegalArgumentException(rMsg, xContext, nArgumentPos); 895 } 896 897 public void raiseRuntimeExceptionOneway(String rMsg, Object xContext) throws com.sun.star.uno.RuntimeException { 898 throw new com.sun.star.uno.RuntimeException(rMsg, xContext); 899 } 900 901 private void dothrow( com.sun.star.uno.RuntimeException t ) 902 throws com.sun.star.uno.RuntimeException 903 { 904 throw t; 905 } 906 public int getRuntimeException() 907 throws com.sun.star.uno.RuntimeException 908 { 909 try 910 { 911 dothrow( new com.sun.star.uno.RuntimeException( 912 _string, _xInterface ) ); 913 return 0; // dummy 914 } 915 catch (com.sun.star.uno.RuntimeException t) 916 { 917 throw t; 918 } 919 } 920 921 public void setRuntimeException(int _runtimeexception) throws com.sun.star.uno.RuntimeException { 922 throw new com.sun.star.uno.RuntimeException(_string, _xInterface); 923 } 924 925 926 927 // XServiceInfo 928 public String getImplementationName() throws com.sun.star.uno.RuntimeException { 929 return __serviceName; 930 } 931 932 public boolean supportsService(String rServiceName) throws com.sun.star.uno.RuntimeException { 933 String rSNL[] = getSupportedServiceNames(); 934 935 for(int nPos = rSNL.length; (nPos--) != 0;) { 936 if (rSNL[nPos].equals(rServiceName)) 937 return true; 938 } 939 940 return false; 941 } 942 943 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException { 944 return new String[]{__serviceName}; 945 } 946 947 // XTypeProvider 948 public Type[] getTypes() throws com.sun.star.uno.RuntimeException { 949 try { 950 return new Type[]{new Type(XBridgeTest.class), new Type(XRecursiveCall.class), new Type(XServiceInfo.class), new Type(XTypeProvider.class)}; 951 } 952 catch(Exception exception) { 953 throw new com.sun.star.uno.RuntimeException(exception.getMessage()); 954 } 955 } 956 957 public byte[] getImplementationId() throws com.sun.star.uno.RuntimeException { 958 return toString().getBytes(); 959 } 960 961 //XBridgeTest2 962 public boolean[] setSequenceBool( /*IN*/boolean[] aSeq ) 963 { 964 arBool = aSeq; 965 return aSeq; 966 } 967 public char[] setSequenceChar( /*IN*/char[] aSeq ) 968 { 969 arChar = aSeq; 970 return aSeq; 971 } 972 public byte[] setSequenceByte( /*IN*/byte[] aSeq ) 973 { 974 arByte = aSeq; 975 return aSeq; 976 } 977 public short[] setSequenceShort( /*IN*/short[] aSeq ) 978 { 979 arShort = aSeq; 980 return aSeq; 981 } 982 public short[] setSequenceUShort( /*IN*/short[] aSeq ) 983 { 984 arUShort = aSeq; 985 return aSeq; 986 } 987 public int[] setSequenceLong( /*IN*/int[] aSeq ) 988 { 989 arLong = aSeq; 990 return aSeq; 991 } 992 public int[] setSequenceULong( /*IN*/int[] aSeq ) 993 { 994 arULong = aSeq; 995 return aSeq; 996 } 997 public long[] setSequenceHyper( /*IN*/long[] aSeq ) 998 { 999 arHyper = aSeq; 1000 return aSeq; 1001 } 1002 public long[] setSequenceUHyper( /*IN*/long[] aSeq ) 1003 { 1004 arUHyper = aSeq; 1005 return aSeq; 1006 } 1007 public float[] setSequenceFloat( /*IN*/float[] aSeq ) 1008 { 1009 arFloat = aSeq; 1010 return aSeq; 1011 } 1012 public double[] setSequenceDouble( /*IN*/double[] aSeq ) 1013 { 1014 arDouble = aSeq; 1015 return aSeq; 1016 } 1017 public TestEnum[] setSequenceEnum( /*IN*/TestEnum[] aSeq ) 1018 { 1019 arEnum = aSeq; 1020 return aSeq; 1021 } 1022 public String[] setSequenceString( /*IN*/String[] aSeq ) 1023 { 1024 arString = aSeq; 1025 return aSeq; 1026 } 1027 public java.lang.Object[] setSequenceXInterface( /*IN*/java.lang.Object[] aSeq ) 1028 { 1029 arObject = aSeq; 1030 return aSeq; 1031 } 1032 public java.lang.Object[] setSequenceAny( /*IN*/java.lang.Object[] aSeq ) 1033 { 1034 arAny = aSeq; 1035 return aSeq; 1036 } 1037 public TestElement[] setSequenceStruct( /*IN*/TestElement[] aSeq ) 1038 { 1039 _testElements = aSeq; 1040 return aSeq; 1041 } 1042 public int[][] setDim2( /*IN*/int[][] aSeq ) 1043 { 1044 arLong2 = aSeq; 1045 return aSeq; 1046 } 1047 public int[][][] setDim3( /*IN*/int[][][] aSeq ) 1048 { 1049 arLong3 = aSeq; 1050 return aSeq; 1051 } 1052 public void setSequencesInOut( /*INOUT*/boolean[][] aSeqBoolean, 1053 /*INOUT*/char[][] aSeqChar, /*INOUT*/byte[][] aSeqByte, 1054 /*INOUT*/short[][] aSeqShort, /*INOUT*/short[][] aSeqUShort, 1055 /*INOUT*/int[][] aSeqLong, /*INOUT*/int[][] aSeqULong, 1056 /*INOUT*/long[][] aSeqHyper, /*INOUT*/long[][] aSeqUHyper, 1057 /*INOUT*/float[][] aSeqFloat, /*INOUT*/double[][] aSeqDouble, 1058 /*INOUT*/TestEnum[][] aSeqEnum, /*INOUT*/String[][] aSeqString, 1059 /*INOUT*/java.lang.Object[][] aSeqXInterface, 1060 /*INOUT*/java.lang.Object[][] aSeqAny, 1061 /*INOUT*/int[][][] aSeqDim2, /*INOUT*/int[][][][] aSeqDim3 ) 1062 { 1063 arBool = aSeqBoolean[0]; 1064 arChar = aSeqChar[0]; 1065 arByte = aSeqByte[0]; 1066 arShort = aSeqShort[0]; 1067 arUShort = aSeqUShort[0]; 1068 arLong = aSeqLong[0]; 1069 arULong = aSeqULong[0]; 1070 arFloat = aSeqFloat[0]; 1071 arDouble = aSeqDouble[0]; 1072 arEnum = aSeqEnum[0]; 1073 arString = aSeqString[0]; 1074 arObject = aSeqXInterface[0]; 1075 arAny = aSeqAny[0]; 1076 arLong2 = aSeqDim2[0]; 1077 arLong3 = aSeqDim3[0]; 1078 } 1079 public void setSequencesOut( /*OUT*/boolean[][] aSeqBoolean, /*OUT*/char[][] aSeqChar, 1080 /*OUT*/byte[][] aSeqByte, /*OUT*/short[][] aSeqShort, 1081 /*OUT*/short[][] aSeqUShort, /*OUT*/int[][] aSeqLong, 1082 /*OUT*/int[][] aSeqULong, /*OUT*/long[][] aSeqHyper, 1083 /*OUT*/long[][] aSeqUHyper, /*OUT*/float[][] aSeqFloat, 1084 /*OUT*/double[][] aSeqDouble, /*OUT*/TestEnum[][] aSeqEnum, 1085 /*OUT*/String[][] aSeqString, 1086 /*OUT*/java.lang.Object[][] aSeqXInterface, 1087 /*OUT*/java.lang.Object[][] aSeqAny, /*OUT*/int[][][] aSeqDim2, 1088 /*OUT*/int[][][][] aSeqDim3 ) 1089 { 1090 aSeqBoolean[0] = arBool; 1091 aSeqChar[0] = arChar; 1092 aSeqByte[0] = arByte; 1093 aSeqShort[0] = arShort; 1094 aSeqUShort[0] = arUShort; 1095 aSeqLong[0] = arLong; 1096 aSeqULong[0] = arULong; 1097 aSeqHyper[0] = arHyper; 1098 aSeqUHyper[0] = arUHyper; 1099 aSeqFloat[0] = arFloat; 1100 aSeqDouble[0] = arDouble; 1101 aSeqEnum[0] = arEnum; 1102 aSeqString[0] = arString; 1103 aSeqXInterface[0] = arObject; 1104 aSeqAny[0] = arAny; 1105 aSeqDim2[0] = arLong2; 1106 aSeqDim3[0] = arLong3; 1107 } 1108 1109 public void testConstructorsService(XComponentContext context) 1110 throws BadConstructorArguments 1111 { 1112 Constructors.create1(context, 1113 true, 1114 Byte.MIN_VALUE, 1115 Short.MIN_VALUE, 1116 (short) -1, 1117 Integer.MIN_VALUE, 1118 -1, 1119 Long.MIN_VALUE, 1120 -1L, 1121 0.123f, 1122 0.456, 1123 'X', 1124 "test", 1125 Type.ANY, 1126 new Any(Type.BOOLEAN, Boolean.TRUE), 1127 new boolean[] { true }, 1128 new byte[] { Byte.MIN_VALUE }, 1129 new short[] { Short.MIN_VALUE }, 1130 new short[] { (short) -1 }, 1131 new int[] { Integer.MIN_VALUE }, 1132 new int[] { -1 }, 1133 new long[] { Long.MIN_VALUE }, 1134 new long[] { -1L }, 1135 new float[] { 0.123f }, 1136 new double[] { 0.456 }, 1137 new char[] { 'X' }, 1138 new String[] { "test" }, 1139 new Type[] { Type.ANY }, 1140 new Boolean[] { Boolean.TRUE }, 1141 new boolean[][] { new boolean[] { true } }, 1142 new Object[][] { 1143 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } }, 1144 new TestEnum[] { TestEnum.TWO }, 1145 new TestStruct[] { new TestStruct(10) }, 1146 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) }, 1147 new TestPolyStruct[] { 1148 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)) }, 1149 new Object[] { null }, 1150 TestEnum.TWO, 1151 new TestStruct(10), 1152 new TestPolyStruct(Boolean.TRUE), 1153 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)), 1154 null); 1155 Constructors.create2(context, new Object[] { 1156 Boolean.TRUE, 1157 new Byte(Byte.MIN_VALUE), 1158 new Short(Short.MIN_VALUE), 1159 new Any(Type.UNSIGNED_SHORT, new Short((short) -1)), 1160 new Integer(Integer.MIN_VALUE), 1161 new Any(Type.UNSIGNED_LONG, new Integer(-1)), 1162 new Long(Long.MIN_VALUE), 1163 new Any(Type.UNSIGNED_HYPER, new Long(-1L)), 1164 new Float(0.123f), 1165 new Double(0.456), 1166 new Character('X'), 1167 "test", 1168 Type.ANY, 1169 new Any(Type.BOOLEAN, Boolean.TRUE), 1170 new boolean[] { true }, 1171 new byte[] { Byte.MIN_VALUE }, 1172 new short[] { Short.MIN_VALUE }, 1173 new Any( 1174 new Type("[]unsigned short"), new short[] { (short) -1 }), 1175 new int[] { Integer.MIN_VALUE }, 1176 new Any(new Type("[]unsigned long"), new int[] { -1 }), 1177 new long[] { Long.MIN_VALUE }, 1178 new Any(new Type("[]unsigned hyper"), new long[] { -1L }), 1179 new float[] { 0.123f }, 1180 new double[] { 0.456 }, 1181 new char[] { 'X' }, 1182 new String[] { "test" }, 1183 new Type[] { Type.ANY }, 1184 new Any(new Type("[]any"), new Boolean[] { Boolean.TRUE }), 1185 new boolean[][] { new boolean[] { true } }, 1186 new Object[][] { 1187 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } }, 1188 new TestEnum[] { TestEnum.TWO }, 1189 new TestStruct[] { new TestStruct(10) }, 1190 new Any( 1191 new Type( 1192 "[]test.testtools.bridgetest.TestPolyStruct<boolean>"), 1193 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) }), 1194 new Any( 1195 new Type("[]test.testtools.bridgetest.TestPolyStruct<any>"), 1196 new TestPolyStruct[] { 1197 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)) 1198 }), 1199 new XInterface[] { null }, 1200 TestEnum.TWO, 1201 new TestStruct(10), 1202 new Any( 1203 new Type( 1204 "test.testtools.bridgetest.TestPolyStruct<boolean>"), 1205 new TestPolyStruct(Boolean.TRUE)), 1206 new Any( 1207 new Type("test.testtools.bridgetest.TestPolyStruct<any>"), 1208 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))), 1209 null }); 1210 Constructors2.create1( 1211 context, 1212 new TestPolyStruct(Type.LONG), 1213 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)), 1214 new TestPolyStruct(new Boolean(true)), 1215 new TestPolyStruct(new Byte(Byte.MIN_VALUE)), 1216 new TestPolyStruct(new Short(Short.MIN_VALUE)), 1217 new TestPolyStruct(new Integer(Integer.MIN_VALUE)), 1218 new TestPolyStruct(new Long(Long.MIN_VALUE)), 1219 new TestPolyStruct(new Character('X')), 1220 new TestPolyStruct("test"), 1221 new TestPolyStruct(new Float(0.123f)), 1222 new TestPolyStruct(new Double(0.456)), 1223 new TestPolyStruct(new com.sun.star.lib.uno.helper.ComponentBase()), 1224 new TestPolyStruct(new com.sun.star.lib.uno.helper.ComponentBase()), 1225 new TestPolyStruct(TestEnum.TWO), 1226 new TestPolyStruct(new TestPolyStruct2(new Character('X'), 1227 new Any(Type.BOOLEAN, Boolean.TRUE))), 1228 new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2( 1229 new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)), "test")), 1230 new TestPolyStruct2("test", new TestPolyStruct2(new Character('X'), 1231 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)))), 1232 new TestPolyStruct2( new TestPolyStruct2(new Character('X'), 1233 new Any(Type.BOOLEAN, Boolean.TRUE)), new TestPolyStruct(new Character('X'))), 1234 new TestPolyStruct(new Type[] { Type.LONG}), 1235 new TestPolyStruct(new Any[] { new Any(Type.BOOLEAN, Boolean.TRUE) }), 1236 new TestPolyStruct(new boolean[] {true}), 1237 new TestPolyStruct(new byte[] {Byte.MIN_VALUE}), 1238 new TestPolyStruct(new short[] {Short.MIN_VALUE}), 1239 new TestPolyStruct(new int[] {Integer.MIN_VALUE}), 1240 new TestPolyStruct(new long[] {Long.MIN_VALUE}), 1241 new TestPolyStruct(new char[] {'X'}), 1242 new TestPolyStruct(new String[] {"test"}), 1243 new TestPolyStruct(new float[] {0.123f}), 1244 new TestPolyStruct(new double[] {0.456d}), 1245 new TestPolyStruct(new Object[] {new com.sun.star.lib.uno.helper.ComponentBase()}), 1246 new TestPolyStruct(new com.sun.star.lang.XComponent[] {new com.sun.star.lib.uno.helper.ComponentBase()}), 1247 new TestPolyStruct(new TestEnum[] {TestEnum.TWO}), 1248 new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2( 1249 new Character('X'), new Any[] {new Any(Type.BOOLEAN, Boolean.TRUE)})}), 1250 new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2( 1251 new TestPolyStruct(new Character('X')), new Any[] {new Any(Type.BOOLEAN, Boolean.TRUE)})}), 1252 new TestPolyStruct(new int[][] { new int[] {Integer.MIN_VALUE} }), 1253 new TestPolyStruct[]{ new TestPolyStruct(new Integer(Integer.MIN_VALUE))}, 1254 new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2( 1255 new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)))}, 1256 new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2( 1257 new TestPolyStruct2(new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)), "test"))}, 1258 new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2( 1259 new Character('X'), new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))))}, 1260 new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2(new Character('X'), new Any( 1261 Type.BOOLEAN, Boolean.TRUE)),new TestPolyStruct(new Character('X')))}, 1262 new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct(new Character('X'))}}, 1263 new TestPolyStruct[][]{new TestPolyStruct[]{ 1264 new TestPolyStruct(new TestPolyStruct2(new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)))}}, 1265 new TestPolyStruct[][]{new TestPolyStruct[] {new TestPolyStruct(new TestPolyStruct2( 1266 new TestPolyStruct2(new Character('X'),new Any(Type.BOOLEAN, Boolean.TRUE)), "test"))}}, 1267 new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2( 1268 "test", new TestPolyStruct2(new Character('X'),new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))))}}, 1269 new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2( 1270 new TestPolyStruct2(new Character('X'),new Any(Type.BOOLEAN, Boolean.TRUE)), 1271 new TestPolyStruct(new Character('X')))}}); 1272 } 1273 1274 public XCurrentContextChecker getCurrentContextChecker() { 1275 return new CurrentContextChecker(); 1276 } 1277 } 1278 1279 /** 1280 * Gives a factory for creating the service. 1281 * This method is called by the <code>JavaLoader</code> 1282 * <p> 1283 * @return returns a <code>XSingleServiceFactory</code> for creating the component 1284 * @param implName the name of the implementation for which a service is desired 1285 * @param multiFactory the service manager to be uses if needed 1286 * @param regKey the registryKey 1287 * @see com.sun.star.comp.loader.JavaLoader 1288 */ 1289 public static XSingleServiceFactory __getServiceFactory(String implName, 1290 XMultiServiceFactory multiFactory, 1291 XRegistryKey regKey) 1292 { 1293 XSingleServiceFactory xSingleServiceFactory = null; 1294 1295 if(implName.equals(_TestObject.class.getName())) 1296 xSingleServiceFactory = FactoryHelper.getServiceFactory(_TestObject.class, 1297 _TestObject.__serviceName, 1298 multiFactory, 1299 regKey); 1300 1301 else if(implName.equals(_PerformancTestObject.class.getName())) 1302 xSingleServiceFactory = FactoryHelper.getServiceFactory(_PerformancTestObject.class, 1303 _PerformancTestObject.__serviceName, 1304 multiFactory, 1305 regKey); 1306 1307 return xSingleServiceFactory; 1308 } 1309 } 1310