1/*************************************************************************
2 *
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
6 *
7 * OpenOffice.org - a multi-platform office productivity suite
8 *
9 * This file is part of OpenOffice.org.
10 *
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org.  If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
25 *
26 ************************************************************************/
27
28#include "com/sun/star/lang/IllegalArgumentException.idl"
29#include "com/sun/star/lang/XComponent.idl"
30#include "com/sun/star/uno/XComponentContext.idl"
31#include "com/sun/star/uno/XInterface.idl"
32
33module test { module testtools { module bridgetest {
34
35enum TestEnum
36{
37    TEST,
38    ONE,
39    TWO,
40    CHECK,
41    LOLA,
42    PALOO,
43    ZA
44};
45
46enum TestBadEnum { M = 1 };
47
48struct TestStruct
49{
50    long member;
51};
52
53/**
54 * simple types
55 */
56struct TestSimple
57{
58    boolean                    Bool;
59    char                       Char;
60    byte                       Byte;
61    short                      Short;
62    unsigned short             UShort;
63    long                       Long;
64    unsigned long              ULong;
65    hyper                      Hyper;
66    unsigned hyper             UHyper;
67    float                      Float;
68    double                     Double;
69    TestEnum                   Enum;
70};
71/**
72 * equal to max size returned in registers on x86_64
73 */
74struct SmallStruct
75{
76    hyper                      a;
77    hyper                      b;
78};
79/**
80 * equal to max size returned in registers on ia64
81 */
82struct MediumStruct
83{
84    hyper                      a;
85    hyper                      b;
86    hyper                      c;
87    hyper                      d;
88};
89/**
90 * bigger than max size returned in registers on ia64
91 */
92struct BigStruct
93{
94    hyper                      a;
95    hyper                      b;
96    hyper                      c;
97    hyper                      d;
98    hyper                      e;
99    hyper                      f;
100    hyper                      g;
101    hyper                      h;
102};
103/**
104 * all floats, ia64 handles them specially
105 */
106struct AllFloats
107{
108    float                      a;
109    float                      b;
110    float                      c;
111    float                      d;
112};
113/**
114 * complex types adding string, inteface, any
115 */
116struct TestElement : TestSimple
117{
118    string                     String;
119    com::sun::star::uno::XInterface   Interface;
120    any                        Any;
121};
122/**
123 * adding even more complexity, sequence< TestElement >
124 */
125struct TestDataElements : TestElement
126{
127    sequence< TestElement > Sequence;
128};
129
130/**
131 * typedef used in interface
132 */
133typedef TestDataElements TestData;
134
135struct TestPolyStruct<T> { T member; };
136struct TestPolyStruct2<T,C> {
137    T member1;
138    C member2;
139};
140
141interface XRecursiveCall : com::sun::star::uno::XInterface
142{
143    /***
144     * @param nToCall If nToCall is 0, the method returns immeadiatly.
145     *                Otherwise, call the given interface with nToCall -1
146     *
147     ***/
148    void callRecursivly( [in] XRecursiveCall xCall , [in] long nToCall );
149};
150
151interface XMultiBase1 {
152    [attribute] double att1; // initially 0.0
153    long fn11([in] long arg); // return 11 * arg
154    string fn12([in] string arg); // return "12" + arg
155};
156
157interface XMultiBase2: XMultiBase1 {
158    long fn21([in] long arg); // return 21 * arg
159    string fn22([in] string arg); // return "22" + arg
160};
161
162interface XMultiBase3 {
163    [attribute] double att3; // initially 0.0
164    long fn31([in] long arg); // return 31 * arg
165    string fn32([in] string arg); // return "32" + arg
166    long fn33(); // return 33
167};
168
169interface XMultiBase3a: XMultiBase3 {};
170
171interface XMultiBase4 {
172    long fn41([in] long arg); // return 41 * arg
173};
174
175interface XMultiBase5 {
176    interface XMultiBase3;
177    interface XMultiBase4;
178    interface XMultiBase1;
179};
180
181interface XMultiBase6 {
182    interface XMultiBase2;
183    interface XMultiBase3a;
184    interface XMultiBase5;
185    long fn61([in] long arg); // return 61 * arg
186    string fn62([in] string arg); // return "62" + arg
187};
188
189interface XMultiBase7 {
190    long fn71([in] long arg); // return 71 * arg
191    string fn72([in] string arg); // return "72" + arg
192    long fn73(); // return 73
193};
194
195interface XMulti {
196    interface XMultiBase6;
197    interface XMultiBase7;
198};
199
200/**
201 * Monster test interface to test bridge calls.
202 * An implementation of this object has to store given values and return whenever there
203 * is an out param or return value.
204 */
205interface XBridgeTestBase : com::sun::star::uno::XInterface
206{
207    /**
208     * in parameter test, tests by calls reference also (complex types)
209     */
210    [oneway] void setValues( [in] boolean bBool, [in] char cChar, [in] byte nByte,
211                             [in] short nShort, [in] unsigned short nUShort,
212                             [in] long nLong, [in] unsigned long nULong,
213                             [in] hyper nHyper, [in] unsigned hyper nUHyper,
214                             [in] float fFloat, [in] double fDouble,
215                             [in] TestEnum eEnum, [in] string aString,
216                             [in] com::sun::star::uno::XInterface xInterface, [in] any aAny,
217                             [in] sequence< TestElement > aSequence,
218                             [in] TestData aStruct );
219    /**
220     * inout parameter test
221     *
222     * @return aStruct. The out parameter contain the values, that were previously set
223     *         by setValues or (if not called before) default constructed values.
224     *
225     */
226    TestData setValues2( [inout] boolean bBool, [inout] char cChar, [inout] byte nByte,
227                         [inout] short nShort, [inout] unsigned short nUShort,
228                         [inout] long nLong, [inout] unsigned long nULong,
229                         [inout] hyper nHyper, [inout] unsigned hyper nUHyper,
230                         [inout] float fFloat, [inout] double fDouble,
231                         [inout] TestEnum eEnum, [inout] string aString,
232                         [inout] com::sun::star::uno::XInterface xInterface, [inout] any aAny,
233                         [inout] sequence< TestElement > aSequence,
234                         [inout] TestData aStruct );
235
236    /**
237     * out parameter test
238     */
239    TestData getValues( [out] boolean bBool, [out] char cChar, [out] byte nByte,
240                        [out] short nShort, [out] unsigned short nUShort,
241                        [out] long nLong, [out] unsigned long nULong,
242                        [out] hyper nHyper, [out] unsigned hyper nUHyper,
243                        [out] float fFloat, [out] double fDouble,
244                        [out] TestEnum eEnum, [out] string aString,
245                        [out] com::sun::star::uno::XInterface xInterface, [out] any aAny,
246                        [out] sequence< TestElement > aSequence,
247                        [out] TestData aStruct );
248
249    /**
250     * register return test 1
251     */
252    SmallStruct echoSmallStruct( [in] SmallStruct aStruct );
253
254    /**
255     * register return test 2
256     */
257    MediumStruct echoMediumStruct( [in] MediumStruct aStruct );
258
259    /**
260     * register return test 3
261     */
262    BigStruct echoBigStruct( [in] BigStruct aStruct );
263
264    /**
265     * register return test 4
266     */
267    AllFloats echoAllFloats( [in] AllFloats aStruct );
268
269    /**
270     * register return test 4 (i107182)
271     */
272    long testPPCAlignment( [in] hyper l1, [in] hyper l2, [in] long i1, [in] hyper l3, [in] long i2 );
273
274    [attribute] boolean                  Bool;
275    [attribute] byte                     Byte;
276    [attribute] char                     Char;
277    [attribute] short                    Short;
278    [attribute] unsigned short           UShort;
279    [attribute] long                     Long;
280    [attribute] unsigned long            ULong;
281    [attribute] hyper                    Hyper;
282    [attribute] unsigned hyper           UHyper;
283    [attribute] float                    Float;
284    [attribute] double                   Double;
285    [attribute] TestEnum                 Enum;
286    [attribute] string                   String;
287    [attribute] com::sun::star::uno::XInterface Interface;
288    [attribute] any                      Any;
289    [attribute] sequence< TestElement >  Sequence;
290    [attribute] TestData                 Struct;
291
292    [attribute] long RaiseAttr1 {
293        set raises (com::sun::star::lang::IllegalArgumentException);
294    };
295    [attribute, readonly] long RaiseAttr2 {
296        get raises (com::sun::star::lang::IllegalArgumentException);
297    };
298
299    TestPolyStruct<boolean> transportPolyBoolean(
300        [in] TestPolyStruct<boolean> arg);
301    void transportPolyHyper([inout] TestPolyStruct<hyper> arg);
302    void transportPolySequence(
303        [in] TestPolyStruct<sequence<any> > arg1,
304        [out] TestPolyStruct<sequence<any> > arg2);
305
306    TestPolyStruct<long> getNullPolyLong();
307    TestPolyStruct<string> getNullPolyString();
308    TestPolyStruct<type> getNullPolyType();
309    TestPolyStruct<any> getNullPolyAny();
310    TestPolyStruct<sequence<boolean> > getNullPolySequence();
311    TestPolyStruct<TestEnum> getNullPolyEnum();
312    TestPolyStruct<TestBadEnum> getNullPolyBadEnum();
313    TestPolyStruct<TestStruct> getNullPolyStruct();
314    TestPolyStruct<XBridgeTestBase> getNullPolyInterface();
315
316    /***
317     * This method returns the parameter value.
318     * Method to extensivly test anys.
319     ****/
320    any transportAny( [in] any value );
321
322    /***
323     * methods to check sequence of calls. Call call() and callOneway
324     * in an arbitrary sequence. Increase the callId for every call.
325     * The testobject sets an error flag.
326
327        @see testSequencePassed
328     ***/
329    void call( [in] long nCallId, [in] long nWaitMUSEC );
330    [oneway] void callOneway( [in] long nCallId, [in] long nWaitMUSEC );
331    boolean sequenceOfCallTestPassed();
332
333    /****
334     * methods to check, if threads thread identity is holded.
335     *
336     ***/
337    void startRecursiveCall( [in] XRecursiveCall xCall , [in] long nToCall );
338
339    XMulti getMulti();
340    string testMulti([in] XMulti multi);
341};
342
343
344/**
345 * Inherting from monster; adds raiseException(), attribute raising RuntimeException.
346 */
347interface XBridgeTest : XBridgeTestBase
348{
349    /**
350     * the exception struct returned has to be filled with given arguments.
351     * return value is for dummy.
352     */
353    TestData raiseException( [in] short ArgumentPosition,
354                             [in] string Message,
355                             [in] com::sun::star::uno::XInterface Context )
356        raises( com::sun::star::lang::IllegalArgumentException );
357
358
359    /**
360     * Throws runtime exception.
361     * check remote bridges handle exceptions during oneway calls properly.
362     * Note that on client side the execption may fly or not. When it flies, it should
363     * have the proper message and context.
364     ***/
365    [oneway] void raiseRuntimeExceptionOneway(  [in] string Message,
366                                                [in] com::sun::star::uno::XInterface Context );
367
368    /**
369     * raises runtime exception;
370     * the exception struct returned has to be filled with formerly set test data.
371     */
372    [attribute] long                     RuntimeException;
373};
374
375
376exception BadConstructorArguments: com::sun::star::uno::Exception {};
377
378service Constructors: com::sun::star::uno::XInterface {
379    create1(
380        [in] boolean arg0,
381        [in] byte arg1,
382        [in] short arg2,
383        [in] unsigned short arg3,
384        [in] long arg4,
385        [in] unsigned long arg5,
386        [in] hyper arg6,
387        [in] unsigned hyper arg7,
388        [in] float arg8,
389        [in] double arg9,
390        [in] char arg10,
391        [in] string arg11,
392        [in] type arg12,
393        [in] any arg13,
394        [in] sequence< boolean > arg14,
395        [in] sequence< byte > arg15,
396        [in] sequence< short > arg16,
397        [in] sequence< unsigned short > arg17,
398        [in] sequence< long > arg18,
399        [in] sequence< unsigned long > arg19,
400        [in] sequence< hyper > arg20,
401        [in] sequence< unsigned hyper > arg21,
402        [in] sequence< float > arg22,
403        [in] sequence< double > arg23,
404        [in] sequence< char > arg24,
405        [in] sequence< string > arg25,
406        [in] sequence< type > arg26,
407        [in] sequence< any > arg27,
408        [in] sequence< sequence< boolean > > arg28,
409        [in] sequence< sequence< any > > arg29,
410        [in] sequence< TestEnum > arg30,
411        [in] sequence< TestStruct > arg31,
412        [in] sequence< TestPolyStruct< boolean > > arg32,
413        [in] sequence< TestPolyStruct< any > > arg33,
414        [in] sequence< com::sun::star::uno::XInterface > arg34,
415        [in] TestEnum arg35,
416        [in] TestStruct arg36,
417        [in] TestPolyStruct< boolean > arg37,
418        [in] TestPolyStruct< any > arg38,
419        [in] com::sun::star::uno::XInterface arg39)
420        raises (BadConstructorArguments);
421
422    create2([in] any... args) raises (BadConstructorArguments);
423
424};
425
426service Constructors2: XMultiBase1 {
427
428    create1(
429        [in] TestPolyStruct<type> arg1,
430        [in] TestPolyStruct<any> arg2,
431        [in] TestPolyStruct<boolean> arg3,
432        [in] TestPolyStruct<byte> arg4,
433        [in] TestPolyStruct<short> arg5,
434        [in] TestPolyStruct<long> arg6,
435        [in] TestPolyStruct<hyper> arg7,
436        [in] TestPolyStruct<char> arg8,
437        [in] TestPolyStruct<string> arg9,
438        [in] TestPolyStruct<float> arg10,
439        [in] TestPolyStruct<double> arg11,
440        [in] TestPolyStruct<com::sun::star::uno::XInterface> arg12,
441        [in] TestPolyStruct<com::sun::star::lang::XComponent> arg13,
442        [in] TestPolyStruct<TestEnum> arg14,
443        [in] TestPolyStruct<TestPolyStruct2<char,any> > arg15,
444        [in] TestPolyStruct<TestPolyStruct2<TestPolyStruct2<char,any>,string> > arg16,
445        [in] TestPolyStruct2<string, TestPolyStruct2<char, TestPolyStruct<any> > > arg17,
446        [in] TestPolyStruct2<TestPolyStruct2<char,any>, TestPolyStruct<char> > arg18,
447        [in] TestPolyStruct<sequence<type> > arg19,
448        [in] TestPolyStruct<sequence<any> > arg20,
449        [in] TestPolyStruct<sequence<boolean> > arg21,
450        [in] TestPolyStruct<sequence<byte> > arg22,
451        [in] TestPolyStruct<sequence<short> > arg23,
452        [in] TestPolyStruct<sequence<long> > arg24,
453        [in] TestPolyStruct<sequence<hyper> > arg25,
454        [in] TestPolyStruct<sequence<char> > arg26,
455        [in] TestPolyStruct<sequence<string> > arg27,
456        [in] TestPolyStruct<sequence<float> > arg28,
457        [in] TestPolyStruct<sequence<double> > arg29,
458        [in] TestPolyStruct<sequence<com::sun::star::uno::XInterface> > arg30,
459        [in] TestPolyStruct<sequence<com::sun::star::lang::XComponent> > arg31,
460        [in] TestPolyStruct<sequence<TestEnum> > arg32,
461        [in] TestPolyStruct<sequence<TestPolyStruct2<char, sequence<any> > > > arg33,
462        [in] TestPolyStruct<sequence<TestPolyStruct2<TestPolyStruct<char>, sequence<any> > > > arg34,
463        [in] TestPolyStruct<sequence<sequence<long> > > arg35,
464        [in] sequence<TestPolyStruct<long > > arg36,
465        [in] sequence<TestPolyStruct<TestPolyStruct2<char,any> > > arg37,
466        [in] sequence<TestPolyStruct<TestPolyStruct2<TestPolyStruct2<char,any>,string> > > arg38,
467        [in] sequence<TestPolyStruct2<string, TestPolyStruct2<char, TestPolyStruct<any> > > > arg39,
468        [in] sequence<TestPolyStruct2<TestPolyStruct2<char,any>, TestPolyStruct<char> > > arg40,
469        [in] sequence<sequence<TestPolyStruct< char > > > arg41,
470        [in] sequence<sequence<TestPolyStruct<TestPolyStruct2<char,any> > > >arg42,
471        [in] sequence<sequence<TestPolyStruct<TestPolyStruct2<TestPolyStruct2<char,any>,string> > > > arg43,
472        [in] sequence<sequence<TestPolyStruct2<string, TestPolyStruct2<char, TestPolyStruct<any> > > > > arg44,
473        [in] sequence<sequence<TestPolyStruct2<TestPolyStruct2<char,any>, TestPolyStruct<char> > > > arg45
474        );
475};
476
477interface XCurrentContextChecker {
478    boolean perform(
479        [in] XCurrentContextChecker other, [in] long setSteps,
480        [in] long checkSteps);
481};
482
483/** Extended tests with sequences.
484 */
485interface XBridgeTest2 : XBridgeTest
486{
487    sequence< boolean > setSequenceBool( [in] sequence< boolean > aSeq);
488    sequence< char > setSequenceChar( [in] sequence< char > aSeq);
489    sequence< byte> setSequenceByte( [in] sequence< byte > aSeq);
490    sequence< short> setSequenceShort( [in] sequence< short > aSeq);
491    sequence< unsigned short > setSequenceUShort( [in] sequence< unsigned short > aSeq);
492    sequence< long > setSequenceLong( [in] sequence< long > aSeq);
493    sequence< unsigned long > setSequenceULong( [in] sequence< unsigned long > aSeq);
494    sequence< hyper > setSequenceHyper( [in] sequence< hyper > aSeq);
495    sequence< unsigned hyper > setSequenceUHyper( [in] sequence< unsigned hyper > aSeq);
496    sequence< float > setSequenceFloat( [in] sequence< float > aSeq);
497    sequence< double > setSequenceDouble( [in] sequence< double > aSeq);
498    sequence< TestEnum > setSequenceEnum( [in] sequence< TestEnum > aSeq);
499    sequence< string > setSequenceString( [in] sequence< string > aString);
500    sequence< com::sun::star::uno::XInterface > setSequenceXInterface(
501        [in] sequence< com::sun::star::uno::XInterface > aSeq);
502    sequence< any > setSequenceAny( [in] sequence< any > aSeq);
503    sequence< TestElement > setSequenceStruct( [in] sequence< TestElement > aSeq);
504
505    sequence< sequence< long > > setDim2( [in] sequence< sequence< long > > aSeq);
506    sequence< sequence < sequence < long > > > setDim3(
507        [in] sequence< sequence < sequence < long > > > aSeq);
508
509    void setSequencesInOut( [inout] sequence< boolean > aSeqBoolean,
510                       [inout] sequence< char > aSeqChar,
511                       [inout] sequence< byte > aSeqByte,
512                       [inout] sequence< short > aSeqShort,
513                       [inout] sequence< unsigned short> aSeqUShort,
514                       [inout] sequence< long > aSeqLong,
515                       [inout] sequence< unsigned long > aSeqULong,
516                       [inout] sequence< hyper > aSeqHyper,
517                       [inout] sequence< unsigned hyper > aSeqUHyper,
518                       [inout] sequence< float > aSeqFloat,
519                       [inout] sequence< double > aSeqDouble,
520                       [inout] sequence< TestEnum > aSeqEnum,
521                       [inout] sequence< string > aSeqString,
522                       [inout] sequence< com::sun::star::uno::XInterface > aSeqXInterface,
523                       [inout] sequence< any > aSeqAny,
524                       [inout] sequence< sequence< long > > aSeqDim2,
525                       [inout] sequence< sequence < sequence < long > > > aSeqDim3);
526
527    void setSequencesOut( [out] sequence< boolean > aSeqBoolean,
528                       [out] sequence< char > aSeqChar,
529                       [out] sequence< byte > aSeqByte,
530                       [out] sequence< short > aSeqShort,
531                       [out] sequence< unsigned short> aSeqUShort,
532                       [out] sequence< long > aSeqLong,
533                       [out] sequence< unsigned long > aSeqULong,
534                       [out] sequence< hyper > aSeqHyper,
535                       [out] sequence< unsigned hyper > aSeqUHyper,
536                       [out] sequence< float > aSeqFloat,
537                       [out] sequence< double > aSeqDouble,
538                       [out] sequence< TestEnum > aSeqEnum,
539                       [out] sequence< string > aSeqString,
540                       [out] sequence< com::sun::star::uno::XInterface > aSeqXInterface,
541                       [out] sequence< any > aSeqAny,
542                       [out] sequence< sequence< long > > aSeqDim2,
543                       [out] sequence< sequence < sequence < long > > > aSeqDim3);
544
545    void testConstructorsService(
546        [in] com::sun::star::uno::XComponentContext context)
547        raises (BadConstructorArguments);
548
549    XCurrentContextChecker getCurrentContextChecker();
550};
551
552}; }; };
553