log.println("getting sheets");
XSpreadsheets xSpreadsheets = (XSpreadsheets)xSpreadsheetDoc.getSheets();
log.println("getting a sheet");
XSpreadsheet oSheet = null;
XIndexAccess oIndexAccess = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class, xSpreadsheets);
try {
oSheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class), oIndexAccess.getByIndex(1));
} catch (com.sun.star.lang.WrappedTargetException e) {
e.printStackTrace(log);
throw new StatusException( "Couldn't get a spreadsheet", e);
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
e.printStackTrace(log);
throw new StatusException( "Couldn't get a spreadsheet", e);
} catch (com.sun.star.lang.IllegalArgumentException e) {
e.printStackTrace(log);
throw new StatusException( "Couldn't get a spreadsheet", e);
}
TestEnvironment tEnv = new TestEnvironment(oObj);
tEnv.addObjRelation("XDispatchProvider.URL", ".uno:Copy") ;
log.println("adding 'Sheet' as ObjRelation");
tEnv.addObjRelation("Sheet", oSheet);
tEnv.addObjRelation("Frame",aModel.getCurrentController().getFrame());
tEnv.addObjRelation("SecondModel",aSecondModel);
tEnv.addObjRelation("FirstModel",aModel);
//Relation for XControlAccess
tEnv.addObjRelation("DOCUMENT", UnoRuntime.queryInterface(XComponent.class,xSpreadsheetDoc));
tEnv.addObjRelation("XControlAccess.isSheet", Boolean.TRUE);
//Relations for XSelectionSupplier
XCell cell_1 = null;
XCell cell_2 = null;
Object cellRange = null;
try {
cellRange = (Object)oSheet.getCellRangeByPosition(0, 0, 3, 3);
cell_1 = oSheet.getCellByPosition(5,5);
cell_2 = oSheet.getCellByPosition(7,7);
cell_2.setValue(17.5);
cell_1.setValue(5.5);
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
e.printStackTrace(log);
throw new StatusException("Couldn't get some cell", e);