I try to pass some text to HelloWorld javascript.
Here my Basic code:
Code: Select all
Sub Main
HelloJS
End Sub
Function HelloJS
Dim oSP, oJS
Dim param(0), s
oSP = ThisComponent.getScriptProvider()
oJS = oSP.getScript("vnd.sun.star.script:Library1.Hello.js?language=JavaScript&location=document")
s = oJS.invoke(Array("I say hello"),Array(),Array())
HelloJS = s
End Function
Code: Select all
importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.text.XTextDocument);
importClass(Packages.com.sun.star.text.XText);
importClass(Packages.com.sun.star.text.XTextRange);
importClass(Packages.com.sun.star.frame.XModel);
sSource = String(ARGUMENTS[0])
oDoc = UnoRuntime.queryInterface(XModel,XSCRIPTCONTEXT.getInvocationContext());
if ( !oDoc )
oDoc = XSCRIPTCONTEXT.getDocument();
xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc);
xText = xTextDoc.getText();
xTextRange = xText.getEnd();
xTextRange.setString( sSource );
How can I get the text?
Thanks