// Wszystko bazuje na przykładzie z OpenOffice.org
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
import com.sun.star.frame.XDesktop;
import com.sun.star.frame.XModel;
import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketAddress;
import drafts.com.sun.star.script.provider.XScriptContext;
import com.sun.star.text.XTextDocument;
import com.sun.star.text.XText;
import com.sun.star.text.XTextRange;
oDoc = XSCRIPTCONTEXT.getDocument();
xTextDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,oDoc);
xText = xTextDoc.getText();
xTextRange = xText.getEnd();
String tekst = xText.getString();
Socket socket = new Socket("127.0.0.1",17024);
OutputStream os = socket.getOutputStream();
os.write(("SayIt|"+tekst+"\n").getBytes());
return 0;
|