ricardoo27-writeexcel 0.6.12.1

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