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