odf-converter 0.0.5 → 0.0.6
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.
- data/.gitignore +1 -0
- data/lib/odf/config.rb +3 -1
- data/lib/odf/converter.rb +12 -2
- data/lib/odf/converter/version.rb +1 -1
- metadata +2 -2
data/.gitignore
CHANGED
data/lib/odf/config.rb
CHANGED
@@ -22,6 +22,7 @@ module ODF
|
|
22
22
|
config_accessor :connection_type
|
23
23
|
config_accessor :host
|
24
24
|
config_accessor :port
|
25
|
+
config_accessor :spawn_cmd
|
25
26
|
end
|
26
27
|
|
27
28
|
# this is ugly. why can't we pass the default value to config_accessor...?
|
@@ -29,6 +30,7 @@ module ODF
|
|
29
30
|
config.office_bin = "soffice"
|
30
31
|
config.connection_type = :socket
|
31
32
|
config.host = :localhost
|
32
|
-
config.port = 2083
|
33
|
+
config.port = 2083
|
34
|
+
config.spawn_cmd = nil
|
33
35
|
end
|
34
36
|
end
|
data/lib/odf/converter.rb
CHANGED
@@ -7,6 +7,8 @@ require "odf/converter/filters/export"
|
|
7
7
|
require "odf/converter/hash"
|
8
8
|
require "odf/converter/version"
|
9
9
|
|
10
|
+
Rubyuno.uno_require 'com.sun.star.lang.IllegalArgumentException'
|
11
|
+
|
10
12
|
module ODF
|
11
13
|
class Converter
|
12
14
|
class DocumentConversionError < Exception; end
|
@@ -15,7 +17,14 @@ module ODF
|
|
15
17
|
|
16
18
|
def initialize
|
17
19
|
config = ODF.config
|
18
|
-
@ctx = Uno::Connector.bootstrap(
|
20
|
+
@ctx = Uno::Connector.bootstrap(
|
21
|
+
office: config.office_bin.to_s,
|
22
|
+
type: config.connection_type.to_s,
|
23
|
+
host: config.host.to_s,
|
24
|
+
port: config.port,
|
25
|
+
spawn_cmd: config.spawn_cmd
|
26
|
+
)
|
27
|
+
|
19
28
|
@smgr = @ctx.getServiceManager
|
20
29
|
@desktop = @smgr.createInstanceWithContext("com.sun.star.frame.Desktop", @ctx)
|
21
30
|
end
|
@@ -77,6 +86,7 @@ module ODF
|
|
77
86
|
|
78
87
|
begin
|
79
88
|
@document = desktop.loadComponentFromURL(input_url, "_blank", 0, props.to_uno_properties)
|
89
|
+
raise DocumentConversionError, "could not load document" unless @document
|
80
90
|
rescue Rubyuno::Com::Sun::Star::Lang::IllegalArgumentException => e
|
81
91
|
raise DocumentConversionError, e.message
|
82
92
|
end
|
@@ -110,4 +120,4 @@ module ODF
|
|
110
120
|
true
|
111
121
|
end
|
112
122
|
end
|
113
|
-
end
|
123
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: odf-converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyuno
|