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 .
21 #include <sal/config.h>
23 #include <test/cppuhelper/propertysetmixin/XSupplier.hpp>
24 #include <test/cppuhelper/propertysetmixin/XTest3.hpp>
26 #include <com/sun/star/beans/Ambiguous.hpp>
27 #include <com/sun/star/beans/Defaulted.hpp>
28 #include <com/sun/star/beans/Optional.hpp>
29 #include <com/sun/star/beans/PropertyVetoException.hpp>
30 #include <com/sun/star/beans/UnknownPropertyException.hpp>
31 #include <com/sun/star/lang/XComponent.hpp>
32 #include <cppuhelper/propertysetmixin.hxx>
33 #include <cppuhelper/factory.hxx>
34 #include <cppuhelper/implbase1.hxx>
35 #include <cppuhelper/implementationentry.hxx>
36 #include <cppuhelper/queryinterface.hxx>
37 #include <cppuhelper/weak.hxx>
38 #include <com/sun/star/uno/Any.hxx>
39 #include <com/sun/star/uno/Exception.hpp>
40 #include <com/sun/star/uno/Reference.hxx>
41 #include <com/sun/star/uno/RuntimeException.hpp>
42 #include <com/sun/star/uno/Sequence.hxx>
43 #include <com/sun/star/uno/Type.hxx>
44 #include <com/sun/star/uno/XComponentContext.hpp>
45 #include <com/sun/star/uno/XInterface.hpp>
46 #include <osl/mutex.hxx>
47 #include <rtl/ustring.h>
48 #include <rtl/ustring.hxx>
49 #include <sal/types.h>
51 namespace com
{ namespace sun
{ namespace star
{
58 public cppu::OWeakObject
, public css::lang::XComponent
,
59 public cppu::PropertySetMixin
< css::lang::XComponent
>
63 css::uno::Reference
< css::uno::XComponentContext
> const & context
):
64 cppu::PropertySetMixin
< css::lang::XComponent
>(
65 context
, static_cast< Implements
>(0),
66 css::uno::Sequence
< rtl::OUString
>())
69 virtual css::uno::Any SAL_CALL
queryInterface(css::uno::Type
const & type
)
70 throw (css::uno::RuntimeException
);
72 virtual void SAL_CALL
acquire() throw () { OWeakObject::acquire(); }
74 virtual void SAL_CALL
release() throw () { OWeakObject::release(); }
76 virtual void SAL_CALL
dispose() throw (css::uno::RuntimeException
) {
77 cppu::PropertySetMixin
< css::lang::XComponent
>::dispose();
80 virtual void SAL_CALL
addEventListener(
81 css::uno::Reference
< css::lang::XEventListener
> const &)
82 throw (css::uno::RuntimeException
)
85 virtual void SAL_CALL
removeEventListener(
86 css::uno::Reference
< css::lang::XEventListener
> const &)
87 throw (css::uno::RuntimeException
)
91 Empty1(Empty1
&); // not defined
92 void operator =(Empty1
&); // not defined
97 css::uno::Any
Empty1::queryInterface(css::uno::Type
const & type
)
98 throw (css::uno::RuntimeException
)
100 css::uno::Any
a(OWeakObject::queryInterface(type
));
104 a
= cppu::queryInterface(
105 type
, static_cast< css::lang::XComponent
* >(this));
108 : cppu::PropertySetMixin
< css::lang::XComponent
>::queryInterface(
113 public cppu::OWeakObject
, public css::lang::XComponent
,
114 public cppu::PropertySetMixin
< css::lang::XComponent
>
118 css::uno::Reference
< css::uno::XComponentContext
> const & context
):
119 cppu::PropertySetMixin
< css::lang::XComponent
>(
121 static_cast< Implements
>(
122 IMPLEMENTS_PROPERTY_SET
| IMPLEMENTS_FAST_PROPERTY_SET
123 | IMPLEMENTS_PROPERTY_ACCESS
),
124 css::uno::Sequence
< rtl::OUString
>())
127 virtual css::uno::Any SAL_CALL
queryInterface(css::uno::Type
const & type
)
128 throw (css::uno::RuntimeException
);
130 virtual void SAL_CALL
acquire() throw () { OWeakObject::acquire(); }
132 virtual void SAL_CALL
release() throw () { OWeakObject::release(); }
134 virtual void SAL_CALL
dispose() throw (css::uno::RuntimeException
) {
135 cppu::PropertySetMixin
< css::lang::XComponent
>::dispose();
138 virtual void SAL_CALL
addEventListener(
139 css::uno::Reference
< css::lang::XEventListener
> const &)
140 throw (css::uno::RuntimeException
)
143 virtual void SAL_CALL
removeEventListener(
144 css::uno::Reference
< css::lang::XEventListener
> const &)
145 throw (css::uno::RuntimeException
)
149 Empty2(Empty2
&); // not defined
150 void operator =(Empty2
&); // not defined
155 css::uno::Any
Empty2::queryInterface(css::uno::Type
const & type
)
156 throw (css::uno::RuntimeException
)
158 css::uno::Any
a(OWeakObject::queryInterface(type
));
162 a
= cppu::queryInterface(
163 type
, static_cast< css::lang::XComponent
* >(this));
166 : cppu::PropertySetMixin
< css::lang::XComponent
>::queryInterface(
170 css::uno::Sequence
< rtl::OUString
> sequenceThird() {
171 css::uno::Sequence
<OUString
> s
{ rtl::OUString("Third") };
176 public cppu::OWeakObject
, public test::cppuhelper::propertysetmixin::XTest3
,
177 public cppu::PropertySetMixin
<
178 test::cppuhelper::propertysetmixin::XTest3
>
182 css::uno::Reference
< css::uno::XComponentContext
> const & context
):
183 cppu::PropertySetMixin
<
184 test::cppuhelper::propertysetmixin::XTest3
>(
186 static_cast< Implements
>(
187 IMPLEMENTS_PROPERTY_SET
| IMPLEMENTS_FAST_PROPERTY_SET
188 | IMPLEMENTS_PROPERTY_ACCESS
),
192 css::beans::Defaulted
< css::beans::Optional
< sal_Int32
> >(
193 css::beans::Optional
< sal_Int32
>(), true),
197 virtual css::uno::Any SAL_CALL
queryInterface(css::uno::Type
const & type
)
198 throw (css::uno::RuntimeException
);
200 virtual void SAL_CALL
acquire() throw () { OWeakObject::acquire(); }
202 virtual void SAL_CALL
release() throw () { OWeakObject::release(); }
204 virtual sal_Int32 SAL_CALL
getFirst() throw (css::uno::RuntimeException
);
206 virtual void SAL_CALL
setFirst(sal_Int32 value
)
207 throw (css::uno::RuntimeException
);
210 css::beans::Ambiguous
<
211 css::beans::Defaulted
< css::beans::Optional
< sal_Int32
> > >
214 css::beans::UnknownPropertyException
, css::uno::RuntimeException
);
216 virtual void SAL_CALL
setSecond(
217 css::beans::Ambiguous
<
218 css::beans::Defaulted
< css::beans::Optional
< ::sal_Int32
> > > const &
221 css::beans::PropertyVetoException
,
222 css::beans::UnknownPropertyException
, css::uno::RuntimeException
);
224 virtual sal_Int32 SAL_CALL
getThird()
226 css::beans::UnknownPropertyException
, css::uno::RuntimeException
);
228 virtual void SAL_CALL
setThird(sal_Int32 value
)
230 css::beans::UnknownPropertyException
, css::uno::RuntimeException
);
232 virtual sal_Int32 SAL_CALL
getFourth()
234 css::beans::UnknownPropertyException
, css::uno::RuntimeException
);
236 virtual void SAL_CALL
setFourth(sal_Int32 value
)
238 css::beans::UnknownPropertyException
, css::uno::RuntimeException
);
241 Full(Full
&); // not defined
242 void operator =(Full
&); // not defined
248 css::beans::Ambiguous
<
249 css::beans::Defaulted
< css::beans::Optional
< sal_Int32
> > > m_a2
;
252 css::uno::Any
Full::queryInterface(css::uno::Type
const & type
)
253 throw (css::uno::RuntimeException
)
255 css::uno::Any
a(OWeakObject::queryInterface(type
));
259 a
= cppu::queryInterface(
261 static_cast< test::cppuhelper::propertysetmixin::XTest3
* >(this));
264 : (cppu::PropertySetMixin
<
265 test::cppuhelper::propertysetmixin::XTest3
>::queryInterface(
269 sal_Int32
Full::getFirst() throw (css::uno::RuntimeException
) {
270 osl::MutexGuard
g(m_mutex
);
274 void Full::setFirst(sal_Int32 value
) throw (css::uno::RuntimeException
) {
276 rtl::OUString("First"), css::uno::Any(),
278 osl::MutexGuard
g(m_mutex
);
282 css::beans::Ambiguous
<
283 css::beans::Defaulted
< css::beans::Optional
< sal_Int32
> > >
285 throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
)
287 osl::MutexGuard
g(m_mutex
);
291 void Full::setSecond(
292 css::beans::Ambiguous
<
293 css::beans::Defaulted
< css::beans::Optional
< ::sal_Int32
> > > const &
296 css::beans::PropertyVetoException
, css::beans::UnknownPropertyException
,
297 css::uno::RuntimeException
)
300 if (value
.Value
.Value
.IsPresent
) {
301 v
<<= value
.Value
.Value
.Value
;
305 rtl::OUString("Second"), css::uno::Any(),
308 osl::MutexGuard
g(m_mutex
);
314 sal_Int32
Full::getThird()
315 throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
)
317 throw css::beans::UnknownPropertyException(
318 rtl::OUString("Third"),
319 static_cast< cppu::OWeakObject
* >(this));
322 void Full::setThird(sal_Int32
)
323 throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
)
325 throw css::beans::UnknownPropertyException(
326 rtl::OUString("Third"),
327 static_cast< cppu::OWeakObject
* >(this));
330 sal_Int32
Full::getFourth()
331 throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
)
333 throw css::beans::UnknownPropertyException(
334 rtl::OUString("Fourth"),
335 static_cast< cppu::OWeakObject
* >(this));
338 void Full::setFourth(sal_Int32
)
339 throw (css::beans::UnknownPropertyException
, css::uno::RuntimeException
)
341 throw css::beans::UnknownPropertyException(
342 rtl::OUString("Fourth"),
343 static_cast< cppu::OWeakObject
* >(this));
347 public cppu::WeakImplHelper1
<
348 test::cppuhelper::propertysetmixin::XSupplier
>
352 css::uno::Reference
< css::uno::XComponentContext
> const & context
):
353 m_context(context
) {}
355 virtual css::uno::Reference
< css::lang::XComponent
> SAL_CALL
getEmpty1()
356 throw (css::uno::RuntimeException
)
357 { return new Empty1(m_context
); }
359 virtual css::uno::Reference
< css::lang::XComponent
> SAL_CALL
getEmpty2()
360 throw (css::uno::RuntimeException
)
361 { return new Empty2(m_context
); }
363 virtual css::uno::Reference
< test::cppuhelper::propertysetmixin::XTest3
>
364 SAL_CALL
getFull() throw (css::uno::RuntimeException
)
365 { return new Full(m_context
); }
368 Supplier(Supplier
&); // not defined
369 void operator =(Supplier
&); // not defined
371 virtual ~Supplier() {}
373 css::uno::Reference
< css::uno::XComponentContext
> m_context
;
376 css::uno::Reference
< css::uno::XInterface
> SAL_CALL
create(
377 css::uno::Reference
< css::uno::XComponentContext
> const & context
)
379 return static_cast< cppu::OWeakObject
* >(new Supplier(context
));
382 rtl::OUString SAL_CALL
getImplementationName() {
383 return rtl::OUString(
384 "test.cppuhelper.propertysetmixin.comp.CppSupplier");
387 css::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames()
389 css::uno::Sequence
< rtl::OUString
> s
{ "test.cppuhelper.propertysetmixin.CppSupplier") };
393 cppu::ImplementationEntry entries
[] = {
394 { &create
, &getImplementationName
, &getSupportedServiceNames
,
395 &cppu::createSingleComponentFactory
, 0, 0 },
396 { 0, 0, 0, 0, 0, 0 } };
400 extern "C" SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
mixin_component_getFactory(
401 char const * implName
, void * serviceManager
, void * registryKey
)
403 return cppu::component_getFactoryHelper(
404 implName
, serviceManager
, registryKey
, entries
);
407 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */