diff options
Diffstat (limited to 'scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_')
-rw-r--r-- | scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_ | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_ new file mode 100644 index 000000000000..36e66aeeb20e --- /dev/null +++ b/scripting/java/org/openoffice/netbeans/modules/office/resources/templates/HelloWorld.java_ @@ -0,0 +1,41 @@ +// If using XMultiServiceFactory need to uncomment import directive below: +//import com.sun.star.lang.XMultiServiceFactory; + +// If using XDesktop need to uncomment import directive below: +//import com.sun.star.frame.XDesktop; + +import com.sun.star.uno.UnoRuntime; +import com.sun.star.lang.*; +import com.sun.star.text.*; + +import drafts.com.sun.star.script.framework.runtime.XScriptContext; + + +public class HelloWorld { + + public void printHello(XScriptContext xSc) { + + /* Methods available from XScriptContext: + xSc.getDocument() returns XModel + xSc.getDesktop() returns XDesktop + xSc.getMultiComponentFactory() returns XMultiComponentFactory + */ + + // Getting the current document as a component + XComponent xcomponent = xSc.getDocument(); + + // Getting the text document object + XTextDocument xtextdocument = (XTextDocument) UnoRuntime.queryInterface( +XTextDocument.class, xcomponent); + + //Getting the text object + XText oText = xtextdocument.getText(); + + //Create a cursor object + XTextCursor oCursor = oText.createTextCursor(); + + // Print out Hello World + oText.insertString( oCursor, "**** HELLO ****", false ); + } + +} |