 | OO-Snippets: Connect to Listening OpenOffice (ooRexx modeled after Java snippet)Commons| Keywords | bootstrap, connect |
|---|
| Language | ooRexx |
|---|
| Application | Office |
|---|
| Authors | Rony G. Flatscher
|
|---|
| Supported Versions | 2.0.x |
|---|
| Supported OS | All |
|---|
| Question | How to connect to a already listening OpenOffice?
You can start a OpenOffice in listening mode with e.g. this command:
soffice -accept="socket,host=localhost,port=9000;urp;StarOffice.ServiceManager"
This commandline starts OpenOffice listening on port 9000
|
|---|
| Answer | This public routine connects to a listening OpenOffice and makes the most important objects available via the environment directory ".local". Modelled after {%internal ./Office.ConnectToListeningOpenOffice.snip}. |
|---|
::requires UNO.CLS
::routine connectListeningOpenOffice public
parse arg ooport
xRemoteContext = .uno~Bootstrap~createInitialComponentContext(.nil)
urlResolver = uno.loadClass("com.sun.star.bridge.UnoUrlResolver")~create(xRemoteContext);
initialObject = urlResolver~resolve("uno:socket,host=localhost,port="ooport";urp;StarOffice.ServiceManager")
xRemoteServiceManager = initialObject~XMultiComponentFactory
xProperySet = xRemoteServiceManager~XPropertySet
oDefaultContext = xProperySet~getPropertyValue("DefaultContext");
xRemoteContext = oDefaultContext~XComponentContext
desktop = xRemoteServiceManager~createInstanceWithContext("com.sun.star.frame.Desktop", xRemoteContext)
.local~desktop = desktop
.local~xRemoteContext = xRemoteContext
.local~xRemoteServiceManager= xRemoteServiceManager
return
any:
say "No OpenOffice is listening. Cannot connect."
|
Changelog| Date | User | Modification |
|---|
| 2006-07-20 | RGF | Initial version |
|