1 import com.sun.star.script.provider.XScriptContext; 2 import com.sun.star.uno.UnoRuntime; 3 import com.sun.star.text.XTextDocument; 4 import com.sun.star.text.XTextRange; 5 import com.sun.star.text.XText; 6 /** 7 * HelloWorld class 8 * 9 */ 10 public class HelloWorld { 11 public static void printHW(XScriptContext xSc) { 12 13 // getting the text document object 14 XTextDocument xtextdocument = (XTextDocument) UnoRuntime.queryInterface( 15 XTextDocument.class, xSc.getDocument()); 16 XText xText = xtextdocument.getText(); 17 XTextRange xTextRange = xText.getEnd(); 18 xTextRange.setString( "Hello World (in Java)" ); 19 20 }// printHW 21 22 } 23