WriteExcel 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +47 -0
  6. data/VERSION +1 -0
  7. data/examples/a_simple.rb +42 -0
  8. data/examples/autofilters.rb +266 -0
  9. data/examples/bigfile.rb +30 -0
  10. data/examples/copyformat.rb +51 -0
  11. data/examples/data_validate.rb +278 -0
  12. data/examples/date_time.rb +86 -0
  13. data/examples/demo.rb +118 -0
  14. data/examples/diag_border.rb +35 -0
  15. data/examples/formats.rb +489 -0
  16. data/examples/header.rb +136 -0
  17. data/examples/hidden.rb +28 -0
  18. data/examples/hyperlink.rb +42 -0
  19. data/examples/images.rb +52 -0
  20. data/examples/merge1.rb +39 -0
  21. data/examples/merge2.rb +44 -0
  22. data/examples/merge3.rb +65 -0
  23. data/examples/merge4.rb +82 -0
  24. data/examples/merge5.rb +79 -0
  25. data/examples/protection.rb +46 -0
  26. data/examples/regions.rb +52 -0
  27. data/examples/repeat.rb +42 -0
  28. data/examples/stats.rb +75 -0
  29. data/examples/stocks.rb +80 -0
  30. data/examples/tab_colors.rb +30 -0
  31. data/lib/WriteExcel.rb +30 -0
  32. data/lib/WriteExcel/biffwriter.rb +259 -0
  33. data/lib/WriteExcel/chart.rb +217 -0
  34. data/lib/WriteExcel/excelformula.y +138 -0
  35. data/lib/WriteExcel/excelformulaparser.rb +573 -0
  36. data/lib/WriteExcel/format.rb +1108 -0
  37. data/lib/WriteExcel/formula.rb +986 -0
  38. data/lib/WriteExcel/olewriter.rb +322 -0
  39. data/lib/WriteExcel/properties.rb +250 -0
  40. data/lib/WriteExcel/storage_lite.rb +590 -0
  41. data/lib/WriteExcel/workbook.rb +2602 -0
  42. data/lib/WriteExcel/worksheet.rb +6378 -0
  43. data/spec/WriteExcel_spec.rb +7 -0
  44. data/spec/spec.opts +1 -0
  45. data/spec/spec_helper.rb +9 -0
  46. data/test/tc_all.rb +31 -0
  47. data/test/tc_biff.rb +104 -0
  48. data/test/tc_chart.rb +22 -0
  49. data/test/tc_example_match.rb +1280 -0
  50. data/test/tc_format.rb +1264 -0
  51. data/test/tc_formula.rb +63 -0
  52. data/test/tc_ole.rb +110 -0
  53. data/test/tc_storage_lite.rb +102 -0
  54. data/test/tc_workbook.rb +115 -0
  55. data/test/tc_worksheet.rb +115 -0
  56. data/test/test_00_IEEE_double.rb +14 -0
  57. data/test/test_01_add_worksheet.rb +12 -0
  58. data/test/test_02_merge_formats.rb +58 -0
  59. data/test/test_04_dimensions.rb +397 -0
  60. data/test/test_05_rows.rb +182 -0
  61. data/test/test_06_extsst.rb +80 -0
  62. data/test/test_11_date_time.rb +484 -0
  63. data/test/test_12_date_only.rb +506 -0
  64. data/test/test_13_date_seconds.rb +486 -0
  65. data/test/test_21_escher.rb +629 -0
  66. data/test/test_22_mso_drawing_group.rb +739 -0
  67. data/test/test_23_note.rb +78 -0
  68. data/test/test_24_txo.rb +80 -0
  69. data/test/test_26_autofilter.rb +327 -0
  70. data/test/test_27_autofilter.rb +144 -0
  71. data/test/test_28_autofilter.rb +174 -0
  72. data/test/test_29_process_jpg.rb +131 -0
  73. data/test/test_30_validation_dval.rb +82 -0
  74. data/test/test_31_validation_dv_strings.rb +131 -0
  75. data/test/test_32_validation_dv_formula.rb +211 -0
  76. data/test/test_40_property_types.rb +191 -0
  77. data/test/test_41_properties.rb +238 -0
  78. data/test/test_42_set_properties.rb +430 -0
  79. data/test/ts_all.rb +34 -0
  80. metadata +154 -0
