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