bootstrap connect Rony G. Flatscher 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

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}.

/* Directives are led in by two "::" and are carried out by the ooRexx ({%external http://www.ooRexx.org}) interpreter, before the program starts. Hence all public classes and routines defined via directives are available upon execution of the ooRexx program. */ ::requires UNO.CLS /* get special UNO ooRexx support, which itself calls the module BSF.CLS, thereby establishing full access to Java using BSF4Rexx */ /** * This public routine connects to a running OpenOffice. This OpenOffice is * listening on a specific port. It connects to this port. * * @param ooport * @return */ ::routine connectListeningOpenOffice public parse arg ooport -- Create an OO Component Context xRemoteContext = .uno~Bootstrap~createInitialComponentContext(.nil) -- create a connector, so that it can contact the office urlResolver = uno.loadClass("{%see com.sun.star.bridge.UnoUrlResolver}")~create(xRemoteContext); initialObject = urlResolver~resolve("uno:socket,host=localhost,port="ooport";urp;StarOffice.ServiceManager") xRemoteServiceManager = initialObject~{%see com.sun.star.lang.XMultiComponentFactory%XMultiComponentFactory} -- retrieve the component context as property (it is not yet -- exported from the office). Query for the XPropertySet interface. xProperySet = xRemoteServiceManager~{%see com.sun.star.beans.XPropertySet%XPropertySet} -- Get the default context from the office server. oDefaultContext = xProperySet~getPropertyValue("DefaultContext"); -- Query for the interface XComponentContext. xRemoteContext = oDefaultContext~{%see com.sun.star.uno.XComponentContext%XComponentContext} -- now create the desktop service -- NOTE: use the office component context here! desktop = xRemoteServiceManager~createInstanceWithContext("{%see com.sun.star.frame.Desktop}", xRemoteContext) -- You will need these Objects often, so define them global... /* Make the following objects globally available via the ooRexx environment directory ".local". Each entry there is available as environment symbol (an ooRexx symbol starting with a dot). */ .local~desktop = desktop -- available as ".desktop" .local~xRemoteContext = xRemoteContext -- available as ".xRemoteContext" .local~xRemoteServiceManager= xRemoteServiceManager -- available as ".xRemoteServiceManager" return any: say "No OpenOffice is listening. Cannot connect."
Initial version