Skip to content
cogniti edited this page Feb 28, 2011 · 4 revisions

Try to connect according to the following section of OpenOffice.org Developer’s Guide:
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/UNO_Interprocess_Connections

Start OpenOffice.org with -accept option. For example:
soffice "-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"
In this case, the instance of OpenOffice.org allows to connect from localhost and listening at port 2083.

# coding: utf-8
require 'runo'

def connect
  local_ctx = Runo.get_component_context
  local_smgr = local_ctx.getServiceManager
  resolver = local_smgr.createInstanceWithContext(
      'com.sun.star.bridge.UnoUrlResolver', local_ctx)
  resolver.resolve('uno:socket,host=localhost,port=2083;urp;StarOffice.ComponentContext')
end

ctx = connect
if ctx.nil?
  print 'failed to connect.'
  exit
end

smgr = ctx.getServiceManager
desktop = smgr.createInstanceWithContext('com.sun.star.frame.Desktop', ctx)
doc = desktop.loadComponentFromURL('private:factory/swriter', '_blank', 0, [])
doc.getText.setString('Honyo honyo.')
Clone this wiki locally