XCell xCell = (XCell)tEnv.getObjRelation("MAKEENTRYINCELL");
XSpreadsheetDocument xSheetDoc = (XSpreadsheetDocument)tEnv.getObjRelation("SPREADSHEET");
XInterface oObj = null;
XText oText = null;
XTextContent oContent = null;
XInterface aField = 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));
String[] services = _oMSF.getAvailableServiceNames();
for (int i=0; i<services.length; i++) {
if (services[i].startsWith("com.sun.star.text.FieldMaster")) {
mbCreateFieldMaster = true;
log.println("service " + i + ": " + services[i]);
}
}
if (mbCreateFieldMaster) {
Object FieldMaster = _oMSF.createInstance("com.sun.star.text.FieldMaster.User");
XPropertySet PFieldMaster = (XPropertySet) UnoRuntime.queryInterface
(XPropertySet.class,(XInterface) FieldMaster);
XDependentTextField xTF = (XDependentTextField)
UnoRuntime.queryInterface(XDependentTextField.class,aField);
PFieldMaster.setPropertyValue("Content","Some content");
xTF.attachTextFieldMaster(PFieldMaster);
}
oText = (XText)UnoRuntime.queryInterface(XText.class, xCell);
XTextCursor the_Cursor = oText.createTextCursor();
oText.insertTextContent(
the_Cursor, oContent, true);
} catch (com.sun.star.lang.WrappedTargetException e) {
log.println("Exception occured while creating test Object.");
e.printStackTrace(log);