 | OO-Snippets: Connect to Listening OpenOffice Variant 2 (UNO.CLS)Commons| Keywords | connect, bootstrap, UNO.CLS |
|---|
| Language | ooRexx |
|---|
| Application | Office |
|---|
| Authors | Rony G. Flatscher (initial)
|
|---|
| Supported Versions | 2.0.x |
|---|
| Supported OS | All |
|---|
| Question | How to connect to a already listening OpenOffice?
You can start OpenOffice in listening mode with e.g. this command:
soffice -accept=socket,host=localhost,port=8100;urp;
This commandline starts OpenOffice listening on port 8100.
|
|---|
| Answer | This snippet connects to a listening OpenOffice and creates a wordprocessor document. |
|---|
call UNO.CLS
localCC = .uno~bootstrap~createInitialComponentContext(.nil)
localSM = localCC~getServiceManager
localUUR = localSM~createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localCC)
localXUUR = localUUR~XUnoUrlResolver
hostname = "localhost"
hostport = 8100
unoUrl = "uno:socket,host="hostname",port="hostport";urp;StarOffice.NamingService"
say "connecting using the URL:" pp(unoURL)"..."
remoteXNS = localXUUR~resolve(unoUrl)~XNamingService
remoteXMSF = remoteXNS~getRegisteredObject("StarOffice.ServiceManager")~XMultiServiceFactory
remoteXD = remoteXMSF~createInstance("com.sun.star.frame.Desktop")~XDesktop
remoteXCL = remoteXD~XComponentLoader
writerComponent = remoteXCL~loadComponentFromURL("private:factory/swriter", "_blank", 0, .uno~noProps)
|
Changelog| Date | User | Modification |
|---|
| 2006-07-20 | RGF | Initial version |
|