Trail_Calc 1.0.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e524b7f7644ffc6e81a394f58e5a2c7d2383c6f6
4
+ data.tar.gz: 948e868f508a398b21607b30f75a91243ebb7f52
5
+ SHA512:
6
+ metadata.gz: 5a19df04f5c3da76238985e7295424e3db280cd60c094c2c16b32902e20acd3b1a2a074a5967f21c48d15617ede56c31ce985f6a38007185027a1a89a0a72c25
7
+ data.tar.gz: 6408433715a3ba8ea48753c606ac051b10aec056f453a5e08c8df59d2162da1a2144545fc4f6c6613277d16ab7e488325cefa65cd9cc97dcdf71174b747adf85
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in Trail_Calc.gemspec
4
+ gemspec
@@ -0,0 +1,39 @@
1
+ # TrailCalc
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'Trail_Calc'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install Trail_Calc
18
+
19
+ ## Usage
20
+
21
+ require 'trail_calc'
22
+
23
+ openCalcWorkbook("file.ods") do |book|
24
+ sheet = book.get_sheet("DataSheet")
25
+ sheet[0,3] = 1
26
+ ...
27
+ book.save
28
+ end
29
+
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/MtTrail/Trail_Calc.
39
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'Trail_Calc/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "Trail_Calc"
8
+ spec.version = TrailCalc::VERSION
9
+ spec.authors = ["Mt.Trail"]
10
+ spec.email = ["trail@trail4you.com"]
11
+
12
+ spec.summary = %q{handling OpenOffice.org's CALC from Ruby.}
13
+ spec.description = %q{handling OpenOffice.org's CALC from Ruby.}
14
+ spec.homepage = "https://github.com/MtTrail/Trail_Calc"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.12"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "Trail_Calc"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,1033 @@
1
+ #! ruby -EWindows-31J
2
+ # -*- mode:ruby; coding:Windows-31J -*-
3
+
4
+ require "Trail_Calc/version"
5
+ require 'win32ole'
6
+ require 'date'
7
+
8
+ #= Trail_Calc
9
+ #== OpenOffice.org Calc�p ruby�g�����W���[��
10
+ #
11
+ #* OpenOffice.org(LibreOffice)��Calc��ruby���瑀�삷�邽�߂�ruby�g�����W���[���ł��B
12
+ #
13
+ #Authors:: Mt.Trail
14
+ #Version:: Ver. 1.03 2016/08/02 Mt.Trail
15
+ #* Ver. 1.03 : gem��
16
+ #* Ver. 1.02 : excel�`�����ł̕ۑ��@�\��lj��A�݊����ɂ͖�肠��A�`���[�g�͈͕̔ύX��bugfix
17
+ #* ver. 1.01 : �`���[�g�̉摜�o�͋@�\�lj�
18
+ #* Ver. 1.00 : ������J��
19
+ #
20
+ #Copyright:: Copyright (C) Mt.Trail 2015 All rights reserved.
21
+ #License:: GPL version 2
22
+ #
23
+ #
24
+ #==�ړI
25
+ #* ruby����OpenOffice.org��Calc���ȒP�ɑ��삷�邱�ƁB
26
+ #
27
+ #* Excel�̖����‹��ŕ\��O���t�������X�V���邽�߂ɍ쐬���܂����B
28
+ #* ��{�I�ɂ̓V�[�g�̃��C�A�E�g��`���[�g�̌`������Calc�ō쐬���f�[�^�̒lj���ύX������������ړI�ō쐬���Ă��܂��B
29
+ #* �ł�����A�ڍׂȃv���p�e�B�̐ݒ��A�V�����`���[�g�̍쐬���̓T�|�[�g���Ă��܂���B
30
+ #* ������ݒ肵���e���v���[�g�̈��p�ӂ��Ă��������̃R�s�[�ŏ�����ݒ肵�Ă��������B
31
+ #
32
+ #= ���p���@
33
+ #* ruby�X�N���v�g��require���ė��p���Ă��������B
34
+ #
35
+ #== �g�p��
36
+ # require 'trail_calc'
37
+ #
38
+ # openCalcWorkbook("file.ods") do |book|
39
+ # sheet = book.get_sheet("DataSheet")
40
+ # sheet[0,3] = 1
41
+ # ...
42
+ # book.save
43
+ # end
44
+ #
45
+ #==�h�L�������g����
46
+ #
47
+ # rdoc --title Trail_Calc --main Trail_calc --all Trail_calc.rb
48
+
49
+ module TrailCalc
50
+ # Dumy module for RDOC
51
+ end
52
+
53
+
54
+ #----------------------------------------------------
55
+ #== �ėp�֐�
56
+ #=== �F�R�[�h����
57
+ # �ԁA�΁A�‚�8bit�l(0����255)�Ŏw�肵��24bit�̐F�R�[�h���쐬���܂��B
58
+ #
59
+ # _red_ :: ��(0-255)
60
+ # _green_ :: ��(0-255)
61
+ # _blue_ :: ��(0-255)
62
+ #
63
+ def rgb(red, green, blue)
64
+ return red << 16 | green << 8 | blue
65
+ end
66
+
67
+ #=== OpenOffice.org�̎�������ruby�̎����֕ϊ�
68
+ #
69
+ # _t_:: OOo�̓��t������\��double�̐��l
70
+ #
71
+ def time_ooo2ruby(t) ## t ��OOo�̓��t������\��double�̐��l
72
+ #OOo�̊�̓f�t�H���g����1899/12/30��
73
+ #Apple��1904/1/1, StartOffice��1900/1/1
74
+ #ruby��1970//1/1 9:0:0 (JST������+9����)
75
+ diff = -2209194000 # Time.at(Time.new(1899,12,30)).to_i
76
+ Time.at(t * 24 * 60 * 60 + diff +0.1) ## 0.1�͔����ȕϊ��덷�̕␳�p
77
+ end
78
+
79
+ #=== ruby�̎�������OpenOffice.org�̎����֕ϊ�
80
+ #
81
+ # _t_:: ruby��Time�I�u�W�F�N�g
82
+ #
83
+ def time_ruby2ooo(t) ## t ruby��Time�I�u�W�F�N�g
84
+ diff = -2209194000 # Time.at(Time.new(1899,12,30)).to_i
85
+ d = (t.to_i - diff)/(24.0 * 60.0 * 60.0)
86
+ end
87
+
88
+ #=== ��΃p�X�̎擾
89
+ #
90
+ # _filename_ :: �t�@�C����
91
+ #
92
+ def getAbsolutePath filename
93
+ fso = WIN32OLE.new('Scripting.FileSystemObject')
94
+ fn = fso.GetAbsolutePathName(filename)
95
+ fn.gsub!(/\\/,'/')
96
+ fn
97
+ end
98
+
99
+
100
+ #----------------------------------------------------
101
+ #== �`���[�g�h�L�������g����
102
+ #
103
+ # �`���[�g�h�L�������g�N���X�̊g�����W���[��
104
+ # �`���[�g�h�L�������g���o�����Ɏ����I�ɑg�ݍ��܂��B
105
+
106
+ module CalcChartDoc
107
+
108
+ #=== �`���[�g�̃^�C�g���擾
109
+ #
110
+ # ret::������
111
+ def get_title
112
+ self.getTitle.String
113
+ end
114
+
115
+ #=== �`���[�g�̃^�C�g���ݒ�
116
+ #
117
+ def set_title(name)
118
+ t = self.getTitle
119
+ t.String = name
120
+ end
121
+
122
+ #=== �`���[�g�̃T�u�^�C�g���擾
123
+ #
124
+ # ret::������
125
+ def get_subtitle
126
+ self.getSubTitle.String
127
+ end
128
+
129
+ #=== �`���[�g�̃T�u�^�C�g���ݒ�
130
+ #
131
+ def set_subtitle(name)
132
+ t = self.getSubTitle
133
+ t.String = name
134
+ end
135
+
136
+ #=== �ύX���ꂽ�����ׂ�
137
+ # OOo�W��
138
+ #
139
+ # isModified()
140
+ # Modified
141
+ # ret::Bool
142
+
143
+ #=== �ۑ�
144
+ # OOo�W��
145
+ #
146
+ # store()
147
+
148
+ #=== X���̍ŏ��l���擾
149
+ #
150
+ # ret::double
151
+ def get_Xmin
152
+ self.Diagram.XAxis.Min
153
+ end
154
+
155
+ #=== X���̍ő�l���擾
156
+ #
157
+ # ret::double
158
+ def get_Xmax
159
+ self.Diagram.XAxis.Max
160
+ end
161
+
162
+ #=== X���̍ŏ��l��ݒ�
163
+ #
164
+ # _t_:: OOo�ł�double�̒l�A�����̏ꍇ��double�ŕ\�������B
165
+ def set_Xmin(t) ## t ��OOo�ł̒l
166
+ self.Diagram.XAxis.Min = t
167
+ end
168
+
169
+ #=== X���̍ő�l��ݒ�
170
+ #
171
+ # _t_:: OOo�ł�double�̒l�A�����̏ꍇ��double�ŕ\�������B
172
+ def set_Xmax(t) ## t ��OOo�ł̒l
173
+ self.Diagram.XAxis.Max = t
174
+ end
175
+
176
+
177
+ #== �`���[�g�̃e���v���[�g
178
+ #
179
+ # �`���[�g�̃e���v���[�g�̎�ނ�\��������̔z��B
180
+ # �擪���f�t�H���g�l�Ƃ���B
181
+
182
+ #=== �_�O���t
183
+ # Role
184
+ # categories
185
+ # values-y
186
+ ChartTemplateBar = [
187
+ "com.sun.star.chart2.template.Column", # 0 # �c
188
+ "com.sun.star.chart2.template.StackedColumn", # 1 # �c�ςݏグ
189
+ "com.sun.star.chart2.template.PercentStackedColumn", # 2 # �c�ςݏグ�p�[�Z���g
190
+ "com.sun.star.chart2.template.ThreeDColumnDeep", # 3 # 3D �c���s������
191
+ "com.sun.star.chart2.template.ThreeDColumnFlat", # 4 # 3D �c���s���Ȃ�
192
+ "com.sun.star.chart2.template.PercentStackedThreeDColumnFlat", # 5 # 3D �c�ςݏグ
193
+ "com.sun.star.chart2.template.StackedThreeDColumnFlat", # 6 # 3D �c�ςݏグ�p�[�Z���g
194
+ "com.sun.star.chart2.template.Bar", # 7 # ��
195
+ "com.sun.star.chart2.template.StackedBar", # 8 # ���ςݏグ
196
+ "com.sun.star.chart2.template.PercentStackedBar", # 9 # ���ςݏグ�p�[�Z���g
197
+ "com.sun.star.chart2.template.ThreeDBarDeep", # 10 # 3D �����s������
198
+ "com.sun.star.chart2.template.ThreeDBarFlat", # 11 # 3D �����s���Ȃ�
199
+ "com.sun.star.chart2.template.StackedThreeDBarFlat", # 12 # 3D ���ςݏグ
200
+ "com.sun.star.chart2.template.PercentStackedThreeDBarFlat" # 13 # 3D ���ςݏグ�p�[�Z���g
201
+ ]
202
+ #
203
+ #=== �~�O���t
204
+ # Role
205
+ # categories
206
+ # values-y
207
+ ChartTemplatePie = [
208
+ "com.sun.star.chart2.template.Pie", # 0 # ��^
209
+ "com.sun.star.chart2.template.PieAllExploded", # 1 # ��^����
210
+ "com.sun.star.chart2.template.ThreeDPie", # 2 # 3D ��^
211
+ "com.sun.star.chart2.template.ThreeDPieAllExploded" # 3 # 3D ��^����
212
+ ]
213
+ #=== �h�[�i�c�O���t
214
+ ChartTemplateDonut = [
215
+ "com.sun.star.chart2.template.Donut", # 0 # �h�[�i�c
216
+ "com.sun.star.chart2.template.DonutAllExploded", # 1 # �h�[�i�c����
217
+ "com.sun.star.chart2.template.ThreeDDonut", # 2 # 3D �h�[�i�c
218
+ "com.sun.star.chart2.template.ThreeDDonutAllExploded" # 3 # 3D �h�[�i�c����
219
+ ]
220
+ #
221
+ #=== �G���A�O���t
222
+ # Role
223
+ # categories
224
+ # values-y
225
+ ChartTemplateArea = [
226
+ "com.sun.star.chart2.template.Area", # 0 # �G���A
227
+ "com.sun.star.chart2.template.StackedArea", # 1 # �ςݏグ
228
+ "com.sun.star.chart2.template.ThreeDArea", # 2 # 3D
229
+ "com.sun.star.chart2.template.StackedThreeDArea", # 3 # 3D �ςݏグ
230
+ "com.sun.star.chart2.template.PercentStackedArea", # 4 # �ςݏグ�p�[�Z���g
231
+ "com.sun.star.chart2.template.PercentStackedThreeDArea" # 5 # 3D �ςݏグ�p�[�Z���g
232
+ ]
233
+ #
234
+ #=== �܂��
235
+ ChartTemplateLine = [
236
+ "com.sun.star.chart2.template.Line", # 0 # ��
237
+ "com.sun.star.chart2.template.Symbol", # 1 # �_
238
+ "com.sun.star.chart2.template.LineSymbol", # 2 # �_�Ɛ�
239
+ "com.sun.star.chart2.template.ThreeDLine", # 3 # 3D ��
240
+ "com.sun.star.chart2.template.ThreeDLineDeep", # 4 # 3D �����s������
241
+ "com.sun.star.chart2.template.StackedLine", # 6 # ���ςݏグ
242
+ "com.sun.star.chart2.template.StackedSymbol", # 5 # �_�ςݏグ
243
+ "com.sun.star.chart2.template.StackedLineSymbol", # 7 # �_�Ɛ��ςݏグ
244
+ "com.sun.star.chart2.template.StackedThreeDLine", # 8 # 3D ���ςݏグ
245
+ "com.sun.star.chart2.template.PercentStackedSymbol", # 9 # �_�ςݏグ�p�[�Z���g
246
+ "com.sun.star.chart2.template.PercentStackedLine", # 10 # ���ςݏグ�p�[�Z���g
247
+ "com.sun.star.chart2.template.PercentStackedLineSymbol", # 11 # �_�Ɛ��ςݏグ�p�[�Z���g
248
+ "com.sun.star.chart2.template.PercentStackedThreeDLine" # 12 # 3D ���ςݏグ�p�[�Z���g
249
+ ]
250
+ #
251
+ #=== �U�z�}
252
+ # Role
253
+ # categories: �n��̃��x��
254
+ # values-x : X �f�[�^
255
+ # values-y: Y �f�[�^
256
+ ChartTemplateScatter = [
257
+ "com.sun.star.chart2.template.ScatterLine", # 0 # ���C���̂�
258
+ "com.sun.star.chart2.template.ScatterLineSymbol", # 1 # ���C���ƃf�[�^�_
259
+ "com.sun.star.chart2.template.ScatterSymbol", # 2 # �f�[�^�_
260
+ "com.sun.star.chart2.template.ThreeDScatter" # 3 # 3D
261
+ ]
262
+ #
263
+ #=== ���[�_�[��
264
+ # Role
265
+ # categories
266
+ # values-y
267
+ ChartTemplateNet = [
268
+ "com.sun.star.chart2.template.NetLine", # 0 # ��
269
+ "com.sun.star.chart2.template.Net", # 1 # �_�Ɛ�
270
+ "com.sun.star.chart2.template.NetSymbol", # 2 # �_
271
+ "com.sun.star.chart2.template.StackedNet", # 3 # �ςݏグ�_�Ɛ�
272
+ "com.sun.star.chart2.template.StackedNetLine", # 4 # �ςݏグ��
273
+ "com.sun.star.chart2.template.StackedNetSymbol", # 5 # �ςݏグ�_
274
+ "com.sun.star.chart2.template.PercentStackedNet", # 6 # �_�Ɛ��ςݏグ�p�[�Z���g
275
+ "com.sun.star.chart2.template.PercentStackedNetLine", # 7 # ���ςݏグ�p�[�Z���g
276
+ "com.sun.star.chart2.template.PercentStackedNetSymbol" # 8 # �_�ςݏグ�p�[�Z���g
277
+ ]
278
+
279
+ #=== ���[�_�[��(�h��‚Ԃ�)
280
+ ChartTemplateFilledNet = [
281
+ "com.sun.star.chart2.template.FilledNet", # 0 # 3.2
282
+ "com.sun.star.chart2.template.StackedFilledNet", # 1 # 3.2
283
+ "com.sun.star.chart2.template.PercentStackedFilledNet" # 2 # 3.2
284
+ ]
285
+
286
+ #=== �X�g�b�N�`���[�g
287
+ ChartTemplateStock = [
288
+ "com.sun.star.chart2.template.StockLowHighClose", # 0 #
289
+ "com.sun.star.chart2.template.StockOpenLowHighClose", # 1 #
290
+ "com.sun.star.chart2.template.StockVolumeLowHighClose", # 2 #
291
+ "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" # 3 #
292
+ ]
293
+
294
+ #=== �o�u���`���[�g
295
+ ChartTemplateBubble = [
296
+ "com.sun.star.chart2.template.Bubble" # 0 #
297
+ ]
298
+
299
+
300
+ #== �`���[�g�̎��
301
+ #
302
+ # �`���[�g�̎�ނƃe���v���[�g�̊֘A�t��
303
+ #
304
+ ChartTypeList = {
305
+ "com.sun.star.chart.AreaDiagram" => ChartTemplateArea, # �\��
306
+ "com.sun.star.chart.BarDiagram" => ChartTemplateBar, # ��
307
+ "com.sun.star.chart.BubbleDiagram" => ChartTemplateBubble, # �o�u��
308
+ "com.sun.star.chart.DonutDiagram" => ChartTemplateDonut, # ��i�h�[�i�c�j
309
+ "com.sun.star.chart.FilledNetDiagram" => ChartTemplateFilledNet, # ���[�_�[��
310
+ "com.sun.star.chart.LineDiagram" => ChartTemplateLine, # ��
311
+ "com.sun.star.chart.NetDiagram" => ChartTemplateNet, # ���[�_�[��
312
+ "com.sun.star.chart.PieDiagram" => ChartTemplatePie, # ��
313
+ "com.sun.star.chart.StockDiagram" => ChartTemplateStock, # ����
314
+ "com.sun.star.chart.XYDiagram" => ChartTemplateScatter # �U�z�}
315
+ }
316
+
317
+ #=== �`���[�g�̎�ނ��擾
318
+ # ret::������
319
+ def get_chartType
320
+ self.Diagram.getDiagramType
321
+ end
322
+
323
+ #=== �f�[�^��͈̔͂�\����������擾
324
+ #
325
+ # _n_:: ���Ԗڂ̃f�[�^�񂩂��w��A�w�肳��Ȃ��ꍇ�ɂ� 0�B
326
+ # ret::������
327
+ def get_Range(n=0)
328
+ self.DataSequences[n].Values.SourceRangeRepresentation
329
+ end
330
+
331
+ #=== X���͈̔͂�ύX����
332
+ #
333
+ # �f�[�^�z��͈̔͂��w�肳�ꂽ�ŏ��l�ƍő�l�֕ύX����B
334
+ # _min_index_:: �ŏ��̍s�ԍ�(1�n�܂�)
335
+ # _max_index_:: �ő�̍s�ԍ�(1�n�܂�)
336
+ # _chartTypeIndex_:: �`���[�g�e���v���[�g�z��ł̃C���f�b�N�X�A�w�肳��Ȃ��ꍇ�ɂ� 0�B
337
+ # ret::�����̂Ƃ�true�A���s�̂Ƃ�false
338
+ #
339
+ def change_Xrange(min_index,max_index,chartTypeIndex=0)
340
+ min_index = min_index.to_i
341
+ max_index = max_index.to_i
342
+ tName = ChartTypeList[self.Diagram.getDiagramType][chartTypeIndex]
343
+ ret = false
344
+ if tName
345
+ ret = true
346
+ n = self.DataSequences.size
347
+ prov = self.getDataProvider
348
+ dt = []
349
+ j = 0
350
+ x_was_taken = false
351
+
352
+ (1..n).each do |i|
353
+ seq = self.DataSequences[i-1]
354
+ role = seq.Values.Role
355
+ range = seq.Values.SourceRangeRepresentation
356
+ range.sub!(/(.*\$)\d+(\:.*\$)\d+/,"\\1#{min_index}\\2#{max_index}")
357
+ new_seq = prov.createDataSequenceByRangeRepresentation(range)
358
+ new_seq.Role = role
359
+ if role == "categories"
360
+ labeldSeq = $manager.createInstance("com.sun.star.chart2.data.LabeledDataSequence")
361
+ labeldSeq.setValues(new_seq)
362
+ dt << labeldSeq
363
+ x_was_taken = true
364
+ j += 1
365
+ elsif (role == "values-x")
366
+ if ! x_was_taken
367
+ dt[j] = $manager.createInstance("com.sun.star.chart2.data.LabeledDataSequence")
368
+ dt[j].setValues(new_seq)
369
+
370
+ if seq.Label
371
+ label_role = seq.Label.Role
372
+ label_range = seq.Label.SourceRangeRepresentation
373
+ new_label_seq = prov.createDataSequenceByRangeRepresentation(label_range)
374
+ new_label_seq.Role = seq.Label.Role
375
+ dt[j].setLabel(new_label_seq)
376
+ end
377
+ x_was_taken = true
378
+ j += 1
379
+ # else
380
+ # print "ignore values-x\n"
381
+ end
382
+ else # (role == "values-y" or else )
383
+ dt[j] = $manager.createInstance("com.sun.star.chart2.data.LabeledDataSequence")
384
+ dt[j].setValues(new_seq)
385
+
386
+ if seq.Label
387
+ label_role = seq.Label.Role
388
+ label_range = seq.Label.SourceRangeRepresentation
389
+ new_label_seq = prov.createDataSequenceByRangeRepresentation(label_range)
390
+ new_label_seq.Role = seq.Label.Role
391
+ dt[j].setLabel(new_label_seq)
392
+ end
393
+ j += 1
394
+ end
395
+ end
396
+ source = self.getUsedData
397
+ source.setData(dt)
398
+ tManager = self.getChartTypeManager
399
+ tTemplate = tManager.createInstance(tName)
400
+ tTemplate.changeDiagramData(self.Diagram.getDiagram, source, [])
401
+ end
402
+ ret
403
+ end
404
+
405
+ #=== �摜�^�C�v��`
406
+ #
407
+ Graphic_Types = {
408
+ 'gif'=>'image/gif',
409
+ 'jpeg'=>'image/jpeg',
410
+ 'jpg'=>'image/jpeg',
411
+ 'png'=>'image/png',
412
+ 'fh'=>'image/x-freehand' ,
413
+ 'cgm'=>'image/cgm',
414
+ 'tiff'=>'image/tiff',
415
+ 'dxf'=>'image/vnd.dxf',
416
+ 'emf'=>'image/x-emf',
417
+ 'tga'=>'image/x-targa',
418
+ 'sgf'=>'image/x-sgf',
419
+ 'svm'=>'image/x-svm',
420
+ 'wmf'=>'image/x-wmf',
421
+ 'pict'=>'image/x-pict',
422
+ 'cmx'=>'image/x-cmx',
423
+ 'svg'=>'image/svg+xml',
424
+ 'bmp'=>'image/x-MS-bmp',
425
+ 'wpg'=>'image/x-wpg',
426
+ 'eps'=>'image/x-eps',
427
+ 'met'=>'image/x-met',
428
+ 'pbm'=>'image/x-portable-bitmap',
429
+ 'pcd'=>'image/x-photo-cd',
430
+ 'pcx'=>'image/x-pcx',
431
+ 'pgm'=>'image/x-portable-graymap',
432
+ 'ppm'=>'image/x-portable-pixmap',
433
+ 'psd'=>'image/vnd.adobe.photoshop',
434
+ 'ras'=>'image/x-cmu-raster',
435
+ 'ras'=>'image/x-sun-raster',
436
+ 'xbm'=>'image/x-xbitmap',
437
+ 'xpm'=>'image/x-xpixmap'
438
+ }
439
+
440
+ #=== �`���[�g�̕ۑ�
441
+ #
442
+ # _filename_::�o�͂���摜�t�@�C�����A�g���q�ʼn摜�^�C�v�𔻒肷��B(bmp,jpg,png...)
443
+ #
444
+ def save(filename)
445
+ done = false
446
+ if filename != ''
447
+ if filename !~ /^file\:\/\/\//
448
+ filename = 'file:///'+getAbsolutePath(filename)
449
+ end
450
+ filename =~ /\.([^\/\.\\]+?)$/
451
+ ext = $1
452
+ ext.downcase! if ext
453
+ t = Graphic_Types[ext]
454
+ else
455
+ print "�摜�̃t�@�C�������w�肵�Ă�������\n"
456
+ return false
457
+ end
458
+ if t == nil
459
+ print "�g���q����摜�^�C�v�����ʂł��܂���B\n"
460
+ return false
461
+ end
462
+
463
+ done = true
464
+ begin
465
+ f = $manager.createInstance("com.sun.star.drawing.GraphicExportFilter")
466
+ f.setSourceDocument(self.getDrawPage)
467
+ opt = _opts($manager,{'URL'=>filename,'MediaType'=>t})
468
+ f.filter(opt)
469
+ rescue
470
+ print "�������݂ł��܂���ł����B#{$!}\n"
471
+ done = false
472
+ end
473
+ done
474
+ end
475
+
476
+ end
477
+
478
+ #----------------------------------------------------
479
+ #= �V�[�g�h�L�������g����
480
+ #
481
+ # �V�[�g�N���X�̊g�����W���[��
482
+ # �V�[�g���o�����Ɏ����I�ɑg�ݍ��܂��B
483
+ module CalcWorksheet
484
+
485
+ #=== �`���[�g�h�L�������g���o��
486
+ #
487
+ # _n_::���Ԗڂ̃`���[�g�����o�����̎w��(0�n�܂�)�A�w�肳��Ȃ��ꍇ�ɂ� 0�B
488
+ # ret::�V�[�g�I�u�W�F�N�g
489
+ def get_chartdoc(n=0)
490
+ charts = self.getCharts
491
+ if n.class == String
492
+ chart = charts.getByName(n)
493
+ else
494
+ chart = charts.getByIndex(n)
495
+ end
496
+ chartDoc = chart.EmbeddedObject
497
+ chartDoc.extend(CalcChartDoc)
498
+ end
499
+
500
+ #=== �Z���̔w�i�F���擾
501
+ #
502
+ # _y_::�s�ԍ�(0�n�܂�)
503
+ # _x_::�J�����ԍ�(0�n�܂�)
504
+ # ret::RGB24bit�ł̐F�R�[�h
505
+ #
506
+ def color(y,x) #
507
+ self.getCellByPosition(x,y).CellBackColor
508
+ end
509
+
510
+ #=== �Z���̔w�i�F��ݒ�
511
+ #
512
+ # _y_::�s�ԍ�(0�n�܂�)
513
+ # _x_::�J�����ԍ�(0�n�܂�)
514
+ # _color_::RGB24bit�ł̐F�R�[�h
515
+ #
516
+ def set_color(y,x,color) #
517
+ self.getCellByPosition(x,y).CellBackColor = color
518
+ end
519
+
520
+ #=== �Z���͈͂̔w�i�F��ݒ�
521
+ #
522
+ # _y1_::�s�ԍ�(0�n�܂�)
523
+ # _x1_::�J�����ԍ�(0�n�܂�)
524
+ # _y2_::�s�ԍ�(0�n�܂�)
525
+ # _x2_::�J�����ԍ�(0�n�܂�)
526
+ # _color_::RGB24bit�ł̐F�R�[�h
527
+ #
528
+ def set_range_color(y1,x1,y2,x2,color) #
529
+ self.getCellRangeByPosition(x1,y1,x2,y2).CellBackColor = color
530
+ end
531
+
532
+ #=== �J�������擾
533
+ #
534
+ # _x_::�J�����ԍ�(0�n�܂�)
535
+ # ret::��(1/100mm�P��)
536
+ def get_width(x) #
537
+ self.Columns.getByIndex(x).Width
538
+ end
539
+
540
+ #=== �J�������ݒ�
541
+ #
542
+ # _x_::�J�����ԍ�(0�n�܂�)
543
+ # _width_::��(1/100mm�P��)
544
+ def set_width(x,width) #
545
+ self.Columns.getByIndex(x).Width = width
546
+ end
547
+
548
+ #=== �Z���̒l���o��
549
+ # sheet[�s�ԍ�,�J�����ԍ�] �ŃZ�����Q�Ƃ���B
550
+ #
551
+ # _y_::�s�ԍ�(0�n�܂�)
552
+ # _x_::�J�����ԍ�(0�n�܂�)
553
+ #
554
+ def [] y,x #
555
+ cell = self.getCellByPosition(x,y)
556
+ if cell.Type == 2 #CellCollectionType::TEXT
557
+ cell.String
558
+ else
559
+ cell.Value
560
+ end
561
+ end
562
+
563
+ #=== �Z���̒l�ݒ�
564
+ # sheet[�s�ԍ�,�J�����ԍ�] �ŃZ�����Q�Ƃ���B
565
+ #
566
+ # _y_::�s�ԍ�(0�n�܂�)
567
+ # _x_::�J�����ԍ�(0�n�܂�)
568
+ # _value_::�ݒ�l
569
+ #
570
+ def []= y,x,value #
571
+ cell = self.getCellByPosition(x,y)
572
+ if value.class == String #CellCollectionType::TEXT
573
+ cell.String = value
574
+ else
575
+ cell.Value= value
576
+ end
577
+ end
578
+
579
+ $a2z = ('A'..'Z').to_a
580
+
581
+ #=== �͈͎w��̕�����쐬
582
+ #
583
+ # _y_::�s�ԍ�(0�n�܂�)
584
+ # _x_::�J�����ԍ�(0�n�܂�)
585
+ # ret::�͈͎w�蕶����
586
+ #
587
+ def r_str(y,x)
588
+ r = ''
589
+ x -= 1
590
+ if x > 26*26
591
+ return "ZZ#{y}"
592
+ else
593
+ r = $a2z[((x/26)-1).to_i] if x > 25
594
+ r += $a2z[(x%26).to_i]
595
+ r += y.to_s
596
+ end
597
+ r
598
+ end
599
+
600
+ #=== �Z���̎����擾
601
+ #
602
+ # _y_::�s�ԍ�(0�n�܂�)
603
+ # _x_::�J�����ԍ�(0�n�܂�)
604
+ # ret::����\��������
605
+ #
606
+ def get_formula( y,x) #
607
+ cell = self.getCellByPosition(x,y)
608
+ cell.Formula
609
+ end
610
+
611
+ #=== �Z���֎���ݒ�
612
+ #
613
+ # _y_::�s�ԍ�(0�n�܂�)
614
+ # _x_::�J�����ԍ�(0�n�܂�)
615
+ # _f_::����\��������
616
+ #
617
+ def set_formula( y,x,f) #
618
+ cell = self.getCellByPosition(x,y)
619
+ cell.Formula = f
620
+ end
621
+
622
+ #=== �s���O���[�v��
623
+ #
624
+ # _y1_::�J�n�s�ԍ�(0�n�܂�)
625
+ # _y2_::�I���s�ԍ�(0�n�܂�)
626
+ #
627
+ # Excel�̃O���[�v����+-�̃A�C�R���̈ʒu���قȂ�܂��B
628
+ def group_row(y1,y2)
629
+ r = self.getCellRangeByPosition(0,y1,0,y2).RangeAddress
630
+ self.group(r,1)
631
+ end
632
+
633
+ #=== ����O���[�v��
634
+ #
635
+ # _y1_::�J�n��ԍ�(0�n�܂�)
636
+ # _y2_::�I����ԍ�(0�n�܂�)
637
+ #
638
+ # Excel�̃O���[�v����+-�̃A�C�R���̈ʒu���قȂ�܂��B
639
+ def group_column(x1,x2)
640
+ r = self.getCellRangeByPosition(x1,0,x2,0).RangeAddress
641
+ self.group(r,0)
642
+ end
643
+
644
+ #=== �Z���̃}�[�W�ݒ�
645
+ #
646
+ # _y1_::����s�ԍ�(0�n�܂�)
647
+ # _x1_::����J�����ԍ�(0�n�܂�)
648
+ # _y2_::�E���s�ԍ�(0�n�܂�)
649
+ # _x2_::�E���J�����ԍ�(0�n�܂�)
650
+ def merge(y1,x1,y2,x2)
651
+ self.getCellRangeByPosition(x1,y1,x2,y2).merge(true)
652
+ end
653
+
654
+ #=== �Z���̃}�[�W����
655
+ #
656
+ # _y1_::����s�ԍ�(0�n�܂�)
657
+ # _x1_::����J�����ԍ�(0�n�܂�)
658
+ # _y2_::�E���s�ԍ�(0�n�܂�)
659
+ # _x2_::�E���J�����ԍ�(0�n�܂�)
660
+ def merge_off(y1,x1,y2,x2)
661
+ self.getCellRangeByPosition(x1,y1,x2,y2).merge(false)
662
+ end
663
+
664
+ #=== �r���g�ݒ�
665
+ #
666
+ # _y1_::����s�ԍ�(0�n�܂�)
667
+ # _x1_::����J�����ԍ�(0�n�܂�)
668
+ # _y2_::�E���s�ԍ�(0�n�܂�)
669
+ # _x2_::�E���J�����ԍ�(0�n�܂�)
670
+ def box(y1,x1,y2,x2)
671
+ r = self.getCellRangeByPosition(x1,y1,x2,y2)
672
+ b = r.RightBorder
673
+ b.InnerLineWidth = 10
674
+
675
+ r.BottomBorder = b
676
+ r.TopBorder = b
677
+ r.LeftBorder = b
678
+ r.RightBorder = b
679
+ end
680
+
681
+
682
+ #=== Wrap�\���ݒ�
683
+ #
684
+ # _y1_::����s�ԍ�(0�n�܂�)
685
+ # _x1_::����J�����ԍ�(0�n�܂�)
686
+ # _y2_::�E���s�ԍ�(0�n�܂�)
687
+ # _x2_::�E���J�����ԍ�(0�n�܂�)
688
+ def wrap(y1,x1,y2,x2)
689
+ self.getCellRangeByPosition(x1,y1,x2,y2).IsTextWrapped = true
690
+ end
691
+
692
+ #=== ���������̕\���ݒ�
693
+ #
694
+ # _y1_::����s�ԍ�(0�n�܂�)
695
+ # _x1_::����J�����ԍ�(0�n�܂�)
696
+ # _y2_::�E���s�ԍ�(0�n�܂�)
697
+ # _x2_::�E���J�����ԍ�(0�n�܂�)
698
+ # _v_:: 0:STANDARD,1:TOP,2:CENTER,3:BOTTOM
699
+ #
700
+ def verticals(y1,x1,y2,x2,v=0)
701
+ self.getCellRangeByPosition(x1,y1,x2,y2).VertJustify = v
702
+ end
703
+
704
+ def vertical(y1,x1,v=0)
705
+ self.getCellByPosition(x1,y1).VertJustify = v
706
+ end
707
+
708
+
709
+ #=== ��t���\���ݒ�
710
+ #
711
+ # _y1_::����s�ԍ�(0�n�܂�)
712
+ # _x1_::����J�����ԍ�(0�n�܂�)
713
+ # _y2_::�E���s�ԍ�(0�n�܂�)
714
+ # _x2_::�E���J�����ԍ�(0�n�܂�)
715
+ #
716
+ def v_tops(y1,x1,y2,x2)
717
+ self.verticals(y1,x1,y2,x2,1)
718
+ end
719
+
720
+ def v_top(y1,x1)
721
+ self.vertical(y1,x1,1)
722
+ end
723
+
724
+ #=== ���������̕\���ݒ�(Range)
725
+ #
726
+ # _y1_::����s�ԍ�(0�n�܂�)
727
+ # _x1_::����J�����ԍ�(0�n�܂�)
728
+ # _y2_::�E���s�ԍ�(0�n�܂�)
729
+ # _x2_::�E���J�����ԍ�(0�n�܂�)
730
+ # _h_:: 0:STANDARD,1:LEFT,2:CENTER,3:RIGHT,4:BLOCK,5:REPEAT
731
+ #
732
+ def horizontals(y1,x1,y2,x2,h=0)
733
+ self.getCellRangeByPosition(x1,y1,x2,y2).HoriJustify = h
734
+ end
735
+
736
+ #=== ���������̕\���ݒ�(Cell)
737
+ #
738
+ # _y1_::����s�ԍ�(0�n�܂�)
739
+ # _x1_::����J�����ԍ�(0�n�܂�)
740
+ # _h_:: 0:STANDARD,1:LEFT,2:CENTER,3:RIGHT,4:BLOCK,5:REPEAT
741
+ #
742
+ def horizontal(y1,x1,h=0)
743
+ self.getCellByPosition(x1,y1).HoriJustify = h
744
+ end
745
+
746
+ #=== �Z���^�[�\���ݒ�(Range)
747
+ #
748
+ # _y1_::����s�ԍ�(0�n�܂�)
749
+ # _x1_::����J�����ԍ�(0�n�܂�)
750
+ # _y2_::�E���s�ԍ�(0�n�܂�)
751
+ # _x2_::�E���J�����ԍ�(0�n�܂�)
752
+ def centers(y1,x1,y2,x2)
753
+ self.horizontals(y1,x1,y2,x2,2)
754
+ end
755
+
756
+ #=== �Z���^�[�\���ݒ�(Cell)
757
+ #
758
+ # _y1_::����s�ԍ�(0�n�܂�)
759
+ # _x1_::����J�����ԍ�(0�n�܂�)
760
+ def center(y1,x1)
761
+ self.horizontal(y1,x1,2)
762
+ end
763
+
764
+ #=== �����R�s�[(Range)
765
+ #
766
+ # _sy_::�R�s�[�� �s�ԍ�(0�n�܂�)
767
+ # _sx_::�R�s�[�� �J�����ԍ�(0�n�܂�)
768
+ # _ty1_::�R�s�[�� ����s�ԍ�(0�n�܂�)
769
+ # _tx1_::�R�s�[�� ����J�����ԍ�(0�n�܂�)
770
+ # _ty2_::�R�s�[�� �E���s�ԍ�(0�n�܂�)
771
+ # _tx2_::�R�s�[�� �E���J�����ԍ�(0�n�܂�)
772
+ def format_copy(sy,sx,ty1,tx1,ty2,tx2)
773
+ s = self.getCellByPosition(sx,sy)
774
+ sp = s.getPropertySetInfo.getProperties
775
+ names = sp.each.map{|p| p.Name}
776
+ ps = s.getPropertyValues(names)
777
+ self.getCellRangeByPosition(tx1,ty1,tx2,ty2).setPropertyValues(names,ps)
778
+ end
779
+
780
+ #=== �����R�s�[2(Range)
781
+ #
782
+ # �R�s�[���s�̏������R�s�[���n�s�R�s�[����B
783
+ # �R�s�[��̓R�s�[���Ɠ����J�������Ƃ���B
784
+ #
785
+ # _sy1_::�R�s�[�� �s�ԍ�(0�n�܂�)
786
+ # _sx1_::�R�s�[�� �J�n�J�����ԍ�(0�n�܂�)
787
+ # _sx2_::�R�s�[�� �I���J�����ԍ�(0�n�܂�)
788
+ # _ty_::�R�s�[�� ����s�ԍ�(0�n�܂�)
789
+ # _tx_::�R�s�[�� ����J�����ԍ�(0�n�܂�)
790
+ # _n_:: �R�s�[�s��
791
+ def format_range_copy(sy,sx1,sx2, ty,tx,n=1)
792
+ return if n < 1
793
+ (sx1..sx2).each do |x|
794
+ self.format_copy(sy,x, ty,tx+(x-sx1),ty+n-1,tx+(x-sx1))
795
+ end
796
+ end
797
+
798
+ #=== �����R�s�[(Cell)
799
+ #
800
+ # _sy_::�R�s�[�� �s�ԍ�(0�n�܂�)
801
+ # _sx_::�R�s�[�� �J�����ԍ�(0�n�܂�)
802
+ # _ty_::�R�s�[�� ����s�ԍ�(0�n�܂�)
803
+ # _tx_::�R�s�[�� ����J�����ԍ�(0�n�܂�)
804
+ def format_copy1(sy,sx,ty,tx)
805
+ s = self.getCellByPosition(sx,sy)
806
+ sp = s.getPropertySetInfo.getProperties
807
+ names = sp.each.map{|p| p.Name}
808
+ ps = s.getPropertyValues(names)
809
+ self.getCellByPosition(tx,ty).setPropertyValues(names,ps)
810
+ end
811
+
812
+ #=== �R�s�[(Range)
813
+ #
814
+ # _sy1_::�R�s�[�� ����s�ԍ�(0�n�܂�)
815
+ # _sx1_::�R�s�[�� ����J�����ԍ�(0�n�܂�)
816
+ # _sy2_::�R�s�[�� �E���s�ԍ�(0�n�܂�)
817
+ # _sx2_::�R�s�[�� �E���J�����ԍ�(0�n�܂�)
818
+ # _ty_::�R�s�[�� ����s�ԍ�(0�n�܂�)
819
+ # _tx_::�R�s�[�� ����J�����ԍ�(0�n�܂�)
820
+ def copy(sy1,sx1,sy2,sx2,ty,tx)
821
+ r = self.getCellRangeByPosition(sx1,sy1,sx2,sy2).getRangeAddress
822
+ c = self.getCellByPosition(tx,ty).getCellAddress
823
+ self.copyRange(c,r)
824
+ end
825
+
826
+
827
+ #=== �s�̑}��
828
+ #
829
+ # _n_:: �s�ԍ�(0�n�܂�)�A���̍s�̑O�ɑ}������B
830
+ # _count_:: ���s�}�����邩�̎w��A�w�肵�Ȃ��ꍇ�ɂ�1�B
831
+ #
832
+ def insert_rows(n,count=1) #
833
+ self.Rows.insertByIndex(n,count)
834
+ end
835
+
836
+ #=== �s�̍폜
837
+ #
838
+ # _n_:: �s�ԍ�(0�n�܂�)�A���̍s���牺���폜����B
839
+ # _count_:: ���s�폜���邩�̎w��A�w�肵�Ȃ��ꍇ�ɂ�1�B
840
+ #
841
+ def remove_rows(n,count=1) #
842
+ r = self.getCellRangeByPosition(0,n,0,n+count-1).getRangeAddress
843
+ self.removerange(r,3)
844
+ end
845
+
846
+
847
+ end
848
+
849
+
850
+ #----------------------------------------------------
851
+ #== OpenOffice�h�L�������g����
852
+ #
853
+ # Calc�h�L�������g�̊g�����W���[���B
854
+ # �h�L�������g���o�����Ɏ����I�ɑg�ݍ��܂��B
855
+ module OOoDocument
856
+
857
+ #=== �V�[�g�̎��o��
858
+ #
859
+ # _s_:: �V�[�g��������܂��̓V�[�g�̃C���f�b�N�X�ԍ�
860
+ # ret:: �V�[�g�I�u�W�F�N�g
861
+ #
862
+ def get_sheet(s)
863
+ if s.class == String
864
+ sheet = self.sheets.getByName(s)
865
+ else
866
+ sheet = self.sheets.getByIndex(s)
867
+ end
868
+ sheet.extend(CalcWorksheet)
869
+ end
870
+
871
+ #=== Active�V�[�g�̐؂�ւ�
872
+ #
873
+ # _s_:: �V�[�g��������܂��̓V�[�g�̃C���f�b�N�X�ԍ�
874
+ #
875
+ def set_active_sheet(s)
876
+ if s.class == String
877
+ self.getCurrentController.setActiveSheet(self.Sheets.getByName(s))
878
+ else
879
+ self.getCurrentController.setActiveSheet(self.Sheets.getByIndex(s))
880
+ end
881
+ end
882
+
883
+ #=== Calc�h�L�������g�̕ۑ�(�����o��)
884
+ #
885
+ # _filename_:: ���O��ς��ĕۑ�����ꍇ�Ƀt�@�C�������w�肷��B
886
+ # ret::����������true�A���s������false
887
+ #
888
+ def save(filename=nil)
889
+ done = true
890
+ begin
891
+ if filename
892
+ if filename !~ /^file\:\/\/\//
893
+ filename = 'file:///'+getAbsolutePath(filename)
894
+ end
895
+
896
+ options = []
897
+ options += get_filtername_option(filename)
898
+ self.storeToURL(filename,options)
899
+ sleep(2)
900
+ else
901
+ self.store()
902
+ sleep(2)
903
+ end
904
+ rescue
905
+ print "�������݂ł��܂���ł����B\n"
906
+ done = false
907
+ end
908
+ done
909
+ end
910
+ end
911
+
912
+
913
+ #----------------------------------------------------
914
+ #== Calc�h�L�������g����
915
+
916
+ #=== �I�v�V�����w��p�z��̍쐬
917
+ #
918
+ # _manager_:: com.sun.star.ServiceManager
919
+ # _hash_:: �I�v�V�����w��(���O�ƒl�̘A�z�z��)
920
+ # ret::�I�v�V�����w��p�̔z��
921
+ #
922
+ def _opts(manager,hash)
923
+ hash.inject(opts = []) {|x,y|
924
+ opt = manager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
925
+ opt[0].Name = y[0]
926
+ opt[0].Value = y[1]
927
+ x << opt
928
+ }
929
+ opts
930
+ end
931
+
932
+ Document_Types = {
933
+ "csv" =>"Text - txt - csv (StarCalc)",
934
+ "fods" =>"OpenDocument Spreadsheet Flat XML",
935
+ "html" =>"HTML (StarCalc)",
936
+ "ods" =>"calc8",
937
+ "ots" =>"calc8_template",
938
+ "pdf" =>"calc_pdf_Export",
939
+ "xhtml"=>"XHTML Calc File",
940
+ "xls" =>"MS Excel 97",
941
+ "xlsx" =>"Calc MS Excel 2007 XML"
942
+ }
943
+
944
+ #=== �h�L�������g�`�������o��
945
+ #
946
+ # �g���q��ods�Ȃ��̔z���Ԃ��B
947
+ # ���̑��Ȃ�Ή�����t�B���^�[���̃v���p�e�B�z���Ԃ��B
948
+ # =filename_::�t�@�C����
949
+ # ret::�t�B���^�[�I�v�V����(�h�L�������g�`����)
950
+ #
951
+ def get_filtername_option( filename)
952
+ filename =~ /\.([^\/\.\\]+?)$/
953
+ ext = $1
954
+ return [] if (ext == nil) or (ext == '')
955
+ ext.downcase!
956
+
957
+ return [] if ext == 'ods'
958
+ t = Document_Types[ext]
959
+ return [] if !t
960
+ return _opts($manager,{"FilterName"=>t})
961
+
962
+ end
963
+
964
+ #----------------------------------------------------
965
+ #=== �����h�L�������g��Open
966
+ #
967
+ # �����u���b�N���󂯎���Ď��s����B
968
+ #
969
+ # _filename:: Calc�h�L�������g�̃t�@�C����
970
+ # _visible_:: Calc�̃E�C���h�E��\������Ƃ�true�A�w�肳��Ȃ��ꍇ�ɂ�true
971
+ #
972
+ def openCalcWorkbook filename, visible=true
973
+ if filename !~ /^file\:\/\/\//
974
+ filename = 'file:///'+getAbsolutePath(filename)
975
+ end
976
+ manager = WIN32OLE.new("com.sun.star.ServiceManager")
977
+ $manager = manager
978
+ desktop = manager.createInstance("com.sun.star.frame.Desktop")
979
+
980
+ options = []
981
+ # options += get_filtername_option(filename)
982
+ options += _opts(manager,{"Hidden" => true}) if !visible
983
+
984
+ book = desktop.loadComponentFromURL(filename, "_blank", 0,options)
985
+
986
+ book.extend(OOoDocument)
987
+
988
+ begin
989
+ yield book
990
+ ensure
991
+ book.close(false)
992
+ end
993
+ ## desktop.terminate ## �J���Ă��鑼��OOo�h�L�������g��������ɂ��Ă��ׂďI�����Ă��܂�
994
+
995
+ end
996
+
997
+
998
+ #----------------------------------------------------
999
+ #=== �V�K�h�L�������g�̍쐬
1000
+ #
1001
+ # �����u���b�N���󂯎���Ď��s����B
1002
+ # save���Ăт����Ƃ��Ƀt�@�C�������w�肵�Ă�ۑ�����B
1003
+ #
1004
+ # _visible_:: Calc�̃E�C���h�E��\������Ƃ�true�A�w�肳��Ȃ��ꍇ�ɂ�true
1005
+ #
1006
+ def createCalcWorkbook visible=true
1007
+ manager = WIN32OLE.new("com.sun.star.ServiceManager")
1008
+ $manager = manager
1009
+ desktop = manager.createInstance("com.sun.star.frame.Desktop")
1010
+ if visible
1011
+ book = desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, [])
1012
+ else
1013
+ book = desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, _opts(manager,{"Hidden" => true}))
1014
+ end
1015
+ book.extend(OOoDocument)
1016
+
1017
+ begin
1018
+ yield book
1019
+ ensure
1020
+ book.close(false)
1021
+ end
1022
+ ## desktop.terminate ## �J���Ă��鑼��OOo�h�L�������g��������ɂ��Ă��ׂďI�����Ă��܂�
1023
+
1024
+ end
1025
+
1026
+
1027
+ if __FILE__ == $0
1028
+
1029
+ print "OpenOffice.org Calc�p ruby�g�����W���[��\n"
1030
+ print "\nruby��RDoc�Ńh�L�������g���쐬���Ă��������B\n"
1031
+ print "rdoc --title Trail_Calc --main Trail_calc --all Trail_calc.rb\n"
1032
+
1033
+ end
@@ -0,0 +1,3 @@
1
+ module TrailCalc
2
+ VERSION = "1.0.3"
3
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Trail_Calc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Mt.Trail
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: handling OpenOffice.org's CALC from Ruby.
42
+ email:
43
+ - trail@trail4you.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - README.md
51
+ - Rakefile
52
+ - Trail_Calc.gemspec
53
+ - bin/console
54
+ - bin/setup
55
+ - lib/Trail_Calc.rb
56
+ - lib/Trail_Calc/version.rb
57
+ homepage: https://github.com/MtTrail/Trail_Calc
58
+ licenses: []
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.5.1
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: handling OpenOffice.org's CALC from Ruby.
80
+ test_files: []
81
+ has_rdoc: