rubyuno 0.3.2 → 0.3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -130,7 +130,7 @@ Runtime::getTypes(const Runtime &runtime, VALUE *value)
130
130
  ID id = rb_intern("getTypes");
131
131
 
132
132
  if (! rb_respond_to(*value, id))
133
- rb_raise(rb_eArgError, "illegal argument does not support com.sun.star.lang.XTypeProvider interface (%s)", value);
133
+ rb_raise(rb_eArgError, "illegal argument does not support com.sun.star.lang.XTypeProvider interface");
134
134
  VALUE types = rb_funcall(*value, id, 0);
135
135
 
136
136
  long size = RARRAY_LEN(types);
@@ -44,54 +44,70 @@ module Uno
44
44
 
45
45
  # Read Professional UNO chapter of Developer's Guide about
46
46
  # UNO Remote protocol.
47
- def self.bootstrap(office="soffice", type="socket",
48
- host="localhost", port=2083, pipe_name=nil, nodelay=false)
49
- url, argument = self.url_construct(type, host, port, pipe_name, nodelay)
47
+ def self.bootstrap(options = {})
48
+ options = {
49
+ :office => 'soffice',
50
+ :type => 'socket',
51
+ :host => '127.0.0.1',
52
+ :port => 2083,
53
+ :nodelay => false
54
+ }.merge(options)
55
+
56
+ url, argument = self.url_construct(options[:type], options[:host], options[:port], options[:pipe_name], options[:nodelay])
57
+
50
58
  r = self.resolver_get
51
59
  c = nil
52
60
  n = 0
61
+
53
62
  begin
54
63
  c = self.connect(url, r)
55
64
  rescue Rubyuno::Com::Sun::Star::Uno::Exception => e
56
- raise e if e.uno_instance_of?(
57
- Rubyuno::Com::Sun::Star::Connection::ConnectionSetupException)
65
+ raise e if e.instance_of?(Rubyuno::Com::Sun::Star::Connection::ConnectionSetupException)
66
+
58
67
  n += 1
59
68
  (raise NoConnectionError,"") if n > @@retry
60
- spawn(ENV, office, argument)
69
+
70
+ if options[:spawn_cmd]
71
+ system options[:spawn_cmd]
72
+ else
73
+ spawn(ENV, options[:office], argument)
74
+ end
75
+
61
76
  sleep(@@sleep_time)
77
+
62
78
  retry
63
79
  end
80
+
64
81
  return c
65
82
  end
66
83
 
67
- def self.connect(url, resolver=nil)
84
+ def self.connect(url, resolver = nil)
68
85
  resolver = self.resolver_get unless resolver
69
86
  return resolver.resolve(url)
70
87
  end
71
-
72
- def self.url_construct(type="socket",
73
- host="localhost", port=2083, pipe_name=nil, nodelay=false)
88
+
89
+ def self.url_construct(type = "socket", host = "127.0.0.1", port = 2083, pipe_name = nil, nodelay = false)
74
90
  case type
75
- when "socket"
76
- part = "socket,host=#{host},port=#{port}," +
77
- "tcpNoDelay=#{nodelay ? 1 : 0};urp;"
78
- url = "uno:#{part}StarOffice.ComponentContext"
79
- argument = "-accept=#{part}StarOffice.ServiceManager"
80
- when "pipe"
81
- pipe_name = "#{PIPE_NAME_PREFIX}#{srand * 10000}" unless pipe_name
82
- part = "pipe,name=#{pipe_name};urp;"
83
- url = "uno:#{part}StarOffice.ServiceManager"
84
- argument = "-accept=#{part}StarOffice.ComponentContext"
85
- else
86
- raise ArgumentError, "Illegal connection type (#{type})"
91
+ when "socket"
92
+ part = "socket,host=#{host},port=#{port}," +
93
+ "tcpNoDelay=#{nodelay ? 1 : 0};urp;"
94
+ url = "uno:#{part}StarOffice.ComponentContext"
95
+ argument = "-headless -nologo -nofirststartwizard -accept=#{part}StarOffice.ServiceManager"
96
+ when "pipe"
97
+ pipe_name = "#{PIPE_NAME_PREFIX}#{srand * 10000}" unless pipe_name
98
+ part = "pipe,name=#{pipe_name};urp;"
99
+ url = "uno:#{part}StarOffice.ServiceManager"
100
+ argument = "-headless -nologo -nofirststartwizard -accept=#{part}StarOffice.ComponentContext"
101
+ else
102
+ raise ArgumentError, "Illegal connection type (#{type})"
87
103
  end
104
+
88
105
  return url, argument
89
106
  end
90
-
107
+
91
108
  def self.resolver_get
92
109
  ctx = Rubyuno.get_component_context
93
- return ctx.getServiceManager.createInstanceWithContext(
94
- "com.sun.star.bridge.UnoUrlResolver", ctx)
110
+ return ctx.getServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", ctx)
95
111
  end
96
112
  end
97
113
  end
@@ -1,3 +1,3 @@
1
1
  module Rubyuno
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyuno
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-07 00:00:00.000000000 Z
13
+ date: 2013-08-15 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Ruby-OpenOffice UNO native bridge
16
16
  email:
@@ -67,20 +67,20 @@ rdoc_options: []
67
67
  require_paths:
68
68
  - lib
69
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
70
  requirements:
72
71
  - - ! '>='
73
72
  - !ruby/object:Gem::Version
74
73
  version: '0'
75
- required_rubygems_version: !ruby/object:Gem::Requirement
76
74
  none: false
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
76
  requirements:
78
77
  - - ! '>='
79
78
  - !ruby/object:Gem::Version
80
79
  version: '0'
80
+ none: false
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 1.8.12
83
+ rubygems_version: 1.8.24
84
84
  signing_key:
85
85
  specification_version: 3
86
86
  summary: rubyuno is a Ruby-UNO (Universal Network Object) bridge, used to interact