2004/09/16 14:26:44 dfoster 1.2.30.2: #i33670# Rename the context variable to XSCRIPTCONTEXT 2004/07/23 09:55:16 dfoster 1.2.30.1: #i30606# Add descriptions to code in examples.
18 lines
626 B
Plaintext
18 lines
626 B
Plaintext
// Hello World in BeanShell
|
|
import com.sun.star.uno.UnoRuntime;
|
|
import com.sun.star.text.XTextDocument;
|
|
import com.sun.star.text.XText;
|
|
import com.sun.star.text.XTextRange;
|
|
|
|
// get the document from the scripting context which is made available to all
|
|
// scripts
|
|
oDoc = XSCRIPTCONTEXT.getDocument();
|
|
//get the XTextDocument interface
|
|
xTextDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,oDoc);
|
|
//get the XText interface
|
|
xText = xTextDoc.getText();
|
|
// get an (empty) XTextRange at the end of the document
|
|
xTextRange = xText.getEnd();
|
|
// set the string
|
|
xTextRange.setString( "Hello World (in BeanShell)" );
|