throws UnknownPropertyException, PropertyVetoException,
com.sun.star.lang.IllegalArgumentException, WrappedTargetException
{
PropertyData p = (PropertyData) properties.get(name);
if (p == null) {
throw new UnknownPropertyException(name, object);
}
if ((isAmbiguous
&& (p.property.Attributes & PropertyAttribute.MAYBEAMBIGUOUS) == 0)
|| (isDefaulted
&& ((p.property.Attributes & PropertyAttribute.MAYBEDEFAULT)
== 0)))
{
throw new com.sun.star.lang.IllegalArgumentException(
("flagging as ambiguous/defaulted non-ambiguous/defaulted"
+ " property " + name),
object, illegalArgumentPosition);
}
XIdlField2 f = (XIdlField2) UnoRuntime.queryInterface(
XIdlField2.class, idlClass.getField(name));
Object[] o = new Object[] {
new Any(type, UnoRuntime.queryInterface(type, object)) };
Object v = wrapValue(
value,
((XIdlField2) UnoRuntime.queryInterface(
XIdlField2.class, idlClass.getField(name))).getType(),
(p.property.Attributes & PropertyAttribute.MAYBEAMBIGUOUS) != 0,
isAmbiguous,
(p.property.Attributes & PropertyAttribute.MAYBEDEFAULT) != 0,
isDefaulted,
(p.property.Attributes & PropertyAttribute.MAYBEVOID) != 0);
try {
f.set(o, v);
} catch (com.sun.star.lang.IllegalArgumentException e) {
if (e.ArgumentPosition == 1) {
throw new com.sun.star.lang.IllegalArgumentException(
e.getMessage(), object, illegalArgumentPosition);
} else {
throw new RuntimeException(
"unexpected com.sun.star.lang.IllegalArgumentException: "
+ e.getMessage());
}
} catch (com.sun.star.lang.IllegalAccessException e) {
//TODO Clarify whether PropertyVetoException is the correct
// exception to throw when trying to set a read-only property:
throw new PropertyVetoException(
"cannot set read-only property " + name, object);
} catch (WrappedTargetRuntimeException e) {
//FIXME A WrappedTargetRuntimeException from XIdlField2.get is not
// guaranteed to originate directly within XIdlField2.get (and thus
// have the expected semantics); it might also be passed through
// from lower layers.
if (new Type(UnknownPropertyException.class).isSupertypeOf(
AnyConverter.getType(e.TargetException))
&& (p.property.Attributes & PropertyAttribute.OPTIONAL) != 0)
{
throw new UnknownPropertyException(name, object);
} else if (new Type(PropertyVetoException.class).isSupertypeOf(
AnyConverter.getType(e.TargetException))
&& ((p.property.Attributes
& PropertyAttribute.CONSTRAINED)
!= 0))