private boolean checkStringListProperty(Property property)
{
// creating instances
boolean bResult = true;
XFastPropertySet xFPS = UnoRuntime.queryInterface(XFastPropertySet.class, aPathSettings);
String name = property.Name;
int handle = property.Handle;
Object oValue;
try
{
oValue = xFPS.getFastPropertyValue(handle);
}
catch (UnknownPropertyException ex)
{
return false;
}
catch (WrappedTargetException ex)
{
return false;
}
if (!AnyConverter.isArray(oValue))
{
System.out.println(" Internal error, type wrong. PathSetting property with name:" + name + " should be an array.");
return false;
}
String val;
try
{
Object oValues = AnyConverter.toArray(oValue);
final String[] aValues = (String[])oValues;
// aNewValues contains a deep copy of aValues
String[] aNewValues = new String[aValues.length];
System.arraycopy(aValues, 0, aNewValues, 0, aValues.length);
if (aValues.length > 0)
{
val = aValues[0];
}
else
{
val = null;
aNewValues = new String[1]; // create a String list
}
System.out.println(" Property has initial value: '" + val + "'");
// set to a new correct value
String newVal = changeToCorrectValue(val);
assertFalse("newVal must not equal val.", newVal.equals(val));
System.out.println(" Try to change to a correct value '" + newVal + "'");
aNewValues[0] = newVal;
try
{
try
{
xFPS.setFastPropertyValue(handle, aNewValues);
}
catch (com.sun.star.lang.WrappedTargetException e)
{
System.out.println(" FAIL: setFastPropertyValue(handle:=" + handle + ", name:='" + name + "')" + e.getMessage());
bResult = false;
}
// Property_internal can't change we will not arrive bejond this line
// check the change
Object oObj = xFPS.getFastPropertyValue(handle);
if (!checkPaths(oObj, aNewValues))
{
System.out.println(" FAIL: Did not change value on property " + name + ".");
bResult = false;
}
// set back to initial setting
System.out.println(" Try to check");
try
{
xFPS.setFastPropertyValue(handle, oValue);
}
catch (com.sun.star.beans.PropertyVetoException e)
{
// should not occur
System.out.println(" FAIL: PropertyVetoException caught: " + e.getMessage());
bResult = false;
}
}
catch (com.sun.star.beans.PropertyVetoException e)
{
if (!name.endsWith("_internal"))
{
// should not occur
System.out.println(" FAIL: PropertyVetoException caught: " + e.getMessage());
bResult = false;
}
else
{
System.out.println(" OK: PropertyVetoException caught: " + e.getMessage() + " it seems not allowed to change internal values.");
}
}
// check if changed
Object checkVal3 = xFPS.getFastPropertyValue(handle);
if (!checkPaths(checkVal3, oValues))
{
System.out.println(" FAIL: Can't change value back to original on property " + name);
bResult = false;
}