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,7 +939,16 @@ public class ValueChanger { ...@@ -938,7 +939,16 @@ 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);
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++) { for (int i = 0; i < Array.getLength(newValue); i++) {
if (!arrType.isPrimitive()) { if (!arrType.isPrimitive()) {
Object elem = changePValue(Array.get(oldValue, i)); Object elem = changePValue(Array.get(oldValue, i));
...@@ -970,6 +980,7 @@ public class ValueChanger { ...@@ -970,6 +980,7 @@ public class ValueChanger {
} }
} }
} }
}
} else if (isStructure(oldValue)) { } else if (isStructure(oldValue)) {
// universal changer for structures // universal changer for structures
Class<?> clazz = oldValue.getClass(); Class<?> clazz = oldValue.getClass();
......
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