Kaydet (Commit) cdbec91d authored tarafından Eike Rathke's avatar Eike Rathke

special case TypedItemList in preparation for tdf#79250

Seems a Sequence<Any> property was never supported in the
qadevOOo/tests/java/ifc/beans/_XPropertySet.java addPropertyChangeListener()
tests, where the property has to be changed in ValueChanger to pass the test.
However, simply generally adding a value to an empty sequence does not work as
it would break other tests in turn, so special-case it to the TypedItemList
property. This is all fubar.

Change-Id: If6d0f45c7440e3553dc8bd293dadb21c5fb09bb5
üst 8c00536d
......@@ -28,6 +28,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.Array;
import com.sun.star.uno.Any;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
public class ValueChanger {
......@@ -938,35 +939,45 @@ public class ValueChanger {
} else if (oldValue.getClass().isArray()) {
// changer for arrays : changes all elements
Class<?> arrType = oldValue.getClass().getComponentType();
newValue = Array.newInstance(arrType, Array.getLength(oldValue));
for (int i = 0; i < Array.getLength(newValue); i++) {
if (!arrType.isPrimitive()) {
Object elem = changePValue(Array.get(oldValue, i));
Array.set(newValue, i, elem);
} else {
if (Boolean.TYPE.equals(arrType)) {
Array.setBoolean(newValue, i,
!Array.getBoolean(oldValue, i));
} else if (Byte.TYPE.equals(arrType)) {
Array.setByte(newValue, i,
(byte) (Array.getByte(oldValue, i) + 1));
} else if (Character.TYPE.equals(arrType)) {
Array.setChar(newValue, i,
(char) (Array.getChar(oldValue, i) + 1));
} else if (Double.TYPE.equals(arrType)) {
Array.setDouble(newValue, i,
Array.getDouble(oldValue, i) + 1);
} else if (Float.TYPE.equals(arrType)) {
Array.setFloat(newValue, i,
Array.getFloat(oldValue, i) + 1);
} else if (Integer.TYPE.equals(arrType)) {
Array.setInt(newValue, i, Array.getInt(oldValue, i) + 1);
} else if (Long.TYPE.equals(arrType)) {
Array.setLong(newValue, i,
Array.getLong(oldValue, i) + 1);
} else if (Short.TYPE.equals(arrType)) {
Array.setShort(newValue, i,
(short) (Array.getShort(oldValue, i) + 1));
int oldLen = Array.getLength(oldValue);
if (oldLen == 0 && "TypedItemList".equals(name) && !arrType.isPrimitive()) {
// This case is needed to make the Sequence<Any> property pass
// the addPropertyChangeListener tests, where the property has
// to be changed (and not stay empty ...)
newValue = Array.newInstance(arrType, 1);
Object elem = new Any(new Type(String.class), "_Any");
Array.set(newValue, 0, elem);
} else {
newValue = Array.newInstance(arrType, oldLen);
for (int i = 0; i < Array.getLength(newValue); i++) {
if (!arrType.isPrimitive()) {
Object elem = changePValue(Array.get(oldValue, i));
Array.set(newValue, i, elem);
} else {
if (Boolean.TYPE.equals(arrType)) {
Array.setBoolean(newValue, i,
!Array.getBoolean(oldValue, i));
} else if (Byte.TYPE.equals(arrType)) {
Array.setByte(newValue, i,
(byte) (Array.getByte(oldValue, i) + 1));
} else if (Character.TYPE.equals(arrType)) {
Array.setChar(newValue, i,
(char) (Array.getChar(oldValue, i) + 1));
} else if (Double.TYPE.equals(arrType)) {
Array.setDouble(newValue, i,
Array.getDouble(oldValue, i) + 1);
} else if (Float.TYPE.equals(arrType)) {
Array.setFloat(newValue, i,
Array.getFloat(oldValue, i) + 1);
} else if (Integer.TYPE.equals(arrType)) {
Array.setInt(newValue, i, Array.getInt(oldValue, i) + 1);
} else if (Long.TYPE.equals(arrType)) {
Array.setLong(newValue, i,
Array.getLong(oldValue, i) + 1);
} else if (Short.TYPE.equals(arrType)) {
Array.setShort(newValue, i,
(short) (Array.getShort(oldValue, i) + 1));
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment