writeexcel 0.1.0 → 0.3.0

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