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