XInterface oInstance = null;
XPropertySet aControl = null;
XPropertySet aControl2 = null;
XPropertySet aControl3 = null;
XPropertySet aControl4 = null;
XGridColumnFactory columns = null;
// creation of testobject here
// first we write what we are intend to do to log file
log.println("creating a test environment");
//get GridControlModel
String objName = "Grid";
XControlShape shape = FormTools.insertControlShape(xDrawDoc, 5000,
7000, 2000, 2000,
"GridControl");
oObj = shape.getControl();
log.println("creating a new environment for drawpage object");
TestEnvironment tEnv = new TestEnvironment(oObj);
try {
columns = (XGridColumnFactory) UnoRuntime.queryInterface(
XGridColumnFactory.class, oObj);
aControl = columns.createColumn("TextField");
aControl2 = columns.createColumn("DateField");
aControl3 = columns.createColumn("TextField");
aControl4 = columns.createColumn("TextField");
} catch (com.sun.star.lang.IllegalArgumentException e) {
// Some exception occures.FAILED
log.println("!!! Couldn't create instance : " + e);
throw new StatusException("Can't create column instances.", e);
}
XNameContainer aContainer = (XNameContainer) UnoRuntime.queryInterface(
XNameContainer.class, oObj);
try {
aContainer.insertByName("First", aControl);
aContainer.insertByName("Second", aControl2);
} catch (com.sun.star.lang.WrappedTargetException e) {
log.println("!!! Could't insert column Instance");
e.printStackTrace(log);
throw new StatusException("Can't insert columns", e);
} catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("!!! Could't insert column Instance");
e.printStackTrace(log);
throw new StatusException("Can't insert columns", e);
} catch (com.sun.star.container.ElementExistException e) {
log.println("!!! Could't insert column Instance");
e.printStackTrace(log);
throw new StatusException("Can't insert columns", e);
}
//Relations for XSelectionSupplier
tEnv.addObjRelation("Selections", new Object[] { aControl, aControl2 });
tEnv.addObjRelation("Comparer",
new Comparator() {
public int compare(Object o1, Object o2) {
XNamed named1 = (XNamed) UnoRuntime.queryInterface(
XNamed.class, o1);
XNamed named2 = (XNamed) UnoRuntime.queryInterface(
XNamed.class, o2);
if (named1.getName().equals(named2.getName())) {
return 0;
}
return -1;
}
public boolean equals(Object obj) {
return compare(this, obj) == 0;
}
});
int THRCNT = 1;
String count = (String)Param.get("THRCNT");
if (count != null)
THRCNT = Integer.parseInt(count);
// INSTANCEn : _XNameContainer; _XNameReplace
log.println("adding INSTANCEn as obj relation to environment");
try {
for (int n = 1; n < (3 * THRCNT + 1); n++) {
log.println("adding INSTANCE" + n +
" as obj relation to environment");
oInstance = columns.createColumn("TextField");
tEnv.addObjRelation("INSTANCE" + n, oInstance);
}
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log);
throw new StatusException("Can't create 'INSTANCEn' relations", e);