1*d71964d5SAndrew Rist// ************************************************************* 2*d71964d5SAndrew Rist// 3*d71964d5SAndrew Rist// Licensed to the Apache Software Foundation (ASF) under one 4*d71964d5SAndrew Rist// or more contributor license agreements. See the NOTICE file 5*d71964d5SAndrew Rist// distributed with this work for additional information 6*d71964d5SAndrew Rist// regarding copyright ownership. The ASF licenses this file 7*d71964d5SAndrew Rist// to you under the Apache License, Version 2.0 (the 8*d71964d5SAndrew Rist// "License"); you may not use this file except in compliance 9*d71964d5SAndrew Rist// with the License. You may obtain a copy of the License at 10*d71964d5SAndrew Rist// 11*d71964d5SAndrew Rist// http://www.apache.org/licenses/LICENSE-2.0 12*d71964d5SAndrew Rist// 13*d71964d5SAndrew Rist// Unless required by applicable law or agreed to in writing, 14*d71964d5SAndrew Rist// software distributed under the License is distributed on an 15*d71964d5SAndrew Rist// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d71964d5SAndrew Rist// KIND, either express or implied. See the License for the 17*d71964d5SAndrew Rist// specific language governing permissions and limitations 18*d71964d5SAndrew Rist// under the License. 19*d71964d5SAndrew Rist// 20*d71964d5SAndrew Rist// ************************************************************* 21cdf0e10cSrcweir// Hello World in JavaScript 22cdf0e10cSrcweirimportClass(Packages.com.sun.star.uno.UnoRuntime); 23cdf0e10cSrcweirimportClass(Packages.com.sun.star.text.XTextDocument); 24cdf0e10cSrcweirimportClass(Packages.com.sun.star.text.XText); 25cdf0e10cSrcweirimportClass(Packages.com.sun.star.text.XTextRange); 26cdf0e10cSrcweir 27cdf0e10cSrcweir//get the document from the scripting context 28cdf0e10cSrcweiroDoc = XSCRIPTCONTEXT.getDocument(); 29cdf0e10cSrcweir//get the XTextDocument interface 30cdf0e10cSrcweirxTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc); 31cdf0e10cSrcweir//get the XText interface 32cdf0e10cSrcweirxText = xTextDoc.getText(); 33cdf0e10cSrcweir//get an (empty) XTextRange interface at the end of the text 34cdf0e10cSrcweirxTextRange = xText.getEnd(); 35cdf0e10cSrcweir//set the text in the XTextRange 36cdf0e10cSrcweirxTextRange.setString( "Hello World (in JavaScript)" ); 37