From cdbec91da4931be72ed4f1b28f78d83a9a0d616f Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Tue, 14 Feb 2017 11:48:22 +0100 Subject: special case TypedItemList in preparation for tdf#79250 Seems a Sequence 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 --- qadevOOo/runner/util/ValueChanger.java | 69 ++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 29 deletions(-) (limited to 'qadevOOo') diff --git a/qadevOOo/runner/util/ValueChanger.java b/qadevOOo/runner/util/ValueChanger.java index ec796aec5757..3905b4485bc3 100644 --- a/qadevOOo/runner/util/ValueChanger.java +++ b/qadevOOo/runner/util/ValueChanger.java @@ -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 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)); + } } } } -- cgit