@@ -0,0 +1,739 @@
1
+ ##########################################################################
2
+ # test_22_mso_drawing_group.rb
3
+ #
4
+ # Tests for the internal methods used to write the MSODRAWINGGROUP record.
5
+ #
6
+ # reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
7
+ #
8
+ # original written in Perl by John McNamara
9
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
10
+ #
11
+ #########################################################################
12
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
13
+
14
+ require "test/unit"
15
+ require 'WriteExcel'
16
+
17
+ class TC_mso_drawing_group < Test::Unit::TestCase
18
+
19
+ def setup
20
+ t = Time.now.strftime("%Y%m%d")
21
+ path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
22
+ @test_file = File.join(Dir.tmpdir, path)
23
+ @workbook = Spreadsheet::WriteExcel.new(@test_file)
24
+ @worksheet1 = @workbook.add_worksheet
25
+ @worksheet2 = @workbook.add_worksheet
26
+ @worksheet3 = @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_1_time
35
+ count = 1
36
+ for i in 1 .. count
37
+ @worksheet1.write_comment(i -1, 0, 'aaa')
38
+ end
39
+ @workbook.calc_mso_sizes
40
+
41
+ caption = sprintf(" \tSheet1: %4d comments.", count)
42
+ target = %w(
43
+ EB 00 5A 00 0F 00 00 F0 52 00 00 00 00 00 06 F0
44
+ 18 00 00 00 02 04 00 00 02 00 00 00 02 00 00 00
45
+ 01 00 00 00 01 00 00 00 02 00 00 00 33 00 0B F0
46
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
47
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
48
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
49
+ ).join(' ')
50
+ result = unpack_record(@workbook.add_mso_drawing_group)
51
+ assert_equal(target, result, caption)
52
+
53
+
54
+ # Test the parameters pass to the worksheets
55
+ caption = caption + ' (params)'
56
+ result_ids = []
57
+ target_ids = [
58
+ 1024, 1, 2, 1025,
59
+ ]
60
+
61
+ @workbook.sheets.each do |sheet|
62
+ sheet.object_ids.each {|id| result_ids.push(id) }
63
+ end
64
+
65
+ assert_equal(target_ids, result_ids, caption)
66
+
67
+ end
68
+
69
+ def test_2_times
70
+ count = 2
71
+ for i in 1 .. count
72
+ @worksheet1.write_comment(i -1, 0, 'aaa')
73
+ end
74
+ @workbook.calc_mso_sizes
75
+
76
+ target = %w(
77
+ EB 00 5A 00 0F 00 00 F0 52 00 00 00 00 00 06 F0
78
+ 18 00 00 00 03 04 00 00 02 00 00 00 03 00 00 00
79
+ 01 00 00 00 01 00 00 00 03 00 00 00 33 00 0B F0
80
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
81
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
82
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
83
+ ).join(' ')
84
+ caption = sprintf( " \tSheet1: %4d comments.", count)
85
+ result = unpack_record(@workbook.add_mso_drawing_group)
86
+ assert_equal(target, result, caption)
87
+
88
+
89
+ # Test the parameters pass to the worksheets
90
+ caption = caption + ' (params)'
91
+ result_ids = []
92
+ target_ids = [
93
+ 1024, 1, 3, 1026,
94
+ ]
95
+
96
+ @workbook.sheets.each do |sheet|
97
+ sheet.object_ids.each {|id| result_ids.push(id) }
98
+ end
99
+ assert_equal(target_ids, result_ids, caption)
100
+
101
+ end
102
+
103
+ def test_3_times
104
+ count = 3
105
+ for i in 1 .. count
106
+ @worksheet1.write_comment(i -1, 0, 'aaa')
107
+ end
108
+ @workbook.calc_mso_sizes
109
+
110
+ target = %w(
111
+ EB 00 5A 00 0F 00 00 F0 52 00 00 00 00 00 06 F0
112
+ 18 00 00 00 04 04 00 00 02 00 00 00 04 00 00 00
113
+ 01 00 00 00 01 00 00 00 04 00 00 00 33 00 0B F0
114
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
115
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
116
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
117
+ ).join(' ')
118
+ caption = sprintf( " \tSheet1: %4d comments.", count)
119
+ result = unpack_record(@workbook.add_mso_drawing_group)
120
+ assert_equal(target, result, caption)
121
+
122
+
123
+ # Test the parameters pass to the worksheets
124
+ caption = caption + ' (params)'
125
+ result_ids = []
126
+ target_ids = [
127
+ 1024, 1, 4, 1027
128
+ ]
129
+
130
+ @workbook.sheets.each do |sheet|
131
+ sheet.object_ids.each {|id| result_ids.push(id) }
132
+ end
133
+ assert_equal(target_ids, result_ids, caption)
134
+
135
+ end
136
+
137
+ def test_1023_times
138
+ count = 1023
139
+ for i in 1 .. count
140
+ @worksheet1.write_comment(i -1, 0, 'aaa')
141
+ end
142
+ @workbook.calc_mso_sizes
143
+
144
+ target = %w(
145
+ EB 00 5A 00 0F 00 00 F0 52 00 00 00 00 00 06 F0
146
+ 18 00 00 00 00 08 00 00 02 00 00 00 00 04 00 00
147
+ 01 00 00 00 01 00 00 00 00 04 00 00 33 00 0B F0
148
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
149
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
150
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
151
+ ).join(' ')
152
+ caption = sprintf( " \tSheet1: %4d comments.", count)
153
+ result = unpack_record(@workbook.add_mso_drawing_group)
154
+ assert_equal(target, result, caption)
155
+
156
+
157
+ # Test the parameters pass to the worksheets
158
+ caption = caption + ' (params)'
159
+ result_ids = []
160
+ target_ids = [
161
+ 1024, 1, 1024, 2047
162
+ ]
163
+
164
+ @workbook.sheets.each do |sheet|
165
+ sheet.object_ids.each {|id| result_ids.push(id) }
166
+ end
167
+ assert_equal(target_ids, result_ids, caption)
168
+
169
+ end
170
+
171
+ def test_1024_times
172
+ count = 1024
173
+ for i in 1 .. count
174
+ @worksheet1.write_comment(i -1, 0, 'aaa')
175
+ end
176
+ @workbook.calc_mso_sizes
177
+
178
+ target = %w(
179
+ EB 00 62 00 0F 00 00 F0 5A 00 00 00 00 00 06 F0
180
+ 20 00 00 00 01 08 00 00 03 00 00 00 01 04 00 00
181
+ 01 00 00 00 01 00 00 00 00 04 00 00 01 00 00 00
182
+ 01 00 00 00 33 00 0B F0 12 00 00 00 BF 00 08 00
183
+ 08 00 81 01 09 00 00 08 C0 01 40 00 00 08 40 00
184
+ 1E F1 10 00 00 00 0D 00 00 08 0C 00 00 08 17 00
185
+ 00 08 F7 00 00 10
186
+ ).join(' ')
187
+ caption = sprintf( " \tSheet1: %4d comments.", count)
188
+ result = unpack_record(@workbook.add_mso_drawing_group)
189
+ assert_equal(target, result, caption)
190
+
191
+
192
+ # Test the parameters pass to the worksheets
193
+ caption = caption + ' (params)'
194
+ result_ids = []
195
+ target_ids = [
196
+ 1024, 1, 1025, 2048
197
+ ]
198
+
199
+ @workbook.sheets.each do |sheet|
200
+ sheet.object_ids.each {|id| result_ids.push(id) }
201
+ end
202
+ assert_equal(target_ids, result_ids, caption)
203
+
204
+ end
205
+
206
+ def test_2048_times
207
+ count = 2048
208
+ for i in 1 .. count
209
+ @worksheet1.write_comment(i -1, 0, 'aaa')
210
+ end
211
+ @workbook.calc_mso_sizes
212
+
213
+ target = %w(
214
+ EB 00 6A 00 0F 00 00 F0 62 00 00 00 00 00 06 F0
215
+ 28 00 00 00 01 0C 00 00 04 00 00 00 01 08 00 00
216
+ 01 00 00 00 01 00 00 00 00 04 00 00 01 00 00 00
217
+ 00 04 00 00 01 00 00 00 01 00 00 00 33 00 0B F0
218
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
219
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
220
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
221
+ ).join(' ')
222
+ caption = sprintf( " \tSheet1: %4d comments.", count)
223
+ result = unpack_record(@workbook.add_mso_drawing_group)
224
+ assert_equal(target, result, caption)
225
+
226
+
227
+ # Test the parameters pass to the worksheets
228
+ caption = caption + ' (params)'
229
+ result_ids = []
230
+ target_ids = [
231
+ 1024, 1, 2049, 3072
232
+ ]
233
+
234
+ @workbook.sheets.each do |sheet|
235
+ sheet.object_ids.each {|id| result_ids.push(id) }
236
+ end
237
+ assert_equal(target_ids, result_ids, caption)
238
+
239
+ end
240
+
241
+ def test_2_sheets_1_and_1_times
242
+ count1 = 1
243
+ count2 = 1
244
+ for i in 1 .. count1
245
+ @worksheet1.write_comment(i -1, 0, 'aaa')
246
+ end
247
+ for i in 1 .. count2
248
+ @worksheet2.write_comment(i -1, 0, 'aaa')
249
+ end
250
+ @workbook.calc_mso_sizes
251
+
252
+ target = %w(
253
+ EB 00 62 00 0F 00 00 F0 5A 00 00 00 00 00 06 F0
254
+ 20 00 00 00 02 08 00 00 03 00 00 00 04 00 00 00
255
+ 02 00 00 00 01 00 00 00 02 00 00 00 02 00 00 00
256
+ 02 00 00 00 33 00 0B F0 12 00 00 00 BF 00 08 00
257
+ 08 00 81 01 09 00 00 08 C0 01 40 00 00 08 40 00
258
+ 1E F1 10 00 00 00 0D 00 00 08 0C 00 00 08 17 00
259
+ 00 08 F7 00 00 10
260
+ ).join(' ')
261
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments..",
262
+ count1, count2)
263
+ result = unpack_record(@workbook.add_mso_drawing_group)
264
+ assert_equal(target, result, caption)
265
+
266
+
267
+ # Test the parameters pass to the worksheets
268
+ caption = caption + ' (params)'
269
+ result_ids = []
270
+ target_ids = [
271
+ 1024, 1, 2, 1025,
272
+ 2048, 2, 2, 2049
273
+ ]
274
+
275
+ @workbook.sheets.each do |sheet|
276
+ sheet.object_ids.each {|id| result_ids.push(id) }
277
+ end
278
+ assert_equal(target_ids, result_ids, caption)
279
+
280
+ end
281
+
282
+ def test_2_sheets_2_and_2_times
283
+ count1 = 2
284
+ count2 = 2
285
+ for i in 1 .. count1
286
+ @worksheet1.write_comment(i -1, 0, 'aaa')
287
+ end
288
+ for i in 1 .. count2
289
+ @worksheet2.write_comment(i -1, 0, 'aaa')
290
+ end
291
+ @workbook.calc_mso_sizes
292
+
293
+ target = %w(
294
+ EB 00 62 00 0F 00 00 F0 5A 00 00 00 00 00 06 F0
295
+ 20 00 00 00 03 08 00 00 03 00 00 00 06 00 00 00
296
+ 02 00 00 00 01 00 00 00 03 00 00 00 02 00 00 00
297
+ 03 00 00 00 33 00 0B F0 12 00 00 00 BF 00 08 00
298
+ 08 00 81 01 09 00 00 08 C0 01 40 00 00 08 40 00
299
+ 1E F1 10 00 00 00 0D 00 00 08 0C 00 00 08 17 00
300
+ 00 08 F7 00 00 10
301
+ ).join(' ')
302
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments..",
303
+ count1, count2)
304
+ result = unpack_record(@workbook.add_mso_drawing_group)
305
+ assert_equal(target, result, caption)
306
+
307
+
308
+ # Test the parameters pass to the worksheets
309
+ caption = caption + ' (params)'
310
+ result_ids = []
311
+ target_ids = [
312
+ 1024, 1, 3, 1026,
313
+ 2048, 2, 3, 2050
314
+ ]
315
+
316
+ @workbook.sheets.each do |sheet|
317
+ sheet.object_ids.each {|id| result_ids.push(id) }
318
+ end
319
+ assert_equal(target_ids, result_ids, caption)
320
+
321
+ end
322
+
323
+ def test_2_sheets_1023_and_1_times
324
+ count1 = 1023
325
+ count2 = 1
326
+ for i in 1 .. count1
327
+ @worksheet1.write_comment(i -1, 0, 'aaa')
328
+ end
329
+ for i in 1 .. count2
330
+ @worksheet2.write_comment(i -1, 0, 'aaa')
331
+ end
332
+ @workbook.calc_mso_sizes
333
+
334
+ target = %w(
335
+ EB 00 62 00 0F 00 00 F0 5A 00 00 00 00 00 06 F0
336
+ 20 00 00 00 02 08 00 00 03 00 00 00 02 04 00 00
337
+ 02 00 00 00 01 00 00 00 00 04 00 00 02 00 00 00
338
+ 02 00 00 00 33 00 0B F0 12 00 00 00 BF 00 08 00
339
+ 08 00 81 01 09 00 00 08 C0 01 40 00 00 08 40 00
340
+ 1E F1 10 00 00 00 0D 00 00 08 0C 00 00 08 17 00
341
+ 00 08 F7 00 00 10
342
+ ).join(' ')
343
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments..",
344
+ count1, count2)
345
+ result = unpack_record(@workbook.add_mso_drawing_group)
346
+ assert_equal(target, result, caption)
347
+
348
+
349
+ # Test the parameters pass to the worksheets
350
+ caption = caption + ' (params)'
351
+ result_ids = []
352
+ target_ids = [
353
+ 1024, 1, 1024, 2047,
354
+ 2048, 2, 2, 2049
355
+ ]
356
+
357
+ @workbook.sheets.each do |sheet|
358
+ sheet.object_ids.each {|id| result_ids.push(id) }
359
+ end
360
+ assert_equal(target_ids, result_ids, caption)
361
+
362
+ end
363
+
364
+ def test_2_sheets_1023_and_1023_times
365
+ count1 = 1023
366
+ count2 = 1023
367
+ for i in 1 .. count1
368
+ @worksheet1.write_comment(i -1, 0, 'aaa')
369
+ end
370
+ for i in 1 .. count2
371
+ @worksheet2.write_comment(i -1, 0, 'aaa')
372
+ end
373
+ @workbook.calc_mso_sizes
374
+
375
+ target = %w(
376
+ EB 00 62 00 0F 00 00 F0 5A 00 00 00 00 00 06 F0
377
+ 20 00 00 00 00 0C 00 00 03 00 00 00 00 08 00 00
378
+ 02 00 00 00 01 00 00 00 00 04 00 00 02 00 00 00
379
+ 00 04 00 00 33 00 0B F0 12 00 00 00 BF 00 08 00
380
+ 08 00 81 01 09 00 00 08 C0 01 40 00 00 08 40 00
381
+ 1E F1 10 00 00 00 0D 00 00 08 0C 00 00 08 17 00
382
+ 00 08 F7 00 00 10
383
+ ).join(' ')
384
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments..",
385
+ count1, count2)
386
+ result = unpack_record(@workbook.add_mso_drawing_group)
387
+ assert_equal(target, result, caption)
388
+
389
+
390
+ # Test the parameters pass to the worksheets
391
+ caption = caption + ' (params)'
392
+ result_ids = []
393
+ target_ids = [
394
+ 1024, 1, 1024, 2047,
395
+ 2048, 2, 1024, 3071
396
+ ]
397
+
398
+ @workbook.sheets.each do |sheet|
399
+ sheet.object_ids.each {|id| result_ids.push(id) }
400
+ end
401
+ assert_equal(target_ids, result_ids, caption)
402
+
403
+ end
404
+
405
+ def test_2_sheets_1024_and_1024_times
406
+ count1 = 1024
407
+ count2 = 1024
408
+ for i in 1 .. count1
409
+ @worksheet1.write_comment(i -1, 0, 'aaa')
410
+ end
411
+ for i in 1 .. count2
412
+ @worksheet2.write_comment(i -1, 0, 'aaa')
413
+ end
414
+ @workbook.calc_mso_sizes
415
+
416
+ target = %w(
417
+ EB 00 72 00 0F 00 00 F0 6A 00 00 00 00 00 06 F0
418
+ 30 00 00 00 01 10 00 00 05 00 00 00 02 08 00 00
419
+ 02 00 00 00 01 00 00 00 00 04 00 00 01 00 00 00
420
+ 01 00 00 00 02 00 00 00 00 04 00 00 02 00 00 00
421
+ 01 00 00 00 33 00 0B F0 12 00 00 00 BF 00 08 00
422
+ 08 00 81 01 09 00 00 08 C0 01 40 00 00 08 40 00
423
+ 1E F1 10 00 00 00 0D 00 00 08 0C 00 00 08 17 00
424
+ 00 08 F7 00 00 10
425
+ ).join(' ')
426
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments..",
427
+ count1, count2)
428
+ result = unpack_record(@workbook.add_mso_drawing_group)
429
+ assert_equal(target, result, caption)
430
+
431
+
432
+ # Test the parameters pass to the worksheets
433
+ caption = caption + ' (params)'
434
+ result_ids = []
435
+ target_ids = [
436
+ 1024, 1, 1025, 2048,
437
+ 3072, 2, 1025, 4096
438
+ ]
439
+
440
+ @workbook.sheets.each do |sheet|
441
+ sheet.object_ids.each {|id| result_ids.push(id) }
442
+ end
443
+ assert_equal(target_ids, result_ids, caption)
444
+
445
+ end
446
+
447
+ def test_2_sheets_1024_and_1_times
448
+ count1 = 1024
449
+ count2 = 1
450
+ for i in 1 .. count1
451
+ @worksheet1.write_comment(i -1, 0, 'aaa')
452
+ end
453
+ for i in 1 .. count2
454
+ @worksheet2.write_comment(i -1, 0, 'aaa')
455
+ end
456
+ @workbook.calc_mso_sizes
457
+
458
+ target = %w(
459
+ EB 00 6A 00 0F 00 00 F0 62 00 00 00 00 00 06 F0
460
+ 28 00 00 00 02 0C 00 00 04 00 00 00 03 04 00 00
461
+ 02 00 00 00 01 00 00 00 00 04 00 00 01 00 00 00
462
+ 01 00 00 00 02 00 00 00 02 00 00 00 33 00 0B F0
463
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
464
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
465
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
466
+ ).join(' ')
467
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments..",
468
+ count1, count2)
469
+ result = unpack_record(@workbook.add_mso_drawing_group)
470
+ assert_equal(target, result, caption)
471
+
472
+
473
+ # Test the parameters pass to the worksheets
474
+ caption = caption + ' (params)'
475
+ result_ids = []
476
+ target_ids = [
477
+ 1024, 1, 1025, 2048,
478
+ 3072, 2, 2, 3073
479
+ ]
480
+
481
+ @workbook.sheets.each do |sheet|
482
+ sheet.object_ids.each {|id| result_ids.push(id) }
483
+ end
484
+ assert_equal(target_ids, result_ids, caption)
485
+
486
+ end
487
+
488
+ def test_3_sheets_1023_and_1_and_1023_times
489
+ count1 = 1023
490
+ count2 = 1
491
+ count3 = 1023
492
+ for i in 1 .. count1
493
+ @worksheet1.write_comment(i -1, 0, 'aaa')
494
+ end
495
+ for i in 1 .. count2
496
+ @worksheet2.write_comment(i -1, 0, 'aaa')
497
+ end
498
+ for i in 1 .. count3
499
+ @worksheet3.write_comment(i -1, 0, 'aaa')
500
+ end
501
+ @workbook.calc_mso_sizes
502
+
503
+ target = %w(
504
+ EB 00 6A 00 0F 00 00 F0 62 00 00 00 00 00 06 F0
505
+ 28 00 00 00 00 10 00 00 04 00 00 00 02 08 00 00
506
+ 03 00 00 00 01 00 00 00 00 04 00 00 02 00 00 00
507
+ 02 00 00 00 03 00 00 00 00 04 00 00 33 00 0B F0
508
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
509
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
510
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
511
+ ).join(' ')
512
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments,"+
513
+ "Sheet3: %4d comments.", count1, count2, count3)
514
+ result = unpack_record(@workbook.add_mso_drawing_group)
515
+ assert_equal(target, result, caption)
516
+
517
+
518
+ # Test the parameters pass to the worksheets
519
+ caption = caption + ' (params)'
520
+ result_ids = []
521
+ target_ids = [
522
+ 1024, 1, 1024, 2047,
523
+ 2048, 2, 2, 2049,
524
+ 3072, 3, 1024, 4095
525
+ ]
526
+
527
+ @workbook.sheets.each do |sheet|
528
+ sheet.object_ids.each {|id| result_ids.push(id) }
529
+ end
530
+ assert_equal(target_ids, result_ids, caption)
531
+
532
+ end
533
+
534
+ def test_3_sheets_1023_and_1023_and_1_times
535
+ count1 = 1023
536
+ count2 = 1023
537
+ count3 = 1
538
+ for i in 1 .. count1
539
+ @worksheet1.write_comment(i -1, 0, 'aaa')
540
+ end
541
+ for i in 1 .. count2
542
+ @worksheet2.write_comment(i -1, 0, 'aaa')
543
+ end
544
+ for i in 1 .. count3
545
+ @worksheet3.write_comment(i -1, 0, 'aaa')
546
+ end
547
+ @workbook.calc_mso_sizes
548
+
549
+ target = %w(
550
+ EB 00 6A 00 0F 00 00 F0 62 00 00 00 00 00 06 F0
551
+ 28 00 00 00 02 0C 00 00 04 00 00 00 02 08 00 00
552
+ 03 00 00 00 01 00 00 00 00 04 00 00 02 00 00 00
553
+ 00 04 00 00 03 00 00 00 02 00 00 00 33 00 0B F0
554
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
555
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
556
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
557
+ ).join(' ')
558
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments,"+
559
+ "Sheet3: %4d comments.", count1, count2, count3)
560
+ result = unpack_record(@workbook.add_mso_drawing_group)
561
+ assert_equal(target, result, caption)
562
+
563
+
564
+ # Test the parameters pass to the worksheets
565
+ caption = caption + ' (params)'
566
+ result_ids = []
567
+ target_ids = [
568
+ 1024, 1, 1024, 2047,
569
+ 2048, 2, 1024, 3071,
570
+ 3072, 3, 2, 3073
571
+ ]
572
+
573
+ @workbook.sheets.each do |sheet|
574
+ sheet.object_ids.each {|id| result_ids.push(id) }
575
+ end
576
+ assert_equal(target_ids, result_ids, caption)
577
+
578
+ end
579
+
580
+ def test_3_sheets_1024_and_1_and_1024_times
581
+ count1 = 1024
582
+ count2 = 1
583
+ count3 = 1024
584
+ for i in 1 .. count1
585
+ @worksheet1.write_comment(i -1, 0, 'aaa')
586
+ end
587
+ for i in 1 .. count2
588
+ @worksheet2.write_comment(i -1, 0, 'aaa')
589
+ end
590
+ for i in 1 .. count3
591
+ @worksheet3.write_comment(i -1, 0, 'aaa')
592
+ end
593
+ @workbook.calc_mso_sizes
594
+
595
+ target = %w(
596
+ EB 00 7A 00 0F 00 00 F0 72 00 00 00 00 00 06 F0
597
+ 38 00 00 00 01 14 00 00 06 00 00 00 04 08 00 00
598
+ 03 00 00 00 01 00 00 00 00 04 00 00 01 00 00 00
599
+ 01 00 00 00 02 00 00 00 02 00 00 00 03 00 00 00
600
+ 00 04 00 00 03 00 00 00 01 00 00 00 33 00 0B F0
601
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
602
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
603
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
604
+ ).join(' ')
605
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments,"+
606
+ "Sheet3: %4d comments.", count1, count2, count3)
607
+ result = unpack_record(@workbook.add_mso_drawing_group)
608
+ assert_equal(target, result, caption)
609
+
610
+
611
+ # Test the parameters pass to the worksheets
612
+ caption = caption + ' (params)'
613
+ result_ids = []
614
+ target_ids = [
615
+ 1024, 1, 1025, 2048,
616
+ 3072, 2, 2, 3073,
617
+ 4096, 3, 1025, 5120
618
+ ]
619
+
620
+ @workbook.sheets.each do |sheet|
621
+ sheet.object_ids.each {|id| result_ids.push(id) }
622
+ end
623
+ assert_equal(target_ids, result_ids, caption)
624
+
625
+ end
626
+
627
+ def test_3_sheets_1024_and_1024_and_1_times
628
+ count1 = 1024
629
+ count2 = 1024
630
+ count3 = 1
631
+ for i in 1 .. count1
632
+ @worksheet1.write_comment(i -1, 0, 'aaa')
633
+ end
634
+ for i in 1 .. count2
635
+ @worksheet2.write_comment(i -1, 0, 'aaa')
636
+ end
637
+ for i in 1 .. count3
638
+ @worksheet3.write_comment(i -1, 0, 'aaa')
639
+ end
640
+ @workbook.calc_mso_sizes
641
+
642
+ target = %w(
643
+ EB 00 7A 00 0F 00 00 F0 72 00 00 00 00 00 06 F0
644
+ 38 00 00 00 02 14 00 00 06 00 00 00 04 08 00 00
645
+ 03 00 00 00 01 00 00 00 00 04 00 00 01 00 00 00
646
+ 01 00 00 00 02 00 00 00 00 04 00 00 02 00 00 00
647
+ 01 00 00 00 03 00 00 00 02 00 00 00 33 00 0B F0
648
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
649
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
650
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
651
+ ).join(' ')
652
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments,"+
653
+ "Sheet3: %4d comments.", count1, count2, count3)
654
+ result = unpack_record(@workbook.add_mso_drawing_group)
655
+ assert_equal(target, result, caption)
656
+
657
+
658
+ # Test the parameters pass to the worksheets
659
+ caption = caption + ' (params)'
660
+ result_ids = []
661
+ target_ids = [
662
+ 1024, 1, 1025, 2048,
663
+ 3072, 2, 1025, 4096,
664
+ 5120, 3, 2, 5121
665
+ ]
666
+
667
+ @workbook.sheets.each do |sheet|
668
+ sheet.object_ids.each {|id| result_ids.push(id) }
669
+ end
670
+ assert_equal(target_ids, result_ids, caption)
671
+
672
+ end
673
+
674
+ def test_3_sheets_1024_and_1024_and_1_times_duplicate
675
+ count1 = 1024
676
+ count2 = 1024
677
+ count3 = 1
678
+ for i in 1 .. count1
679
+ @worksheet1.write_comment(i -1, 0, 'aaa')
680
+ end
681
+ for i in 1 .. count2
682
+ @worksheet2.write_comment(i -1, 0, 'aaa')
683
+ end
684
+ for i in 1 .. count3
685
+ @worksheet3.write_comment(i -1, 0, 'aaa')
686
+ end
687
+ # dupulicate -- these are ignored. result is same as prev.--
688
+ for i in 1 .. count1
689
+ @worksheet1.write_comment(i -1, 0, 'aaa')
690
+ end
691
+ for i in 1 .. count2
692
+ @worksheet2.write_comment(i -1, 0, 'aaa')
693
+ end
694
+ for i in 1 .. count3
695
+ @worksheet3.write_comment(i -1, 0, 'aaa')
696
+ end
697
+ @workbook.calc_mso_sizes
698
+
699
+ target = %w(
700
+ EB 00 7A 00 0F 00 00 F0 72 00 00 00 00 00 06 F0
701
+ 38 00 00 00 02 14 00 00 06 00 00 00 04 08 00 00
702
+ 03 00 00 00 01 00 00 00 00 04 00 00 01 00 00 00
703
+ 01 00 00 00 02 00 00 00 00 04 00 00 02 00 00 00
704
+ 01 00 00 00 03 00 00 00 02 00 00 00 33 00 0B F0
705
+ 12 00 00 00 BF 00 08 00 08 00 81 01 09 00 00 08
706
+ C0 01 40 00 00 08 40 00 1E F1 10 00 00 00 0D 00
707
+ 00 08 0C 00 00 08 17 00 00 08 F7 00 00 10
708
+ ).join(' ')
709
+ caption = sprintf( " \tSheet1: %4d comments, Sheet2: %4d comments,"+
710
+ "Sheet3: %4d comments.", count1, count2, count3)
711
+ result = unpack_record(@workbook.add_mso_drawing_group)
712
+ assert_equal(target, result, caption)
713
+
714
+
715
+ # Test the parameters pass to the worksheets
716
+ caption = caption + ' (params)'
717
+ result_ids = []
718
+ target_ids = [
719
+ 1024, 1, 1025, 2048,
720
+ 3072, 2, 1025, 4096,
721
+ 5120, 3, 2, 5121
722
+ ]
723
+
724
+ @workbook.sheets.each do |sheet|
725
+ sheet.object_ids.each {|id| result_ids.push(id) }
726
+ end
727
+ assert_equal(target_ids, result_ids, caption)
728
+
729
+ end
730
+
731
+ ###############################################################################
732
+ #
733
+ # Unpack the binary data into a format suitable for printing in tests.
734
+ #
735
+ def unpack_record(data)
736
+ data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
737
+ end
738
+
739
+ end