XComponent xcomponent = xcomponentloader.loadComponentFromURL(
"private:factory/swriter", "_blank", 0,
new PropertyValue[0] );
// Querying for the interface XTextDocument on the xcomponent
XTextDocument xtextdocument = ( XTextDocument ) UnoRuntime.queryInterface(
XTextDocument.class, xcomponent );
// Querying for the interface XMultiServiceFactory on the xtextdocument
XMultiServiceFactory xmultiservicefactoryDocument =
( XMultiServiceFactory ) UnoRuntime.queryInterface(
XMultiServiceFactory.class, xtextdocument );
// Providing a log file for output
PrintWriter printwriterLog = new PrintWriter( new BufferedWriter(
new FileWriter( "log.txt" ) ) );
Object objectGraphic = null;
try {
// Creating the service GraphicObject
objectGraphic =
xmultiservicefactoryDocument.createInstance(
"com.sun.star.text.GraphicObject" );
}
catch ( Exception exception ) {
System.out.println( "Could not create instance" );
exception.printStackTrace( printwriterLog );
}
// Getting the text
XText xtext = xtextdocument.getText();
// Getting the cursor on the document
XTextCursor xtextcursor = xtext.createTextCursor();
// Querying for the interface XTextContent on the GraphicObject