2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package test
.cppuhelper
.propertysetmixin
.comp
;
21 import com
.sun
.star
.beans
.Ambiguous
;
22 import com
.sun
.star
.beans
.Defaulted
;
23 import com
.sun
.star
.beans
.Optional
;
24 import com
.sun
.star
.beans
.UnknownPropertyException
;
25 import com
.sun
.star
.beans
.PropertyValue
;
26 import com
.sun
.star
.beans
.PropertyVetoException
;
27 import com
.sun
.star
.beans
.XFastPropertySet
;
28 import com
.sun
.star
.beans
.XPropertyAccess
;
29 import com
.sun
.star
.beans
.XPropertyChangeListener
;
30 import com
.sun
.star
.beans
.XPropertySet
;
31 import com
.sun
.star
.beans
.XPropertySetInfo
;
32 import com
.sun
.star
.beans
.XVetoableChangeListener
;
33 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
34 import com
.sun
.star
.lang
.WrappedTargetException
;
35 import com
.sun
.star
.lang
.XComponent
;
36 import com
.sun
.star
.lang
.XEventListener
;
37 import com
.sun
.star
.lang
.XMultiServiceFactory
;
38 import com
.sun
.star
.lang
.XSingleServiceFactory
;
39 import com
.sun
.star
.lib
.uno
.helper
.WeakBase
;
40 import com
.sun
.star
.lib
.uno
.helper
.PropertySetMixin
;
41 import com
.sun
.star
.registry
.XRegistryKey
;
42 import com
.sun
.star
.uno
.Any
;
43 import com
.sun
.star
.uno
.IQueryInterface
;
44 import com
.sun
.star
.uno
.Type
;
45 import com
.sun
.star
.uno
.XComponentContext
;
46 import test
.cppuhelper
.propertysetmixin
.XSupplier
;
47 import test
.cppuhelper
.propertysetmixin
.XTest3
;
49 public final class JavaSupplier
extends WeakBase
implements XSupplier
{
50 public JavaSupplier(XComponentContext context
) {
51 this.context
= context
;
54 public XComponent
getEmpty1() { return new Empty1(); }
56 public XComponent
getEmpty2() { return new Empty2(); }
58 public XTest3
getFull() { return new Full(); }
60 public static XSingleServiceFactory
__getServiceFactory(
61 String implName
, XMultiServiceFactory multiFactory
, XRegistryKey regKey
)
63 return implName
.equals(implementationName
)
64 ? FactoryHelper
.getServiceFactory(
65 JavaSupplier
.class, serviceName
, multiFactory
, regKey
)
69 private static final String implementationName
70 = JavaSupplier
.class.getName();
71 private static final String serviceName
72 = "test.cppuhelper.propertysetmixin.JavaSupplier";
74 private final class Empty1
extends WeakBase
implements XComponent
{
77 public void dispose() {
81 public void addEventListener(XEventListener listener
) {}
83 public void removeEventListener(XEventListener listener
) {}
85 private final PropertySetMixin prop
= new PropertySetMixin(
86 context
, this, new Type(XComponent
.class), null);
89 private final class Empty2
extends WeakBase
90 implements XComponent
, XPropertySet
, XFastPropertySet
, XPropertyAccess
94 public void dispose() {
98 public void addEventListener(XEventListener listener
) {}
100 public void removeEventListener(XEventListener listener
) {}
102 public com
.sun
.star
.beans
.XPropertySetInfo
getPropertySetInfo() {
103 return prop
.getPropertySetInfo();
106 public void setPropertyValue(String propertyName
, Object value
)
107 throws UnknownPropertyException
, PropertyVetoException
,
108 com
.sun
.star
.lang
.IllegalArgumentException
, WrappedTargetException
110 prop
.setPropertyValue(propertyName
, value
);
113 public Object
getPropertyValue(String propertyName
)
114 throws UnknownPropertyException
, WrappedTargetException
116 return prop
.getPropertyValue(propertyName
);
119 public void addPropertyChangeListener(
120 String propertyName
, XPropertyChangeListener listener
)
121 throws UnknownPropertyException
, WrappedTargetException
123 prop
.addPropertyChangeListener(propertyName
, listener
);
126 public void removePropertyChangeListener(
127 String propertyName
, XPropertyChangeListener listener
)
128 throws UnknownPropertyException
, WrappedTargetException
130 prop
.removePropertyChangeListener(propertyName
, listener
);
133 public void addVetoableChangeListener(
134 String propertyName
, XVetoableChangeListener listener
)
135 throws UnknownPropertyException
, WrappedTargetException
137 prop
.addVetoableChangeListener(propertyName
, listener
);
140 public void removeVetoableChangeListener(
141 String propertyName
, XVetoableChangeListener listener
)
142 throws UnknownPropertyException
, WrappedTargetException
144 prop
.removeVetoableChangeListener(propertyName
, listener
);
147 public void setFastPropertyValue(int handle
, Object value
)
148 throws UnknownPropertyException
, PropertyVetoException
,
149 com
.sun
.star
.lang
.IllegalArgumentException
, WrappedTargetException
151 prop
.setFastPropertyValue(handle
, value
);
154 public Object
getFastPropertyValue(int handle
)
155 throws UnknownPropertyException
, WrappedTargetException
157 return prop
.getFastPropertyValue(handle
);
160 public PropertyValue
[] getPropertyValues() {
161 return prop
.getPropertyValues();
164 public void setPropertyValues(PropertyValue
[] props
)
165 throws UnknownPropertyException
, PropertyVetoException
,
166 com
.sun
.star
.lang
.IllegalArgumentException
, WrappedTargetException
168 prop
.setPropertyValues(props
);
171 private final PropertySetMixin prop
= new PropertySetMixin(
172 context
, this, new Type(XComponent
.class), null);
175 private final class Full
extends WeakBase
176 implements XTest3
, XPropertySet
, XFastPropertySet
, XPropertyAccess
180 public synchronized int getFirst() {
184 public void setFirst(int value
) {
185 prop
.prepareSet("First", null);
186 synchronized (this) {
191 public synchronized Ambiguous
getSecond()
192 throws UnknownPropertyException
197 public void setSecond(Ambiguous value
)
198 throws PropertyVetoException
, UnknownPropertyException
200 PropertySetMixin
.BoundListeners l
201 = new PropertySetMixin
.BoundListeners();
204 (((Optional
) ((Defaulted
) value
.Value
).Value
).IsPresent
205 ?
((Optional
) ((Defaulted
) value
.Value
).Value
).Value
208 synchronized (this) {
214 public int getThird() throws UnknownPropertyException
{
215 throw new UnknownPropertyException("Third", this);
218 public void setThird(int value
) throws UnknownPropertyException
{
219 throw new UnknownPropertyException("Third", this);
222 public int getFourth() throws UnknownPropertyException
{
223 throw new UnknownPropertyException("Fourth", this);
226 public void setFourth(int value
) throws UnknownPropertyException
{
227 throw new UnknownPropertyException("Fourth", this);
230 public com
.sun
.star
.beans
.XPropertySetInfo
getPropertySetInfo() {
231 return prop
.getPropertySetInfo();
234 public void setPropertyValue(String propertyName
, Object value
)
235 throws UnknownPropertyException
, PropertyVetoException
,
236 com
.sun
.star
.lang
.IllegalArgumentException
, WrappedTargetException
238 prop
.setPropertyValue(propertyName
, value
);
241 public Object
getPropertyValue(String propertyName
)
242 throws UnknownPropertyException
, WrappedTargetException
244 return prop
.getPropertyValue(propertyName
);
247 public void addPropertyChangeListener(
248 String propertyName
, XPropertyChangeListener listener
)
249 throws UnknownPropertyException
, WrappedTargetException
251 prop
.addPropertyChangeListener(propertyName
, listener
);
254 public void removePropertyChangeListener(
255 String propertyName
, XPropertyChangeListener listener
)
256 throws UnknownPropertyException
, WrappedTargetException
258 prop
.removePropertyChangeListener(propertyName
, listener
);
261 public void addVetoableChangeListener(
262 String propertyName
, XVetoableChangeListener listener
)
263 throws UnknownPropertyException
, WrappedTargetException
265 prop
.addVetoableChangeListener(propertyName
, listener
);
268 public void removeVetoableChangeListener(
269 String propertyName
, XVetoableChangeListener listener
)
270 throws UnknownPropertyException
, WrappedTargetException
272 prop
.removeVetoableChangeListener(propertyName
, listener
);
275 public void setFastPropertyValue(int handle
, Object value
)
276 throws UnknownPropertyException
, PropertyVetoException
,
277 com
.sun
.star
.lang
.IllegalArgumentException
, WrappedTargetException
279 prop
.setFastPropertyValue(handle
, value
);
282 public Object
getFastPropertyValue(int handle
)
283 throws UnknownPropertyException
, WrappedTargetException
285 return prop
.getFastPropertyValue(handle
);
288 public PropertyValue
[] getPropertyValues() {
289 return prop
.getPropertyValues();
292 public void setPropertyValues(PropertyValue
[] props
)
293 throws UnknownPropertyException
, PropertyVetoException
,
294 com
.sun
.star
.lang
.IllegalArgumentException
, WrappedTargetException
296 prop
.setPropertyValues(props
);
299 private final PropertySetMixin prop
= new PropertySetMixin(
300 context
, this, new Type(XTest3
.class), new String
[] { "Third" });
303 private Ambiguous a2
= new Ambiguous(
304 new Defaulted(new Optional(), true), false);
307 private final XComponentContext context
;