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