XInterface oObj = null;
XText oText = null;
XTextContent oContent = null;
XInterface aField = null;
XTextFieldsSupplier xTextFieldsSupp = null;
try {
// we want to create an instance of ScCellFieldObj.
// to do this we must get an MultiServiceFactory.
XMultiServiceFactory _oMSF = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, xSheetDoc);
aField = (XInterface)
_oMSF.createInstance("com.sun.star.text.TextField.URL");
oContent = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, aField);
XSpreadsheets oSheets = xSheetDoc.getSheets() ;
XIndexAccess oIndexSheets = (XIndexAccess)
UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
XSpreadsheet oSheet = (XSpreadsheet) AnyConverter.toObject(
new Type(XSpreadsheet.class),oIndexSheets.getByIndex(0));
XCell oCell = oSheet.getCellByPosition(2,3);
oText = (XText)UnoRuntime.queryInterface(XText.class, oCell);
oText.insertTextContent(
oText.createTextCursor(), oContent, true);
xTextFieldsSupp = (XTextFieldsSupplier)
UnoRuntime.queryInterface(XTextFieldsSupplier.class, oCell);
oObj = xTextFieldsSupp.getTextFields().createEnumeration();
} catch (com.sun.star.lang.WrappedTargetException e) {
log.println("Exception occured while creating test Object.");
e.printStackTrace(log);
throw new StatusException("Couldn't create test object", e);
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
log.println("Exception occured while creating test Object.");
e.printStackTrace(log);
throw new StatusException("Couldn't create test object", e);
} catch (com.sun.star.lang.IllegalArgumentException e) {
log.println("Exception occured while creating test Object.");
e.printStackTrace(log);
throw new StatusException("Couldn't create test object", e);
} catch (com.sun.star.uno.Exception e) {
log.println("Exception occured while creating test Object.");
e.printStackTrace(log);
throw new StatusException("Couldn't create test object", e);
}
TestEnvironment tEnv = new TestEnvironment(oObj) ;
tEnv.addObjRelation("ENUM", xTextFieldsSupp.getTextFields());
return tEnv;
}