1// Hello World in JavaScript
2importClass(Packages.com.sun.star.uno.UnoRuntime);
3importClass(Packages.com.sun.star.text.XTextDocument);
4importClass(Packages.com.sun.star.text.XText);
5importClass(Packages.com.sun.star.text.XTextRange);
6
7//get the document from the scripting context
8oDoc = XSCRIPTCONTEXT.getDocument();
9//get the XTextDocument interface
10xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc);
11//get the XText interface
12xText = xTextDoc.getText();
13//get an (empty) XTextRange interface at the end of the text
14xTextRange = xText.getEnd();
15//set the text in the XTextRange
16xTextRange.setString( "Hello World (in JavaScript)" );
17