@see PrintWriter
*/
protected synchronized TestEnvironment createTestEnvironment(TestParameters tParam,
PrintWriter log) {
// creation of testobject here
XTextTable oObj = null;
TestEnvironment tEnv = null;
Object instance = null;
try {
oObj = SOF.createTextTable(xTextDoc);
instance = SOF.createTextTable(xTextDoc);
} catch (com.sun.star.uno.Exception uE) {
uE.printStackTrace(log);
throw new StatusException("Couldn't create testobj : " +
uE.getMessage(), uE);
}
int nRow = 6;
int nCol = 2;
oObj.initialize(nRow, nCol);
log.println("Creating instance...");
tEnv = new TestEnvironment(oObj);
if (SOF.getTableCollection(xTextDoc).getCount() == 0) {
try {
SOF.insertTextContent(xTextDoc, oObj);
} catch (com.sun.star.uno.Exception uE) {
uE.printStackTrace(log);
throw new StatusException("Couldn't create TextTable : " +
uE.getMessage(), uE);
}
}
XPropertySet props = (XPropertySet) UnoRuntime.queryInterface(
XPropertySet.class, oObj);
try {
props.setPropertyValue("ChartRowAsLabel", new Boolean(true));
props.setPropertyValue("ChartColumnAsLabel", new Boolean(true));
} catch (Exception e) {
e.printStackTrace(log);
}
//Adding relation for util.XTextTable
tEnv.addObjRelation("NROW", new Integer(nRow));
tEnv.addObjRelation("NCOL", new Integer(nCol));
//Adding ObjRelation for XCellRangeData
Object[][] newData = new Object[6][];
Object[] line = new Object[2];
line[0] = new Double(1.5);
line[1] = new Double(2.5);
newData[0] = line;
newData[1] = line;
newData[2] = line;
newData[3] = line;
newData[4] = line;
newData[5] = line;
tEnv.addObjRelation("NewData", newData);
//Adding relation for util.XSortable
final PrintWriter finalLog = log;
final XTextTable oTable = oObj;
tEnv.addObjRelation("SORTCHECKER",
new ifc.util._XSortable.XSortChecker() {
PrintWriter out = finalLog;
public void setPrintWriter(PrintWriter log) {
out = log;
}
public void prepareToSort() {
oTable.getCellByName("A1").setValue(4);
XTextRange textRange = (XTextRange) UnoRuntime.queryInterface(
XTextRange.class,
oTable.getCellByName("A2"));
textRange.setString("b");
oTable.getCellByName("A3").setValue(3);
textRange = (XTextRange) UnoRuntime.queryInterface(
XTextRange.class,
oTable.getCellByName("A4"));
textRange.setString("a");
oTable.getCellByName("A5").setValue(23);
textRange = (XTextRange) UnoRuntime.queryInterface(
XTextRange.class,
oTable.getCellByName("A6"));
textRange.setString("ab");
}
public boolean checkSort(boolean isSortNumbering,
boolean isSortAscending) {
out.println("Sort checking...");
boolean res = false;
String[] value = new String[6];
for (int i = 0; i < 6; i++) {
XCell cell = oTable.getCellByName("A" + (i + 1));
XTextRange textRange = (XTextRange) UnoRuntime.queryInterface(
XTextRange.class, cell);
value[i] = textRange.getString();
}