calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / testtools / source / bridgetest / constructors.cxx
blob04b953fff0e2c656cfc8ae1eed7455831d5c14e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <sal/config.h>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/lang/XComponent.hpp>
25 #include <com/sun/star/uno/Any.hxx>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include <com/sun/star/uno/Type.hxx>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/uno/XInterface.hpp>
31 #include <cppu/unotype.hxx>
32 #include <cppuhelper/factory.hxx>
33 #include <cppuhelper/implbase.hxx>
34 #include <cppuhelper/implementationentry.hxx>
35 #include <cppuhelper/weak.hxx>
36 #include <rtl/ustring.hxx>
37 #include <sal/types.h>
38 #include <test/testtools/bridgetest/BadConstructorArguments.hpp>
39 #include <test/testtools/bridgetest/TestEnum.hpp>
40 #include <test/testtools/bridgetest/TestStruct.hpp>
41 #include <test/testtools/bridgetest/TestPolyStruct.hpp>
42 #include <test/testtools/bridgetest/TestPolyStruct2.hpp>
43 #include <test/testtools/bridgetest/XMultiBase1.hpp>
45 namespace {
47 namespace ttb = ::test::testtools::bridgetest;
48 class Impl:
49 public cppu::WeakImplHelper<css::lang::XInitialization>
51 public:
52 Impl() {}
53 Impl(const Impl&) = delete;
54 Impl& operator=(const Impl&) = delete;
56 private:
57 virtual ~Impl() override {}
59 virtual void SAL_CALL initialize(
60 css::uno::Sequence< css::uno::Any > const & arguments) override;
63 void Impl::initialize(css::uno::Sequence< css::uno::Any > const & arguments)
65 bool arg0;
66 ::sal_Int8 arg1 = sal_Int8();
67 ::sal_Int16 arg2 = sal_Int16();
68 ::sal_uInt16 arg3 = sal_uInt16();
69 ::sal_Int32 arg4 = sal_Int32();
70 ::sal_uInt32 arg5 = sal_uInt32();
71 ::sal_Int64 arg6 = sal_Int64();
72 ::sal_uInt64 arg7 = sal_uInt64();
73 float arg8 = float();
74 double arg9 = double();
75 sal_Unicode arg10 = sal_Unicode();
76 OUString arg11;
77 css::uno::Type arg12;
78 bool arg13;
79 css::uno::Sequence< sal_Bool > arg14;
80 css::uno::Sequence< ::sal_Int8 > arg15;
81 css::uno::Sequence< ::sal_Int16 > arg16;
82 css::uno::Sequence< ::sal_uInt16 > arg17;
83 css::uno::Sequence< ::sal_Int32 > arg18;
84 css::uno::Sequence< ::sal_uInt32 > arg19;
85 css::uno::Sequence< ::sal_Int64 > arg20;
86 css::uno::Sequence< ::sal_uInt64 > arg21;
87 css::uno::Sequence< float > arg22;
88 css::uno::Sequence< double > arg23;
89 css::uno::Sequence< sal_Unicode > arg24;
90 css::uno::Sequence< OUString > arg25;
91 css::uno::Sequence< css::uno::Type > arg26;
92 css::uno::Sequence< css::uno::Any > arg27;
93 bool arg27b;
94 css::uno::Sequence< css::uno::Sequence< sal_Bool > > arg28;
95 css::uno::Sequence< css::uno::Sequence< css::uno::Any > > arg29;
96 bool arg29b;
97 css::uno::Sequence< ::test::testtools::bridgetest::TestEnum > arg30;
98 css::uno::Sequence< ::test::testtools::bridgetest::TestStruct > arg31;
99 css::uno::Sequence<
100 ::test::testtools::bridgetest::TestPolyStruct< sal_Bool > > arg32;
101 css::uno::Sequence<
102 ::test::testtools::bridgetest::TestPolyStruct< css::uno::Any > > arg33;
103 bool arg33b;
104 css::uno::Sequence< css::uno::Reference< css::uno::XInterface > > arg34;
105 ::test::testtools::bridgetest::TestEnum arg35;
106 ::test::testtools::bridgetest::TestStruct arg36;
107 ::test::testtools::bridgetest::TestPolyStruct< sal_Bool > arg37;
108 ::test::testtools::bridgetest::TestPolyStruct< css::uno::Any > arg38;
109 bool arg38b;
110 css::uno::Reference< css::uno::XInterface > arg39;
111 bool ok = (arguments.getLength() == 40
112 && (arguments[0] >>= arg0) && arg0
113 && (arguments[1] >>= arg1) && arg1 == SAL_MIN_INT8
114 && (arguments[2] >>= arg2) && arg2 == SAL_MIN_INT16
115 && (arguments[3] >>= arg3) && arg3 == SAL_MAX_UINT16
116 && (arguments[4] >>= arg4) && arg4 == SAL_MIN_INT32
117 && (arguments[5] >>= arg5) && arg5 == SAL_MAX_UINT32
118 && (arguments[6] >>= arg6) && arg6 == SAL_MIN_INT64
119 && (arguments[7] >>= arg7) && arg7 == SAL_MAX_UINT64
120 && (arguments[8] >>= arg8) && arg8 == 0.123f
121 && (arguments[9] >>= arg9) && arg9 == 0.456
122 && (arguments[10] >>= arg10) && arg10 == 'X'
123 && (arguments[11] >>= arg11)
124 && arg11 == "test"
125 && (arguments[12] >>= arg12)
126 && arg12 == ::cppu::UnoType< css::uno::Any >::get()
127 && (arguments[13] >>= arg13) && arg13
128 && (arguments[14] >>= arg14) && arg14.getLength() == 1 && arg14[0]
129 && (arguments[15] >>= arg15) && arg15.getLength() == 1
130 && arg15[0] == SAL_MIN_INT8
131 && (arguments[16] >>= arg16) && arg16.getLength() == 1
132 && arg16[0] == SAL_MIN_INT16
133 && (arguments[17] >>= arg17) && arg17.getLength() == 1
134 && arg17[0] == SAL_MAX_UINT16
135 && (arguments[18] >>= arg18) && arg18.getLength() == 1
136 && arg18[0] == SAL_MIN_INT32
137 && (arguments[19] >>= arg19) && arg19.getLength() == 1
138 && arg19[0] == SAL_MAX_UINT32
139 && (arguments[20] >>= arg20) && arg20.getLength() == 1
140 && arg20[0] == SAL_MIN_INT64
141 && (arguments[21] >>= arg21) && arg21.getLength() == 1
142 && arg21[0] == SAL_MAX_UINT64
143 && (arguments[22] >>= arg22) && arg22.getLength() == 1
144 && arg22[0] == 0.123f
145 && (arguments[23] >>= arg23) && arg23.getLength() == 1
146 && arg23[0] == 0.456
147 && (arguments[24] >>= arg24) && arg24.getLength() == 1
148 && arg24[0] == 'X'
149 && (arguments[25] >>= arg25) && arg25.getLength() == 1
150 && arg25[0] == "test"
151 && (arguments[26] >>= arg26) && arg26.getLength() == 1
152 && arg26[0] == ::cppu::UnoType< css::uno::Any >::get()
153 && (arguments[27] >>= arg27) && arg27.getLength() == 1
154 && (arg27[0] >>= arg27b) && arg27b
155 && (arguments[28] >>= arg28) && arg28.getLength() == 1
156 && arg28[0].getLength() == 1 && arg28[0][0]
157 && (arguments[29] >>= arg29) && arg29.getLength() == 1
158 && arg29[0].getLength() == 1 && (arg29[0][0] >>= arg29b) && arg29b
159 && (arguments[30] >>= arg30) && arg30.getLength() == 1
160 && arg30[0] == ::test::testtools::bridgetest::TestEnum_TWO
161 && (arguments[31] >>= arg31) && arg31.getLength() == 1
162 && arg31[0].member == 10
163 && (arguments[32] >>= arg32) && arg32.getLength() == 1
164 && arg32[0].member
165 && (arguments[33] >>= arg33) && arg33.getLength() == 1
166 && (arg33[0].member >>= arg33b) && arg33b
167 && (arguments[34] >>= arg34) && arg34.getLength() == 1
168 && !arg34[0].is()
169 && (arguments[35] >>= arg35)
170 && arg35 == ::test::testtools::bridgetest::TestEnum_TWO
171 && (arguments[36] >>= arg36) && arg36.member == 10
172 && (arguments[37] >>= arg37) && arg37.member
173 && (arguments[38] >>= arg38) && (arg38.member >>= arg38b) && arg38b
174 && (arguments[39] >>= arg39) && !arg39.is());
175 if (!ok)
177 throw ::test::testtools::bridgetest::BadConstructorArguments();
182 class Impl2: public ::cppu::WeakImplHelper<
183 css::lang::XInitialization, ttb::XMultiBase1 >
185 public:
186 Impl2(): m_attr1(0.0) {}
188 private:
189 virtual ~Impl2() override {}
191 virtual void SAL_CALL initialize(
192 css::uno::Sequence< css::uno::Any > const & arguments) override;
194 //XMultiBase1
195 virtual double SAL_CALL getatt1() override;
196 virtual void SAL_CALL setatt1( double _att1 ) override;
197 virtual ::sal_Int32 SAL_CALL fn11( ::sal_Int32 arg ) override;
198 virtual OUString SAL_CALL fn12( const OUString& arg ) override;
201 double m_attr1;
204 void Impl2::initialize(css::uno::Sequence< css::uno::Any > const & arguments)
206 ttb::TestPolyStruct< css::uno::Type > arg0;
207 ttb::TestPolyStruct< css::uno::Any > arg1;
208 css::uno::Any arg1b(true);
209 ttb::TestPolyStruct< sal_Bool > arg2;
210 ttb::TestPolyStruct< ::sal_Int8 > arg3;
211 ttb::TestPolyStruct< ::sal_Int16 > arg4;
212 ttb::TestPolyStruct< ::sal_Int32 > arg5;
213 ttb::TestPolyStruct< ::sal_Int64 > arg6;
214 ttb::TestPolyStruct< ::sal_Unicode > arg7;
215 ttb::TestPolyStruct< OUString > arg8;
216 ttb::TestPolyStruct< float > arg9;
217 ttb::TestPolyStruct< double > arg10;
218 ttb::TestPolyStruct<css::uno::Reference<css::uno::XInterface> > arg11;
219 ttb::TestPolyStruct<css::uno::Reference< css::lang::XComponent> > arg12;
220 ttb::TestPolyStruct<ttb::TestEnum> arg13;
221 ttb::TestPolyStruct<
222 ttb::TestPolyStruct2<sal_Unicode, css::uno::Any> > arg14;
223 ttb::TestPolyStruct< ttb::TestPolyStruct2 <
224 ttb::TestPolyStruct2< sal_Unicode, css::uno::Any >,
225 OUString > > arg15;
226 ttb::TestPolyStruct2< OUString,ttb::TestPolyStruct2 <
227 ::sal_Unicode, ttb::TestPolyStruct < css::uno::Any > > > arg16;
228 ttb::TestPolyStruct2< ttb::TestPolyStruct2<sal_Unicode, css::uno::Any >,
229 ttb::TestPolyStruct<sal_Unicode> > arg17;
230 ttb::TestPolyStruct<css::uno::Sequence< css::uno::Type > > arg18;
231 ttb::TestPolyStruct<css::uno::Sequence<css::uno::Any> > arg19;
232 ttb::TestPolyStruct<css::uno::Sequence< sal_Bool > > arg20;
233 ttb::TestPolyStruct<css::uno::Sequence< ::sal_Int8 > > arg21;
234 ttb::TestPolyStruct<css::uno::Sequence< ::sal_Int16 > > arg22;
235 ttb::TestPolyStruct<css::uno::Sequence< ::sal_Int32 > > arg23;
236 ttb::TestPolyStruct<css::uno::Sequence< ::sal_Int64 > > arg24;
237 ttb::TestPolyStruct<css::uno::Sequence< sal_Unicode> > arg25;
238 ttb::TestPolyStruct<css::uno::Sequence< OUString > > arg26;
239 ttb::TestPolyStruct<css::uno::Sequence<float> > arg27;
240 ttb::TestPolyStruct<css::uno::Sequence<double> > arg28;
241 ttb::TestPolyStruct<css::uno::Sequence<css::uno::Reference<css::uno::XInterface> > > arg29;
242 ttb::TestPolyStruct<css::uno::Sequence<css::uno::Reference<css::lang::XComponent> > > arg30;
243 ttb::TestPolyStruct<css::uno::Sequence<ttb::TestEnum> > arg31;
244 ttb::TestPolyStruct<css::uno::Sequence<ttb::TestPolyStruct2<
245 ::sal_Unicode, css::uno::Sequence<css::uno::Any> > > > arg32;
246 bool arg32a = false;
247 ttb::TestPolyStruct<css::uno::Sequence<ttb::TestPolyStruct2<
248 ttb::TestPolyStruct< ::sal_Unicode>, css::uno::Sequence<css::uno::Any> > > > arg33;
249 ttb::TestPolyStruct<css::uno::Sequence<css::uno::Sequence< ::sal_Int32> > > arg34;
250 css::uno::Sequence<ttb::TestPolyStruct< ::sal_Int32> > arg35;
251 css::uno::Sequence<ttb::TestPolyStruct<ttb::TestPolyStruct2< ::sal_Unicode, css::uno::Any> > > arg36;
252 css::uno::Sequence<ttb::TestPolyStruct<ttb::TestPolyStruct2<
253 ttb::TestPolyStruct2< ::sal_Unicode,css::uno::Any >, OUString> > > arg37;
254 css::uno::Sequence<ttb::TestPolyStruct2< OUString, ttb::TestPolyStruct2<
255 ::sal_Unicode, ttb::TestPolyStruct<css::uno::Any> > > > arg38;
256 css::uno::Sequence<ttb::TestPolyStruct2<ttb::TestPolyStruct2<
257 ::sal_Unicode, css::uno::Any>, ttb::TestPolyStruct< ::sal_Unicode> > > arg39;
258 css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct< ::sal_Unicode> > > arg40;
259 css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct<ttb::TestPolyStruct2< ::sal_Unicode, css::uno::Any> > > >arg41;
260 css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct<
261 ttb::TestPolyStruct2<ttb::TestPolyStruct2<sal_Unicode, css::uno::Any>, OUString> > > > arg42;
262 css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct2<
263 OUString, ttb::TestPolyStruct2< ::sal_Unicode, ttb::TestPolyStruct<css::uno::Any> > > > > arg43;
264 css::uno::Sequence<css::uno::Sequence<ttb::TestPolyStruct2<
265 ttb::TestPolyStruct2< ::sal_Unicode, css::uno::Any>, ttb::TestPolyStruct<
266 ::sal_Unicode> > > > arg44;
268 if (!(arguments.getLength() == 45
269 && (arguments[0] >>= arg0) && arg0.member == cppu::UnoType<sal_Int32>::get()
270 && (arguments[1] >>= arg1) && arg1.member == arg1b
271 && (arguments[2] >>= arg2) && arg2.member
272 && (arguments[3] >>= arg3) && arg3.member == SAL_MIN_INT8
273 && (arguments[4] >>= arg4) && arg4.member == SAL_MIN_INT16
274 && (arguments[5] >>= arg5) && arg5.member == SAL_MIN_INT32
275 && (arguments[6] >>= arg6) && arg6.member == SAL_MIN_INT64
276 && (arguments[7] >>= arg7) && arg7.member == 'X'
277 && (arguments[8] >>= arg8) && arg8.member == "test"
278 && (arguments[9] >>= arg9) && arg9.member == 0.123f
279 && (arguments[10] >>= arg10) && arg10.member == 0.456
280 && (arguments[11] >>= arg11)
281 && (arguments[12] >>= arg12)
282 && (arguments[13] >>= arg13) && arg13.member == ttb::TestEnum_TWO
283 && (arguments[14] >>= arg14) && arg14.member.member1 == 'X' && arg14.member.member2 == arg1b
284 && (arguments[15] >>= arg15) && arg15.member.member1.member1 == 'X'
285 && arg15.member.member1.member2 == arg1b
286 && arg15.member.member2 == "test"
287 && (arguments[16] >>= arg16) && arg16.member1 == "test"
288 && arg16.member2.member1 == 'X'
289 && arg16.member2.member2.member == arg1b
290 && (arguments[17] >>= arg17) && arg17.member1.member1 == 'X'
291 && arg17.member1.member2 == arg1b
292 && arg17.member2.member == 'X'
293 && (arguments[18] >>= arg18) && arg18.member.getLength() == 1
294 && arg18.member[0] == ::cppu::UnoType<sal_Int32>::get()
295 && (arguments[19] >>= arg19) && arg19.member.getLength() == 1
296 && arg19.member[0] == arg1b
297 && (arguments[20] >>= arg20) && arg20.member.getLength() == 1
298 && arg20.member[0]
299 && (arguments[21] >>= arg21) && arg21.member.getLength() == 1
300 && arg21.member[0] == SAL_MIN_INT8
301 && (arguments[22] >>= arg22) && arg22.member.getLength() == 1
302 && arg22.member[0] == SAL_MIN_INT16
303 && (arguments[23] >>= arg23) && arg23.member.getLength() == 1
304 && arg23.member[0] == SAL_MIN_INT32
305 && (arguments[24] >>= arg24) && arg24.member.getLength() == 1
306 && arg24.member[0] == SAL_MIN_INT64
307 && (arguments[25] >>= arg25) && arg25.member.getLength() == 1
308 && arg25.member[0] == 'X'
309 && (arguments[26] >>= arg26) && arg26.member.getLength() == 1
310 && arg26.member[0] == "test"
311 && (arguments[27] >>= arg27) && arg27.member.getLength() == 1
312 && arg27.member[0] == 0.123f
313 && (arguments[28] >>= arg28) && arg28.member.getLength() == 1
314 && arg28.member[0] == 0.456
315 && (arguments[29] >>= arg29) && arg29.member.getLength() == 1
316 && arg29.member[0] != nullptr
317 && (arguments[30] >>= arg30) && arg30.member.getLength() == 1
318 && arg30.member[0] != nullptr
319 && (arguments[31] >>= arg31) && arg31.member.getLength() == 1
320 && arg31.member[0] == ttb::TestEnum_TWO
321 && (arguments[32] >>= arg32) && arg32.member.getLength() == 1
322 && arg32.member[0].member1 == 'X'
323 && arg32.member[0].member2.getLength() == 1
324 && (arg32.member[0].member2[0] >>= arg32a) && arg32a
325 && (arguments[33] >>= arg33) && arg33.member.getLength() == 1
326 && arg33.member[0].member1.member == 'X'
327 && arg33.member[0].member2.getLength() == 1
328 && arg33.member[0].member2[0] == arg1b
329 && (arguments[34] >>= arg34) && arg34.member.getLength() == 1
330 && arg34.member[0].getLength() == 1 && arg34.member[0][0] == SAL_MIN_INT32
331 && (arguments[35] >>= arg35) && arg35.getLength() == 1
332 && arg35[0].member == SAL_MIN_INT32
333 && (arguments[36] >>= arg36) && arg36.getLength() == 1
334 && arg36[0].member.member1 == 'X'
335 && arg36[0].member.member2 == arg1b
336 && (arguments[37] >>= arg37) && arg37.getLength() == 1
337 && arg37[0].member.member1.member1 == 'X'
338 && arg37[0].member.member1.member2 == arg1b
339 && arg37[0].member.member2 == "test"
340 && (arguments[38] >>= arg38) && arg38.getLength() == 1
341 && arg38[0].member1 == "test"
342 && arg38[0].member2.member1 == 'X'
343 && arg38[0].member2.member2.member == arg1b
344 && (arguments[39] >>= arg39) && arg39.getLength() == 1
345 && arg39[0].member1.member1 == 'X'
346 && arg39[0].member1.member2 == arg1b
347 && arg39[0].member2.member == 'X'
348 && (arguments[40] >>= arg40) && arg40.getLength() == 1
349 && arg40[0].getLength() == 1
350 && arg40[0][0].member == 'X'
351 && (arguments[41] >>= arg41) && arg41.getLength() == 1
352 && arg41[0].getLength() == 1
353 && arg41[0][0].member.member1 == 'X'
354 && arg41[0][0].member.member2 == arg1b
355 && (arguments[42] >>= arg42) && arg42.getLength() == 1
356 && arg42[0].getLength() == 1
357 && arg42[0][0].member.member1.member1 == 'X'
358 && arg42[0][0].member.member1.member2 == arg1b
359 && arg42[0][0].member.member2 == "test"
360 && (arguments[43] >>= arg43) && arg43.getLength() == 1
361 && arg43[0].getLength() == 1
362 && arg43[0][0].member1 == "test"
363 && arg43[0][0].member2.member1 == 'X'
364 && arg43[0][0].member2.member2.member == arg1b
365 && (arguments[44] >>= arg44) && arg44.getLength() == 1
366 && arg44[0].getLength() == 1
367 && arg44[0][0].member1.member1 == 'X'
368 && arg44[0][0].member1.member2 == arg1b
369 && arg44[0][0].member2.member == 'X'
372 throw ::test::testtools::bridgetest::BadConstructorArguments();
375 //check if interfaces work
376 arg11.member->acquire();
377 arg11.member->release();
378 arg12.member->acquire();
379 arg12.member->release();
380 arg29.member[0]->acquire();
381 arg29.member[0]->release();
385 //XMultiBase1
386 double Impl2::getatt1()
388 return m_attr1;
391 void Impl2::setatt1( double _att1 )
393 m_attr1 = _att1;
396 ::sal_Int32 Impl2::fn11( ::sal_Int32 arg )
398 return 11 * arg;
401 OUString Impl2::fn12( const OUString& arg )
403 return "12" + arg;
406 css::uno::Reference< css::uno::XInterface > create(
407 SAL_UNUSED_PARAMETER css::uno::Reference< css::uno::XComponentContext >
408 const &)
410 return static_cast< ::cppu::OWeakObject * >(new Impl);
413 OUString getImplementationName() {
414 return
415 "comp.test.testtools.bridgetest.Constructors";
418 css::uno::Sequence< OUString > getSupportedServiceNames() {
419 return { "test.testtools.bridgetest.Constructors" };
422 css::uno::Reference< css::uno::XInterface > create2(
423 SAL_UNUSED_PARAMETER css::uno::Reference< css::uno::XComponentContext >
424 const &)
426 return static_cast< ::cppu::OWeakObject * >(new Impl2);
429 OUString getImplementationName2() {
430 return "comp.test.testtools.bridgetest.Constructors2";
433 css::uno::Sequence< OUString > getSupportedServiceNames2() {
434 return { "test.testtools.bridgetest.Constructors2" };
437 ::cppu::ImplementationEntry const entries[] = {
438 { &create, &getImplementationName, &getSupportedServiceNames,
439 &::cppu::createSingleComponentFactory, nullptr, 0 },
440 { &create2, &getImplementationName2, &getSupportedServiceNames2,
441 &::cppu::createSingleComponentFactory, nullptr, 0 },
442 { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } };
445 extern "C" SAL_DLLPUBLIC_EXPORT void * component_getFactory(
446 char const * implName, void * serviceManager, void * registryKey)
448 return ::cppu::component_getFactoryHelper(
449 implName, serviceManager, registryKey, entries);
452 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */