writeexcel 0.5.0 → 0.6.0

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