1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <cppu/unotype.hxx>
23 #include <o3tl/string_view.hxx>
24 #include <osl/diagnose.h>
25 #include <osl/diagnose.hxx>
26 #include <osl/thread.hxx>
27 #include <osl/mutex.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <cppuhelper/factory.hxx>
31 #include <cppuhelper/exc_hlp.hxx>
32 #include <cppuhelper/compbase_ex.hxx>
33 #include <cppuhelper/supportsservice.hxx>
34 #include <com/sun/star/lang/IllegalArgumentException.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/lang/XComponent.hpp>
37 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 #include <com/sun/star/uno/Any.hxx>
39 #include <com/sun/star/uno/RuntimeException.hpp>
40 #include <com/sun/star/uno/Sequence.hxx>
42 #include <test/testtools/bridgetest/Constructors.hpp>
43 #include <test/testtools/bridgetest/Constructors2.hpp>
44 #include <test/testtools/bridgetest/TestPolyStruct.hpp>
45 #include <test/testtools/bridgetest/TestPolyStruct2.hpp>
46 #include <test/testtools/bridgetest/XBridgeTest2.hpp>
47 #include <test/testtools/bridgetest/XMulti.hpp>
49 #include "currentcontextchecker.hxx"
54 using namespace com::sun::star::uno
;
55 using namespace com::sun::star::lang
;
56 using namespace com::sun::star::registry
;
57 using namespace test::testtools::bridgetest
;
60 #pragma warning (disable : 4503) // irrelevant for test code
63 constexpr OUStringLiteral SERVICENAME
= u
"com.sun.star.test.bridge.CppTestObject";
64 constexpr OUStringLiteral IMPLNAME
= u
"com.sun.star.comp.bridge.CppTestObject";
66 namespace bridge_object
70 static Sequence
< OUString
> getSupportedServiceNames()
72 return { SERVICENAME
};
76 static void assign( TestElement
& rData
,
77 bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
78 sal_Int16 nShort
, sal_uInt16 nUShort
,
79 sal_Int32 nLong
, sal_uInt32 nULong
,
80 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
81 float fFloat
, double fDouble
,
82 TestEnum eEnum
, const OUString
& rStr
,
83 sal_Int8 nByte2
, sal_Int16 nShort2
,
84 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
85 const css::uno::Any
& rAny
)
91 rData
.UShort
= nUShort
;
95 rData
.UHyper
= nUHyper
;
97 rData
.Double
= fDouble
;
100 rData
.Byte2
= nByte2
;
101 rData
.Short2
= nShort2
;
102 rData
.Interface
= xTest
;
106 static void assign( TestData
& rData
,
107 bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
108 sal_Int16 nShort
, sal_uInt16 nUShort
,
109 sal_Int32 nLong
, sal_uInt32 nULong
,
110 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
111 float fFloat
, double fDouble
,
112 TestEnum eEnum
, const OUString
& rStr
,
113 sal_Int8 nByte2
, sal_Int16 nShort2
,
114 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
115 const css::uno::Any
& rAny
,
116 const css::uno::Sequence
< TestElement
>& rSequence
)
118 assign( static_cast<TestElement
&>(rData
),
119 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
120 eEnum
, rStr
, nByte2
, nShort2
, xTest
, rAny
);
121 rData
.Sequence
= rSequence
;
127 public osl::DebugBase
<Test_Impl
>,
128 public WeakImplHelper
< XBridgeTest2
, XServiceInfo
, XRecursiveCall
>
130 TestData _aData
, _aStructData
;
131 sal_Int32 m_nLastCallId
;
133 bool m_bSequenceOfCallTestPassed
;
136 Sequence
<sal_Bool
> _arBool
;
137 Sequence
<sal_Unicode
> _arChar
;
138 Sequence
<sal_Int8
> _arByte
;
139 Sequence
<sal_Int16
> _arShort
;
140 Sequence
<sal_uInt16
> _arUShort
;
141 Sequence
<sal_Int32
> _arLong
;
142 Sequence
<sal_uInt32
> _arULong
;
143 Sequence
<sal_Int64
> _arHyper
;
144 Sequence
<sal_uInt64
> _arUHyper
;
145 Sequence
<OUString
> _arString
;
146 Sequence
<float> _arFloat
;
147 Sequence
<double> _arDouble
;
148 Sequence
<TestEnum
> _arEnum
;
149 Sequence
<Reference
<XInterface
> > _arObject
;
150 Sequence
<Sequence
<sal_Int32
> > _arLong2
;
151 Sequence
<Sequence
<Sequence
<sal_Int32
> > > _arLong3
;
152 Sequence
<Any
> _arAny
;
153 Sequence
<TestElement
> _arStruct
;
156 Test_Impl() : m_nLastCallId( 0 ),
157 m_bFirstCall( true ),
158 m_bSequenceOfCallTestPassed( true )
161 void SAL_CALL
acquire() noexcept override
163 OWeakObject::acquire();
165 void SAL_CALL
release() noexcept override
167 OWeakObject::release();
171 virtual OUString SAL_CALL
getImplementationName() override
;
172 virtual sal_Bool SAL_CALL
supportsService( const OUString
& rServiceName
) override
;
173 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
176 virtual void SAL_CALL
setValues( sal_Bool bBool
,
188 const OUString
& rStr
,
191 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
192 const css::uno::Any
& rAny
,
193 const css::uno::Sequence
<TestElement
>& rSequence
,
194 const ::test::testtools::bridgetest::TestDataElements
& rStruct
) override
;
196 virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL
setValues2( sal_Bool
& bBool
,
211 css::uno::Reference
< css::uno::XInterface
>& xTest
,
213 css::uno::Sequence
<TestElement
>& rSequence
,
214 ::test::testtools::bridgetest::TestDataElements
& rStruct
) override
;
216 virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL
getValues( sal_Bool
& bBool
,
231 css::uno::Reference
< css::uno::XInterface
>& xTest
,
233 css::uno::Sequence
< TestElement
>& rSequence
,
234 ::test::testtools::bridgetest::TestDataElements
& rStruct
) override
;
236 virtual SmallStruct SAL_CALL
echoSmallStruct(const SmallStruct
& rStruct
) override
238 virtual MediumStruct SAL_CALL
echoMediumStruct(const MediumStruct
& rStruct
) override
240 virtual BigStruct SAL_CALL
echoBigStruct(const BigStruct
& rStruct
) override
242 virtual TwoFloats SAL_CALL
echoTwoFloats(const TwoFloats
& rStruct
) override
244 virtual FourFloats SAL_CALL
echoFourFloats(const FourFloats
& rStruct
) override
246 virtual MixedFloatAndInteger SAL_CALL
echoMixedFloatAndInteger(const MixedFloatAndInteger
& rStruct
) override
248 virtual DoubleHyper SAL_CALL
echoDoubleHyper(DoubleHyper
const & s
) override
{ return s
; }
249 virtual HyperDouble SAL_CALL
echoHyperDouble(HyperDouble
const & s
) override
{ return s
; }
250 virtual FloatFloatLongByte SAL_CALL
echoFloatFloatLongByte(FloatFloatLongByte
const & s
)
253 virtual ThreeByteStruct SAL_CALL
echoThreeByteStruct(const ThreeByteStruct
& rStruct
) override
255 virtual sal_Int32 SAL_CALL
testPPCAlignment( sal_Int64
, sal_Int64
, sal_Int32
, sal_Int64
, sal_Int32 i2
) override
257 virtual sal_Int32 SAL_CALL
testPPC64Alignment( double , double , double , sal_Int32 i1
) override
259 virtual double SAL_CALL
testTenDoubles( double d1
, double d2
, double d3
, double d4
, double d5
, double d6
, double d7
, double d8
, double d9
, double d10
) override
260 { return d1
+ d2
+ d3
+ d4
+ d5
+ d6
+ d7
+ d8
+ d9
+ d10
; }
261 virtual sal_Bool SAL_CALL
getBool() override
262 { return _aData
.Bool
; }
263 virtual sal_Int8 SAL_CALL
getByte() override
264 { return _aData
.Byte
; }
265 virtual sal_Unicode SAL_CALL
getChar() override
266 { return _aData
.Char
; }
267 virtual sal_Int16 SAL_CALL
getShort() override
268 { return _aData
.Short
; }
269 virtual sal_uInt16 SAL_CALL
getUShort() override
270 { return _aData
.UShort
; }
271 virtual sal_Int32 SAL_CALL
getLong() override
272 { return _aData
.Long
; }
273 virtual sal_uInt32 SAL_CALL
getULong() override
274 { return _aData
.ULong
; }
275 virtual sal_Int64 SAL_CALL
getHyper() override
276 { return _aData
.Hyper
; }
277 virtual sal_uInt64 SAL_CALL
getUHyper() override
278 { return _aData
.UHyper
; }
279 virtual float SAL_CALL
getFloat() override
280 { return _aData
.Float
; }
281 virtual double SAL_CALL
getDouble() override
282 { return _aData
.Double
; }
283 virtual TestEnum SAL_CALL
getEnum() override
284 { return _aData
.Enum
; }
285 virtual OUString SAL_CALL
getString() override
286 { return _aData
.String
; }
287 virtual sal_Int8 SAL_CALL
getByte2() override
288 { return _aData
.Byte2
; }
289 virtual sal_Int16 SAL_CALL
getShort2() override
290 { return _aData
.Short2
; }
291 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getInterface( ) override
292 { return _aData
.Interface
; }
293 virtual css::uno::Any SAL_CALL
getAny() override
294 { return _aData
.Any
; }
295 virtual css::uno::Sequence
< TestElement
> SAL_CALL
getSequence() override
296 { return _aData
.Sequence
; }
297 virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL
getStruct() override
298 { return _aStructData
; }
300 virtual void SAL_CALL
setBool( sal_Bool _bool
) override
301 { _aData
.Bool
= _bool
; }
302 virtual void SAL_CALL
setByte( sal_Int8 _byte
) override
303 { _aData
.Byte
= _byte
; }
304 virtual void SAL_CALL
setChar( sal_Unicode _char
) override
305 { _aData
.Char
= _char
; }
306 virtual void SAL_CALL
setShort( sal_Int16 _short
) override
307 { _aData
.Short
= _short
; }
308 virtual void SAL_CALL
setUShort( sal_uInt16 _ushort
) override
309 { _aData
.UShort
= _ushort
; }
310 virtual void SAL_CALL
setLong( sal_Int32 _long
) override
311 { _aData
.Long
= _long
; }
312 virtual void SAL_CALL
setULong( sal_uInt32 _ulong
) override
313 { _aData
.ULong
= _ulong
; }
314 virtual void SAL_CALL
setHyper( sal_Int64 _hyper
) override
315 { _aData
.Hyper
= _hyper
; }
316 virtual void SAL_CALL
setUHyper( sal_uInt64 _uhyper
) override
317 { _aData
.UHyper
= _uhyper
; }
318 virtual void SAL_CALL
setFloat( float _float
) override
319 { _aData
.Float
= _float
; }
320 virtual void SAL_CALL
setDouble( double _double
) override
321 { _aData
.Double
= _double
; }
322 virtual void SAL_CALL
setEnum( TestEnum _enum
) override
323 { _aData
.Enum
= _enum
; }
324 virtual void SAL_CALL
setString( const OUString
& _string
) override
325 { _aData
.String
= _string
; }
326 virtual void SAL_CALL
setByte2( sal_Int8 _byte
) override
327 { _aData
.Byte2
= _byte
; }
328 virtual void SAL_CALL
setShort2( sal_Int16 _short
) override
329 { _aData
.Short2
= _short
; }
330 virtual void SAL_CALL
setInterface( const css::uno::Reference
< css::uno::XInterface
>& _interface
) override
331 { _aData
.Interface
= _interface
; }
332 virtual void SAL_CALL
setAny( const css::uno::Any
& _any
) override
333 { _aData
.Any
= _any
; }
334 virtual void SAL_CALL
setSequence( const css::uno::Sequence
<TestElement
>& _sequence
) override
335 { _aData
.Sequence
= _sequence
; }
336 virtual void SAL_CALL
setStruct( const ::test::testtools::bridgetest::TestDataElements
& _struct
) override
337 { _aStructData
= _struct
; }
339 virtual sal_Int32 SAL_CALL
getRaiseAttr1() override
340 { throw RuntimeException(); }
342 virtual void SAL_CALL
setRaiseAttr1(sal_Int32
) override
343 { throw IllegalArgumentException(); }
345 virtual sal_Int32 SAL_CALL
getRaiseAttr2() override
346 { throw IllegalArgumentException(); }
348 virtual TestPolyStruct
< sal_Bool
> SAL_CALL
transportPolyBoolean(
349 TestPolyStruct
< sal_Bool
> const & arg
) override
352 virtual void SAL_CALL
transportPolyHyper(TestPolyStruct
< sal_Int64
> &) override
{}
354 virtual void SAL_CALL
transportPolySequence(
355 TestPolyStruct
< Sequence
< Any
> > const & arg1
,
356 TestPolyStruct
< Sequence
< Any
> > & arg2
) override
359 virtual TestPolyStruct
< sal_Int32
> SAL_CALL
getNullPolyLong() override
360 { return TestPolyStruct
< sal_Int32
>(0); /* work around MS compiler bug */ }
362 virtual TestPolyStruct
< OUString
> SAL_CALL
getNullPolyString() override
363 { return TestPolyStruct
< OUString
>(); }
365 virtual TestPolyStruct
< Type
> SAL_CALL
getNullPolyType() override
366 { return TestPolyStruct
< Type
>(); }
368 virtual TestPolyStruct
< Any
> SAL_CALL
getNullPolyAny() override
369 { return TestPolyStruct
< Any
>(); }
371 virtual TestPolyStruct
< Sequence
< sal_Bool
> > SAL_CALL
372 getNullPolySequence() override
373 { return TestPolyStruct
< Sequence
< sal_Bool
> >(); }
375 virtual TestPolyStruct
< TestEnum
> SAL_CALL
getNullPolyEnum() override
376 { return TestPolyStruct
< TestEnum
>(
377 test::testtools::bridgetest::TestEnum_TEST
);
378 /* work around MS compiler bug */ }
380 virtual TestPolyStruct
< TestBadEnum
> SAL_CALL
getNullPolyBadEnum() override
381 { return TestPolyStruct
< TestBadEnum
>(
382 test::testtools::bridgetest::TestBadEnum_M
);
383 /* explicitly instantiate with default enumerator */ }
385 virtual TestPolyStruct
< TestStruct
> SAL_CALL
getNullPolyStruct() override
386 { return TestPolyStruct
< TestStruct
>(); }
388 virtual TestPolyStruct
< Reference
< XBridgeTestBase
> > SAL_CALL
389 getNullPolyInterface() override
390 { return TestPolyStruct
< Reference
< XBridgeTestBase
> >(); }
392 virtual css::uno::Any SAL_CALL
transportAny(
393 const css::uno::Any
& value
) override
;
395 virtual void SAL_CALL
call( sal_Int32 nCallId
, sal_Int32 nWaitMUSEC
) override
;
396 virtual void SAL_CALL
callOneway( sal_Int32 nCallId
, sal_Int32 nWaitMUSEC
) override
;
397 virtual sal_Bool SAL_CALL
sequenceOfCallTestPassed( ) override
;
398 virtual void SAL_CALL
startRecursiveCall(
399 const css::uno::Reference
< XRecursiveCall
>& xCall
, sal_Int32 nToCall
) override
;
401 virtual Reference
< XMulti
> SAL_CALL
getMulti() override
;
403 virtual OUString SAL_CALL
testMulti(Reference
< XMulti
> const & multi
) override
;
405 public: // XBridgeTest
406 virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL
raiseException( sal_Int16 nArgumentPos
, const OUString
& rMsg
, const Reference
< XInterface
> & xCOntext
) override
;
408 virtual void SAL_CALL
raiseRuntimeExceptionOneway(
409 const OUString
& Message
, const css::uno::Reference
< css::uno::XInterface
>& Context
) override
;
411 virtual sal_Int32 SAL_CALL
getRuntimeException() override
;
412 virtual void SAL_CALL
setRuntimeException( sal_Int32 _runtimeexception
) override
;
415 virtual Sequence
< sal_Bool
> SAL_CALL
setSequenceBool(
416 const Sequence
< sal_Bool
>& aSeq
) override
;
417 virtual Sequence
< sal_Unicode
> SAL_CALL
setSequenceChar(
418 const Sequence
< sal_Unicode
>& aSeq
) override
;
419 virtual Sequence
< sal_Int8
> SAL_CALL
setSequenceByte(
420 const Sequence
< sal_Int8
>& aSeq
) override
;
421 virtual Sequence
< sal_Int16
> SAL_CALL
setSequenceShort(
422 const Sequence
< sal_Int16
>& aSeq
) override
;
423 virtual Sequence
< sal_uInt16
> SAL_CALL
setSequenceUShort(
424 const Sequence
< sal_uInt16
>& aSeq
) override
;
425 virtual Sequence
< sal_Int32
> SAL_CALL
setSequenceLong(
426 const Sequence
< sal_Int32
>& aSeq
) override
;
427 virtual Sequence
< sal_uInt32
> SAL_CALL
setSequenceULong(
428 const Sequence
< sal_uInt32
>& aSeq
) override
;
429 virtual Sequence
< sal_Int64
> SAL_CALL
setSequenceHyper(
430 const Sequence
< sal_Int64
>& aSeq
) override
;
431 virtual Sequence
< sal_uInt64
> SAL_CALL
setSequenceUHyper(
432 const Sequence
< sal_uInt64
>& aSeq
) override
;
433 virtual Sequence
< float > SAL_CALL
setSequenceFloat(
434 const Sequence
< float >& aSeq
) override
;
435 virtual Sequence
< double > SAL_CALL
setSequenceDouble(
436 const Sequence
< double >& aSeq
) override
;
437 virtual Sequence
< TestEnum
> SAL_CALL
setSequenceEnum(
438 const Sequence
< TestEnum
>& aSeq
) override
;
439 virtual Sequence
< OUString
> SAL_CALL
setSequenceString(
440 const Sequence
< OUString
>& aString
) override
;
441 virtual Sequence
< Reference
< XInterface
> > SAL_CALL
setSequenceXInterface(
442 const Sequence
< Reference
< XInterface
> >& aSeq
) override
;
443 virtual Sequence
<Any
> SAL_CALL
setSequenceAny(
444 const Sequence
<Any
>& aSeq
) override
;
445 virtual Sequence
<TestElement
> SAL_CALL
setSequenceStruct(
446 const Sequence
< TestElement
>& aSeq
) override
;
447 virtual Sequence
< Sequence
< sal_Int32
> > SAL_CALL
setDim2(
448 const Sequence
<Sequence
< sal_Int32
> >& aSeq
) override
;
449 virtual Sequence
< Sequence
< Sequence
< sal_Int32
> > > SAL_CALL
setDim3(
450 const Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeq
) override
;
451 virtual void SAL_CALL
setSequencesInOut(Sequence
< sal_Bool
>& aSeqBoolean
,
452 Sequence
< sal_Unicode
>& aSeqChar
,
453 Sequence
< sal_Int8
>& aSeqByte
,
454 Sequence
< sal_Int16
>& aSeqShort
,
455 Sequence
< sal_uInt16
>& aSeqUShort
,
456 Sequence
< sal_Int32
>& aSeqLong
,
457 Sequence
< sal_uInt32
>& aSeqULong
,
458 Sequence
< sal_Int64
>& aSeqHyper
,
459 Sequence
< sal_uInt64
>& aSeqUHyper
,
460 Sequence
< float >& aSeqFloat
,
461 Sequence
< double >& aSeqDouble
,
462 Sequence
< TestEnum
>& aSeqTestEnum
,
463 Sequence
< OUString
>& aSeqString
,
464 Sequence
<Reference
<XInterface
> >& aSeqXInterface
,
465 Sequence
< Any
>& aSeqAny
,
466 Sequence
< Sequence
< sal_Int32
> >& aSeqDim2
,
467 Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeqDim3
) override
;
468 virtual void SAL_CALL
setSequencesOut( Sequence
< sal_Bool
>& aSeqBoolean
,
469 Sequence
< sal_Unicode
>& aSeqChar
,
470 Sequence
< sal_Int8
>& aSeqByte
,
471 Sequence
< sal_Int16
>& aSeqShort
,
472 Sequence
< sal_uInt16
>& aSeqUShort
,
473 Sequence
< sal_Int32
>& aSeqLong
,
474 Sequence
< sal_uInt32
>& aSeqULong
,
475 Sequence
< sal_Int64
>& aSeqHyper
,
476 Sequence
< sal_uInt64
>& aSeqUHyper
,
477 Sequence
< float >& aSeqFloat
,
478 Sequence
< double >& aSeqDouble
,
479 Sequence
< TestEnum
>& aSeqEnum
,
480 Sequence
< OUString
>& aSeqString
,
481 Sequence
< Reference
< XInterface
> >& aSeqXInterface
,
482 Sequence
< Any
>& aSeqAny
,
483 Sequence
< Sequence
< sal_Int32
> >& aSeqDim2
,
484 Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeqDim3
) override
;
485 virtual void SAL_CALL
testConstructorsService(
486 Reference
< XComponentContext
> const & context
) override
;
487 virtual Reference
< XCurrentContextChecker
> SAL_CALL
488 getCurrentContextChecker() override
;
491 virtual void SAL_CALL
callRecursivly( const css::uno::Reference
< XRecursiveCall
>& xCall
, sal_Int32 nToCall
) override
;
494 //Dummy class for XComponent implementation
495 class Dummy
: public osl::DebugBase
<Dummy
>,
496 public WeakComponentImplHelperBase
499 Dummy(): WeakComponentImplHelperBase(*Mutex::getGlobalMutex()){}
505 Any
Test_Impl::transportAny( const Any
& value
)
513 void wait(sal_Int32 microSeconds
) {
514 OSL_ASSERT(microSeconds
>= 0 && microSeconds
<= SAL_MAX_INT32
/ 1000);
515 osl::Thread::wait(std::chrono::microseconds(microSeconds
));
520 void Test_Impl::call( sal_Int32 nCallId
, sal_Int32 nWaitMUSEC
)
525 m_bFirstCall
= false;
529 m_bSequenceOfCallTestPassed
= m_bSequenceOfCallTestPassed
&& (nCallId
> m_nLastCallId
);
531 m_nLastCallId
= nCallId
;
535 void Test_Impl::callOneway( sal_Int32 nCallId
, sal_Int32 nWaitMUSEC
)
538 m_bSequenceOfCallTestPassed
= m_bSequenceOfCallTestPassed
&& (nCallId
> m_nLastCallId
);
539 m_nLastCallId
= nCallId
;
543 sal_Bool
Test_Impl::sequenceOfCallTestPassed()
545 return m_bSequenceOfCallTestPassed
;
549 void SAL_CALL
Test_Impl::startRecursiveCall(
550 const css::uno::Reference
< XRecursiveCall
>& xCall
, sal_Int32 nToCall
)
552 MutexGuard
guard( m_mutex
);
556 xCall
->callRecursivly( this , nToCall
);
561 void SAL_CALL
Test_Impl::callRecursivly(
562 const css::uno::Reference
< XRecursiveCall
>& xCall
,
565 MutexGuard
guard( m_mutex
);
569 xCall
->callRecursivly( this , nToCall
);
573 Reference
< XMulti
> Test_Impl::getMulti() {
574 return new testtools::bridgetest::Multi
;
577 OUString
Test_Impl::testMulti(Reference
< XMulti
> const & multi
)
579 return testtools::bridgetest::testMulti(multi
);
583 void Test_Impl::setValues( sal_Bool bBool
,
595 const OUString
& rStr
,
598 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
599 const css::uno::Any
& rAny
,
600 const css::uno::Sequence
<TestElement
>& rSequence
,
601 const ::test::testtools::bridgetest::TestDataElements
& rStruct
)
604 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
605 eEnum
, rStr
, nByte2
, nShort2
, xTest
, rAny
, rSequence
);
606 _aStructData
= rStruct
;
609 ::test::testtools::bridgetest::TestDataElements
Test_Impl::setValues2( sal_Bool
& bBool
,
624 css::uno::Reference
< css::uno::XInterface
>& xTest
,
626 css::uno::Sequence
<TestElement
>& rSequence
,
627 ::test::testtools::bridgetest::TestDataElements
& rStruct
)
630 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
631 eEnum
, rStr
, nByte2
, nShort2
, xTest
, rAny
, rSequence
);
632 _aStructData
= rStruct
;
634 auto pSequence
= rSequence
.getArray();
635 std::swap(pSequence
[ 0 ], pSequence
[ 1 ]);
640 ::test::testtools::bridgetest::TestDataElements
Test_Impl::getValues( sal_Bool
& bBool
,
655 css::uno::Reference
< css::uno::XInterface
>& xTest
,
657 css::uno::Sequence
<TestElement
>& rSequence
,
658 ::test::testtools::bridgetest::TestDataElements
& rStruct
)
663 nShort
= _aData
.Short
;
664 nUShort
= _aData
.UShort
;
666 nULong
= _aData
.ULong
;
667 nHyper
= _aData
.Hyper
;
668 nUHyper
= _aData
.UHyper
;
669 fFloat
= _aData
.Float
;
670 fDouble
= _aData
.Double
;
672 rStr
= _aData
.String
;
673 nByte2
= _aData
.Byte2
;
674 nShort2
= _aData
.Short2
;
675 xTest
= _aData
.Interface
;
677 rSequence
= _aData
.Sequence
;
678 rStruct
= _aStructData
;
682 ::test::testtools::bridgetest::TestDataElements
Test_Impl::raiseException( sal_Int16 nArgumentPos
, const OUString
& rMsg
, const Reference
< XInterface
> & xContext
)
684 IllegalArgumentException aExc
;
685 aExc
.ArgumentPosition
= nArgumentPos
;
686 aExc
.Message
= _aData
.String
= rMsg
;
687 aExc
.Context
= _aData
.Interface
= xContext
;
691 void Test_Impl::raiseRuntimeExceptionOneway( const OUString
& rMsg
, const Reference
< XInterface
> & xContext
)
693 RuntimeException aExc
;
694 aExc
.Message
= _aData
.String
= rMsg
;
695 aExc
.Context
= _aData
.Interface
= xContext
;
699 static void dothrow2(const RuntimeException
& e
)
703 static void dothrow(const RuntimeException
& e
)
706 // currently only for MSVC:
707 // just to test whether all bridges fall back to a RuntimeException
708 // in case of a thrown non-UNO exception:
711 throw ::std::bad_alloc();
717 Any
a( getCaughtException() );
718 RuntimeException exc
;
719 OSL_VERIFY( a
>>= exc
);
721 catch (...) // never throws anything
723 fprintf( stderr
, "\ngetCaughtException() failed!\n" );
731 sal_Int32
Test_Impl::getRuntimeException()
735 dothrow( RuntimeException( _aData
.String
, _aData
.Interface
) );
739 Any
a( getCaughtException() );
742 return 0; // for dummy
745 void Test_Impl::setRuntimeException( sal_Int32
)
747 RuntimeException aExc
;
748 aExc
.Message
= _aData
.String
;
749 aExc
.Context
= _aData
.Interface
;
750 throwException( Any( aExc
) );
753 // XBridgeTest2 -------------------------------------------------------------
754 Sequence
< sal_Bool
> SAL_CALL
Test_Impl::setSequenceBool(
755 const Sequence
< sal_Bool
>& aSeq
)
761 Sequence
< sal_Unicode
> SAL_CALL
Test_Impl::setSequenceChar(
762 const Sequence
< sal_Unicode
>& aSeq
)
768 Sequence
< sal_Int8
> SAL_CALL
Test_Impl::setSequenceByte(
769 const Sequence
< sal_Int8
>& aSeq
)
775 Sequence
< sal_Int16
> SAL_CALL
Test_Impl::setSequenceShort(
776 const Sequence
< sal_Int16
>& aSeq
)
782 Sequence
< sal_uInt16
> SAL_CALL
Test_Impl::setSequenceUShort(
783 const Sequence
< sal_uInt16
>& aSeq
)
789 Sequence
< sal_Int32
> SAL_CALL
Test_Impl::setSequenceLong(
790 const Sequence
< sal_Int32
>& aSeq
)
796 Sequence
< sal_uInt32
> SAL_CALL
Test_Impl::setSequenceULong(
797 const Sequence
< sal_uInt32
>& aSeq
)
803 Sequence
< sal_Int64
> SAL_CALL
Test_Impl::setSequenceHyper(
804 const Sequence
< sal_Int64
>& aSeq
)
810 Sequence
< sal_uInt64
> SAL_CALL
Test_Impl::setSequenceUHyper(
811 const Sequence
< sal_uInt64
>& aSeq
)
817 Sequence
< float > SAL_CALL
Test_Impl::setSequenceFloat(
818 const Sequence
< float >& aSeq
)
824 Sequence
< double > SAL_CALL
Test_Impl::setSequenceDouble(
825 const Sequence
< double >& aSeq
)
831 Sequence
< TestEnum
> SAL_CALL
Test_Impl::setSequenceEnum(
832 const Sequence
< TestEnum
>& aSeq
)
838 Sequence
< OUString
> SAL_CALL
Test_Impl::setSequenceString(
839 const Sequence
< OUString
>& aSeq
)
845 Sequence
< Reference
< XInterface
> > SAL_CALL
Test_Impl::setSequenceXInterface(
846 const Sequence
< Reference
< XInterface
> >& aSeq
)
852 Sequence
<Any
> SAL_CALL
Test_Impl::setSequenceAny(
853 const Sequence
<Any
>& aSeq
)
859 Sequence
<TestElement
> SAL_CALL
Test_Impl::setSequenceStruct(
860 const Sequence
< TestElement
>& aSeq
)
866 Sequence
< Sequence
< sal_Int32
> > SAL_CALL
Test_Impl::setDim2(
867 const Sequence
<Sequence
< sal_Int32
> >& aSeq
)
873 Sequence
< Sequence
< Sequence
< sal_Int32
> > > SAL_CALL
Test_Impl::setDim3(
874 const Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeq
)
880 void SAL_CALL
Test_Impl::setSequencesInOut(Sequence
< sal_Bool
>& aSeqBoolean
,
881 Sequence
< sal_Unicode
>& aSeqChar
,
882 Sequence
< sal_Int8
>& aSeqByte
,
883 Sequence
< sal_Int16
>& aSeqShort
,
884 Sequence
< sal_uInt16
>& aSeqUShort
,
885 Sequence
< sal_Int32
>& aSeqLong
,
886 Sequence
< sal_uInt32
>& aSeqULong
,
887 Sequence
< sal_Int64
>& aSeqHyper
,
888 Sequence
< sal_uInt64
>& aSeqUHyper
,
889 Sequence
< float >& aSeqFloat
,
890 Sequence
< double >& aSeqDouble
,
891 Sequence
< TestEnum
>& aSeqTestEnum
,
892 Sequence
< OUString
>& aSeqString
,
893 Sequence
<Reference
<XInterface
> >& aSeqXInterface
,
894 Sequence
< Any
>& aSeqAny
,
895 Sequence
< Sequence
< sal_Int32
> >& aSeqDim2
,
896 Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeqDim3
)
898 _arBool
= aSeqBoolean
;
901 _arShort
= aSeqShort
;
902 _arUShort
= aSeqUShort
;
904 _arULong
= aSeqULong
;
905 _arHyper
= aSeqHyper
;
906 _arUHyper
= aSeqUHyper
;
907 _arFloat
= aSeqFloat
;
908 _arDouble
= aSeqDouble
;
909 _arEnum
= aSeqTestEnum
;
910 _arString
= aSeqString
;
911 _arObject
= aSeqXInterface
;
917 void SAL_CALL
Test_Impl::setSequencesOut( Sequence
< sal_Bool
>& aSeqBoolean
,
918 Sequence
< sal_Unicode
>& aSeqChar
,
919 Sequence
< sal_Int8
>& aSeqByte
,
920 Sequence
< sal_Int16
>& aSeqShort
,
921 Sequence
< sal_uInt16
>& aSeqUShort
,
922 Sequence
< sal_Int32
>& aSeqLong
,
923 Sequence
< sal_uInt32
>& aSeqULong
,
924 Sequence
< sal_Int64
>& aSeqHyper
,
925 Sequence
< sal_uInt64
>& aSeqUHyper
,
926 Sequence
< float >& aSeqFloat
,
927 Sequence
< double >& aSeqDouble
,
928 Sequence
< TestEnum
>& aSeqEnum
,
929 Sequence
< OUString
>& aSeqString
,
930 Sequence
< Reference
< XInterface
> >& aSeqXInterface
,
931 Sequence
< Any
>& aSeqAny
,
932 Sequence
< Sequence
< sal_Int32
> >& aSeqDim2
,
933 Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeqDim3
)
935 aSeqBoolean
= _arBool
;
938 aSeqShort
= _arShort
;
939 aSeqUShort
= _arUShort
;
941 aSeqULong
= _arULong
;
942 aSeqHyper
= _arHyper
;
943 aSeqUHyper
= _arUHyper
;
944 aSeqFloat
= _arFloat
;
945 aSeqDouble
= _arDouble
;
947 aSeqString
= _arString
;
948 aSeqXInterface
= _arObject
;
954 void Test_Impl::testConstructorsService(
955 Reference
< XComponentContext
> const & context
)
957 Sequence
< sal_Bool
> arg14
{ true };
958 Sequence
< sal_Int8
> arg15
{ SAL_MIN_INT8
};
959 Sequence
< sal_Int16
> arg16
{ SAL_MIN_INT16
};
960 Sequence
< sal_uInt16
> arg17
{ SAL_MAX_UINT16
};
961 Sequence
< sal_Int32
> arg18
{ SAL_MIN_INT32
};
962 Sequence
< sal_uInt32
> arg19
{ SAL_MAX_UINT32
};
963 Sequence
< sal_Int64
> arg20
{ SAL_MIN_INT64
};
964 Sequence
< sal_uInt64
> arg21
{ SAL_MAX_UINT64
};
965 Sequence
< float > arg22
{ 0.123f
};
966 Sequence
< double > arg23
{ 0.456 };
967 Sequence
< sal_Unicode
> arg24
{ 'X' };
968 Sequence
< OUString
> arg25
{ "test" };
969 Sequence
< Type
> arg26
{ UnoType
< Any
>::get() };
970 Sequence
< Any
> arg27
{ Any(true) };
971 Sequence
< Sequence
< sal_Bool
> > arg28
{ { true } };
972 Sequence
< Sequence
< Any
> > arg29
{ { Any(true) } };
973 Sequence
< TestEnum
> arg30
{ TestEnum_TWO
};
974 Sequence
< TestStruct
> arg31(1); arg31
.getArray()[0].member
= 10;
975 Sequence
< TestPolyStruct
< sal_Bool
> > arg32
{ { true } };
976 Sequence
< TestPolyStruct
< Any
> > arg33(1); arg33
.getArray()[0].member
<<= true;
977 Sequence
< Reference
< XInterface
> > arg34(1);
978 Constructors::create1(context
,
991 UnoType
< Any
>::get(),
1016 TestPolyStruct
< sal_Bool
>(true),
1017 TestPolyStruct
< Any
>(Any(true)),
1018 Reference
< XInterface
>(nullptr));
1019 Sequence
< Any
> args
{
1023 Any(SAL_MAX_UINT16
),
1025 Any(SAL_MAX_UINT32
),
1027 Any(SAL_MAX_UINT64
),
1031 Any(OUString("test")),
1032 Any(UnoType
< Any
>::get()),
1056 Any(TestStruct(10)),
1057 Any(TestPolyStruct
< sal_Bool
>(true)),
1058 Any(TestPolyStruct
< Any
>(Any(true))),
1059 Any(Reference
< XInterface
>(nullptr))
1061 assert(args
.getLength() == 40);
1062 Constructors::create2(context
, args
);
1064 Sequence
<Type
> argSeq1
{ cppu::UnoType
<sal_Int32
>::get() };
1065 Sequence
<Reference
<XInterface
> > argSeq2
{ static_cast<XComponent
*>(new Dummy()) };
1066 Sequence
<Reference
<XComponent
> > argSeq2a
{ static_cast<XComponent
*>(new Dummy()) };
1068 Sequence
<TestPolyStruct2
<sal_Unicode
, Sequence
<Any
> > > argSeq3
1069 { TestPolyStruct2
<sal_Unicode
, Sequence
<Any
> >('X', arg27
) };
1070 Sequence
<TestPolyStruct2
<TestPolyStruct
<sal_Unicode
>, Sequence
<Any
> > > argSeq4
1071 { TestPolyStruct2
<TestPolyStruct
<sal_Unicode
>, Sequence
<Any
> >(
1072 TestPolyStruct
<sal_Unicode
>('X'), arg27
) };
1073 Sequence
<Sequence
<sal_Int32
> > argSeq5
{ { SAL_MIN_INT32
} };
1074 Sequence
<TestPolyStruct
<sal_Int32
> > argSeq6
{ TestPolyStruct
<sal_Int32
>(SAL_MIN_INT32
) };
1075 Sequence
<TestPolyStruct
<TestPolyStruct2
<sal_Unicode
, Any
> > > argSeq7
1076 { TestPolyStruct
<TestPolyStruct2
<sal_Unicode
, Any
> >(
1077 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true))) };
1078 Sequence
<TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
> > > argSeq8
1079 { TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
> > (
1080 TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
>(
1081 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true)), OUString("test"))) };
1082 Sequence
<TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> > > > argSeq9
1083 { TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> > >(
1084 OUString("test"), TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> >(
1085 'X', TestPolyStruct
<Any
>(Any(true)))) };
1086 Sequence
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>, TestPolyStruct
<sal_Unicode
> > > argSeq10
1087 { TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>, TestPolyStruct
<sal_Unicode
> >(
1088 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true)), TestPolyStruct
<sal_Unicode
>('X')) };
1089 Sequence
<Sequence
<TestPolyStruct
<sal_Unicode
> > > argSeq11
1090 { { TestPolyStruct
<sal_Unicode
>('X') } };
1091 Sequence
<Sequence
<TestPolyStruct
<TestPolyStruct2
<sal_Unicode
,Any
> > > > argSeq12
1092 { { TestPolyStruct
<TestPolyStruct2
<sal_Unicode
,Any
> >(
1093 TestPolyStruct2
<sal_Unicode
,Any
>('X', Any(true))) } };
1094 Sequence
<Sequence
<TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>,OUString
> > > > argSeq13
1095 { {TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>,OUString
> >(
1096 TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>,OUString
>(
1097 TestPolyStruct2
<sal_Unicode
,Any
>('X', Any(true)), OUString("test")))} };
1098 Sequence
<Sequence
<TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> > > > > argSeq14
1099 { { TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> > >(
1100 OUString("test"), TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> >(
1101 'X', TestPolyStruct
<Any
>(Any(true)))) } };
1102 Sequence
<Sequence
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>, TestPolyStruct
<sal_Unicode
> > > > argSeq15
1103 { { TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>, TestPolyStruct
<sal_Unicode
> >(
1104 TestPolyStruct2
<sal_Unicode
,Any
>('X',Any(true)), TestPolyStruct
<sal_Unicode
>('X')) } };
1106 Constructors2::create1(
1108 TestPolyStruct
<Type
>(cppu::UnoType
<sal_Int32
>::get()),
1109 TestPolyStruct
<Any
>(Any(true)),
1110 TestPolyStruct
<sal_Bool
>(true),
1111 TestPolyStruct
<sal_Int8
>(SAL_MIN_INT8
),
1112 TestPolyStruct
<sal_Int16
>(SAL_MIN_INT16
),
1113 TestPolyStruct
<sal_Int32
>(SAL_MIN_INT32
),
1114 TestPolyStruct
<sal_Int64
>(SAL_MIN_INT64
),
1115 TestPolyStruct
<sal_Unicode
>('X'),
1116 TestPolyStruct
<OUString
>(OUString("test")),
1117 TestPolyStruct
<float>(0.123f
),
1118 TestPolyStruct
<double>(0.456),
1119 TestPolyStruct
<Reference
<XInterface
> >(static_cast<XBridgeTest2
*>(this)),
1120 TestPolyStruct
<Reference
<XComponent
> >(static_cast<XComponent
*>(new Dummy())),
1121 TestPolyStruct
<TestEnum
>(TestEnum_TWO
),
1122 TestPolyStruct
<TestPolyStruct2
<sal_Unicode
, Any
> >(
1123 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true))),
1124 TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
> > (
1125 TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
>(
1126 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true)), OUString("test"))),
1127 TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
,TestPolyStruct
<Any
> > >(
1129 TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> >('X', TestPolyStruct
<Any
>(Any(true)))),
1130 TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>, TestPolyStruct
<sal_Unicode
> >(
1131 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true)),
1132 TestPolyStruct
<sal_Unicode
>('X')),
1133 TestPolyStruct
<Sequence
<Type
> >(argSeq1
),
1134 TestPolyStruct
<Sequence
<Any
> >(arg27
),
1135 TestPolyStruct
<Sequence
<sal_Bool
> >(arg14
),
1136 TestPolyStruct
<Sequence
<sal_Int8
> >(arg15
),
1137 TestPolyStruct
<Sequence
<sal_Int16
> >(arg16
),
1138 TestPolyStruct
<Sequence
<sal_Int32
> >(arg18
),
1139 TestPolyStruct
<Sequence
<sal_Int64
> >(arg20
),
1140 TestPolyStruct
<Sequence
<sal_Unicode
> >(arg24
),
1141 TestPolyStruct
<Sequence
<OUString
> >(arg25
),
1142 TestPolyStruct
<Sequence
<float> >(arg22
),
1143 TestPolyStruct
<Sequence
<double> >(arg23
),
1144 TestPolyStruct
<Sequence
<Reference
<XInterface
> > >(argSeq2
),
1145 TestPolyStruct
<Sequence
<Reference
<XComponent
> > >(argSeq2a
),
1146 TestPolyStruct
<Sequence
<TestEnum
> >(arg30
),
1147 TestPolyStruct
<Sequence
<TestPolyStruct2
<sal_Unicode
, Sequence
<Any
> > > >(argSeq3
),
1148 TestPolyStruct
<Sequence
<TestPolyStruct2
<TestPolyStruct
<sal_Unicode
>, Sequence
<Any
> > > > (argSeq4
),
1149 TestPolyStruct
<Sequence
<Sequence
<sal_Int32
> > >(argSeq5
),
1162 Reference
< XCurrentContextChecker
> Test_Impl::getCurrentContextChecker()
1164 return new testtools::bridgetest::CurrentContextChecker
;
1169 OUString
Test_Impl::getImplementationName()
1174 sal_Bool
Test_Impl::supportsService( const OUString
& rServiceName
)
1176 return cppu::supportsService(this, rServiceName
);
1179 Sequence
< OUString
> Test_Impl::getSupportedServiceNames()
1181 return bridge_object::getSupportedServiceNames();
1185 static Reference
< XInterface
> Test_Impl_create(
1186 SAL_UNUSED_PARAMETER
const Reference
< XMultiServiceFactory
> & )
1188 return Reference
< XInterface
>( static_cast<XBridgeTest
*>(new Test_Impl()) );
1195 SAL_DLLPUBLIC_EXPORT
void * component_getFactory(
1196 const char * pImplName
, SAL_UNUSED_PARAMETER
void * pServiceManager
,
1197 SAL_UNUSED_PARAMETER
void * )
1199 void * pRet
= nullptr;
1201 if (pServiceManager
&& o3tl::equalsAscii(IMPLNAME
, pImplName
))
1203 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
1204 static_cast< XMultiServiceFactory
* >( pServiceManager
),
1206 bridge_object::Test_Impl_create
,
1207 bridge_object::getSupportedServiceNames() ) );
1211 xFactory
->acquire();
1212 pRet
= xFactory
.get();
1220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */