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 .
23 #include <cppu/unotype.hxx>
24 #include <o3tl/string_view.hxx>
25 #include <osl/diagnose.h>
26 #include <osl/diagnose.hxx>
27 #include <osl/thread.hxx>
28 #include <osl/mutex.hxx>
30 #include <cppuhelper/implbase.hxx>
31 #include <cppuhelper/factory.hxx>
32 #include <cppuhelper/exc_hlp.hxx>
33 #include <cppuhelper/compbase_ex.hxx>
34 #include <cppuhelper/supportsservice.hxx>
35 #include <com/sun/star/lang/IllegalArgumentException.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/lang/XComponent.hpp>
38 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
39 #include <com/sun/star/uno/Any.hxx>
40 #include <com/sun/star/uno/RuntimeException.hpp>
41 #include <com/sun/star/uno/Sequence.hxx>
43 #include <test/testtools/bridgetest/Constructors.hpp>
44 #include <test/testtools/bridgetest/Constructors2.hpp>
45 #include <test/testtools/bridgetest/TestPolyStruct.hpp>
46 #include <test/testtools/bridgetest/TestPolyStruct2.hpp>
47 #include <test/testtools/bridgetest/XBridgeTest2.hpp>
48 #include <test/testtools/bridgetest/XMulti.hpp>
50 #include "currentcontextchecker.hxx"
55 using namespace com::sun::star::uno
;
56 using namespace com::sun::star::lang
;
57 using namespace com::sun::star::registry
;
58 using namespace test::testtools::bridgetest
;
61 #pragma warning (disable : 4503) // irrelevant for test code
64 constexpr OUString SERVICENAME
= u
"com.sun.star.test.bridge.CppTestObject"_ustr
;
65 constexpr OUString IMPLNAME
= u
"com.sun.star.comp.bridge.CppTestObject"_ustr
;
67 namespace bridge_object
71 static Sequence
< OUString
> getSupportedServiceNames()
73 return { SERVICENAME
};
77 static void assign( TestElement
& rData
,
78 bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
79 sal_Int16 nShort
, sal_uInt16 nUShort
,
80 sal_Int32 nLong
, sal_uInt32 nULong
,
81 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
82 float fFloat
, double fDouble
,
83 TestEnum eEnum
, const OUString
& rStr
,
84 sal_Int8 nByte2
, sal_Int16 nShort2
,
85 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
86 const css::uno::Any
& rAny
)
92 rData
.UShort
= nUShort
;
96 rData
.UHyper
= nUHyper
;
98 rData
.Double
= fDouble
;
101 rData
.Byte2
= nByte2
;
102 rData
.Short2
= nShort2
;
103 rData
.Interface
= xTest
;
107 static void assign( TestData
& rData
,
108 bool bBool
, sal_Unicode cChar
, sal_Int8 nByte
,
109 sal_Int16 nShort
, sal_uInt16 nUShort
,
110 sal_Int32 nLong
, sal_uInt32 nULong
,
111 sal_Int64 nHyper
, sal_uInt64 nUHyper
,
112 float fFloat
, double fDouble
,
113 TestEnum eEnum
, const OUString
& rStr
,
114 sal_Int8 nByte2
, sal_Int16 nShort2
,
115 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
116 const css::uno::Any
& rAny
,
117 const css::uno::Sequence
< TestElement
>& rSequence
)
119 assign( static_cast<TestElement
&>(rData
),
120 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
121 eEnum
, rStr
, nByte2
, nShort2
, xTest
, rAny
);
122 rData
.Sequence
= rSequence
;
128 public osl::DebugBase
<Test_Impl
>,
129 public WeakImplHelper
< XBridgeTest2
, XServiceInfo
, XRecursiveCall
>
131 TestData _aData
, _aStructData
;
132 sal_Int32 m_nLastCallId
;
134 bool m_bSequenceOfCallTestPassed
;
137 Sequence
<sal_Bool
> _arBool
;
138 Sequence
<sal_Unicode
> _arChar
;
139 Sequence
<sal_Int8
> _arByte
;
140 Sequence
<sal_Int16
> _arShort
;
141 Sequence
<sal_uInt16
> _arUShort
;
142 Sequence
<sal_Int32
> _arLong
;
143 Sequence
<sal_uInt32
> _arULong
;
144 Sequence
<sal_Int64
> _arHyper
;
145 Sequence
<sal_uInt64
> _arUHyper
;
146 Sequence
<OUString
> _arString
;
147 Sequence
<float> _arFloat
;
148 Sequence
<double> _arDouble
;
149 Sequence
<TestEnum
> _arEnum
;
150 Sequence
<Reference
<XInterface
> > _arObject
;
151 Sequence
<Sequence
<sal_Int32
> > _arLong2
;
152 Sequence
<Sequence
<Sequence
<sal_Int32
> > > _arLong3
;
153 Sequence
<Any
> _arAny
;
154 Sequence
<TestElement
> _arStruct
;
157 Test_Impl() : m_nLastCallId( 0 ),
158 m_bFirstCall( true ),
159 m_bSequenceOfCallTestPassed( true )
162 void SAL_CALL
acquire() noexcept override
164 OWeakObject::acquire();
166 void SAL_CALL
release() noexcept override
168 OWeakObject::release();
172 virtual OUString SAL_CALL
getImplementationName() override
;
173 virtual sal_Bool SAL_CALL
supportsService( const OUString
& rServiceName
) override
;
174 virtual Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
177 virtual void SAL_CALL
setValues( sal_Bool bBool
,
189 const OUString
& rStr
,
192 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
193 const css::uno::Any
& rAny
,
194 const css::uno::Sequence
<TestElement
>& rSequence
,
195 const ::test::testtools::bridgetest::TestDataElements
& rStruct
) override
;
197 virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL
setValues2( sal_Bool
& bBool
,
212 css::uno::Reference
< css::uno::XInterface
>& xTest
,
214 css::uno::Sequence
<TestElement
>& rSequence
,
215 ::test::testtools::bridgetest::TestDataElements
& rStruct
) override
;
217 virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL
getValues( sal_Bool
& bBool
,
232 css::uno::Reference
< css::uno::XInterface
>& xTest
,
234 css::uno::Sequence
< TestElement
>& rSequence
,
235 ::test::testtools::bridgetest::TestDataElements
& rStruct
) override
;
237 virtual SmallStruct SAL_CALL
echoSmallStruct(const SmallStruct
& rStruct
) override
239 virtual MediumStruct SAL_CALL
echoMediumStruct(const MediumStruct
& rStruct
) override
241 virtual BigStruct SAL_CALL
echoBigStruct(const BigStruct
& rStruct
) override
243 virtual TwoFloats SAL_CALL
echoTwoFloats(const TwoFloats
& rStruct
) override
245 virtual FourFloats SAL_CALL
echoFourFloats(const FourFloats
& rStruct
) override
247 virtual MixedFloatAndInteger SAL_CALL
echoMixedFloatAndInteger(const MixedFloatAndInteger
& rStruct
) override
249 virtual DoubleHyper SAL_CALL
echoDoubleHyper(DoubleHyper
const & s
) override
{ return s
; }
250 virtual HyperDouble SAL_CALL
echoHyperDouble(HyperDouble
const & s
) override
{ return s
; }
251 virtual FloatFloatLongByte SAL_CALL
echoFloatFloatLongByte(FloatFloatLongByte
const & s
)
254 virtual ThreeByteStruct SAL_CALL
echoThreeByteStruct(const ThreeByteStruct
& rStruct
) override
256 virtual sal_Int32 SAL_CALL
testPPCAlignment( sal_Int64
, sal_Int64
, sal_Int32
, sal_Int64
, sal_Int32 i2
) override
258 virtual sal_Int32 SAL_CALL
testPPC64Alignment( double , double , double , sal_Int32 i1
) override
260 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
261 { return d1
+ d2
+ d3
+ d4
+ d5
+ d6
+ d7
+ d8
+ d9
+ d10
; }
262 virtual sal_Bool SAL_CALL
getBool() override
263 { return _aData
.Bool
; }
264 virtual sal_Int8 SAL_CALL
getByte() override
265 { return _aData
.Byte
; }
266 virtual sal_Unicode SAL_CALL
getChar() override
267 { return _aData
.Char
; }
268 virtual sal_Int16 SAL_CALL
getShort() override
269 { return _aData
.Short
; }
270 virtual sal_uInt16 SAL_CALL
getUShort() override
271 { return _aData
.UShort
; }
272 virtual sal_Int32 SAL_CALL
getLong() override
273 { return _aData
.Long
; }
274 virtual sal_uInt32 SAL_CALL
getULong() override
275 { return _aData
.ULong
; }
276 virtual sal_Int64 SAL_CALL
getHyper() override
277 { return _aData
.Hyper
; }
278 virtual sal_uInt64 SAL_CALL
getUHyper() override
279 { return _aData
.UHyper
; }
280 virtual float SAL_CALL
getFloat() override
281 { return _aData
.Float
; }
282 virtual double SAL_CALL
getDouble() override
283 { return _aData
.Double
; }
284 virtual TestEnum SAL_CALL
getEnum() override
285 { return _aData
.Enum
; }
286 virtual OUString SAL_CALL
getString() override
287 { return _aData
.String
; }
288 virtual sal_Int8 SAL_CALL
getByte2() override
289 { return _aData
.Byte2
; }
290 virtual sal_Int16 SAL_CALL
getShort2() override
291 { return _aData
.Short2
; }
292 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getInterface( ) override
293 { return _aData
.Interface
; }
294 virtual css::uno::Any SAL_CALL
getAny() override
295 { return _aData
.Any
; }
296 virtual css::uno::Sequence
< TestElement
> SAL_CALL
getSequence() override
297 { return _aData
.Sequence
; }
298 virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL
getStruct() override
299 { return _aStructData
; }
301 virtual void SAL_CALL
setBool( sal_Bool _bool
) override
302 { _aData
.Bool
= _bool
; }
303 virtual void SAL_CALL
setByte( sal_Int8 _byte
) override
304 { _aData
.Byte
= _byte
; }
305 virtual void SAL_CALL
setChar( sal_Unicode _char
) override
306 { _aData
.Char
= _char
; }
307 virtual void SAL_CALL
setShort( sal_Int16 _short
) override
308 { _aData
.Short
= _short
; }
309 virtual void SAL_CALL
setUShort( sal_uInt16 _ushort
) override
310 { _aData
.UShort
= _ushort
; }
311 virtual void SAL_CALL
setLong( sal_Int32 _long
) override
312 { _aData
.Long
= _long
; }
313 virtual void SAL_CALL
setULong( sal_uInt32 _ulong
) override
314 { _aData
.ULong
= _ulong
; }
315 virtual void SAL_CALL
setHyper( sal_Int64 _hyper
) override
316 { _aData
.Hyper
= _hyper
; }
317 virtual void SAL_CALL
setUHyper( sal_uInt64 _uhyper
) override
318 { _aData
.UHyper
= _uhyper
; }
319 virtual void SAL_CALL
setFloat( float _float
) override
320 { _aData
.Float
= _float
; }
321 virtual void SAL_CALL
setDouble( double _double
) override
322 { _aData
.Double
= _double
; }
323 virtual void SAL_CALL
setEnum( TestEnum _enum
) override
324 { _aData
.Enum
= _enum
; }
325 virtual void SAL_CALL
setString( const OUString
& _string
) override
326 { _aData
.String
= _string
; }
327 virtual void SAL_CALL
setByte2( sal_Int8 _byte
) override
328 { _aData
.Byte2
= _byte
; }
329 virtual void SAL_CALL
setShort2( sal_Int16 _short
) override
330 { _aData
.Short2
= _short
; }
331 virtual void SAL_CALL
setInterface( const css::uno::Reference
< css::uno::XInterface
>& _interface
) override
332 { _aData
.Interface
= _interface
; }
333 virtual void SAL_CALL
setAny( const css::uno::Any
& _any
) override
334 { _aData
.Any
= _any
; }
335 virtual void SAL_CALL
setSequence( const css::uno::Sequence
<TestElement
>& _sequence
) override
336 { _aData
.Sequence
= _sequence
; }
337 virtual void SAL_CALL
setStruct( const ::test::testtools::bridgetest::TestDataElements
& _struct
) override
338 { _aStructData
= _struct
; }
340 virtual sal_Int32 SAL_CALL
getRaiseAttr1() override
341 { throw RuntimeException(); }
343 virtual void SAL_CALL
setRaiseAttr1(sal_Int32
) override
344 { throw IllegalArgumentException(); }
346 virtual sal_Int32 SAL_CALL
getRaiseAttr2() override
347 { throw IllegalArgumentException(); }
349 virtual TestPolyStruct
< sal_Bool
> SAL_CALL
transportPolyBoolean(
350 TestPolyStruct
< sal_Bool
> const & arg
) override
353 virtual void SAL_CALL
transportPolyHyper(TestPolyStruct
< sal_Int64
> &) override
{}
355 virtual void SAL_CALL
transportPolySequence(
356 TestPolyStruct
< Sequence
< Any
> > const & arg1
,
357 TestPolyStruct
< Sequence
< Any
> > & arg2
) override
360 virtual TestPolyStruct
< sal_Int32
> SAL_CALL
getNullPolyLong() override
361 { return TestPolyStruct
< sal_Int32
>(0); /* work around MS compiler bug */ }
363 virtual TestPolyStruct
< OUString
> SAL_CALL
getNullPolyString() override
364 { return TestPolyStruct
< OUString
>(); }
366 virtual TestPolyStruct
< Type
> SAL_CALL
getNullPolyType() override
367 { return TestPolyStruct
< Type
>(); }
369 virtual TestPolyStruct
< Any
> SAL_CALL
getNullPolyAny() override
370 { return TestPolyStruct
< Any
>(); }
372 virtual TestPolyStruct
< Sequence
< sal_Bool
> > SAL_CALL
373 getNullPolySequence() override
374 { return TestPolyStruct
< Sequence
< sal_Bool
> >(); }
376 virtual TestPolyStruct
< TestEnum
> SAL_CALL
getNullPolyEnum() override
377 { return TestPolyStruct
< TestEnum
>(
378 test::testtools::bridgetest::TestEnum_TEST
);
379 /* work around MS compiler bug */ }
381 virtual TestPolyStruct
< TestBadEnum
> SAL_CALL
getNullPolyBadEnum() override
382 { return TestPolyStruct
< TestBadEnum
>(
383 test::testtools::bridgetest::TestBadEnum_M
);
384 /* explicitly instantiate with default enumerator */ }
386 virtual TestPolyStruct
< TestStruct
> SAL_CALL
getNullPolyStruct() override
387 { return TestPolyStruct
< TestStruct
>(); }
389 virtual TestPolyStruct
< Reference
< XBridgeTestBase
> > SAL_CALL
390 getNullPolyInterface() override
391 { return TestPolyStruct
< Reference
< XBridgeTestBase
> >(); }
393 virtual css::uno::Any SAL_CALL
transportAny(
394 const css::uno::Any
& value
) override
;
396 virtual void SAL_CALL
call( sal_Int32 nCallId
, sal_Int32 nWaitMUSEC
) override
;
397 virtual void SAL_CALL
callOneway( sal_Int32 nCallId
, sal_Int32 nWaitMUSEC
) override
;
398 virtual sal_Bool SAL_CALL
sequenceOfCallTestPassed( ) override
;
399 virtual void SAL_CALL
startRecursiveCall(
400 const css::uno::Reference
< XRecursiveCall
>& xCall
, sal_Int32 nToCall
) override
;
402 virtual Reference
< XMulti
> SAL_CALL
getMulti() override
;
404 virtual OUString SAL_CALL
testMulti(Reference
< XMulti
> const & multi
) override
;
406 public: // XBridgeTest
407 virtual ::test::testtools::bridgetest::TestDataElements SAL_CALL
raiseException( sal_Int16 nArgumentPos
, const OUString
& rMsg
, const Reference
< XInterface
> & xCOntext
) override
;
409 virtual void SAL_CALL
raiseRuntimeExceptionOneway(
410 const OUString
& Message
, const css::uno::Reference
< css::uno::XInterface
>& Context
) override
;
412 virtual sal_Int32 SAL_CALL
getRuntimeException() override
;
413 virtual void SAL_CALL
setRuntimeException( sal_Int32 _runtimeexception
) override
;
416 virtual Sequence
< sal_Bool
> SAL_CALL
setSequenceBool(
417 const Sequence
< sal_Bool
>& aSeq
) override
;
418 virtual Sequence
< sal_Unicode
> SAL_CALL
setSequenceChar(
419 const Sequence
< sal_Unicode
>& aSeq
) override
;
420 virtual Sequence
< sal_Int8
> SAL_CALL
setSequenceByte(
421 const Sequence
< sal_Int8
>& aSeq
) override
;
422 virtual Sequence
< sal_Int16
> SAL_CALL
setSequenceShort(
423 const Sequence
< sal_Int16
>& aSeq
) override
;
424 virtual Sequence
< sal_uInt16
> SAL_CALL
setSequenceUShort(
425 const Sequence
< sal_uInt16
>& aSeq
) override
;
426 virtual Sequence
< sal_Int32
> SAL_CALL
setSequenceLong(
427 const Sequence
< sal_Int32
>& aSeq
) override
;
428 virtual Sequence
< sal_uInt32
> SAL_CALL
setSequenceULong(
429 const Sequence
< sal_uInt32
>& aSeq
) override
;
430 virtual Sequence
< sal_Int64
> SAL_CALL
setSequenceHyper(
431 const Sequence
< sal_Int64
>& aSeq
) override
;
432 virtual Sequence
< sal_uInt64
> SAL_CALL
setSequenceUHyper(
433 const Sequence
< sal_uInt64
>& aSeq
) override
;
434 virtual Sequence
< float > SAL_CALL
setSequenceFloat(
435 const Sequence
< float >& aSeq
) override
;
436 virtual Sequence
< double > SAL_CALL
setSequenceDouble(
437 const Sequence
< double >& aSeq
) override
;
438 virtual Sequence
< TestEnum
> SAL_CALL
setSequenceEnum(
439 const Sequence
< TestEnum
>& aSeq
) override
;
440 virtual Sequence
< OUString
> SAL_CALL
setSequenceString(
441 const Sequence
< OUString
>& aString
) override
;
442 virtual Sequence
< Reference
< XInterface
> > SAL_CALL
setSequenceXInterface(
443 const Sequence
< Reference
< XInterface
> >& aSeq
) override
;
444 virtual Sequence
<Any
> SAL_CALL
setSequenceAny(
445 const Sequence
<Any
>& aSeq
) override
;
446 virtual Sequence
<TestElement
> SAL_CALL
setSequenceStruct(
447 const Sequence
< TestElement
>& aSeq
) override
;
448 virtual Sequence
< Sequence
< sal_Int32
> > SAL_CALL
setDim2(
449 const Sequence
<Sequence
< sal_Int32
> >& aSeq
) override
;
450 virtual Sequence
< Sequence
< Sequence
< sal_Int32
> > > SAL_CALL
setDim3(
451 const Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeq
) override
;
452 virtual void SAL_CALL
setSequencesInOut(Sequence
< sal_Bool
>& aSeqBoolean
,
453 Sequence
< sal_Unicode
>& aSeqChar
,
454 Sequence
< sal_Int8
>& aSeqByte
,
455 Sequence
< sal_Int16
>& aSeqShort
,
456 Sequence
< sal_uInt16
>& aSeqUShort
,
457 Sequence
< sal_Int32
>& aSeqLong
,
458 Sequence
< sal_uInt32
>& aSeqULong
,
459 Sequence
< sal_Int64
>& aSeqHyper
,
460 Sequence
< sal_uInt64
>& aSeqUHyper
,
461 Sequence
< float >& aSeqFloat
,
462 Sequence
< double >& aSeqDouble
,
463 Sequence
< TestEnum
>& aSeqTestEnum
,
464 Sequence
< OUString
>& aSeqString
,
465 Sequence
<Reference
<XInterface
> >& aSeqXInterface
,
466 Sequence
< Any
>& aSeqAny
,
467 Sequence
< Sequence
< sal_Int32
> >& aSeqDim2
,
468 Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeqDim3
) override
;
469 virtual void SAL_CALL
setSequencesOut( Sequence
< sal_Bool
>& aSeqBoolean
,
470 Sequence
< sal_Unicode
>& aSeqChar
,
471 Sequence
< sal_Int8
>& aSeqByte
,
472 Sequence
< sal_Int16
>& aSeqShort
,
473 Sequence
< sal_uInt16
>& aSeqUShort
,
474 Sequence
< sal_Int32
>& aSeqLong
,
475 Sequence
< sal_uInt32
>& aSeqULong
,
476 Sequence
< sal_Int64
>& aSeqHyper
,
477 Sequence
< sal_uInt64
>& aSeqUHyper
,
478 Sequence
< float >& aSeqFloat
,
479 Sequence
< double >& aSeqDouble
,
480 Sequence
< TestEnum
>& aSeqEnum
,
481 Sequence
< OUString
>& aSeqString
,
482 Sequence
< Reference
< XInterface
> >& aSeqXInterface
,
483 Sequence
< Any
>& aSeqAny
,
484 Sequence
< Sequence
< sal_Int32
> >& aSeqDim2
,
485 Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeqDim3
) override
;
486 virtual void SAL_CALL
testConstructorsService(
487 Reference
< XComponentContext
> const & context
) override
;
488 virtual Reference
< XCurrentContextChecker
> SAL_CALL
489 getCurrentContextChecker() override
;
492 virtual void SAL_CALL
callRecursivly( const css::uno::Reference
< XRecursiveCall
>& xCall
, sal_Int32 nToCall
) override
;
495 //Dummy class for XComponent implementation
496 class Dummy
: public osl::DebugBase
<Dummy
>,
497 public WeakComponentImplHelperBase
500 Dummy(): WeakComponentImplHelperBase(*Mutex::getGlobalMutex()){}
506 Any
Test_Impl::transportAny( const Any
& value
)
514 void wait(sal_Int32 microSeconds
) {
515 OSL_ASSERT(microSeconds
>= 0 && microSeconds
<= SAL_MAX_INT32
/ 1000);
516 std::this_thread::sleep_for(std::chrono::microseconds(microSeconds
));
521 void Test_Impl::call( sal_Int32 nCallId
, sal_Int32 nWaitMUSEC
)
526 m_bFirstCall
= false;
530 m_bSequenceOfCallTestPassed
= m_bSequenceOfCallTestPassed
&& (nCallId
> m_nLastCallId
);
532 m_nLastCallId
= nCallId
;
536 void Test_Impl::callOneway( sal_Int32 nCallId
, sal_Int32 nWaitMUSEC
)
539 m_bSequenceOfCallTestPassed
= m_bSequenceOfCallTestPassed
&& (nCallId
> m_nLastCallId
);
540 m_nLastCallId
= nCallId
;
544 sal_Bool
Test_Impl::sequenceOfCallTestPassed()
546 return m_bSequenceOfCallTestPassed
;
550 void SAL_CALL
Test_Impl::startRecursiveCall(
551 const css::uno::Reference
< XRecursiveCall
>& xCall
, sal_Int32 nToCall
)
553 MutexGuard
guard( m_mutex
);
557 xCall
->callRecursivly( this , nToCall
);
562 void SAL_CALL
Test_Impl::callRecursivly(
563 const css::uno::Reference
< XRecursiveCall
>& xCall
,
566 MutexGuard
guard( m_mutex
);
570 xCall
->callRecursivly( this , nToCall
);
574 Reference
< XMulti
> Test_Impl::getMulti() {
575 return new testtools::bridgetest::Multi
;
578 OUString
Test_Impl::testMulti(Reference
< XMulti
> const & multi
)
580 return testtools::bridgetest::testMulti(multi
);
584 void Test_Impl::setValues( sal_Bool bBool
,
596 const OUString
& rStr
,
599 const css::uno::Reference
< css::uno::XInterface
>& xTest
,
600 const css::uno::Any
& rAny
,
601 const css::uno::Sequence
<TestElement
>& rSequence
,
602 const ::test::testtools::bridgetest::TestDataElements
& rStruct
)
605 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
606 eEnum
, rStr
, nByte2
, nShort2
, xTest
, rAny
, rSequence
);
607 _aStructData
= rStruct
;
610 ::test::testtools::bridgetest::TestDataElements
Test_Impl::setValues2( sal_Bool
& bBool
,
625 css::uno::Reference
< css::uno::XInterface
>& xTest
,
627 css::uno::Sequence
<TestElement
>& rSequence
,
628 ::test::testtools::bridgetest::TestDataElements
& rStruct
)
631 bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
, nUHyper
, fFloat
, fDouble
,
632 eEnum
, rStr
, nByte2
, nShort2
, xTest
, rAny
, rSequence
);
633 _aStructData
= rStruct
;
635 auto pSequence
= rSequence
.getArray();
636 std::swap(pSequence
[ 0 ], pSequence
[ 1 ]);
641 ::test::testtools::bridgetest::TestDataElements
Test_Impl::getValues( sal_Bool
& bBool
,
656 css::uno::Reference
< css::uno::XInterface
>& xTest
,
658 css::uno::Sequence
<TestElement
>& rSequence
,
659 ::test::testtools::bridgetest::TestDataElements
& rStruct
)
664 nShort
= _aData
.Short
;
665 nUShort
= _aData
.UShort
;
667 nULong
= _aData
.ULong
;
668 nHyper
= _aData
.Hyper
;
669 nUHyper
= _aData
.UHyper
;
670 fFloat
= _aData
.Float
;
671 fDouble
= _aData
.Double
;
673 rStr
= _aData
.String
;
674 nByte2
= _aData
.Byte2
;
675 nShort2
= _aData
.Short2
;
676 xTest
= _aData
.Interface
;
678 rSequence
= _aData
.Sequence
;
679 rStruct
= _aStructData
;
683 ::test::testtools::bridgetest::TestDataElements
Test_Impl::raiseException( sal_Int16 nArgumentPos
, const OUString
& rMsg
, const Reference
< XInterface
> & xContext
)
685 _aData
.String
= rMsg
;
686 _aData
.Interface
= xContext
;
687 throw IllegalArgumentException(rMsg
, xContext
, nArgumentPos
);
690 void Test_Impl::raiseRuntimeExceptionOneway( const OUString
& rMsg
, const Reference
< XInterface
> & xContext
)
692 _aData
.String
= rMsg
;
693 _aData
.Interface
= xContext
;
694 throw RuntimeException(rMsg
, xContext
);
697 static void dothrow2(const RuntimeException
& e
)
701 static void dothrow(const RuntimeException
& e
)
704 // currently only for MSVC:
705 // just to test whether all bridges fall back to a RuntimeException
706 // in case of a thrown non-UNO exception:
709 throw ::std::bad_alloc();
715 Any
a( getCaughtException() );
716 RuntimeException exc
;
717 OSL_VERIFY( a
>>= exc
);
719 catch (...) // never throws anything
721 fprintf( stderr
, "\ngetCaughtException() failed!\n" );
729 sal_Int32
Test_Impl::getRuntimeException()
733 dothrow( RuntimeException( _aData
.String
, _aData
.Interface
) );
737 Any
a( getCaughtException() );
740 return 0; // for dummy
743 void Test_Impl::setRuntimeException( sal_Int32
)
745 RuntimeException
aExc(_aData
.String
, _aData
.Interface
);
746 throwException( Any( aExc
) );
749 // XBridgeTest2 -------------------------------------------------------------
750 Sequence
< sal_Bool
> SAL_CALL
Test_Impl::setSequenceBool(
751 const Sequence
< sal_Bool
>& aSeq
)
757 Sequence
< sal_Unicode
> SAL_CALL
Test_Impl::setSequenceChar(
758 const Sequence
< sal_Unicode
>& aSeq
)
764 Sequence
< sal_Int8
> SAL_CALL
Test_Impl::setSequenceByte(
765 const Sequence
< sal_Int8
>& aSeq
)
771 Sequence
< sal_Int16
> SAL_CALL
Test_Impl::setSequenceShort(
772 const Sequence
< sal_Int16
>& aSeq
)
778 Sequence
< sal_uInt16
> SAL_CALL
Test_Impl::setSequenceUShort(
779 const Sequence
< sal_uInt16
>& aSeq
)
785 Sequence
< sal_Int32
> SAL_CALL
Test_Impl::setSequenceLong(
786 const Sequence
< sal_Int32
>& aSeq
)
792 Sequence
< sal_uInt32
> SAL_CALL
Test_Impl::setSequenceULong(
793 const Sequence
< sal_uInt32
>& aSeq
)
799 Sequence
< sal_Int64
> SAL_CALL
Test_Impl::setSequenceHyper(
800 const Sequence
< sal_Int64
>& aSeq
)
806 Sequence
< sal_uInt64
> SAL_CALL
Test_Impl::setSequenceUHyper(
807 const Sequence
< sal_uInt64
>& aSeq
)
813 Sequence
< float > SAL_CALL
Test_Impl::setSequenceFloat(
814 const Sequence
< float >& aSeq
)
820 Sequence
< double > SAL_CALL
Test_Impl::setSequenceDouble(
821 const Sequence
< double >& aSeq
)
827 Sequence
< TestEnum
> SAL_CALL
Test_Impl::setSequenceEnum(
828 const Sequence
< TestEnum
>& aSeq
)
834 Sequence
< OUString
> SAL_CALL
Test_Impl::setSequenceString(
835 const Sequence
< OUString
>& aSeq
)
841 Sequence
< Reference
< XInterface
> > SAL_CALL
Test_Impl::setSequenceXInterface(
842 const Sequence
< Reference
< XInterface
> >& aSeq
)
848 Sequence
<Any
> SAL_CALL
Test_Impl::setSequenceAny(
849 const Sequence
<Any
>& aSeq
)
855 Sequence
<TestElement
> SAL_CALL
Test_Impl::setSequenceStruct(
856 const Sequence
< TestElement
>& aSeq
)
862 Sequence
< Sequence
< sal_Int32
> > SAL_CALL
Test_Impl::setDim2(
863 const Sequence
<Sequence
< sal_Int32
> >& aSeq
)
869 Sequence
< Sequence
< Sequence
< sal_Int32
> > > SAL_CALL
Test_Impl::setDim3(
870 const Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeq
)
876 void SAL_CALL
Test_Impl::setSequencesInOut(Sequence
< sal_Bool
>& aSeqBoolean
,
877 Sequence
< sal_Unicode
>& aSeqChar
,
878 Sequence
< sal_Int8
>& aSeqByte
,
879 Sequence
< sal_Int16
>& aSeqShort
,
880 Sequence
< sal_uInt16
>& aSeqUShort
,
881 Sequence
< sal_Int32
>& aSeqLong
,
882 Sequence
< sal_uInt32
>& aSeqULong
,
883 Sequence
< sal_Int64
>& aSeqHyper
,
884 Sequence
< sal_uInt64
>& aSeqUHyper
,
885 Sequence
< float >& aSeqFloat
,
886 Sequence
< double >& aSeqDouble
,
887 Sequence
< TestEnum
>& aSeqTestEnum
,
888 Sequence
< OUString
>& aSeqString
,
889 Sequence
<Reference
<XInterface
> >& aSeqXInterface
,
890 Sequence
< Any
>& aSeqAny
,
891 Sequence
< Sequence
< sal_Int32
> >& aSeqDim2
,
892 Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeqDim3
)
894 _arBool
= aSeqBoolean
;
897 _arShort
= aSeqShort
;
898 _arUShort
= aSeqUShort
;
900 _arULong
= aSeqULong
;
901 _arHyper
= aSeqHyper
;
902 _arUHyper
= aSeqUHyper
;
903 _arFloat
= aSeqFloat
;
904 _arDouble
= aSeqDouble
;
905 _arEnum
= aSeqTestEnum
;
906 _arString
= aSeqString
;
907 _arObject
= aSeqXInterface
;
913 void SAL_CALL
Test_Impl::setSequencesOut( Sequence
< sal_Bool
>& aSeqBoolean
,
914 Sequence
< sal_Unicode
>& aSeqChar
,
915 Sequence
< sal_Int8
>& aSeqByte
,
916 Sequence
< sal_Int16
>& aSeqShort
,
917 Sequence
< sal_uInt16
>& aSeqUShort
,
918 Sequence
< sal_Int32
>& aSeqLong
,
919 Sequence
< sal_uInt32
>& aSeqULong
,
920 Sequence
< sal_Int64
>& aSeqHyper
,
921 Sequence
< sal_uInt64
>& aSeqUHyper
,
922 Sequence
< float >& aSeqFloat
,
923 Sequence
< double >& aSeqDouble
,
924 Sequence
< TestEnum
>& aSeqEnum
,
925 Sequence
< OUString
>& aSeqString
,
926 Sequence
< Reference
< XInterface
> >& aSeqXInterface
,
927 Sequence
< Any
>& aSeqAny
,
928 Sequence
< Sequence
< sal_Int32
> >& aSeqDim2
,
929 Sequence
< Sequence
< Sequence
< sal_Int32
> > >& aSeqDim3
)
931 aSeqBoolean
= _arBool
;
934 aSeqShort
= _arShort
;
935 aSeqUShort
= _arUShort
;
937 aSeqULong
= _arULong
;
938 aSeqHyper
= _arHyper
;
939 aSeqUHyper
= _arUHyper
;
940 aSeqFloat
= _arFloat
;
941 aSeqDouble
= _arDouble
;
943 aSeqString
= _arString
;
944 aSeqXInterface
= _arObject
;
950 void Test_Impl::testConstructorsService(
951 Reference
< XComponentContext
> const & context
)
953 Sequence
< sal_Bool
> arg14
{ true };
954 Sequence
< sal_Int8
> arg15
{ SAL_MIN_INT8
};
955 Sequence
< sal_Int16
> arg16
{ SAL_MIN_INT16
};
956 Sequence
< sal_uInt16
> arg17
{ SAL_MAX_UINT16
};
957 Sequence
< sal_Int32
> arg18
{ SAL_MIN_INT32
};
958 Sequence
< sal_uInt32
> arg19
{ SAL_MAX_UINT32
};
959 Sequence
< sal_Int64
> arg20
{ SAL_MIN_INT64
};
960 Sequence
< sal_uInt64
> arg21
{ SAL_MAX_UINT64
};
961 Sequence
< float > arg22
{ 0.123f
};
962 Sequence
< double > arg23
{ 0.456 };
963 Sequence
< sal_Unicode
> arg24
{ 'X' };
964 Sequence
< OUString
> arg25
{ u
"test"_ustr
};
965 Sequence
< Type
> arg26
{ UnoType
< Any
>::get() };
966 Sequence
< Any
> arg27
{ Any(true) };
967 Sequence
< Sequence
< sal_Bool
> > arg28
{ { true } };
968 Sequence
< Sequence
< Any
> > arg29
{ { Any(true) } };
969 Sequence
< TestEnum
> arg30
{ TestEnum_TWO
};
970 Sequence
< TestStruct
> arg31(1); arg31
.getArray()[0].member
= 10;
971 Sequence
< TestPolyStruct
< sal_Bool
> > arg32
{ { true } };
972 Sequence
< TestPolyStruct
< Any
> > arg33(1); arg33
.getArray()[0].member
<<= true;
973 Sequence
< Reference
< XInterface
> > arg34(1);
974 Constructors::create1(context
,
987 UnoType
< Any
>::get(),
1012 TestPolyStruct
< sal_Bool
>(true),
1013 TestPolyStruct
< Any
>(Any(true)),
1014 Reference
< XInterface
>(nullptr));
1015 Sequence
< Any
> args
{
1019 Any(SAL_MAX_UINT16
),
1021 Any(SAL_MAX_UINT32
),
1023 Any(SAL_MAX_UINT64
),
1028 Any(UnoType
< Any
>::get()),
1052 Any(TestStruct(10)),
1053 Any(TestPolyStruct
< sal_Bool
>(true)),
1054 Any(TestPolyStruct
< Any
>(Any(true))),
1055 Any(Reference
< XInterface
>(nullptr))
1057 assert(args
.getLength() == 40);
1058 Constructors::create2(context
, args
);
1060 Sequence
<Type
> argSeq1
{ cppu::UnoType
<sal_Int32
>::get() };
1061 Sequence
<Reference
<XInterface
> > argSeq2
{ static_cast<XComponent
*>(new Dummy()) };
1062 Sequence
<Reference
<XComponent
> > argSeq2a
{ static_cast<XComponent
*>(new Dummy()) };
1064 Sequence
<TestPolyStruct2
<sal_Unicode
, Sequence
<Any
> > > argSeq3
1065 { TestPolyStruct2
<sal_Unicode
, Sequence
<Any
> >('X', arg27
) };
1066 Sequence
<TestPolyStruct2
<TestPolyStruct
<sal_Unicode
>, Sequence
<Any
> > > argSeq4
1067 { TestPolyStruct2
<TestPolyStruct
<sal_Unicode
>, Sequence
<Any
> >(
1068 TestPolyStruct
<sal_Unicode
>('X'), arg27
) };
1069 Sequence
<Sequence
<sal_Int32
> > argSeq5
{ { SAL_MIN_INT32
} };
1070 Sequence
<TestPolyStruct
<sal_Int32
> > argSeq6
{ TestPolyStruct
<sal_Int32
>(SAL_MIN_INT32
) };
1071 Sequence
<TestPolyStruct
<TestPolyStruct2
<sal_Unicode
, Any
> > > argSeq7
1072 { TestPolyStruct
<TestPolyStruct2
<sal_Unicode
, Any
> >(
1073 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true))) };
1074 Sequence
<TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
> > > argSeq8
1075 { TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
> > (
1076 TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
>(
1077 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true)), u
"test"_ustr
)) };
1078 Sequence
<TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> > > > argSeq9
1079 { TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> > >(
1080 u
"test"_ustr
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> >(
1081 'X', TestPolyStruct
<Any
>(Any(true)))) };
1082 Sequence
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>, TestPolyStruct
<sal_Unicode
> > > argSeq10
1083 { TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>, TestPolyStruct
<sal_Unicode
> >(
1084 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true)), TestPolyStruct
<sal_Unicode
>('X')) };
1085 Sequence
<Sequence
<TestPolyStruct
<sal_Unicode
> > > argSeq11
1086 { { TestPolyStruct
<sal_Unicode
>('X') } };
1087 Sequence
<Sequence
<TestPolyStruct
<TestPolyStruct2
<sal_Unicode
,Any
> > > > argSeq12
1088 { { TestPolyStruct
<TestPolyStruct2
<sal_Unicode
,Any
> >(
1089 TestPolyStruct2
<sal_Unicode
,Any
>('X', Any(true))) } };
1090 Sequence
<Sequence
<TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>,OUString
> > > > argSeq13
1091 { {TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>,OUString
> >(
1092 TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>,OUString
>(
1093 TestPolyStruct2
<sal_Unicode
,Any
>('X', Any(true)), u
"test"_ustr
))} };
1094 Sequence
<Sequence
<TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> > > > > argSeq14
1095 { { TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> > >(
1096 u
"test"_ustr
, TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> >(
1097 'X', TestPolyStruct
<Any
>(Any(true)))) } };
1098 Sequence
<Sequence
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>, TestPolyStruct
<sal_Unicode
> > > > argSeq15
1099 { { TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
,Any
>, TestPolyStruct
<sal_Unicode
> >(
1100 TestPolyStruct2
<sal_Unicode
,Any
>('X',Any(true)), TestPolyStruct
<sal_Unicode
>('X')) } };
1102 Constructors2::create1(
1104 TestPolyStruct
<Type
>(cppu::UnoType
<sal_Int32
>::get()),
1105 TestPolyStruct
<Any
>(Any(true)),
1106 TestPolyStruct
<sal_Bool
>(true),
1107 TestPolyStruct
<sal_Int8
>(SAL_MIN_INT8
),
1108 TestPolyStruct
<sal_Int16
>(SAL_MIN_INT16
),
1109 TestPolyStruct
<sal_Int32
>(SAL_MIN_INT32
),
1110 TestPolyStruct
<sal_Int64
>(SAL_MIN_INT64
),
1111 TestPolyStruct
<sal_Unicode
>('X'),
1112 TestPolyStruct
<OUString
>(u
"test"_ustr
),
1113 TestPolyStruct
<float>(0.123f
),
1114 TestPolyStruct
<double>(0.456),
1115 TestPolyStruct
<Reference
<XInterface
> >(static_cast<XBridgeTest2
*>(this)),
1116 TestPolyStruct
<Reference
<XComponent
> >(static_cast<XComponent
*>(new Dummy())),
1117 TestPolyStruct
<TestEnum
>(TestEnum_TWO
),
1118 TestPolyStruct
<TestPolyStruct2
<sal_Unicode
, Any
> >(
1119 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true))),
1120 TestPolyStruct
<TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
> > (
1121 TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>,OUString
>(
1122 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true)), u
"test"_ustr
)),
1123 TestPolyStruct2
<OUString
, TestPolyStruct2
<sal_Unicode
,TestPolyStruct
<Any
> > >(
1125 TestPolyStruct2
<sal_Unicode
, TestPolyStruct
<Any
> >('X', TestPolyStruct
<Any
>(Any(true)))),
1126 TestPolyStruct2
<TestPolyStruct2
<sal_Unicode
, Any
>, TestPolyStruct
<sal_Unicode
> >(
1127 TestPolyStruct2
<sal_Unicode
, Any
>('X', Any(true)),
1128 TestPolyStruct
<sal_Unicode
>('X')),
1129 TestPolyStruct
<Sequence
<Type
> >(argSeq1
),
1130 TestPolyStruct
<Sequence
<Any
> >(arg27
),
1131 TestPolyStruct
<Sequence
<sal_Bool
> >(arg14
),
1132 TestPolyStruct
<Sequence
<sal_Int8
> >(arg15
),
1133 TestPolyStruct
<Sequence
<sal_Int16
> >(arg16
),
1134 TestPolyStruct
<Sequence
<sal_Int32
> >(arg18
),
1135 TestPolyStruct
<Sequence
<sal_Int64
> >(arg20
),
1136 TestPolyStruct
<Sequence
<sal_Unicode
> >(arg24
),
1137 TestPolyStruct
<Sequence
<OUString
> >(arg25
),
1138 TestPolyStruct
<Sequence
<float> >(arg22
),
1139 TestPolyStruct
<Sequence
<double> >(arg23
),
1140 TestPolyStruct
<Sequence
<Reference
<XInterface
> > >(argSeq2
),
1141 TestPolyStruct
<Sequence
<Reference
<XComponent
> > >(argSeq2a
),
1142 TestPolyStruct
<Sequence
<TestEnum
> >(arg30
),
1143 TestPolyStruct
<Sequence
<TestPolyStruct2
<sal_Unicode
, Sequence
<Any
> > > >(argSeq3
),
1144 TestPolyStruct
<Sequence
<TestPolyStruct2
<TestPolyStruct
<sal_Unicode
>, Sequence
<Any
> > > > (argSeq4
),
1145 TestPolyStruct
<Sequence
<Sequence
<sal_Int32
> > >(argSeq5
),
1158 Reference
< XCurrentContextChecker
> Test_Impl::getCurrentContextChecker()
1160 return new testtools::bridgetest::CurrentContextChecker
;
1165 OUString
Test_Impl::getImplementationName()
1170 sal_Bool
Test_Impl::supportsService( const OUString
& rServiceName
)
1172 return cppu::supportsService(this, rServiceName
);
1175 Sequence
< OUString
> Test_Impl::getSupportedServiceNames()
1177 return bridge_object::getSupportedServiceNames();
1181 static Reference
< XInterface
> Test_Impl_create(
1182 SAL_UNUSED_PARAMETER
const Reference
< XMultiServiceFactory
> & )
1184 return Reference
< XInterface
>( static_cast<XBridgeTest
*>(new Test_Impl()) );
1191 SAL_DLLPUBLIC_EXPORT
void * component_getFactory(
1192 const char * pImplName
, SAL_UNUSED_PARAMETER
void * pServiceManager
,
1193 SAL_UNUSED_PARAMETER
void * )
1195 void * pRet
= nullptr;
1197 if (pServiceManager
&& o3tl::equalsAscii(IMPLNAME
, pImplName
))
1199 Reference
< XSingleServiceFactory
> xFactory( createSingleFactory(
1200 static_cast< XMultiServiceFactory
* >( pServiceManager
),
1202 bridge_object::Test_Impl_create
,
1203 bridge_object::getSupportedServiceNames() ) );
1207 xFactory
->acquire();
1208 pRet
= xFactory
.get();
1216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */