Top > OOoSF > JRuby > Automation

オートメーション Edit

Java でおこなうのと同じように。

  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
require 'java'
class Uno
  class << self
    def query(type, object)
      com.sun.star.uno.UnoRuntime.queryInterface(type.java_class, object)
    end
  end
end
 
def jruby_connect()
  begin
    loc_context = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(nil)
    xmsf = loc_context.getServiceManager()
    resolver = Uno.query(
      com.sun.star.bridge.XUnoUrlResolver,
      xmsf.createInstanceWithContext(
        "com.sun.star.bridge.UnoUrlResolver", loc_context))
    resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
  rescue => evar
    p "connection error: " + evar
  end
end
 
obj = jruby_connect()
if obj:
    ctx = Uno.query(com.sun.star.uno.XComponentContext, obj);
  if ctx:
      p "connected."
  end
end

socket では接続できるが pipe だと失敗した気がする。


Reload   New Lower page making Edit Freeze Diff Upload Copy Rename   Front page List of pages Search Recent changes Backup   Help   RSS of recent changes