rubyuno 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/CHANGES +16 -0
- data/Gemfile +4 -0
- data/LICENSE +202 -0
- data/README +46 -0
- data/Rakefile +603 -0
- data/ext/rubyuno/adapter.cxx +271 -0
- data/ext/rubyuno/extconf.rb +125 -0
- data/ext/rubyuno/libruno.def +26 -0
- data/ext/rubyuno/loader.cxx +184 -0
- data/ext/rubyuno/module.cxx +1263 -0
- data/ext/rubyuno/rubyuno.hxx +263 -0
- data/ext/rubyuno/runo.def +2 -0
- data/ext/rubyuno/runtime.cxx +524 -0
- data/ext/rubyuno/string.cxx +252 -0
- data/ext/rubyuno/type.cxx +358 -0
- data/lib/rubyloader.rb +302 -0
- data/lib/rubyscriptprovider.rb +1025 -0
- data/lib/rubyuno.rb +20 -0
- data/lib/rubyuno/uno.rb +105 -0
- data/lib/rubyuno/uno/connector.rb +97 -0
- data/lib/rubyuno/version.rb +3 -0
- data/rubyuno.gemspec +17 -0
- data/sample/calc-chart.rb +66 -0
- data/sample/dialog_listener.rb +70 -0
- data/sample/filter-names.rb +123 -0
- data/sample/inputbox.rb +74 -0
- data/sample/mri.rb +17 -0
- data/sample/open-doc1.rb +20 -0
- metadata +89 -0
data/sample/inputbox.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'runo'
|
4
|
+
|
5
|
+
module Runo
|
6
|
+
class << self
|
7
|
+
# Shows input box that is create at runtime.
|
8
|
+
# -> String|nil
|
9
|
+
def inputbox(message="", title="", default="", ctx=nil)
|
10
|
+
dlg_width, dlg_height = 350, 100
|
11
|
+
btn_width, btn_height = 80, 28
|
12
|
+
field_height = 28
|
13
|
+
if ! ctx
|
14
|
+
ctx = @@component_context
|
15
|
+
end
|
16
|
+
smgr = ctx.getServiceManager
|
17
|
+
desktop = smgr.createInstanceWithContext(
|
18
|
+
"com.sun.star.frame.Desktop", ctx)
|
19
|
+
pos_size = desktop.getActiveFrame.getContainerWindow.getPosSize
|
20
|
+
dlg = smgr.createInstanceWithContext(
|
21
|
+
"com.sun.star.awt.UnoControlDialog", ctx)
|
22
|
+
dlg_model = smgr.createInstanceWithContext(
|
23
|
+
"com.sun.star.awt.UnoControlDialogModel", ctx)
|
24
|
+
dlg.setModel(dlg_model)
|
25
|
+
dlg_model.Title = title
|
26
|
+
dlg.setPosSize((pos_size.Width - dlg_width)/2,
|
27
|
+
(pos_size.Height - dlg_height)/2,
|
28
|
+
dlg_width, dlg_height, PS_POSSIZE)
|
29
|
+
|
30
|
+
label_model = dlg_model.createInstance(
|
31
|
+
"com.sun.star.awt.UnoControlFixedTextModel")
|
32
|
+
dlg_model.insertByName("label", label_model)
|
33
|
+
edit_model = dlg_model.createInstance(
|
34
|
+
"com.sun.star.awt.UnoControlEditModel")
|
35
|
+
dlg_model.insertByName("edit", edit_model)
|
36
|
+
btn_ok_model = dlg_model.createInstance(
|
37
|
+
"com.sun.star.awt.UnoControlButtonModel")
|
38
|
+
dlg_model.insertByName("btn_ok", btn_ok_model)
|
39
|
+
btn_cancel_model = dlg_model.createInstance(
|
40
|
+
"com.sun.star.awt.UnoControlButtonModel")
|
41
|
+
dlg_model.insertByName("btn_cancel", btn_cancel_model)
|
42
|
+
|
43
|
+
btn_ok_model.setPropertyValues(
|
44
|
+
["PushButtonType", "DefaultButton", "Label"],
|
45
|
+
[1, true, "~OK"])
|
46
|
+
btn_cancel_model.setPropertyValues(
|
47
|
+
["PushButtonType", "Label"],
|
48
|
+
[2, "~Cancel"])
|
49
|
+
label_model.VerticalAlign = 1
|
50
|
+
dlg.getControl("label").setPosSize(4, 2,
|
51
|
+
dlg_width - 8, field_height, PS_POSSIZE)
|
52
|
+
dlg.getControl("edit").setPosSize(2, field_height + 6,
|
53
|
+
dlg_width - 4, field_height, PS_POSSIZE)
|
54
|
+
dlg.getControl("btn_ok").setPosSize(
|
55
|
+
dlg_width - btn_width - 5, dlg_height - field_height - 5,
|
56
|
+
btn_width, btn_height, PS_POSSIZE)
|
57
|
+
dlg.getControl("btn_cancel").setPosSize(
|
58
|
+
dlg_width - btn_width * 2 - 15, dlg_height - field_height - 5,
|
59
|
+
btn_width, btn_height, PS_POSSIZE)
|
60
|
+
|
61
|
+
label_model.Label = message
|
62
|
+
edit_model.Text = default
|
63
|
+
|
64
|
+
ret = nil
|
65
|
+
dlg.setVisible(true)
|
66
|
+
if dlg.execute == 1
|
67
|
+
ret = edit_model.Text
|
68
|
+
end
|
69
|
+
dlg.dispose
|
70
|
+
ret
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
data/sample/mri.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'uno'
|
4
|
+
|
5
|
+
# You can use extension to know well about UNO object.
|
6
|
+
# http://extensions.services.openoffice.org/project/MRI
|
7
|
+
#
|
8
|
+
# inspect method is one of general Ruby's Object instance method. So,
|
9
|
+
# you can not call it directory, use Runo.#invoke method.
|
10
|
+
|
11
|
+
ctx = Runo.component_context
|
12
|
+
smgr = ctx.getServiceManager
|
13
|
+
|
14
|
+
mri = smgr.createInstanceWithContext("mytools.Mri", ctx)
|
15
|
+
Runo.invoke(mri, 'inspect', [ctx])
|
16
|
+
|
17
|
+
|
data/sample/open-doc1.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'uno'
|
4
|
+
|
5
|
+
ctx = Runo.component_context
|
6
|
+
desktop = Runo.get_desktop
|
7
|
+
|
8
|
+
doc1 = desktop.loadComponentFromURL('private:factory/swriter', '_blank', 0, [])
|
9
|
+
text = doc1.getText
|
10
|
+
cursor = text.createTextCursor
|
11
|
+
cursor.setString('RUNO')
|
12
|
+
cursor.ParaStyleName = 'Heading 1'
|
13
|
+
|
14
|
+
para = text.appendParagraph([])
|
15
|
+
para.ParaStyleName = 'Text body'
|
16
|
+
para.setString('RUNO is a bridge between Ruby and UNO.')
|
17
|
+
para = text.finishParagraph([])
|
18
|
+
|
19
|
+
|
20
|
+
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyuno
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniel Vandersluis
|
9
|
+
- Tsutomu Uchino
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-07-06 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: Ruby-OpenOffice UNO native bridge
|
16
|
+
email:
|
17
|
+
- daniel@codexed.com
|
18
|
+
- hanya.runo@gmail.com
|
19
|
+
executables: []
|
20
|
+
extensions:
|
21
|
+
- ext/rubyuno/extconf.rb
|
22
|
+
extra_rdoc_files: []
|
23
|
+
files:
|
24
|
+
- .gitignore
|
25
|
+
- CHANGES
|
26
|
+
- Gemfile
|
27
|
+
- LICENSE
|
28
|
+
- README
|
29
|
+
- Rakefile
|
30
|
+
- doc/Rakefile
|
31
|
+
- doc/index.rd
|
32
|
+
- doc/rpc.rd
|
33
|
+
- doc/rubyloader.rd
|
34
|
+
- doc/runo.rd
|
35
|
+
- doc/scriptprovider.rd
|
36
|
+
- doc/toc/rpc.rd
|
37
|
+
- doc/toc/rubyloader.rd
|
38
|
+
- doc/toc/runo.rd
|
39
|
+
- doc/toc/scriptprovider.rd
|
40
|
+
- ext/rubyuno/adapter.cxx
|
41
|
+
- ext/rubyuno/extconf.rb
|
42
|
+
- ext/rubyuno/libruno.def
|
43
|
+
- ext/rubyuno/loader.cxx
|
44
|
+
- ext/rubyuno/module.cxx
|
45
|
+
- ext/rubyuno/rubyuno.hxx
|
46
|
+
- ext/rubyuno/runo.def
|
47
|
+
- ext/rubyuno/runtime.cxx
|
48
|
+
- ext/rubyuno/string.cxx
|
49
|
+
- ext/rubyuno/type.cxx
|
50
|
+
- lib/rubyloader.rb
|
51
|
+
- lib/rubyscriptprovider.rb
|
52
|
+
- lib/rubyuno.rb
|
53
|
+
- lib/rubyuno/uno.rb
|
54
|
+
- lib/rubyuno/uno/connector.rb
|
55
|
+
- lib/rubyuno/version.rb
|
56
|
+
- rubyuno.gemspec
|
57
|
+
- sample/calc-chart.rb
|
58
|
+
- sample/dialog_listener.rb
|
59
|
+
- sample/filter-names.rb
|
60
|
+
- sample/inputbox.rb
|
61
|
+
- sample/mri.rb
|
62
|
+
- sample/open-doc1.rb
|
63
|
+
homepage: http://www.github.com/dvandersluis/rubyuno
|
64
|
+
licenses: []
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.8.12
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: rubyuno is a Ruby-UNO (Universal Network Object) bridge, used to interact
|
87
|
+
with OpenOffice.org
|
88
|
+
test_files: []
|
89
|
+
has_rdoc:
|