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