int height = addr.EndRow - addr.StartRow + 1 ;
log.println( "Object area is ((" + leftCol + "," + topRow + "),(" +
(leftCol + width - 1) + "," + (topRow + height - 1) + ")" );
XCellRange new_range = null;
try {
// first we need to create an array formula
new_range =
oObj.getCellRangeByPosition(0, 0, 0, height - 1);
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.print("Get cell range by position failed: ");
e.printStackTrace(log);
tRes.tested("collapseToCurrentArray()", false);
}
log.println("DB: Successfully new range created");
XArrayFormulaRange arrFormulaRange = (XArrayFormulaRange)
UnoRuntime.queryInterface (XArrayFormulaRange.class, new_range);
// write a simple formula (this array assigns another array)
arrFormulaRange.setArrayFormula("A1:A" + height) ;
// collapse cursor into one cell and then try to apply the method
oObj.collapseToSize (1, 1) ;
oObj.collapseToCurrentArray() ;
// check the size of result range
int cols = ( (XColumnRowRange)UnoRuntime.queryInterface(
XColumnRowRange.class, oObj) ).getColumns().getCount();
int rows = ( (XColumnRowRange)UnoRuntime.queryInterface(
XColumnRowRange.class, oObj) ).getRows().getCount();
if (cols == 1 && rows == height) {
bResult = true;
} else {
bResult = false;
log.println("The size of cell range must be 1x" + height +
", but after method call it was " + cols + "x" + rows);
}
// erase array formula
arrFormulaRange.setArrayFormula("");
// check if array formula has been cleared with last statement
try {
// if array formula isn't cleared exception is thrown
new_range.getCellByPosition(0,0).setValue(111) ;
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
bResult = false ;
log.println(
"Array formula hasn't been cleared with setArrayFormula(\"\")");
XSheetOperation clearRange = (XSheetOperation)