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; ...@@ -28,6 +28,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import com.sun.star.uno.Any; import com.sun.star.uno.Any;
import com.sun.star.uno.AnyConverter; import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
public class ValueChanger { public class ValueChanger {
...@@ -938,35 +939,45 @@ public class ValueChanger { ...@@ -938,35 +939,45 @@ public class ValueChanger {
} else if (oldValue.getClass().isArray()) { } else if (oldValue.getClass().isArray()) {
// changer for arrays : changes all elements // changer for arrays : changes all elements
Class<?> arrType = oldValue.getClass().getComponentType(); Class<?> arrType = oldValue.getClass().getComponentType();
newValue = Array.newInstance(arrType, Array.getLength(oldValue)); int oldLen = Array.getLength(oldValue);
for (int i = 0; i < Array.getLength(newValue); i++) { if (oldLen == 0 && "TypedItemList".equals(name) && !arrType.isPrimitive()) {
if (!arrType.isPrimitive()) { // This case is needed to make the Sequence<Any> property pass
Object elem = changePValue(Array.get(oldValue, i)); // the addPropertyChangeListener tests, where the property has
Array.set(newValue, i, elem); // to be changed (and not stay empty ...)
} else { newValue = Array.newInstance(arrType, 1);
if (Boolean.TYPE.equals(arrType)) { Object elem = new Any(new Type(String.class), "_Any");
Array.setBoolean(newValue, i, Array.set(newValue, 0, elem);
!Array.getBoolean(oldValue, i)); } else {
} else if (Byte.TYPE.equals(arrType)) { newValue = Array.newInstance(arrType, oldLen);
Array.setByte(newValue, i, for (int i = 0; i < Array.getLength(newValue); i++) {
(byte) (Array.getByte(oldValue, i) + 1)); if (!arrType.isPrimitive()) {
} else if (Character.TYPE.equals(arrType)) { Object elem = changePValue(Array.get(oldValue, i));
Array.setChar(newValue, i, Array.set(newValue, i, elem);
(char) (Array.getChar(oldValue, i) + 1)); } else {
} else if (Double.TYPE.equals(arrType)) { if (Boolean.TYPE.equals(arrType)) {
Array.setDouble(newValue, i, Array.setBoolean(newValue, i,
Array.getDouble(oldValue, i) + 1); !Array.getBoolean(oldValue, i));
} else if (Float.TYPE.equals(arrType)) { } else if (Byte.TYPE.equals(arrType)) {
Array.setFloat(newValue, i, Array.setByte(newValue, i,
Array.getFloat(oldValue, i) + 1); (byte) (Array.getByte(oldValue, i) + 1));
} else if (Integer.TYPE.equals(arrType)) { } else if (Character.TYPE.equals(arrType)) {
Array.setInt(newValue, i, Array.getInt(oldValue, i) + 1); Array.setChar(newValue, i,
} else if (Long.TYPE.equals(arrType)) { (char) (Array.getChar(oldValue, i) + 1));
Array.setLong(newValue, i, } else if (Double.TYPE.equals(arrType)) {
Array.getLong(oldValue, i) + 1); Array.setDouble(newValue, i,
} else if (Short.TYPE.equals(arrType)) { Array.getDouble(oldValue, i) + 1);
Array.setShort(newValue, i, } else if (Float.TYPE.equals(arrType)) {
(short) (Array.getShort(oldValue, i) + 1)); 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