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,578 +1,578 @@
1
- # -*- coding: utf-8 -*-
2
- require 'helper'
3
- require 'stringio'
4
-
5
- ###############################################################################
6
- #
7
- # A test for Chart.
8
- #
9
- # Tests for the Excel chart.rb methods.
10
- #
11
- # reverse(''), December 2009, John McNamara, jmcnamara@cpan.org
12
- #
13
- # original written in Perl by John McNamara
14
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
15
- #
16
- class TC_ChartGeneric < Test::Unit::TestCase
17
- def setup
18
- io = StringIO.new
19
- workbook = WriteExcel.new(io)
20
- @chart = Writeexcel::Chart.new('', 'chart', 0, 0, 0, 0, 0, 0, 0, 0)
21
- end
22
-
23
- def teardown
24
- @chart.cleanup
25
- end
26
-
27
- ###############################################################################
28
- #
29
- # Test the _store_fbi method.
30
- #
31
- def test_store_fbi
32
- caption = " \tChart: _store_fbi()"
33
- expected = %w(
34
- 60 10 0A 00 B8 38 A1 22 C8 00 00 00 05 00
35
- ).join(' ')
36
- got = unpack_record(@chart.store_fbi(5, 10, 0x38B8, 0x22A1, 0x0000))
37
- assert_equal(expected, got, caption)
38
-
39
- expected = %w(
40
- 60 10 0A 00 B8 38 A1 22 C8 00 00 00 06 00
41
- ).join(' ')
42
- got = unpack_record(@chart.store_fbi(6, 10, 0x38B8, 0x22A1, 0x0000))
43
- assert_equal(expected, got, caption)
44
- end
45
-
46
- ###############################################################################
47
- #
48
- # Test the _store_chart method.
49
- #
50
- def test_store_chart
51
- caption = " \tChart: _store_chart()"
52
- expected = %w(
53
- 02 10 10 00 00 00 00 00 00 00 00 00 E0 51 DD 02
54
- 38 B8 C2 01
55
- ).join(' ')
56
- values = [0x0000, 0x0000, 0x02DD51E0, 0x01C2B838]
57
- got = unpack_record(@chart.store_chart(*values))
58
- assert_equal(expected, got, caption)
59
- end
60
-
61
- ###############################################################################
62
- #
63
- # Test the _store_series method.
64
- #
65
- def test_store_series
66
- caption = " \tChart: _store_series()"
67
- expected = %w(
68
- 03 10 0C 00 01 00 01 00 08 00 08 00 01 00 00 00
69
- ).join(' ')
70
- got = unpack_record(@chart.store_series(8, 8))
71
- assert_equal(expected, got, caption)
72
- end
73
-
74
- ###############################################################################
75
- #
76
- # Test the _store_begin method.
77
- #
78
- def test_store_begin
79
- caption = " \tChart: _store_begin()"
80
- expected = %w(
81
- 33 10 00 00
82
- ).join(' ')
83
- got = unpack_record(@chart.store_begin)
84
- assert_equal(expected, got, caption)
85
- end
86
-
87
- ###############################################################################
88
- #
89
- # Test the _store_end method.
90
- #
91
- def test_store_end
92
- caption = " \tChart: _store_end()"
93
- expected = %w(
94
- 34 10 00 00
95
- ).join(' ')
96
- got = unpack_record(@chart.store_end)
97
- assert_equal(expected, got, caption)
98
- end
99
-
100
- ###############################################################################
101
- #
102
- # Test the _store_ai method.
103
- #
104
- def test_store_ai
105
- caption = " \tChart: _store_ai()"
106
- values = [0, 1, '']
107
- expected = %w(
108
- 51 10 08 00 00 01 00 00 00 00 00 00
109
- ).join(' ')
110
- got = unpack_record(@chart.store_ai(*values))
111
- assert_equal(expected, got, caption)
112
-
113
- values = [1, 2, ['3B00000000070000000000'].pack('H*')]
114
- expected = %w(
115
- 51 10 13 00 01 02 00 00 00 00 0B 00 3B 00 00 00
116
- 00 07 00 00 00 00 00
117
- ).join(' ')
118
- got = unpack_record(@chart.store_ai(*values))
119
- assert_equal(expected, got, caption)
120
- end
121
-
122
- ###############################################################################
123
- #
124
- # Test the _store_dataformat method.
125
- #
126
- def test_store_dataformat
127
- caption = " \tChart: _store_dataformat()"
128
- expected = %w(
129
- 06 10 08 00 FF FF 00 00 00 00 00 00
130
- ).join(' ')
131
- got = unpack_record(@chart.store_dataformat(0, 0, 0xFFFF))
132
- assert_equal(expected, got, caption)
133
-
134
- expected = %w(
135
- 06 10 08 00 00 00 00 00 FD FF 00 00
136
- ).join(' ')
137
- got = unpack_record(@chart.store_dataformat(0, 0xFFFD, 0))
138
- assert_equal(expected, got, caption)
139
- end
140
-
141
- ###############################################################################
142
- #
143
- # Test the _store_3dbarshape method.
144
- #
145
- def test_store_3dbarshape
146
- caption = " \tChart: _store_3dbarshape()"
147
- expected = %w(
148
- 5F 10 02 00 00 00
149
- ).join(' ')
150
- got = unpack_record(@chart.store_3dbarshape)
151
- assert_equal(expected, got, caption)
152
- end
153
-
154
- ###############################################################################
155
- #
156
- # Test the _store_sertocrt method.
157
- #
158
- def test_store_sertocrt
159
- caption = " \tChart: _store_sertocrt()"
160
- expected = %w(
161
- 45 10 02 00 00 00
162
- ).join(' ')
163
- got = unpack_record(@chart.store_sertocrt)
164
- assert_equal(expected, got, caption)
165
- end
166
-
167
- ###############################################################################
168
- #
169
- # Test the _store_shtprops method.
170
- #
171
- def test_store_shtprops
172
- caption = " \tChart: _store_shtprops()"
173
- expected = %w(
174
- 44 10 04 00 0E 00 00 00
175
- ).join(' ')
176
- got = unpack_record(@chart.store_shtprops)
177
- assert_equal(expected, got, caption)
178
- end
179
-
180
- ###############################################################################
181
- #
182
- # Test the _store_defaulttext method.
183
- #
184
- def test_store_defaulttext
185
- caption = " \tChart: _store_defaulttext()"
186
- expected = %w(
187
- 24 10 02 00 02 00
188
- ).join(' ')
189
- got = unpack_record(@chart.store_defaulttext)
190
- assert_equal(expected, got, caption)
191
- end
192
-
193
- ###############################################################################
194
- #
195
- # Test the _store_charttext method.
196
- #
197
- def test_store_charttext
198
- caption = " \tChart: _store_charttext()"
199
- expected = %w(
200
- 25 10 20 00 02 02 01 00 00 00 00 00 46 FF FF FF
201
- 06 FF FF FF 00 00 00 00 00 00 00 00 B1 00 4D 00
202
- 00 00 00 00
203
- ).join(' ')
204
- got = unpack_record(@chart.store_charttext)
205
- assert_equal(expected, got, caption)
206
- end
207
-
208
- ###############################################################################
209
- #
210
- # Test the _store_fontx method.
211
- #
212
- def test_store_fontx
213
- caption = " \tChart: _store_fontx()"
214
- expected = %w(
215
- 26 10 02 00 05 00
216
- ).join(' ')
217
- got = unpack_record(@chart.store_fontx(5))
218
- assert_equal(expected, got, caption)
219
- end
220
-
221
- ###############################################################################
222
- #
223
- # Test the _store_axesused method.
224
- #
225
- def test_store_axesused
226
- caption = " \tChart: _store_axesused()"
227
- expected = %w(
228
- 46 10 02 00 01 00
229
- ).join(' ')
230
- got = unpack_record(@chart.store_axesused(1))
231
- assert_equal(expected, got, caption)
232
- end
233
-
234
- ###############################################################################
235
- #
236
- # Test the _store_axisparent method.
237
- #
238
- def test_store_axisparent
239
- caption = " \tChart: _store_axisparent()"
240
- expected = %w(
241
- 41 10 12 00 00 00 F8 00 00 00 F5 01 00 00 7F 0E
242
- 00 00 36 0B 00 00
243
- ).join(' ')
244
- values = [0, 0x00F8, 0x01F5, 0x0E7F, 0x0B36]
245
- got = unpack_record(@chart.store_axisparent(*values))
246
- assert_equal(expected, got, caption)
247
- end
248
-
249
- ###############################################################################
250
- #
251
- # Test the _store_axis method.
252
- #
253
- def test_store_axis
254
- caption = " \tChart: _store_axis()"
255
- expected = %w(
256
- 1D 10 12 00 00 00 00 00 00 00 00 00 00 00 00 00
257
- 00 00 00 00 00 00
258
- ).join(' ')
259
- got = unpack_record(@chart.store_axis(0))
260
- assert_equal(expected, got, caption)
261
- end
262
-
263
- ###############################################################################
264
- #
265
- # Test the _store_catserrange method.
266
- #
267
- def test_store_catserrange
268
- caption = " \tChart: _store_catserrange()"
269
- expected = %w(
270
- 20 10 08 00 01 00 01 00 01 00 01 00
271
- ).join(' ')
272
- got = unpack_record(@chart.store_catserrange)
273
- assert_equal(expected, got, caption)
274
- end
275
-
276
- ###############################################################################
277
- #
278
- # Test the _store_axcext method.
279
- #
280
- def test_store_axcext
281
- caption = " \tChart: _store_axcext()"
282
- expected = %w(
283
- 62 10 12 00 00 00 00 00 01 00 00 00 01 00 00 00
284
- 00 00 00 00 EF 00
285
- ).join(' ')
286
- got = unpack_record(@chart.store_axcext)
287
- assert_equal(expected, got, caption)
288
- end
289
-
290
- ###############################################################################
291
- #
292
- # Test the _store_tick method.
293
- #
294
- def test_store_tick
295
- caption = " \tChart: _store_tick()"
296
- expected = %w(
297
- 1E 10 1E 00 02 00 03 01 00 00 00 00 00 00 00 00
298
- 00 00 00 00 00 00 00 00 00 00 00 00 23 00 4D 00
299
- 00 00
300
- ).join(' ')
301
- got = unpack_record(@chart.store_tick)
302
- assert_equal(expected, got, caption)
303
- end
304
-
305
- ###############################################################################
306
- #
307
- # Test the _store_valuerange method.
308
- #
309
- def test_store_valuerange
310
- caption = " \tChart: _store_valuerange()"
311
- expected = %w(
312
- 1F 10 2A 00 00 00 00 00 00 00 00 00 00 00 00 00
313
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
314
- 00 00 00 00 00 00 00 00 00 00 00 00 1F 01
315
- ).join(' ')
316
- got = unpack_record(@chart.store_valuerange)
317
- assert_equal(expected, got, caption)
318
- end
319
-
320
- ###############################################################################
321
- #
322
- # Test the _store_axislineformat method.
323
- #
324
- def test_store_axislineformat
325
- caption = " \tChart: _store_axislineformat()"
326
- expected = %w(
327
- 21 10 02 00 01 00
328
- ).join(' ')
329
- got = unpack_record(@chart.store_axislineformat)
330
- assert_equal(expected, got, caption)
331
- end
332
-
333
- ###############################################################################
334
- #
335
- # Test the _store_lineformat method.
336
- #
337
- def test_store_lineformat
338
- caption = " \tChart: _store_lineformat()"
339
- expected = %w(
340
- 07 10 0C 00 00 00 00 00 00 00 FF FF 09 00 4D 00
341
- ).join(' ')
342
- values = [0x00000000, 0x0000, 0xFFFF, 0x0009, 0x004D]
343
- got = unpack_record(@chart.store_lineformat(*values))
344
- assert_equal(expected, got, caption)
345
- end
346
-
347
- ###############################################################################
348
- #
349
- # Test the _store_frame method.
350
- #
351
- def test_store_frame
352
- caption = " \tChart: _store_frame()"
353
- expected = %w(
354
- 32 10 04 00 00 00 03 00
355
- ).join(' ')
356
- got = unpack_record(@chart.store_frame(0x00, 0x03))
357
- assert_equal(expected, got, caption)
358
- end
359
-
360
- ###############################################################################
361
- #
362
- # Test the _store_areaformat method.
363
- #
364
- def test_store_areaformat
365
- caption = " \tChart: _store_areaformat()"
366
- expected = %w(
367
- 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
368
- 16 00 4F 00
369
- ).join(' ')
370
- values = [0x00C0C0C0, 0x00, 0x01, 0x00, 0x16, 0x4F]
371
- got = unpack_record(@chart.store_areaformat(*values))
372
- assert_equal(expected, got, caption)
373
- end
374
-
375
- ###############################################################################
376
- #
377
- # Test the _store_chartformat method.
378
- #
379
- def test_store_chartformat
380
- caption = " \tChart: _store_chartformat()"
381
- expected = %w(
382
- 14 10 14 00 00 00 00 00 00 00 00 00 00 00 00 00
383
- 00 00 00 00 00 00 00 00
384
- ).join(' ')
385
- got = unpack_record(@chart.store_chartformat)
386
- assert_equal(expected, got, caption)
387
- end
388
-
389
- ###############################################################################
390
- #
391
- # Test the _store_legend method.
392
- #
393
- def test_store_legend
394
- caption = " \tChart: _store_legend()"
395
- expected = %w(
396
- 15 10 14 00 F9 05 00 00 E9 0E 00 00 7D 04 00 00
397
- 9C 00 00 00 00 01 0F 00
398
- ).join(' ')
399
- values = [0x05F9, 0x0EE9, 0x047D, 0x009C, 0x00, 0x01, 0x000F]
400
- got = unpack_record(@chart.store_legend(*values))
401
- assert_equal(expected, got, caption)
402
- end
403
-
404
- ###############################################################################
405
- #
406
- # Test the _store_pos method.
407
- #
408
- def test_store_pos
409
- caption = " \tChart: _store_pos()"
410
- expected = %w(
411
- 4F 10 14 00 05 00 02 00 83 0E 00 00 F9 06 00 00
412
- 00 00 00 00 00 00 00 00
413
- ).join(' ')
414
- values = [5, 2, 0x0E83, 0x06F9, 0, 0]
415
- got = unpack_record(@chart.store_pos(*values))
416
- assert_equal(expected, got, caption)
417
- end
418
-
419
- ###############################################################################
420
- #
421
- # Test the _store_text method.
422
- #
423
- def test_store_text
424
- caption = " \tChart: _store_text()"
425
- expected = %w(
426
- 25 10 20 00 02 02 01 00 00 00 00 00 46 FF FF FF
427
- 06 FF FF FF 00 00 00 00 00 00 00 00 B1 00 4D 00
428
- 20 10 00 00
429
- ).join(' ')
430
- values = [0xFFFFFF46, 0xFFFFFF06, 0, 0, 0x00B1, 0x1020]
431
- got = unpack_record(@chart.store_text(*values))
432
- assert_equal(expected, got, caption)
433
- end
434
-
435
- ###############################################################################
436
- #
437
- # Test the _store_plotgrowth method.
438
- #
439
- def test_store_plotgrowth
440
- caption = " \tChart: _store_plotgrowth()"
441
- expected = %w(
442
- 64 10 08 00 00 00 01 00 00 00 01 00
443
- ).join(' ')
444
- got = unpack_record(@chart.store_plotgrowth)
445
- assert_equal(expected, got, caption)
446
- end
447
-
448
- ###############################################################################
449
- #
450
- # Test the _store_seriestext method.
451
- #
452
- def test_store_seriestext
453
- caption = " \tChart: _store_seriestext()"
454
- expected = %w(
455
- 0D 10 14 00 00 00 10 00 4E 61 6D 65
456
- 20 66 6F 72 20 53 65 72
457
- 69 65 73 31
458
- ).join(' ')
459
- str = 'Name for Series1'
460
- got = unpack_record(@chart.store_seriestext(str, 0))
461
- assert_equal(expected, got, caption)
462
- end
463
-
464
- ###############################################################################
465
- #
466
- # Test the _store_seriestext method.
467
- #
468
- def test_store_seriestext_utf16
469
- caption = " \tChart: _store_seriestext()"
470
- expected = %w(
471
- 0D 10 24 00 00 00 10 01 4E 00 61 00 6D 00 65 00
472
- 20 00 66 00 6F 00 72 00 20 00 53 00 65 00 72 00
473
- 69 00 65 00 73 00 31 00
474
- ).join(' ')
475
- str = 'Name for Series1'.unpack('C*').pack('n*')
476
- got = unpack_record(@chart.store_seriestext(str, 1))
477
- assert_equal(expected, got, caption)
478
- end
479
-
480
- ###############################################################################
481
- #
482
- # Test the _store_objectlink method.
483
- #
484
- def test_store_objectlink
485
- caption = " \tChart: _store_objectlink()"
486
- expected = %w(
487
- 27 10 06 00 01 00 00 00 00 00
488
- ).join(' ')
489
- got = unpack_record(@chart.store_objectlink(1))
490
- assert_equal(expected, got, caption)
491
- end
492
-
493
- ###############################################################################
494
- #
495
- # Test the _store_pieformat method.
496
- #
497
- def test_store_pieformat
498
- caption = " \tChart: _store_pieformat()"
499
- expected = %w(
500
- 0B 10 02 00 00 00
501
- ).join(' ')
502
- got = unpack_record(@chart.store_pieformat)
503
- assert_equal(expected, got, caption)
504
- end
505
-
506
- ###############################################################################
507
- #
508
- # Test the _store_markerformat method.
509
- #
510
- def test_store_markerformat
511
- caption = " \tChart: _store_markerformat()"
512
- expected = %w(
513
- 09 10 14 00 00 00 00 00 00 00 00 00 02 00 01 00
514
- 4D 00 4D 00 3C 00 00 00
515
- ).join(' ')
516
- values = [0x00, 0x00, 0x02, 0x01, 0x4D, 0x4D, 0x3C]
517
- got = unpack_record(@chart.store_markerformat(*values))
518
- assert_equal(expected, got, caption)
519
- end
520
-
521
- ###############################################################################
522
- #
523
- # Test the _store_dropbar method.
524
- #
525
- def test_store_dropbar
526
- caption = " \tChart: _store_dropbar()"
527
- expected = %w(
528
- 3D 10 02 00 96 00
529
- ).join(' ')
530
- got = unpack_record(@chart.store_dropbar)
531
- assert_equal(expected, got, caption)
532
- end
533
-
534
- ###############################################################################
535
- #
536
- # Test the _store_chartline method.
537
- #
538
- def test_store_chartline
539
- caption = " \tChart: _store_chartline()"
540
- expected = %w(
541
- 1C 10 02 00 01 00
542
- ).join(' ')
543
- got = unpack_record(@chart.store_chartline)
544
- assert_equal(expected, got, caption)
545
- end
546
-
547
- ###############################################################################
548
- #
549
- # Test the _store_serparent method.
550
- #
551
- def test_store_serparent
552
- caption = " \tChart: _store_serparent()"
553
- expected = %w(
554
- 4A 10 02 00 01 00
555
- ).join(' ')
556
- got = unpack_record(@chart.store_serparent(1))
557
- assert_equal(expected, got, caption)
558
- end
559
-
560
- ###############################################################################
561
- #
562
- # Test the _store_serauxtrend method.
563
- #
564
- def test_store_serauxtrend
565
- caption = " \tChart: _store_serauxtrend()"
566
- expected = %w(
567
- 4B 10 1C 00 00 01 FF FF FF FF 00 01 FF FF 00 00
568
- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
569
- ).join(' ')
570
- values = [0x00, 0x01, 0x00, 0x00]
571
- got = unpack_record(@chart.store_serauxtrend(*values))
572
- assert_equal(expected, got, caption)
573
- end
574
-
575
- def unpack_record(data)
576
- data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
577
- end
578
- end
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'stringio'
4
+
5
+ ###############################################################################
6
+ #
7
+ # A test for Chart.
8
+ #
9
+ # Tests for the Excel chart.rb methods.
10
+ #
11
+ # reverse(''), December 2009, John McNamara, jmcnamara@cpan.org
12
+ #
13
+ # original written in Perl by John McNamara
14
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
15
+ #
16
+ class TC_ChartGeneric < Test::Unit::TestCase
17
+ def setup
18
+ io = StringIO.new
19
+ workbook = WriteExcel.new(io)
20
+ @chart = Writeexcel::Chart.new('', 'chart', 0, 0, 0, 0, 0, 0, 0, 0)
21
+ end
22
+
23
+ def teardown
24
+ @chart.cleanup
25
+ end
26
+
27
+ ###############################################################################
28
+ #
29
+ # Test the _store_fbi method.
30
+ #
31
+ def test_store_fbi
32
+ caption = " \tChart: _store_fbi()"
33
+ expected = %w(
34
+ 60 10 0A 00 B8 38 A1 22 C8 00 00 00 05 00
35
+ ).join(' ')
36
+ got = unpack_record(@chart.store_fbi(5, 10, 0x38B8, 0x22A1, 0x0000))
37
+ assert_equal(expected, got, caption)
38
+
39
+ expected = %w(
40
+ 60 10 0A 00 B8 38 A1 22 C8 00 00 00 06 00
41
+ ).join(' ')
42
+ got = unpack_record(@chart.store_fbi(6, 10, 0x38B8, 0x22A1, 0x0000))
43
+ assert_equal(expected, got, caption)
44
+ end
45
+
46
+ ###############################################################################
47
+ #
48
+ # Test the _store_chart method.
49
+ #
50
+ def test_store_chart
51
+ caption = " \tChart: _store_chart()"
52
+ expected = %w(
53
+ 02 10 10 00 00 00 00 00 00 00 00 00 E0 51 DD 02
54
+ 38 B8 C2 01
55
+ ).join(' ')
56
+ values = [0x0000, 0x0000, 0x02DD51E0, 0x01C2B838]
57
+ got = unpack_record(@chart.store_chart(*values))
58
+ assert_equal(expected, got, caption)
59
+ end
60
+
61
+ ###############################################################################
62
+ #
63
+ # Test the _store_series method.
64
+ #
65
+ def test_store_series
66
+ caption = " \tChart: _store_series()"
67
+ expected = %w(
68
+ 03 10 0C 00 01 00 01 00 08 00 08 00 01 00 00 00
69
+ ).join(' ')
70
+ got = unpack_record(@chart.store_series(8, 8))
71
+ assert_equal(expected, got, caption)
72
+ end
73
+
74
+ ###############################################################################
75
+ #
76
+ # Test the _store_begin method.
77
+ #
78
+ def test_store_begin
79
+ caption = " \tChart: _store_begin()"
80
+ expected = %w(
81
+ 33 10 00 00
82
+ ).join(' ')
83
+ got = unpack_record(@chart.store_begin)
84
+ assert_equal(expected, got, caption)
85
+ end
86
+
87
+ ###############################################################################
88
+ #
89
+ # Test the _store_end method.
90
+ #
91
+ def test_store_end
92
+ caption = " \tChart: _store_end()"
93
+ expected = %w(
94
+ 34 10 00 00
95
+ ).join(' ')
96
+ got = unpack_record(@chart.store_end)
97
+ assert_equal(expected, got, caption)
98
+ end
99
+
100
+ ###############################################################################
101
+ #
102
+ # Test the _store_ai method.
103
+ #
104
+ def test_store_ai
105
+ caption = " \tChart: _store_ai()"
106
+ values = [0, 1, '']
107
+ expected = %w(
108
+ 51 10 08 00 00 01 00 00 00 00 00 00
109
+ ).join(' ')
110
+ got = unpack_record(@chart.store_ai(*values))
111
+ assert_equal(expected, got, caption)
112
+
113
+ values = [1, 2, ['3B00000000070000000000'].pack('H*')]
114
+ expected = %w(
115
+ 51 10 13 00 01 02 00 00 00 00 0B 00 3B 00 00 00
116
+ 00 07 00 00 00 00 00
117
+ ).join(' ')
118
+ got = unpack_record(@chart.store_ai(*values))
119
+ assert_equal(expected, got, caption)
120
+ end
121
+
122
+ ###############################################################################
123
+ #
124
+ # Test the _store_dataformat method.
125
+ #
126
+ def test_store_dataformat
127
+ caption = " \tChart: _store_dataformat()"
128
+ expected = %w(
129
+ 06 10 08 00 FF FF 00 00 00 00 00 00
130
+ ).join(' ')
131
+ got = unpack_record(@chart.store_dataformat(0, 0, 0xFFFF))
132
+ assert_equal(expected, got, caption)
133
+
134
+ expected = %w(
135
+ 06 10 08 00 00 00 00 00 FD FF 00 00
136
+ ).join(' ')
137
+ got = unpack_record(@chart.store_dataformat(0, 0xFFFD, 0))
138
+ assert_equal(expected, got, caption)
139
+ end
140
+
141
+ ###############################################################################
142
+ #
143
+ # Test the _store_3dbarshape method.
144
+ #
145
+ def test_store_3dbarshape
146
+ caption = " \tChart: _store_3dbarshape()"
147
+ expected = %w(
148
+ 5F 10 02 00 00 00
149
+ ).join(' ')
150
+ got = unpack_record(@chart.store_3dbarshape)
151
+ assert_equal(expected, got, caption)
152
+ end
153
+
154
+ ###############################################################################
155
+ #
156
+ # Test the _store_sertocrt method.
157
+ #
158
+ def test_store_sertocrt
159
+ caption = " \tChart: _store_sertocrt()"
160
+ expected = %w(
161
+ 45 10 02 00 00 00
162
+ ).join(' ')
163
+ got = unpack_record(@chart.store_sertocrt)
164
+ assert_equal(expected, got, caption)
165
+ end
166
+
167
+ ###############################################################################
168
+ #
169
+ # Test the _store_shtprops method.
170
+ #
171
+ def test_store_shtprops
172
+ caption = " \tChart: _store_shtprops()"
173
+ expected = %w(
174
+ 44 10 04 00 0E 00 00 00
175
+ ).join(' ')
176
+ got = unpack_record(@chart.store_shtprops)
177
+ assert_equal(expected, got, caption)
178
+ end
179
+
180
+ ###############################################################################
181
+ #
182
+ # Test the _store_defaulttext method.
183
+ #
184
+ def test_store_defaulttext
185
+ caption = " \tChart: _store_defaulttext()"
186
+ expected = %w(
187
+ 24 10 02 00 02 00
188
+ ).join(' ')
189
+ got = unpack_record(@chart.store_defaulttext)
190
+ assert_equal(expected, got, caption)
191
+ end
192
+
193
+ ###############################################################################
194
+ #
195
+ # Test the _store_charttext method.
196
+ #
197
+ def test_store_charttext
198
+ caption = " \tChart: _store_charttext()"
199
+ expected = %w(
200
+ 25 10 20 00 02 02 01 00 00 00 00 00 46 FF FF FF
201
+ 06 FF FF FF 00 00 00 00 00 00 00 00 B1 00 4D 00
202
+ 00 00 00 00
203
+ ).join(' ')
204
+ got = unpack_record(@chart.store_charttext)
205
+ assert_equal(expected, got, caption)
206
+ end
207
+
208
+ ###############################################################################
209
+ #
210
+ # Test the _store_fontx method.
211
+ #
212
+ def test_store_fontx
213
+ caption = " \tChart: _store_fontx()"
214
+ expected = %w(
215
+ 26 10 02 00 05 00
216
+ ).join(' ')
217
+ got = unpack_record(@chart.store_fontx(5))
218
+ assert_equal(expected, got, caption)
219
+ end
220
+
221
+ ###############################################################################
222
+ #
223
+ # Test the _store_axesused method.
224
+ #
225
+ def test_store_axesused
226
+ caption = " \tChart: _store_axesused()"
227
+ expected = %w(
228
+ 46 10 02 00 01 00
229
+ ).join(' ')
230
+ got = unpack_record(@chart.store_axesused(1))
231
+ assert_equal(expected, got, caption)
232
+ end
233
+
234
+ ###############################################################################
235
+ #
236
+ # Test the _store_axisparent method.
237
+ #
238
+ def test_store_axisparent
239
+ caption = " \tChart: _store_axisparent()"
240
+ expected = %w(
241
+ 41 10 12 00 00 00 F8 00 00 00 F5 01 00 00 7F 0E
242
+ 00 00 36 0B 00 00
243
+ ).join(' ')
244
+ values = [0, 0x00F8, 0x01F5, 0x0E7F, 0x0B36]
245
+ got = unpack_record(@chart.store_axisparent(*values))
246
+ assert_equal(expected, got, caption)
247
+ end
248
+
249
+ ###############################################################################
250
+ #
251
+ # Test the _store_axis method.
252
+ #
253
+ def test_store_axis
254
+ caption = " \tChart: _store_axis()"
255
+ expected = %w(
256
+ 1D 10 12 00 00 00 00 00 00 00 00 00 00 00 00 00
257
+ 00 00 00 00 00 00
258
+ ).join(' ')
259
+ got = unpack_record(@chart.store_axis(0))
260
+ assert_equal(expected, got, caption)
261
+ end
262
+
263
+ ###############################################################################
264
+ #
265
+ # Test the _store_catserrange method.
266
+ #
267
+ def test_store_catserrange
268
+ caption = " \tChart: _store_catserrange()"
269
+ expected = %w(
270
+ 20 10 08 00 01 00 01 00 01 00 01 00
271
+ ).join(' ')
272
+ got = unpack_record(@chart.store_catserrange)
273
+ assert_equal(expected, got, caption)
274
+ end
275
+
276
+ ###############################################################################
277
+ #
278
+ # Test the _store_axcext method.
279
+ #
280
+ def test_store_axcext
281
+ caption = " \tChart: _store_axcext()"
282
+ expected = %w(
283
+ 62 10 12 00 00 00 00 00 01 00 00 00 01 00 00 00
284
+ 00 00 00 00 EF 00
285
+ ).join(' ')
286
+ got = unpack_record(@chart.store_axcext)
287
+ assert_equal(expected, got, caption)
288
+ end
289
+
290
+ ###############################################################################
291
+ #
292
+ # Test the _store_tick method.
293
+ #
294
+ def test_store_tick
295
+ caption = " \tChart: _store_tick()"
296
+ expected = %w(
297
+ 1E 10 1E 00 02 00 03 01 00 00 00 00 00 00 00 00
298
+ 00 00 00 00 00 00 00 00 00 00 00 00 23 00 4D 00
299
+ 00 00
300
+ ).join(' ')
301
+ got = unpack_record(@chart.store_tick)
302
+ assert_equal(expected, got, caption)
303
+ end
304
+
305
+ ###############################################################################
306
+ #
307
+ # Test the _store_valuerange method.
308
+ #
309
+ def test_store_valuerange
310
+ caption = " \tChart: _store_valuerange()"
311
+ expected = %w(
312
+ 1F 10 2A 00 00 00 00 00 00 00 00 00 00 00 00 00
313
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
314
+ 00 00 00 00 00 00 00 00 00 00 00 00 1F 01
315
+ ).join(' ')
316
+ got = unpack_record(@chart.store_valuerange)
317
+ assert_equal(expected, got, caption)
318
+ end
319
+
320
+ ###############################################################################
321
+ #
322
+ # Test the _store_axislineformat method.
323
+ #
324
+ def test_store_axislineformat
325
+ caption = " \tChart: _store_axislineformat()"
326
+ expected = %w(
327
+ 21 10 02 00 01 00
328
+ ).join(' ')
329
+ got = unpack_record(@chart.store_axislineformat)
330
+ assert_equal(expected, got, caption)
331
+ end
332
+
333
+ ###############################################################################
334
+ #
335
+ # Test the _store_lineformat method.
336
+ #
337
+ def test_store_lineformat
338
+ caption = " \tChart: _store_lineformat()"
339
+ expected = %w(
340
+ 07 10 0C 00 00 00 00 00 00 00 FF FF 09 00 4D 00
341
+ ).join(' ')
342
+ values = [0x00000000, 0x0000, 0xFFFF, 0x0009, 0x004D]
343
+ got = unpack_record(@chart.store_lineformat(*values))
344
+ assert_equal(expected, got, caption)
345
+ end
346
+
347
+ ###############################################################################
348
+ #
349
+ # Test the _store_frame method.
350
+ #
351
+ def test_store_frame
352
+ caption = " \tChart: _store_frame()"
353
+ expected = %w(
354
+ 32 10 04 00 00 00 03 00
355
+ ).join(' ')
356
+ got = unpack_record(@chart.store_frame(0x00, 0x03))
357
+ assert_equal(expected, got, caption)
358
+ end
359
+
360
+ ###############################################################################
361
+ #
362
+ # Test the _store_areaformat method.
363
+ #
364
+ def test_store_areaformat
365
+ caption = " \tChart: _store_areaformat()"
366
+ expected = %w(
367
+ 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
368
+ 16 00 4F 00
369
+ ).join(' ')
370
+ values = [0x00C0C0C0, 0x00, 0x01, 0x00, 0x16, 0x4F]
371
+ got = unpack_record(@chart.store_areaformat(*values))
372
+ assert_equal(expected, got, caption)
373
+ end
374
+
375
+ ###############################################################################
376
+ #
377
+ # Test the _store_chartformat method.
378
+ #
379
+ def test_store_chartformat
380
+ caption = " \tChart: _store_chartformat()"
381
+ expected = %w(
382
+ 14 10 14 00 00 00 00 00 00 00 00 00 00 00 00 00
383
+ 00 00 00 00 00 00 00 00
384
+ ).join(' ')
385
+ got = unpack_record(@chart.store_chartformat)
386
+ assert_equal(expected, got, caption)
387
+ end
388
+
389
+ ###############################################################################
390
+ #
391
+ # Test the _store_legend method.
392
+ #
393
+ def test_store_legend
394
+ caption = " \tChart: _store_legend()"
395
+ expected = %w(
396
+ 15 10 14 00 F9 05 00 00 E9 0E 00 00 7D 04 00 00
397
+ 9C 00 00 00 00 01 0F 00
398
+ ).join(' ')
399
+ values = [0x05F9, 0x0EE9, 0x047D, 0x009C, 0x00, 0x01, 0x000F]
400
+ got = unpack_record(@chart.store_legend(*values))
401
+ assert_equal(expected, got, caption)
402
+ end
403
+
404
+ ###############################################################################
405
+ #
406
+ # Test the _store_pos method.
407
+ #
408
+ def test_store_pos
409
+ caption = " \tChart: _store_pos()"
410
+ expected = %w(
411
+ 4F 10 14 00 05 00 02 00 83 0E 00 00 F9 06 00 00
412
+ 00 00 00 00 00 00 00 00
413
+ ).join(' ')
414
+ values = [5, 2, 0x0E83, 0x06F9, 0, 0]
415
+ got = unpack_record(@chart.store_pos(*values))
416
+ assert_equal(expected, got, caption)
417
+ end
418
+
419
+ ###############################################################################
420
+ #
421
+ # Test the _store_text method.
422
+ #
423
+ def test_store_text
424
+ caption = " \tChart: _store_text()"
425
+ expected = %w(
426
+ 25 10 20 00 02 02 01 00 00 00 00 00 46 FF FF FF
427
+ 06 FF FF FF 00 00 00 00 00 00 00 00 B1 00 4D 00
428
+ 20 10 00 00
429
+ ).join(' ')
430
+ values = [0xFFFFFF46, 0xFFFFFF06, 0, 0, 0x00B1, 0x1020]
431
+ got = unpack_record(@chart.store_text(*values))
432
+ assert_equal(expected, got, caption)
433
+ end
434
+
435
+ ###############################################################################
436
+ #
437
+ # Test the _store_plotgrowth method.
438
+ #
439
+ def test_store_plotgrowth
440
+ caption = " \tChart: _store_plotgrowth()"
441
+ expected = %w(
442
+ 64 10 08 00 00 00 01 00 00 00 01 00
443
+ ).join(' ')
444
+ got = unpack_record(@chart.store_plotgrowth)
445
+ assert_equal(expected, got, caption)
446
+ end
447
+
448
+ ###############################################################################
449
+ #
450
+ # Test the _store_seriestext method.
451
+ #
452
+ def test_store_seriestext
453
+ caption = " \tChart: _store_seriestext()"
454
+ expected = %w(
455
+ 0D 10 14 00 00 00 10 00 4E 61 6D 65
456
+ 20 66 6F 72 20 53 65 72
457
+ 69 65 73 31
458
+ ).join(' ')
459
+ str = 'Name for Series1'
460
+ got = unpack_record(@chart.store_seriestext(str, 0))
461
+ assert_equal(expected, got, caption)
462
+ end
463
+
464
+ ###############################################################################
465
+ #
466
+ # Test the _store_seriestext method.
467
+ #
468
+ def test_store_seriestext_utf16
469
+ caption = " \tChart: _store_seriestext()"
470
+ expected = %w(
471
+ 0D 10 24 00 00 00 10 01 4E 00 61 00 6D 00 65 00
472
+ 20 00 66 00 6F 00 72 00 20 00 53 00 65 00 72 00
473
+ 69 00 65 00 73 00 31 00
474
+ ).join(' ')
475
+ str = 'Name for Series1'.unpack('C*').pack('n*')
476
+ got = unpack_record(@chart.store_seriestext(str, 1))
477
+ assert_equal(expected, got, caption)
478
+ end
479
+
480
+ ###############################################################################
481
+ #
482
+ # Test the _store_objectlink method.
483
+ #
484
+ def test_store_objectlink
485
+ caption = " \tChart: _store_objectlink()"
486
+ expected = %w(
487
+ 27 10 06 00 01 00 00 00 00 00
488
+ ).join(' ')
489
+ got = unpack_record(@chart.store_objectlink(1))
490
+ assert_equal(expected, got, caption)
491
+ end
492
+
493
+ ###############################################################################
494
+ #
495
+ # Test the _store_pieformat method.
496
+ #
497
+ def test_store_pieformat
498
+ caption = " \tChart: _store_pieformat()"
499
+ expected = %w(
500
+ 0B 10 02 00 00 00
501
+ ).join(' ')
502
+ got = unpack_record(@chart.store_pieformat)
503
+ assert_equal(expected, got, caption)
504
+ end
505
+
506
+ ###############################################################################
507
+ #
508
+ # Test the _store_markerformat method.
509
+ #
510
+ def test_store_markerformat
511
+ caption = " \tChart: _store_markerformat()"
512
+ expected = %w(
513
+ 09 10 14 00 00 00 00 00 00 00 00 00 02 00 01 00
514
+ 4D 00 4D 00 3C 00 00 00
515
+ ).join(' ')
516
+ values = [0x00, 0x00, 0x02, 0x01, 0x4D, 0x4D, 0x3C]
517
+ got = unpack_record(@chart.store_markerformat(*values))
518
+ assert_equal(expected, got, caption)
519
+ end
520
+
521
+ ###############################################################################
522
+ #
523
+ # Test the _store_dropbar method.
524
+ #
525
+ def test_store_dropbar
526
+ caption = " \tChart: _store_dropbar()"
527
+ expected = %w(
528
+ 3D 10 02 00 96 00
529
+ ).join(' ')
530
+ got = unpack_record(@chart.store_dropbar)
531
+ assert_equal(expected, got, caption)
532
+ end
533
+
534
+ ###############################################################################
535
+ #
536
+ # Test the _store_chartline method.
537
+ #
538
+ def test_store_chartline
539
+ caption = " \tChart: _store_chartline()"
540
+ expected = %w(
541
+ 1C 10 02 00 01 00
542
+ ).join(' ')
543
+ got = unpack_record(@chart.store_chartline)
544
+ assert_equal(expected, got, caption)
545
+ end
546
+
547
+ ###############################################################################
548
+ #
549
+ # Test the _store_serparent method.
550
+ #
551
+ def test_store_serparent
552
+ caption = " \tChart: _store_serparent()"
553
+ expected = %w(
554
+ 4A 10 02 00 01 00
555
+ ).join(' ')
556
+ got = unpack_record(@chart.store_serparent(1))
557
+ assert_equal(expected, got, caption)
558
+ end
559
+
560
+ ###############################################################################
561
+ #
562
+ # Test the _store_serauxtrend method.
563
+ #
564
+ def test_store_serauxtrend
565
+ caption = " \tChart: _store_serauxtrend()"
566
+ expected = %w(
567
+ 4B 10 1C 00 00 01 FF FF FF FF 00 01 FF FF 00 00
568
+ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
569
+ ).join(' ')
570
+ values = [0x00, 0x01, 0x00, 0x00]
571
+ got = unpack_record(@chart.store_serauxtrend(*values))
572
+ assert_equal(expected, got, caption)
573
+ end
574
+
575
+ def unpack_record(data)
576
+ data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
577
+ end
578
+ end