writeexcel 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitattributes +1 -1
- data/.gitignore +24 -24
- data/README.rdoc +34 -55
- data/VERSION +1 -1
- data/charts/chartex.rb +316 -316
- data/charts/demo1.rb +46 -46
- data/charts/demo2.rb +65 -65
- data/charts/demo3.rb +117 -117
- data/charts/demo4.rb +119 -119
- data/charts/demo5.rb +48 -48
- data/examples/a_simple.rb +43 -43
- data/examples/autofilter.rb +265 -265
- data/examples/bigfile.rb +30 -30
- data/examples/chart_area.rb +121 -121
- data/examples/chart_bar.rb +120 -120
- data/examples/chart_column.rb +120 -120
- data/examples/chart_line.rb +120 -120
- data/examples/chart_pie.rb +108 -108
- data/examples/chart_scatter.rb +121 -121
- data/examples/chart_stock.rb +148 -148
- data/examples/chess.rb +142 -142
- data/examples/colors.rb +129 -129
- data/examples/comments1.rb +27 -27
- data/examples/comments2.rb +352 -352
- data/examples/copyformat.rb +52 -52
- data/examples/data_validate.rb +279 -279
- data/examples/date_time.rb +87 -87
- data/examples/defined_name.rb +32 -32
- data/examples/demo.rb +124 -124
- data/examples/diag_border.rb +36 -36
- data/examples/formats.rb +490 -490
- data/examples/formula_result.rb +30 -30
- data/examples/header.rb +137 -137
- data/examples/hide_sheet.rb +29 -29
- data/examples/hyperlink.rb +43 -43
- data/examples/images.rb +63 -63
- data/examples/indent.rb +31 -31
- data/examples/merge1.rb +40 -40
- data/examples/merge2.rb +45 -45
- data/examples/merge3.rb +66 -66
- data/examples/merge4.rb +83 -83
- data/examples/merge5.rb +80 -80
- data/examples/merge6.rb +67 -67
- data/examples/outline.rb +255 -255
- data/examples/outline_collapsed.rb +209 -209
- data/examples/panes.rb +113 -113
- data/examples/properties.rb +34 -34
- data/examples/properties_jp.rb +33 -33
- data/examples/protection.rb +47 -47
- data/examples/regions.rb +53 -53
- data/examples/repeat.rb +43 -43
- data/examples/right_to_left.rb +27 -27
- data/examples/row_wrap.rb +53 -53
- data/examples/stats.rb +74 -74
- data/examples/stocks.rb +81 -81
- data/examples/tab_colors.rb +31 -31
- data/examples/utf8.rb +15 -15
- data/examples/write_arrays.rb +83 -83
- data/lib/writeexcel/biffwriter.rb +232 -232
- data/lib/writeexcel/caller_info.rb +12 -12
- data/lib/writeexcel/chart.rb +2190 -2177
- data/lib/writeexcel/charts/area.rb +154 -154
- data/lib/writeexcel/charts/bar.rb +177 -177
- data/lib/writeexcel/charts/column.rb +156 -156
- data/lib/writeexcel/charts/external.rb +66 -66
- data/lib/writeexcel/charts/line.rb +154 -154
- data/lib/writeexcel/charts/pie.rb +169 -169
- data/lib/writeexcel/charts/scatter.rb +192 -192
- data/lib/writeexcel/charts/stock.rb +213 -213
- data/lib/writeexcel/colors.rb +64 -64
- data/lib/writeexcel/compatibility.rb +0 -255
- data/lib/writeexcel/debug_info.rb +37 -33
- data/lib/writeexcel/excelformulaparser.rb +587 -587
- data/lib/writeexcel/format.rb +13 -4
- data/lib/writeexcel/formula.rb +26 -9
- data/lib/writeexcel/helper.rb +68 -64
- data/lib/writeexcel/olewriter.rb +311 -311
- data/lib/writeexcel/properties.rb +242 -240
- data/lib/writeexcel/storage_lite.rb +984 -978
- data/lib/writeexcel/workbook.rb +3210 -3192
- data/lib/writeexcel/worksheet.rb +143 -51
- data/lib/writeexcel/write_file.rb +44 -40
- data/lib/writeexcel.rb +1159 -1159
- data/test/helper.rb +31 -28
- data/test/perl_output/README +31 -31
- data/test/test_00_IEEE_double.rb +13 -13
- data/test/test_01_add_worksheet.rb +10 -10
- data/test/test_02_merge_formats.rb +53 -53
- data/test/test_04_dimensions.rb +392 -392
- data/test/test_05_rows.rb +179 -179
- data/test/test_06_extsst.rb +77 -77
- data/test/test_11_date_time.rb +479 -479
- data/test/test_12_date_only.rb +501 -501
- data/test/test_13_date_seconds.rb +481 -481
- data/test/test_21_escher.rb +637 -637
- data/test/test_22_mso_drawing_group.rb +745 -745
- data/test/test_23_note.rb +73 -73
- data/test/test_24_txo.rb +75 -75
- data/test/test_25_position_object.rb +84 -84
- data/test/test_26_autofilter.rb +314 -314
- data/test/test_27_autofilter.rb +131 -131
- data/test/test_28_autofilter.rb +161 -161
- data/test/test_29_process_jpg.rb +683 -683
- data/test/test_30_validation_dval.rb +77 -77
- data/test/test_31_validation_dv_strings.rb +126 -126
- data/test/test_32_validation_dv_formula.rb +206 -206
- data/test/test_40_property_types.rb +188 -188
- data/test/test_41_properties.rb +235 -235
- data/test/test_42_set_properties.rb +437 -437
- data/test/test_50_name_stored.rb +299 -299
- data/test/test_51_name_print_area.rb +357 -357
- data/test/test_52_name_print_titles.rb +454 -454
- data/test/test_53_autofilter.rb +203 -203
- data/test/test_60_chart_generic.rb +578 -578
- data/test/test_61_chart_subclasses.rb +95 -95
- data/test/test_62_chart_formats.rb +272 -272
- data/test/test_63_chart_area_formats.rb +649 -649
- data/test/test_biff.rb +75 -75
- data/test/test_compatibility.rb +12 -627
- data/test/test_example_match.rb +3144 -3144
- data/test/test_formula.rb +61 -61
- data/test/test_ole.rb +106 -106
- data/test/test_storage_lite.rb +125 -125
- data/test/test_workbook.rb +139 -139
- data/test/test_worksheet.rb +110 -110
- data/utils/add_magic_comment.rb +80 -80
- data/writeexcel.gemspec +4 -6
- data/writeexcel.rdoc +58 -15
- metadata +9 -6
- data/test/test_new_encoding.rb +0 -205
data/test/test_21_escher.rb
CHANGED
@@ -1,637 +1,637 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
###############################################################################
|
3
|
-
#
|
4
|
-
# A test for WriteExcel.
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# all test is commented out because Workbook#add_mso_... was set to private
|
8
|
-
# method. Before that, all test passed.
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# Tests for the internal methods used to write the records in an Escher drawing
|
14
|
-
# object such as images, comments and filters.
|
15
|
-
#
|
16
|
-
# reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
|
17
|
-
#
|
18
|
-
# original written in Perl by John McNamara
|
19
|
-
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
20
|
-
#
|
21
|
-
############################################################################
|
22
|
-
require 'helper'
|
23
|
-
require 'stringio'
|
24
|
-
|
25
|
-
class TC_escher < Test::Unit::TestCase
|
26
|
-
|
27
|
-
def setup
|
28
|
-
@workbook = WriteExcel.new(StringIO.new)
|
29
|
-
@worksheet = @workbook.add_worksheet
|
30
|
-
end
|
31
|
-
|
32
|
-
def teardown
|
33
|
-
@workbook.close
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_dummy
|
37
|
-
assert(true)
|
38
|
-
end
|
39
|
-
|
40
|
-
=begin
|
41
|
-
def test_for_the_generic_method
|
42
|
-
data_for_test.each do |data|
|
43
|
-
caption = data.shift
|
44
|
-
target = data.pop
|
45
|
-
|
46
|
-
data[3].gsub!(/ /,'')
|
47
|
-
data[3] = [data[3]].pack('H*')
|
48
|
-
|
49
|
-
caption = sprintf(" \t_add_mso_generic(): (0x%04X) %s", data[0], caption)
|
50
|
-
|
51
|
-
result = unpack_record(@worksheet.add_mso_generic(*data))
|
52
|
-
|
53
|
-
assert_equal(target, result, caption)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_for_store_mso_dgg_container
|
58
|
-
caption = sprintf(" \t_store_mso_dgg_container()")
|
59
|
-
target = %w( 0F 00 00 F0 52 00 00 00 ).join(' ')
|
60
|
-
|
61
|
-
@workbook.mso_size = 94
|
62
|
-
result = unpack_record(@workbook.store_mso_dgg_container)
|
63
|
-
|
64
|
-
assert_equal(target, result, caption)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_for_store_mso_dgg
|
68
|
-
caption = sprintf(" \t_store_mso_dgg()")
|
69
|
-
data = [ 1026, 2, 2, 1, [[1,2]] ]
|
70
|
-
target = %w( 00 00 06 F0
|
71
|
-
18 00 00 00 02 04 00 00 02 00 00 00 02 00 00 00
|
72
|
-
01 00 00 00 01 00 00 00 02 00 00 00
|
73
|
-
).join(' ')
|
74
|
-
|
75
|
-
result = unpack_record(@workbook.store_mso_dgg(*data))
|
76
|
-
|
77
|
-
assert_equal(target, result, caption)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_for_store_mso_opt
|
81
|
-
caption = sprintf(" \t_store_mso_opt()")
|
82
|
-
target = %w( 33 00 0B F0
|
83
|
-
12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
|
84
|
-
C0 01 40 00 00 08
|
85
|
-
).join(' ')
|
86
|
-
|
87
|
-
result = unpack_record(@workbook.store_mso_opt)
|
88
|
-
|
89
|
-
assert_equal(target, result, caption)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_for_store_mso_split_menu_colors
|
93
|
-
caption = sprintf(" \t_store_mso_split_menu_colors()")
|
94
|
-
target = %w( 40 00 1E F1 10 00 00 00 0D 00
|
95
|
-
00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
|
96
|
-
).join(' ')
|
97
|
-
|
98
|
-
result = unpack_record(@workbook.store_mso_split_menu_colors)
|
99
|
-
|
100
|
-
assert_equal(target, result, caption)
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_for_store_mso_dg_container
|
104
|
-
caption = sprintf(" \t_store_mso_dg_container()")
|
105
|
-
data = [0xC8]
|
106
|
-
target = %w( 0F 00 02 F0 C8 00 00 00 ).join(' ')
|
107
|
-
|
108
|
-
result = unpack_record(@worksheet.store_mso_dg_container(*data))
|
109
|
-
|
110
|
-
assert_equal(target, result, caption)
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_for_store_mso_dg
|
114
|
-
caption = sprintf(" \t_store_mso_dg()")
|
115
|
-
data = [1, 2, 1025]
|
116
|
-
target = %w( 10 00 08 F0
|
117
|
-
08 00 00 00 02 00 00 00 01 04 00 00
|
118
|
-
).join(' ')
|
119
|
-
|
120
|
-
result = unpack_record(@worksheet.store_mso_dg(*data))
|
121
|
-
|
122
|
-
assert_equal(target, result, caption)
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_for_store_mso_spgr_container
|
126
|
-
caption = sprintf(" \t_store_mso_spgr_container()")
|
127
|
-
data = [0xB0]
|
128
|
-
target = %w(
|
129
|
-
0F 00 03 F0 B0 00 00 00
|
130
|
-
).join(' ')
|
131
|
-
|
132
|
-
result = unpack_record(@worksheet.store_mso_spgr_container(*data))
|
133
|
-
|
134
|
-
assert_equal(target, result, caption)
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_for_store_mso_sp_container
|
138
|
-
caption = sprintf(" \t_store_mso_sp_container()")
|
139
|
-
data = [0x28]
|
140
|
-
target = %w(
|
141
|
-
0F 00 04 F0 28 00 00 00
|
142
|
-
).join(' ')
|
143
|
-
|
144
|
-
result = unpack_record(@worksheet.store_mso_sp_container(*data))
|
145
|
-
|
146
|
-
assert_equal(target, result, caption)
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_for_store_mso_sp
|
150
|
-
caption = sprintf(" \t_store_mso_sp()")
|
151
|
-
data = [0, 1024, 0x0005]
|
152
|
-
target = %w(
|
153
|
-
02 00 0A F0 08 00 00 00 00 04 00 00 05 00 00 00
|
154
|
-
).join(' ')
|
155
|
-
|
156
|
-
result = unpack_record(@worksheet.store_mso_sp(*data))
|
157
|
-
|
158
|
-
assert_equal(target, result, caption)
|
159
|
-
|
160
|
-
data = [202, 1025, 0x0A00]
|
161
|
-
target = %w(
|
162
|
-
A2 0C 0A F0 08 00 00 00 01 04 00 00 00 0A 00 00
|
163
|
-
).join(' ')
|
164
|
-
|
165
|
-
result = unpack_record(@worksheet.store_mso_sp(*data))
|
166
|
-
|
167
|
-
assert_equal(target, result, caption)
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_for_store_mso_opt_comment
|
171
|
-
caption = sprintf(" \t_store_mso_opt_comment()")
|
172
|
-
data = [0x80]
|
173
|
-
target = %w(
|
174
|
-
93 00 0B F0 36 00 00 00
|
175
|
-
80 00 00 00 00 00 BF 00 08 00 08 00
|
176
|
-
58 01 00 00 00 00 81 01 50 00 00 08 83 01 50 00
|
177
|
-
00 08 BF 01 10 00 11 00 01 02 00 00 00 00 3F 02
|
178
|
-
03 00 03 00 BF 03 02 00 0A 00
|
179
|
-
).join(' ')
|
180
|
-
|
181
|
-
result = unpack_record(@worksheet.store_mso_opt_comment(*data))
|
182
|
-
|
183
|
-
assert_equal(target, result, caption)
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_for_store_mso_client_anchor
|
187
|
-
|
188
|
-
# A1
|
189
|
-
range = 'A1'
|
190
|
-
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
191
|
-
data = @worksheet.substitute_cellref(range)
|
192
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
193
|
-
data = data[-1]
|
194
|
-
target = %w(
|
195
|
-
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 00 00
|
196
|
-
1E 00 03 00 F0 00 04 00 78 00
|
197
|
-
).join(' ')
|
198
|
-
|
199
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
200
|
-
|
201
|
-
assert_equal(target, result, caption)
|
202
|
-
|
203
|
-
# A2
|
204
|
-
range = 'A2'
|
205
|
-
data = @worksheet.substitute_cellref(range)
|
206
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
207
|
-
data = data[-1]
|
208
|
-
target = %w(
|
209
|
-
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 00 00
|
210
|
-
69 00 03 00 F0 00 04 00 C4 00
|
211
|
-
).join(' ')
|
212
|
-
|
213
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
214
|
-
|
215
|
-
assert_equal(target, result, caption)
|
216
|
-
|
217
|
-
|
218
|
-
# A3
|
219
|
-
range = 'A3'
|
220
|
-
data = @worksheet.substitute_cellref(range)
|
221
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
222
|
-
data = data[-1]
|
223
|
-
target = %w(
|
224
|
-
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 01 00
|
225
|
-
69 00 03 00 F0 00 05 00 C4 00
|
226
|
-
).join(' ')
|
227
|
-
|
228
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
229
|
-
|
230
|
-
assert_equal(target, result, caption)
|
231
|
-
|
232
|
-
|
233
|
-
# A65534
|
234
|
-
range = 'A65534'
|
235
|
-
data = @worksheet.substitute_cellref(range)
|
236
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
237
|
-
data = data[-1]
|
238
|
-
target = %w(
|
239
|
-
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 F9 FF
|
240
|
-
3C 00 03 00 F0 00 FD FF 97 00
|
241
|
-
).join(' ')
|
242
|
-
|
243
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
244
|
-
|
245
|
-
assert_equal(target, result, caption)
|
246
|
-
|
247
|
-
|
248
|
-
# A65536
|
249
|
-
range = 'A65536'
|
250
|
-
data = @worksheet.substitute_cellref(range)
|
251
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
252
|
-
data = data[-1]
|
253
|
-
target = %w(
|
254
|
-
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 FB FF
|
255
|
-
1E 00 03 00 F0 00 FF FF 78 00
|
256
|
-
).join(' ')
|
257
|
-
|
258
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
259
|
-
|
260
|
-
assert_equal(target, result, caption)
|
261
|
-
|
262
|
-
|
263
|
-
# IT3
|
264
|
-
range = 'IT3'
|
265
|
-
data = @worksheet.substitute_cellref(range)
|
266
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
267
|
-
data = data[-1]
|
268
|
-
target = %w(
|
269
|
-
00 00 10 F0 12 00 00 00 03 00 FA 00 10 03 01 00
|
270
|
-
69 00 FC 00 10 03 05 00 C4 00
|
271
|
-
).join(' ')
|
272
|
-
|
273
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
274
|
-
|
275
|
-
assert_equal(target, result, caption)
|
276
|
-
|
277
|
-
|
278
|
-
# IU3
|
279
|
-
range = 'IU3'
|
280
|
-
data = @worksheet.substitute_cellref(range)
|
281
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
282
|
-
data = data[-1]
|
283
|
-
target = %w(
|
284
|
-
00 00 10 F0 12 00 00 00 03 00 FB 00 10 03 01 00
|
285
|
-
69 00 FD 00 10 03 05 00 C4 00
|
286
|
-
).join(' ')
|
287
|
-
|
288
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
289
|
-
|
290
|
-
assert_equal(target, result, caption)
|
291
|
-
|
292
|
-
|
293
|
-
#
|
294
|
-
range = 'IU3'
|
295
|
-
data = @worksheet.substitute_cellref(range)
|
296
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
297
|
-
data = data[-1]
|
298
|
-
target = %w(
|
299
|
-
00 00 10 F0 12 00 00 00 03 00 FB 00 10 03 01 00
|
300
|
-
69 00 FD 00 10 03 05 00 C4 00
|
301
|
-
).join(' ')
|
302
|
-
|
303
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
304
|
-
|
305
|
-
assert_equal(target, result, caption)
|
306
|
-
|
307
|
-
|
308
|
-
# IV3
|
309
|
-
range = 'IV3'
|
310
|
-
data = @worksheet.substitute_cellref(range)
|
311
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
312
|
-
data = data[-1]
|
313
|
-
target = %w(
|
314
|
-
00 00 10 F0 12 00 00 00 03 00 FC 00 10 03 01 00
|
315
|
-
69 00 FE 00 10 03 05 00 C4 00
|
316
|
-
).join(' ')
|
317
|
-
|
318
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
319
|
-
|
320
|
-
assert_equal(target, result, caption)
|
321
|
-
|
322
|
-
end
|
323
|
-
|
324
|
-
def test_for_store_mso_client_anchor_where_comment_offsets_have_changed
|
325
|
-
range = 'A3'
|
326
|
-
caption = sprintf(" \t_store_mso_client_anchor(%s). Cell offsets changes.", range)
|
327
|
-
data = @worksheet.substitute_cellref(range)
|
328
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
329
|
-
:x_offset=>18, :y_offset=>9)
|
330
|
-
data = data[-1]
|
331
|
-
target = %w(
|
332
|
-
00 00 10 F0 12 00
|
333
|
-
00 00 03 00 01 00 20 01 01 00 88 00 03 00 20 01
|
334
|
-
05 00 E2 00
|
335
|
-
).join(' ')
|
336
|
-
|
337
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
338
|
-
|
339
|
-
assert_equal(target, result, caption)
|
340
|
-
end
|
341
|
-
|
342
|
-
def test_for_store_mso_client_anchor_where_comment_dimensions_have_changed
|
343
|
-
# x_scale, y_scale
|
344
|
-
range = 'A3'
|
345
|
-
caption = sprintf(" \t_store_mso_client_anchor(%s). Dimensions changes.", range)
|
346
|
-
data = @worksheet.substitute_cellref(range)
|
347
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
348
|
-
:x_scale=>3, :y_scale=>2)
|
349
|
-
data = data[-1]
|
350
|
-
target = %w(
|
351
|
-
00 00 10 F0 12 00 00 00 03 00
|
352
|
-
01 00 F0 00 01 00 69 00 07 00 F0 00 0A 00 1E 00
|
353
|
-
).join(' ')
|
354
|
-
|
355
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
356
|
-
|
357
|
-
assert_equal(target, result, caption)
|
358
|
-
|
359
|
-
|
360
|
-
# width, height
|
361
|
-
data = @worksheet.substitute_cellref(range)
|
362
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
363
|
-
:width=>384, :height=>148)
|
364
|
-
data = data[-1]
|
365
|
-
target = %w(
|
366
|
-
00 00 10 F0 12 00 00 00 03 00
|
367
|
-
01 00 F0 00 01 00 69 00 07 00 F0 00 0A 00 1E 00
|
368
|
-
).join(' ')
|
369
|
-
|
370
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
371
|
-
|
372
|
-
assert_equal(target, result, caption)
|
373
|
-
|
374
|
-
end
|
375
|
-
|
376
|
-
def test_for_store_mso_client_anchor_where_column_widths_have_changed
|
377
|
-
# set_column G:G
|
378
|
-
range = 'F3'
|
379
|
-
@worksheet.set_column('G:G', 20)
|
380
|
-
|
381
|
-
caption = sprintf(" \t_store_mso_client_anchor(%s). Col width changes.", range)
|
382
|
-
data = @worksheet.substitute_cellref(range)
|
383
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
384
|
-
data = data[-1]
|
385
|
-
|
386
|
-
target = %w(
|
387
|
-
00 00 10 F0 12 00
|
388
|
-
00 00 03 00 06 00 6A 00 01 00 69 00 06 00 F2 03
|
389
|
-
05 00 C4 00
|
390
|
-
).join(' ')
|
391
|
-
|
392
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
393
|
-
|
394
|
-
assert_equal(target, result, caption)
|
395
|
-
|
396
|
-
|
397
|
-
# set_column L:O
|
398
|
-
range = 'K3'
|
399
|
-
@worksheet.set_column('L:O', 4)
|
400
|
-
|
401
|
-
data = @worksheet.substitute_cellref(range)
|
402
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
403
|
-
data = data[-1]
|
404
|
-
|
405
|
-
target = %w(
|
406
|
-
00 00 10 F0 12 00
|
407
|
-
00 00 03 00 0B 00 D1 01 01 00 69 00 0F 00 B0 00
|
408
|
-
05 00 C4 00
|
409
|
-
).join(' ')
|
410
|
-
|
411
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
412
|
-
|
413
|
-
assert_equal(target, result, caption)
|
414
|
-
|
415
|
-
end
|
416
|
-
|
417
|
-
def test_for_store_mso_client_anchor_where_row_height_have_changed
|
418
|
-
# set_row 5 to 8
|
419
|
-
range = 'A6'
|
420
|
-
@worksheet.set_row(5, 6)
|
421
|
-
@worksheet.set_row(6, 6)
|
422
|
-
@worksheet.set_row(7, 6)
|
423
|
-
@worksheet.set_row(8, 6)
|
424
|
-
|
425
|
-
caption = sprintf(" \t_store_mso_client_anchor(%s). Row height changed.", range)
|
426
|
-
data = @worksheet.substitute_cellref(range)
|
427
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
428
|
-
data = data[-1]
|
429
|
-
|
430
|
-
target = %w(
|
431
|
-
00 00 10 F0 12 00
|
432
|
-
00 00 03 00 01 00 F0 00 04 00 69 00 03 00 F0 00
|
433
|
-
0A 00 E2 00
|
434
|
-
).join(' ')
|
435
|
-
|
436
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
437
|
-
|
438
|
-
assert_equal(target, result, caption)
|
439
|
-
|
440
|
-
|
441
|
-
# set_row 14
|
442
|
-
range = 'A15'
|
443
|
-
@worksheet.set_row(14, 60)
|
444
|
-
|
445
|
-
caption = sprintf(" \t_store_mso_client_anchor(%s). Row height changed.", range)
|
446
|
-
data = @worksheet.substitute_cellref(range)
|
447
|
-
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
448
|
-
data = data[-1]
|
449
|
-
|
450
|
-
target = %w(
|
451
|
-
00 00 10 F0 12 00
|
452
|
-
00 00 03 00 01 00 F0 00 0D 00 69 00 03 00 F0 00
|
453
|
-
0E 00 CD 00
|
454
|
-
).join(' ')
|
455
|
-
|
456
|
-
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
457
|
-
|
458
|
-
assert_equal(target, result, caption)
|
459
|
-
|
460
|
-
end
|
461
|
-
|
462
|
-
def test_for_store_mso_client_data
|
463
|
-
caption = sprintf(" \t_store_mso_client_data")
|
464
|
-
target = %w(
|
465
|
-
00 00 11 F0 00 00 00 00
|
466
|
-
).join(' ')
|
467
|
-
|
468
|
-
result = unpack_record(@worksheet.store_mso_client_data)
|
469
|
-
|
470
|
-
assert_equal(target, result, caption)
|
471
|
-
end
|
472
|
-
|
473
|
-
def test_for_store_obj_comment
|
474
|
-
caption = sprintf(" \t_store_obj_comment")
|
475
|
-
data = [0x01]
|
476
|
-
target = %w(
|
477
|
-
5D 00 34 00 15 00 12 00 19 00 01 00 11 40 00 00
|
478
|
-
00 00 00 00 00 00 00 00 00 00 0D 00 16 00 00 00
|
479
|
-
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
480
|
-
00 00 00 00 00 00 00 00
|
481
|
-
).join(' ')
|
482
|
-
|
483
|
-
result = unpack_record(@worksheet.store_obj_comment(*data))
|
484
|
-
|
485
|
-
assert_equal(target, result, caption)
|
486
|
-
end
|
487
|
-
|
488
|
-
def test_for_store_mso_client_text_box
|
489
|
-
caption = sprintf(" \t_store_mso_client_text_box")
|
490
|
-
target = %w(
|
491
|
-
00 00 0D F0 00 00 00 00
|
492
|
-
).join(' ')
|
493
|
-
|
494
|
-
result = unpack_record(@worksheet.store_mso_client_text_box)
|
495
|
-
|
496
|
-
assert_equal(target, result, caption)
|
497
|
-
end
|
498
|
-
=end
|
499
|
-
|
500
|
-
###############################################################################
|
501
|
-
#
|
502
|
-
# Unpack the binary data into a format suitable for printing in tests.
|
503
|
-
#
|
504
|
-
def unpack_record(data)
|
505
|
-
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
506
|
-
end
|
507
|
-
|
508
|
-
def data_for_test
|
509
|
-
return [
|
510
|
-
[ 'DggContainer', # Caption
|
511
|
-
0xF000, # Type
|
512
|
-
15, # Version
|
513
|
-
0, # Instance
|
514
|
-
'', # Data
|
515
|
-
82, # Length
|
516
|
-
'0F 00 00 F0 52 00 00 00', # Target
|
517
|
-
],
|
518
|
-
|
519
|
-
[ 'DgContainer', # Caption
|
520
|
-
0xF002, # Type
|
521
|
-
15, # Version
|
522
|
-
0, # Instance
|
523
|
-
'', # Data
|
524
|
-
328, # Length
|
525
|
-
'0F 00 02 F0 48 01 00 00', # Target
|
526
|
-
],
|
527
|
-
|
528
|
-
[ 'SpgrContainer', # Caption
|
529
|
-
0xF003, # Type
|
530
|
-
15, # Version
|
531
|
-
0, # Instance
|
532
|
-
'', # Data
|
533
|
-
304, # Length
|
534
|
-
'0F 00 03 F0 30 01 00 00', # Target
|
535
|
-
],
|
536
|
-
|
537
|
-
[ 'SpContainer', # Caption
|
538
|
-
0xF004, # Type
|
539
|
-
15, # Version
|
540
|
-
0, # Instance
|
541
|
-
'', # Data
|
542
|
-
40, # Length
|
543
|
-
'0F 00 04 F0 28 00 00 00', # Target
|
544
|
-
],
|
545
|
-
|
546
|
-
[ 'Dgg', # Caption
|
547
|
-
0xF006, # Type
|
548
|
-
0, # Version
|
549
|
-
0, # Instance
|
550
|
-
'02 04 00 00 02 00 00 00 ' + # Data
|
551
|
-
'02 00 00 00 01 00 00 00 ' +
|
552
|
-
'01 00 00 00 02 00 00 00',
|
553
|
-
nil, # Length
|
554
|
-
'00 00 06 F0 18 00 00 00 ' + # Target
|
555
|
-
'02 04 00 00 02 00 00 00 ' +
|
556
|
-
'02 00 00 00 01 00 00 00 ' +
|
557
|
-
'01 00 00 00 02 00 00 00',
|
558
|
-
],
|
559
|
-
|
560
|
-
[ 'Dg', # Caption
|
561
|
-
0xF008, # Type
|
562
|
-
0, # Version
|
563
|
-
1, # Instance
|
564
|
-
'03 00 00 00 02 04 00 00', # Data
|
565
|
-
nil, # Length
|
566
|
-
'10 00 08 F0 08 00 00 00 ' + # Target
|
567
|
-
'03 00 00 00 02 04 00 00',
|
568
|
-
],
|
569
|
-
|
570
|
-
[ 'Spgr', # Caption
|
571
|
-
0xF009, # Type
|
572
|
-
1, # Version
|
573
|
-
0, # Instance
|
574
|
-
'00 0E 00 0E 40 41 00 00 ' + # Data
|
575
|
-
'00 0E 00 0E 40 41 00 00',
|
576
|
-
nil, # Length
|
577
|
-
'01 00 09 F0 10 00 00 00 ' + # Target
|
578
|
-
'00 0E 00 0E 40 41 00 00 ' +
|
579
|
-
'00 0E 00 0E 40 41 00 00',
|
580
|
-
],
|
581
|
-
|
582
|
-
[ 'ClientTextbox', # Caption
|
583
|
-
0xF00D, # Type
|
584
|
-
0, # Version
|
585
|
-
0, # Instance
|
586
|
-
'', # Data
|
587
|
-
nil, # Length
|
588
|
-
'00 00 0D F0 00 00 00 00', # Target
|
589
|
-
],
|
590
|
-
|
591
|
-
[ 'ClientAnchor', # Caption
|
592
|
-
0xF010, # Type
|
593
|
-
0, # Version
|
594
|
-
0, # Instance
|
595
|
-
'03 00 01 00 F0 00 01 00 ' + # Data
|
596
|
-
'69 00 03 00 F0 00 05 00 ' +
|
597
|
-
'C4 00',
|
598
|
-
nil, # Length
|
599
|
-
'00 00 10 F0 12 00 00 00 ' + # Target
|
600
|
-
'03 00 01 00 F0 00 01 00 ' +
|
601
|
-
'69 00 03 00 F0 00 05 00 ' +
|
602
|
-
'C4 00',
|
603
|
-
],
|
604
|
-
|
605
|
-
[ 'ClientData', # Caption
|
606
|
-
0xF011, # Type
|
607
|
-
0, # Version
|
608
|
-
0, # Instance
|
609
|
-
'', # Data
|
610
|
-
nil, # Length
|
611
|
-
'00 00 11 F0 00 00 00 00', # Target
|
612
|
-
],
|
613
|
-
|
614
|
-
[ 'SplitMenuColors', # Caption
|
615
|
-
0xF11E, # Type
|
616
|
-
0, # Version
|
617
|
-
4, # Instance
|
618
|
-
'0D 00 00 08 0C 00 00 08 ' + # Data
|
619
|
-
'17 00 00 08 F7 00 00 10',
|
620
|
-
nil, # Length
|
621
|
-
'40 00 1E F1 10 00 00 00 ' + # Target
|
622
|
-
'0D 00 00 08 0C 00 00 08 ' +
|
623
|
-
'17 00 00 08 F7 00 00 10',
|
624
|
-
],
|
625
|
-
|
626
|
-
[ 'BstoreContainer', # Caption
|
627
|
-
0xF001, # Type
|
628
|
-
15, # Version
|
629
|
-
1, # Instance
|
630
|
-
'', # Data
|
631
|
-
163, # Length
|
632
|
-
'1F 00 01 F0 A3 00 00 00', # Target
|
633
|
-
],
|
634
|
-
]
|
635
|
-
end
|
636
|
-
|
637
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
###############################################################################
|
3
|
+
#
|
4
|
+
# A test for WriteExcel.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# all test is commented out because Workbook#add_mso_... was set to private
|
8
|
+
# method. Before that, all test passed.
|
9
|
+
#
|
10
|
+
#
|
11
|
+
#
|
12
|
+
#
|
13
|
+
# Tests for the internal methods used to write the records in an Escher drawing
|
14
|
+
# object such as images, comments and filters.
|
15
|
+
#
|
16
|
+
# reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
|
17
|
+
#
|
18
|
+
# original written in Perl by John McNamara
|
19
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
20
|
+
#
|
21
|
+
############################################################################
|
22
|
+
require 'helper'
|
23
|
+
require 'stringio'
|
24
|
+
|
25
|
+
class TC_escher < Test::Unit::TestCase
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@workbook = WriteExcel.new(StringIO.new)
|
29
|
+
@worksheet = @workbook.add_worksheet
|
30
|
+
end
|
31
|
+
|
32
|
+
def teardown
|
33
|
+
@workbook.close
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_dummy
|
37
|
+
assert(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
=begin
|
41
|
+
def test_for_the_generic_method
|
42
|
+
data_for_test.each do |data|
|
43
|
+
caption = data.shift
|
44
|
+
target = data.pop
|
45
|
+
|
46
|
+
data[3].gsub!(/ /,'')
|
47
|
+
data[3] = [data[3]].pack('H*')
|
48
|
+
|
49
|
+
caption = sprintf(" \t_add_mso_generic(): (0x%04X) %s", data[0], caption)
|
50
|
+
|
51
|
+
result = unpack_record(@worksheet.add_mso_generic(*data))
|
52
|
+
|
53
|
+
assert_equal(target, result, caption)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_for_store_mso_dgg_container
|
58
|
+
caption = sprintf(" \t_store_mso_dgg_container()")
|
59
|
+
target = %w( 0F 00 00 F0 52 00 00 00 ).join(' ')
|
60
|
+
|
61
|
+
@workbook.mso_size = 94
|
62
|
+
result = unpack_record(@workbook.store_mso_dgg_container)
|
63
|
+
|
64
|
+
assert_equal(target, result, caption)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_for_store_mso_dgg
|
68
|
+
caption = sprintf(" \t_store_mso_dgg()")
|
69
|
+
data = [ 1026, 2, 2, 1, [[1,2]] ]
|
70
|
+
target = %w( 00 00 06 F0
|
71
|
+
18 00 00 00 02 04 00 00 02 00 00 00 02 00 00 00
|
72
|
+
01 00 00 00 01 00 00 00 02 00 00 00
|
73
|
+
).join(' ')
|
74
|
+
|
75
|
+
result = unpack_record(@workbook.store_mso_dgg(*data))
|
76
|
+
|
77
|
+
assert_equal(target, result, caption)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_for_store_mso_opt
|
81
|
+
caption = sprintf(" \t_store_mso_opt()")
|
82
|
+
target = %w( 33 00 0B F0
|
83
|
+
12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
|
84
|
+
C0 01 40 00 00 08
|
85
|
+
).join(' ')
|
86
|
+
|
87
|
+
result = unpack_record(@workbook.store_mso_opt)
|
88
|
+
|
89
|
+
assert_equal(target, result, caption)
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_for_store_mso_split_menu_colors
|
93
|
+
caption = sprintf(" \t_store_mso_split_menu_colors()")
|
94
|
+
target = %w( 40 00 1E F1 10 00 00 00 0D 00
|
95
|
+
00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
|
96
|
+
).join(' ')
|
97
|
+
|
98
|
+
result = unpack_record(@workbook.store_mso_split_menu_colors)
|
99
|
+
|
100
|
+
assert_equal(target, result, caption)
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_for_store_mso_dg_container
|
104
|
+
caption = sprintf(" \t_store_mso_dg_container()")
|
105
|
+
data = [0xC8]
|
106
|
+
target = %w( 0F 00 02 F0 C8 00 00 00 ).join(' ')
|
107
|
+
|
108
|
+
result = unpack_record(@worksheet.store_mso_dg_container(*data))
|
109
|
+
|
110
|
+
assert_equal(target, result, caption)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_for_store_mso_dg
|
114
|
+
caption = sprintf(" \t_store_mso_dg()")
|
115
|
+
data = [1, 2, 1025]
|
116
|
+
target = %w( 10 00 08 F0
|
117
|
+
08 00 00 00 02 00 00 00 01 04 00 00
|
118
|
+
).join(' ')
|
119
|
+
|
120
|
+
result = unpack_record(@worksheet.store_mso_dg(*data))
|
121
|
+
|
122
|
+
assert_equal(target, result, caption)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_for_store_mso_spgr_container
|
126
|
+
caption = sprintf(" \t_store_mso_spgr_container()")
|
127
|
+
data = [0xB0]
|
128
|
+
target = %w(
|
129
|
+
0F 00 03 F0 B0 00 00 00
|
130
|
+
).join(' ')
|
131
|
+
|
132
|
+
result = unpack_record(@worksheet.store_mso_spgr_container(*data))
|
133
|
+
|
134
|
+
assert_equal(target, result, caption)
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_for_store_mso_sp_container
|
138
|
+
caption = sprintf(" \t_store_mso_sp_container()")
|
139
|
+
data = [0x28]
|
140
|
+
target = %w(
|
141
|
+
0F 00 04 F0 28 00 00 00
|
142
|
+
).join(' ')
|
143
|
+
|
144
|
+
result = unpack_record(@worksheet.store_mso_sp_container(*data))
|
145
|
+
|
146
|
+
assert_equal(target, result, caption)
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_for_store_mso_sp
|
150
|
+
caption = sprintf(" \t_store_mso_sp()")
|
151
|
+
data = [0, 1024, 0x0005]
|
152
|
+
target = %w(
|
153
|
+
02 00 0A F0 08 00 00 00 00 04 00 00 05 00 00 00
|
154
|
+
).join(' ')
|
155
|
+
|
156
|
+
result = unpack_record(@worksheet.store_mso_sp(*data))
|
157
|
+
|
158
|
+
assert_equal(target, result, caption)
|
159
|
+
|
160
|
+
data = [202, 1025, 0x0A00]
|
161
|
+
target = %w(
|
162
|
+
A2 0C 0A F0 08 00 00 00 01 04 00 00 00 0A 00 00
|
163
|
+
).join(' ')
|
164
|
+
|
165
|
+
result = unpack_record(@worksheet.store_mso_sp(*data))
|
166
|
+
|
167
|
+
assert_equal(target, result, caption)
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_for_store_mso_opt_comment
|
171
|
+
caption = sprintf(" \t_store_mso_opt_comment()")
|
172
|
+
data = [0x80]
|
173
|
+
target = %w(
|
174
|
+
93 00 0B F0 36 00 00 00
|
175
|
+
80 00 00 00 00 00 BF 00 08 00 08 00
|
176
|
+
58 01 00 00 00 00 81 01 50 00 00 08 83 01 50 00
|
177
|
+
00 08 BF 01 10 00 11 00 01 02 00 00 00 00 3F 02
|
178
|
+
03 00 03 00 BF 03 02 00 0A 00
|
179
|
+
).join(' ')
|
180
|
+
|
181
|
+
result = unpack_record(@worksheet.store_mso_opt_comment(*data))
|
182
|
+
|
183
|
+
assert_equal(target, result, caption)
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_for_store_mso_client_anchor
|
187
|
+
|
188
|
+
# A1
|
189
|
+
range = 'A1'
|
190
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s)", range)
|
191
|
+
data = @worksheet.substitute_cellref(range)
|
192
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
193
|
+
data = data[-1]
|
194
|
+
target = %w(
|
195
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 00 00
|
196
|
+
1E 00 03 00 F0 00 04 00 78 00
|
197
|
+
).join(' ')
|
198
|
+
|
199
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
200
|
+
|
201
|
+
assert_equal(target, result, caption)
|
202
|
+
|
203
|
+
# A2
|
204
|
+
range = 'A2'
|
205
|
+
data = @worksheet.substitute_cellref(range)
|
206
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
207
|
+
data = data[-1]
|
208
|
+
target = %w(
|
209
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 00 00
|
210
|
+
69 00 03 00 F0 00 04 00 C4 00
|
211
|
+
).join(' ')
|
212
|
+
|
213
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
214
|
+
|
215
|
+
assert_equal(target, result, caption)
|
216
|
+
|
217
|
+
|
218
|
+
# A3
|
219
|
+
range = 'A3'
|
220
|
+
data = @worksheet.substitute_cellref(range)
|
221
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
222
|
+
data = data[-1]
|
223
|
+
target = %w(
|
224
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 01 00
|
225
|
+
69 00 03 00 F0 00 05 00 C4 00
|
226
|
+
).join(' ')
|
227
|
+
|
228
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
229
|
+
|
230
|
+
assert_equal(target, result, caption)
|
231
|
+
|
232
|
+
|
233
|
+
# A65534
|
234
|
+
range = 'A65534'
|
235
|
+
data = @worksheet.substitute_cellref(range)
|
236
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
237
|
+
data = data[-1]
|
238
|
+
target = %w(
|
239
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 F9 FF
|
240
|
+
3C 00 03 00 F0 00 FD FF 97 00
|
241
|
+
).join(' ')
|
242
|
+
|
243
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
244
|
+
|
245
|
+
assert_equal(target, result, caption)
|
246
|
+
|
247
|
+
|
248
|
+
# A65536
|
249
|
+
range = 'A65536'
|
250
|
+
data = @worksheet.substitute_cellref(range)
|
251
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
252
|
+
data = data[-1]
|
253
|
+
target = %w(
|
254
|
+
00 00 10 F0 12 00 00 00 03 00 01 00 F0 00 FB FF
|
255
|
+
1E 00 03 00 F0 00 FF FF 78 00
|
256
|
+
).join(' ')
|
257
|
+
|
258
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
259
|
+
|
260
|
+
assert_equal(target, result, caption)
|
261
|
+
|
262
|
+
|
263
|
+
# IT3
|
264
|
+
range = 'IT3'
|
265
|
+
data = @worksheet.substitute_cellref(range)
|
266
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
267
|
+
data = data[-1]
|
268
|
+
target = %w(
|
269
|
+
00 00 10 F0 12 00 00 00 03 00 FA 00 10 03 01 00
|
270
|
+
69 00 FC 00 10 03 05 00 C4 00
|
271
|
+
).join(' ')
|
272
|
+
|
273
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
274
|
+
|
275
|
+
assert_equal(target, result, caption)
|
276
|
+
|
277
|
+
|
278
|
+
# IU3
|
279
|
+
range = 'IU3'
|
280
|
+
data = @worksheet.substitute_cellref(range)
|
281
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
282
|
+
data = data[-1]
|
283
|
+
target = %w(
|
284
|
+
00 00 10 F0 12 00 00 00 03 00 FB 00 10 03 01 00
|
285
|
+
69 00 FD 00 10 03 05 00 C4 00
|
286
|
+
).join(' ')
|
287
|
+
|
288
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
289
|
+
|
290
|
+
assert_equal(target, result, caption)
|
291
|
+
|
292
|
+
|
293
|
+
#
|
294
|
+
range = 'IU3'
|
295
|
+
data = @worksheet.substitute_cellref(range)
|
296
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
297
|
+
data = data[-1]
|
298
|
+
target = %w(
|
299
|
+
00 00 10 F0 12 00 00 00 03 00 FB 00 10 03 01 00
|
300
|
+
69 00 FD 00 10 03 05 00 C4 00
|
301
|
+
).join(' ')
|
302
|
+
|
303
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
304
|
+
|
305
|
+
assert_equal(target, result, caption)
|
306
|
+
|
307
|
+
|
308
|
+
# IV3
|
309
|
+
range = 'IV3'
|
310
|
+
data = @worksheet.substitute_cellref(range)
|
311
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
312
|
+
data = data[-1]
|
313
|
+
target = %w(
|
314
|
+
00 00 10 F0 12 00 00 00 03 00 FC 00 10 03 01 00
|
315
|
+
69 00 FE 00 10 03 05 00 C4 00
|
316
|
+
).join(' ')
|
317
|
+
|
318
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
319
|
+
|
320
|
+
assert_equal(target, result, caption)
|
321
|
+
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_for_store_mso_client_anchor_where_comment_offsets_have_changed
|
325
|
+
range = 'A3'
|
326
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Cell offsets changes.", range)
|
327
|
+
data = @worksheet.substitute_cellref(range)
|
328
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
329
|
+
:x_offset=>18, :y_offset=>9)
|
330
|
+
data = data[-1]
|
331
|
+
target = %w(
|
332
|
+
00 00 10 F0 12 00
|
333
|
+
00 00 03 00 01 00 20 01 01 00 88 00 03 00 20 01
|
334
|
+
05 00 E2 00
|
335
|
+
).join(' ')
|
336
|
+
|
337
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
338
|
+
|
339
|
+
assert_equal(target, result, caption)
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_for_store_mso_client_anchor_where_comment_dimensions_have_changed
|
343
|
+
# x_scale, y_scale
|
344
|
+
range = 'A3'
|
345
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Dimensions changes.", range)
|
346
|
+
data = @worksheet.substitute_cellref(range)
|
347
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
348
|
+
:x_scale=>3, :y_scale=>2)
|
349
|
+
data = data[-1]
|
350
|
+
target = %w(
|
351
|
+
00 00 10 F0 12 00 00 00 03 00
|
352
|
+
01 00 F0 00 01 00 69 00 07 00 F0 00 0A 00 1E 00
|
353
|
+
).join(' ')
|
354
|
+
|
355
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
356
|
+
|
357
|
+
assert_equal(target, result, caption)
|
358
|
+
|
359
|
+
|
360
|
+
# width, height
|
361
|
+
data = @worksheet.substitute_cellref(range)
|
362
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test',
|
363
|
+
:width=>384, :height=>148)
|
364
|
+
data = data[-1]
|
365
|
+
target = %w(
|
366
|
+
00 00 10 F0 12 00 00 00 03 00
|
367
|
+
01 00 F0 00 01 00 69 00 07 00 F0 00 0A 00 1E 00
|
368
|
+
).join(' ')
|
369
|
+
|
370
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
371
|
+
|
372
|
+
assert_equal(target, result, caption)
|
373
|
+
|
374
|
+
end
|
375
|
+
|
376
|
+
def test_for_store_mso_client_anchor_where_column_widths_have_changed
|
377
|
+
# set_column G:G
|
378
|
+
range = 'F3'
|
379
|
+
@worksheet.set_column('G:G', 20)
|
380
|
+
|
381
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Col width changes.", range)
|
382
|
+
data = @worksheet.substitute_cellref(range)
|
383
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
384
|
+
data = data[-1]
|
385
|
+
|
386
|
+
target = %w(
|
387
|
+
00 00 10 F0 12 00
|
388
|
+
00 00 03 00 06 00 6A 00 01 00 69 00 06 00 F2 03
|
389
|
+
05 00 C4 00
|
390
|
+
).join(' ')
|
391
|
+
|
392
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
393
|
+
|
394
|
+
assert_equal(target, result, caption)
|
395
|
+
|
396
|
+
|
397
|
+
# set_column L:O
|
398
|
+
range = 'K3'
|
399
|
+
@worksheet.set_column('L:O', 4)
|
400
|
+
|
401
|
+
data = @worksheet.substitute_cellref(range)
|
402
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
403
|
+
data = data[-1]
|
404
|
+
|
405
|
+
target = %w(
|
406
|
+
00 00 10 F0 12 00
|
407
|
+
00 00 03 00 0B 00 D1 01 01 00 69 00 0F 00 B0 00
|
408
|
+
05 00 C4 00
|
409
|
+
).join(' ')
|
410
|
+
|
411
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
412
|
+
|
413
|
+
assert_equal(target, result, caption)
|
414
|
+
|
415
|
+
end
|
416
|
+
|
417
|
+
def test_for_store_mso_client_anchor_where_row_height_have_changed
|
418
|
+
# set_row 5 to 8
|
419
|
+
range = 'A6'
|
420
|
+
@worksheet.set_row(5, 6)
|
421
|
+
@worksheet.set_row(6, 6)
|
422
|
+
@worksheet.set_row(7, 6)
|
423
|
+
@worksheet.set_row(8, 6)
|
424
|
+
|
425
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Row height changed.", range)
|
426
|
+
data = @worksheet.substitute_cellref(range)
|
427
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
428
|
+
data = data[-1]
|
429
|
+
|
430
|
+
target = %w(
|
431
|
+
00 00 10 F0 12 00
|
432
|
+
00 00 03 00 01 00 F0 00 04 00 69 00 03 00 F0 00
|
433
|
+
0A 00 E2 00
|
434
|
+
).join(' ')
|
435
|
+
|
436
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
437
|
+
|
438
|
+
assert_equal(target, result, caption)
|
439
|
+
|
440
|
+
|
441
|
+
# set_row 14
|
442
|
+
range = 'A15'
|
443
|
+
@worksheet.set_row(14, 60)
|
444
|
+
|
445
|
+
caption = sprintf(" \t_store_mso_client_anchor(%s). Row height changed.", range)
|
446
|
+
data = @worksheet.substitute_cellref(range)
|
447
|
+
data = @worksheet.comment_params(data[0], data[1], 'Test')
|
448
|
+
data = data[-1]
|
449
|
+
|
450
|
+
target = %w(
|
451
|
+
00 00 10 F0 12 00
|
452
|
+
00 00 03 00 01 00 F0 00 0D 00 69 00 03 00 F0 00
|
453
|
+
0E 00 CD 00
|
454
|
+
).join(' ')
|
455
|
+
|
456
|
+
result = unpack_record(@worksheet.store_mso_client_anchor(3, *data))
|
457
|
+
|
458
|
+
assert_equal(target, result, caption)
|
459
|
+
|
460
|
+
end
|
461
|
+
|
462
|
+
def test_for_store_mso_client_data
|
463
|
+
caption = sprintf(" \t_store_mso_client_data")
|
464
|
+
target = %w(
|
465
|
+
00 00 11 F0 00 00 00 00
|
466
|
+
).join(' ')
|
467
|
+
|
468
|
+
result = unpack_record(@worksheet.store_mso_client_data)
|
469
|
+
|
470
|
+
assert_equal(target, result, caption)
|
471
|
+
end
|
472
|
+
|
473
|
+
def test_for_store_obj_comment
|
474
|
+
caption = sprintf(" \t_store_obj_comment")
|
475
|
+
data = [0x01]
|
476
|
+
target = %w(
|
477
|
+
5D 00 34 00 15 00 12 00 19 00 01 00 11 40 00 00
|
478
|
+
00 00 00 00 00 00 00 00 00 00 0D 00 16 00 00 00
|
479
|
+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
480
|
+
00 00 00 00 00 00 00 00
|
481
|
+
).join(' ')
|
482
|
+
|
483
|
+
result = unpack_record(@worksheet.store_obj_comment(*data))
|
484
|
+
|
485
|
+
assert_equal(target, result, caption)
|
486
|
+
end
|
487
|
+
|
488
|
+
def test_for_store_mso_client_text_box
|
489
|
+
caption = sprintf(" \t_store_mso_client_text_box")
|
490
|
+
target = %w(
|
491
|
+
00 00 0D F0 00 00 00 00
|
492
|
+
).join(' ')
|
493
|
+
|
494
|
+
result = unpack_record(@worksheet.store_mso_client_text_box)
|
495
|
+
|
496
|
+
assert_equal(target, result, caption)
|
497
|
+
end
|
498
|
+
=end
|
499
|
+
|
500
|
+
###############################################################################
|
501
|
+
#
|
502
|
+
# Unpack the binary data into a format suitable for printing in tests.
|
503
|
+
#
|
504
|
+
def unpack_record(data)
|
505
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
506
|
+
end
|
507
|
+
|
508
|
+
def data_for_test
|
509
|
+
return [
|
510
|
+
[ 'DggContainer', # Caption
|
511
|
+
0xF000, # Type
|
512
|
+
15, # Version
|
513
|
+
0, # Instance
|
514
|
+
'', # Data
|
515
|
+
82, # Length
|
516
|
+
'0F 00 00 F0 52 00 00 00', # Target
|
517
|
+
],
|
518
|
+
|
519
|
+
[ 'DgContainer', # Caption
|
520
|
+
0xF002, # Type
|
521
|
+
15, # Version
|
522
|
+
0, # Instance
|
523
|
+
'', # Data
|
524
|
+
328, # Length
|
525
|
+
'0F 00 02 F0 48 01 00 00', # Target
|
526
|
+
],
|
527
|
+
|
528
|
+
[ 'SpgrContainer', # Caption
|
529
|
+
0xF003, # Type
|
530
|
+
15, # Version
|
531
|
+
0, # Instance
|
532
|
+
'', # Data
|
533
|
+
304, # Length
|
534
|
+
'0F 00 03 F0 30 01 00 00', # Target
|
535
|
+
],
|
536
|
+
|
537
|
+
[ 'SpContainer', # Caption
|
538
|
+
0xF004, # Type
|
539
|
+
15, # Version
|
540
|
+
0, # Instance
|
541
|
+
'', # Data
|
542
|
+
40, # Length
|
543
|
+
'0F 00 04 F0 28 00 00 00', # Target
|
544
|
+
],
|
545
|
+
|
546
|
+
[ 'Dgg', # Caption
|
547
|
+
0xF006, # Type
|
548
|
+
0, # Version
|
549
|
+
0, # Instance
|
550
|
+
'02 04 00 00 02 00 00 00 ' + # Data
|
551
|
+
'02 00 00 00 01 00 00 00 ' +
|
552
|
+
'01 00 00 00 02 00 00 00',
|
553
|
+
nil, # Length
|
554
|
+
'00 00 06 F0 18 00 00 00 ' + # Target
|
555
|
+
'02 04 00 00 02 00 00 00 ' +
|
556
|
+
'02 00 00 00 01 00 00 00 ' +
|
557
|
+
'01 00 00 00 02 00 00 00',
|
558
|
+
],
|
559
|
+
|
560
|
+
[ 'Dg', # Caption
|
561
|
+
0xF008, # Type
|
562
|
+
0, # Version
|
563
|
+
1, # Instance
|
564
|
+
'03 00 00 00 02 04 00 00', # Data
|
565
|
+
nil, # Length
|
566
|
+
'10 00 08 F0 08 00 00 00 ' + # Target
|
567
|
+
'03 00 00 00 02 04 00 00',
|
568
|
+
],
|
569
|
+
|
570
|
+
[ 'Spgr', # Caption
|
571
|
+
0xF009, # Type
|
572
|
+
1, # Version
|
573
|
+
0, # Instance
|
574
|
+
'00 0E 00 0E 40 41 00 00 ' + # Data
|
575
|
+
'00 0E 00 0E 40 41 00 00',
|
576
|
+
nil, # Length
|
577
|
+
'01 00 09 F0 10 00 00 00 ' + # Target
|
578
|
+
'00 0E 00 0E 40 41 00 00 ' +
|
579
|
+
'00 0E 00 0E 40 41 00 00',
|
580
|
+
],
|
581
|
+
|
582
|
+
[ 'ClientTextbox', # Caption
|
583
|
+
0xF00D, # Type
|
584
|
+
0, # Version
|
585
|
+
0, # Instance
|
586
|
+
'', # Data
|
587
|
+
nil, # Length
|
588
|
+
'00 00 0D F0 00 00 00 00', # Target
|
589
|
+
],
|
590
|
+
|
591
|
+
[ 'ClientAnchor', # Caption
|
592
|
+
0xF010, # Type
|
593
|
+
0, # Version
|
594
|
+
0, # Instance
|
595
|
+
'03 00 01 00 F0 00 01 00 ' + # Data
|
596
|
+
'69 00 03 00 F0 00 05 00 ' +
|
597
|
+
'C4 00',
|
598
|
+
nil, # Length
|
599
|
+
'00 00 10 F0 12 00 00 00 ' + # Target
|
600
|
+
'03 00 01 00 F0 00 01 00 ' +
|
601
|
+
'69 00 03 00 F0 00 05 00 ' +
|
602
|
+
'C4 00',
|
603
|
+
],
|
604
|
+
|
605
|
+
[ 'ClientData', # Caption
|
606
|
+
0xF011, # Type
|
607
|
+
0, # Version
|
608
|
+
0, # Instance
|
609
|
+
'', # Data
|
610
|
+
nil, # Length
|
611
|
+
'00 00 11 F0 00 00 00 00', # Target
|
612
|
+
],
|
613
|
+
|
614
|
+
[ 'SplitMenuColors', # Caption
|
615
|
+
0xF11E, # Type
|
616
|
+
0, # Version
|
617
|
+
4, # Instance
|
618
|
+
'0D 00 00 08 0C 00 00 08 ' + # Data
|
619
|
+
'17 00 00 08 F7 00 00 10',
|
620
|
+
nil, # Length
|
621
|
+
'40 00 1E F1 10 00 00 00 ' + # Target
|
622
|
+
'0D 00 00 08 0C 00 00 08 ' +
|
623
|
+
'17 00 00 08 F7 00 00 10',
|
624
|
+
],
|
625
|
+
|
626
|
+
[ 'BstoreContainer', # Caption
|
627
|
+
0xF001, # Type
|
628
|
+
15, # Version
|
629
|
+
1, # Instance
|
630
|
+
'', # Data
|
631
|
+
163, # Length
|
632
|
+
'1F 00 01 F0 A3 00 00 00', # Target
|
633
|
+
],
|
634
|
+
]
|
635
|
+
end
|
636
|
+
|
637
|
+
end
|