XTextCursor xCursor = xTextDoc.getText().createTextCursor();
try {
XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory)
UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDoc);
Object o = xMultiServiceFactory.createInstance("com.sun.star.text.TextEmbeddedObject" );
XTextContent xTextContent = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, o);
String sChartClassID = "12dcae26-281f-416f-a234-c3086127382e";
XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTextContent);
xPropertySet.setPropertyValue( "CLSID", sChartClassID );
xTextDoc.getText().insertTextContent( xCursor, xTextContent, false );
}
catch(com.sun.star.uno.Exception e) {
e.printStackTrace((java.io.PrintWriter)log);
}
XTextEmbeddedObjectsSupplier oTEOS = (XTextEmbeddedObjectsSupplier) UnoRuntime.queryInterface(
XTextEmbeddedObjectsSupplier.class,
xTextDoc);
XNameAccess oEmObj = oTEOS.getEmbeddedObjects();
XIndexAccess oEmIn = (XIndexAccess) UnoRuntime.queryInterface(
XIndexAccess.class, oEmObj);
try {
oObj = (XInterface) AnyConverter.toObject(
new Type(XInterface.class), oEmIn.getByIndex(0));
} catch (com.sun.star.uno.Exception e) {
e.printStackTrace(log);
throw new StatusException("Couldn't get Object", e);
}
TestEnvironment tEnv = new TestEnvironment(oObj);
tEnv.addObjRelation("NoAttach", "SwXTextEmbeddedObject");
XTextFrame aFrame = SOF.createTextFrame(xTextDoc, 500, 500);
XText oText = xTextDoc.getText();
XTextCursor oCursor = oText.createTextCursor();
XTextContent the_content = (XTextContent) UnoRuntime.queryInterface(
XTextContent.class, aFrame);
try {
oText.insertTextContent(oCursor, the_content, true);
} catch (com.sun.star.lang.IllegalArgumentException e) {