writeexcel 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/.gitattributes +1 -0
  2. data/README.rdoc +12 -6
  3. data/VERSION +1 -1
  4. data/charts/chartex.rb +316 -315
  5. data/charts/demo1.rb +1 -0
  6. data/charts/demo2.rb +1 -0
  7. data/charts/demo3.rb +117 -116
  8. data/charts/demo4.rb +119 -118
  9. data/charts/demo5.rb +48 -47
  10. data/examples/a_simple.rb +1 -0
  11. data/examples/autofilter.rb +1 -0
  12. data/examples/bigfile.rb +30 -29
  13. data/examples/chart_area.rb +121 -120
  14. data/examples/chart_bar.rb +120 -119
  15. data/examples/chart_column.rb +120 -119
  16. data/examples/chart_line.rb +120 -119
  17. data/examples/chart_pie.rb +108 -107
  18. data/examples/chart_scatter.rb +121 -120
  19. data/examples/chart_stock.rb +148 -147
  20. data/examples/chess.rb +1 -0
  21. data/examples/colors.rb +1 -0
  22. data/examples/comments1.rb +1 -0
  23. data/examples/comments2.rb +3 -2
  24. data/examples/copyformat.rb +1 -0
  25. data/examples/data_validate.rb +1 -0
  26. data/examples/date_time.rb +1 -0
  27. data/examples/defined_name.rb +1 -0
  28. data/examples/demo.rb +1 -0
  29. data/examples/diag_border.rb +1 -0
  30. data/examples/formats.rb +1 -0
  31. data/examples/formula_result.rb +1 -0
  32. data/examples/header.rb +1 -0
  33. data/examples/hide_sheet.rb +1 -0
  34. data/examples/hyperlink.rb +1 -0
  35. data/examples/images.rb +1 -0
  36. data/examples/indent.rb +1 -0
  37. data/examples/merge1.rb +1 -0
  38. data/examples/merge2.rb +1 -0
  39. data/examples/merge3.rb +1 -0
  40. data/examples/merge4.rb +1 -0
  41. data/examples/merge5.rb +1 -0
  42. data/examples/merge6.rb +67 -66
  43. data/examples/outline.rb +1 -0
  44. data/examples/outline_collapsed.rb +1 -0
  45. data/examples/panes.rb +1 -0
  46. data/examples/properties.rb +1 -0
  47. data/examples/properties_jp.rb +1 -0
  48. data/examples/protection.rb +1 -0
  49. data/examples/regions.rb +1 -0
  50. data/examples/repeat.rb +1 -0
  51. data/examples/right_to_left.rb +1 -0
  52. data/examples/row_wrap.rb +1 -0
  53. data/examples/stats.rb +1 -0
  54. data/examples/stocks.rb +1 -0
  55. data/examples/tab_colors.rb +1 -0
  56. data/examples/write_arrays.rb +1 -0
  57. data/lib/writeexcel.rb +6 -1
  58. data/lib/writeexcel/biffwriter.rb +21 -20
  59. data/lib/writeexcel/chart.rb +25 -12
  60. data/lib/writeexcel/charts/area.rb +153 -152
  61. data/lib/writeexcel/charts/bar.rb +178 -177
  62. data/lib/writeexcel/charts/column.rb +157 -156
  63. data/lib/writeexcel/charts/external.rb +62 -61
  64. data/lib/writeexcel/charts/line.rb +153 -152
  65. data/lib/writeexcel/charts/pie.rb +170 -169
  66. data/lib/writeexcel/charts/scatter.rb +4 -3
  67. data/lib/writeexcel/charts/stock.rb +212 -211
  68. data/lib/writeexcel/compatibility.rb +320 -0
  69. data/lib/writeexcel/excelformulaparser.rb +587 -586
  70. data/lib/writeexcel/format.rb +12 -13
  71. data/lib/writeexcel/formula.rb +30 -28
  72. data/lib/writeexcel/helper.rb +23 -0
  73. data/lib/writeexcel/olewriter.rb +5 -16
  74. data/lib/writeexcel/properties.rb +43 -54
  75. data/lib/writeexcel/storage_lite.rb +981 -968
  76. data/lib/writeexcel/workbook.rb +94 -73
  77. data/lib/writeexcel/worksheet.rb +230 -210
  78. data/test/helper.rb +19 -0
  79. data/test/test_00_IEEE_double.rb +1 -0
  80. data/test/test_01_add_worksheet.rb +1 -0
  81. data/test/test_02_merge_formats.rb +3 -5
  82. data/test/test_04_dimensions.rb +3 -5
  83. data/test/test_05_rows.rb +6 -6
  84. data/test/test_06_extsst.rb +8 -8
  85. data/test/test_11_date_time.rb +3 -5
  86. data/test/test_12_date_only.rb +3 -5
  87. data/test/test_13_date_seconds.rb +4 -6
  88. data/test/test_21_escher.rb +3 -5
  89. data/test/test_22_mso_drawing_group.rb +20 -22
  90. data/test/test_23_note.rb +5 -7
  91. data/test/test_24_txo.rb +3 -5
  92. data/test/test_25_position_object.rb +84 -79
  93. data/test/test_26_autofilter.rb +3 -13
  94. data/test/test_27_autofilter.rb +3 -13
  95. data/test/test_28_autofilter.rb +3 -13
  96. data/test/test_29_process_jpg.rb +5 -0
  97. data/test/test_30_validation_dval.rb +3 -5
  98. data/test/test_31_validation_dv_strings.rb +3 -5
  99. data/test/test_32_validation_dv_formula.rb +3 -5
  100. data/test/test_40_property_types.rb +10 -9
  101. data/test/test_41_properties.rb +1 -0
  102. data/test/test_42_set_properties.rb +14 -15
  103. data/test/test_50_name_stored.rb +299 -302
  104. data/test/test_51_name_print_area.rb +357 -360
  105. data/test/test_52_name_print_titles.rb +454 -457
  106. data/test/test_53_autofilter.rb +203 -206
  107. data/test/test_60_chart_generic.rb +5 -0
  108. data/test/test_61_chart_subclasses.rb +95 -94
  109. data/test/test_62_chart_formats.rb +272 -267
  110. data/test/test_63_chart_area_formats.rb +649 -644
  111. data/test/test_biff.rb +12 -38
  112. data/test/test_compatibility.rb +627 -0
  113. data/test/test_example_match.rb +3 -18
  114. data/test/test_format.rb +46 -105
  115. data/test/test_formula.rb +1 -0
  116. data/test/test_ole.rb +3 -4
  117. data/test/test_storage_lite.rb +125 -146
  118. data/test/test_workbook.rb +2 -23
  119. data/test/test_worksheet.rb +4 -5
  120. data/utils/add_magic_comment.rb +80 -0
  121. data/writeexcel.gemspec +8 -2
  122. metadata +10 -4
@@ -1,644 +1,649 @@
1
- require 'helper'
2
- require 'stringio'
3
-
4
- ###############################################################################
5
- #
6
- # A test for Spreadsheet::WriteExcel::Chart.
7
- #
8
- # Tests for the Excel Chart.pm format conversion methods.
9
- #
10
- # reverse('ゥ'), January 2010, John McNamara, jmcnamara@cpan.org
11
- #
12
- # original written in Perl by John McNamara
13
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
14
- #
15
- class TC_ChartAreaFormats < Test::Unit::TestCase
16
- def setup
17
- @io = StringIO.new
18
- @workbook = WriteExcel.new(@io)
19
- @chart = @workbook.add_chart(:type => Chart::Column)
20
- @chart.using_tmpfile = false
21
- @caption1 = " \tChart: chartarea format - line";
22
- @caption2 = " \tChart: chartarea format - area";
23
- @embed_caption1 = " \tChart: embedded chartarea format - line";
24
- @embed_caption2 = " \tChart: embedded chartarea format - area";
25
- @plotarea_caption1 = " \tChart: plotarea format - line";
26
- @plotarea_caption2 = " \tChart: plotarea format - area";
27
- end
28
-
29
- ###############################################################################
30
- #
31
- # 1. Test the chartarea format methods. See the set_*area() properties below.
32
- #
33
- def test_the_chartarea_format_methods
34
- reset_chart(@chart)
35
-
36
- @chart.set_chartarea(
37
- :color => 'red',
38
- :line_color => 'black',
39
- :line_pattern => 2,
40
- :line_weight => 3
41
- )
42
-
43
- expected_line = %w(
44
- 07 10 0C 00 00 00 00 00 01 00 01 00 00 00 08 00
45
- ).join(' ')
46
-
47
- expected_area = %w(
48
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
49
- 0A 00 08 00
50
- ).join(' ')
51
-
52
- got_line, got_area = get_chartarea_formats(@chart)
53
-
54
- assert_equal(expected_line, got_line, @caption1)
55
- assert_equal(expected_area, got_area, @caption2)
56
-
57
-
58
- reset_chart(@chart)
59
-
60
- @chart.set_chartarea(
61
- :color => 'red'
62
- )
63
-
64
- expected_line = %w(
65
- 07 10 0C 00 00 00 00 00 05 00 FF FF 08 00 4D 00
66
- ).join(' ')
67
-
68
- expected_area = %w(
69
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
70
- 0A 00 08 00
71
- ).join(' ')
72
-
73
- got_line, got_area = get_chartarea_formats(@chart)
74
-
75
- assert_equal(expected_line, got_line, @caption1)
76
- assert_equal(expected_area, got_area, @caption2)
77
-
78
-
79
- reset_chart(@chart)
80
-
81
- @chart.set_chartarea(
82
- :line_color => 'red'
83
- )
84
-
85
- expected_line = %w(
86
- 07 10 0C 00 FF 00 00 00 00 00 FF FF 00 00 0A 00
87
- ).join(' ')
88
-
89
- expected_area = %w(
90
- 0A 10 10 00 FF FF FF 00 00 00 00 00 00 00 00 00
91
- 4E 00 4D 00
92
- ).join(' ')
93
-
94
- got_line, got_area = get_chartarea_formats(@chart)
95
-
96
- assert_equal(expected_line, got_line, @caption1)
97
- assert_equal(expected_area, got_area, @caption2)
98
-
99
-
100
- reset_chart(@chart)
101
-
102
- @chart.set_chartarea(
103
- :line_pattern => 2
104
- )
105
-
106
- expected_line = %w(
107
- 07 10 0C 00 00 00 00 00 01 00 FF FF 00 00 4F 00
108
- ).join(' ')
109
-
110
- expected_area = %w(
111
- 0A 10 10 00 FF FF FF 00 00 00 00 00 00 00 00 00
112
- 4E 00 4D 00
113
- ).join(' ')
114
-
115
- got_line, got_area = get_chartarea_formats(@chart)
116
-
117
- assert_equal(expected_line, got_line, @caption1)
118
- assert_equal(expected_area, got_area, @caption2)
119
-
120
-
121
- reset_chart(@chart)
122
-
123
- @chart.set_chartarea(
124
- :line_weight => 3
125
- )
126
-
127
- expected_line = %w(
128
- 07 10 0C 00 00 00 00 00 00 00 01 00 00 00 4F 00
129
- ).join(' ')
130
-
131
- expected_area = %w(
132
- 0A 10 10 00 FF FF FF 00 00 00 00 00 00 00 00 00
133
- 4E 00 4D 00
134
- ).join(' ')
135
-
136
- got_line, got_area = get_chartarea_formats(@chart)
137
-
138
- assert_equal(expected_line, got_line, @caption1)
139
- assert_equal(expected_area, got_area, @caption2)
140
-
141
-
142
- reset_chart(@chart)
143
-
144
- @chart.set_chartarea(
145
- :color => 'red',
146
- :line_color => 'black'
147
- )
148
-
149
- expected_line = %w(
150
- 07 10 0C 00 00 00 00 00 00 00 FF FF 00 00 08 00
151
- ).join(' ')
152
-
153
- expected_area = %w(
154
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
155
- 0A 00 08 00
156
- ).join(' ')
157
-
158
- got_line, got_area = get_chartarea_formats(@chart)
159
-
160
- assert_equal(expected_line, got_line, @caption1)
161
- assert_equal(expected_area, got_area, @caption2)
162
-
163
-
164
- reset_chart(@chart)
165
-
166
- @chart.set_chartarea(
167
- :color => 'red',
168
- :line_pattern => 2
169
- )
170
-
171
- expected_line = %w(
172
- 07 10 0C 00 00 00 00 00 01 00 FF FF 00 00 4F 00
173
- ).join(' ')
174
-
175
- expected_area = %w(
176
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
177
- 0A 00 08 00
178
- ).join(' ')
179
-
180
- got_line, got_area = get_chartarea_formats(@chart)
181
-
182
- assert_equal(expected_line, got_line, @caption1)
183
- assert_equal(expected_area, got_area, @caption2)
184
-
185
-
186
- reset_chart(@chart)
187
-
188
- @chart.set_chartarea(
189
- :color => 'red',
190
- :line_weight => 3
191
- )
192
-
193
- expected_line = %w(
194
- 07 10 0C 00 00 00 00 00 00 00 01 00 00 00 4F 00
195
- ).join(' ')
196
-
197
- expected_area = %w(
198
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
199
- 0A 00 08 00
200
- ).join(' ')
201
-
202
- got_line, got_area = get_chartarea_formats(@chart)
203
-
204
- assert_equal(expected_line, got_line, @caption1)
205
- assert_equal(expected_area, got_area, @caption2)
206
-
207
-
208
- @chart.embedded = true
209
-
210
- reset_chart(@chart, true)
211
-
212
- @chart.set_chartarea(
213
- )
214
-
215
- expected_line = %w(
216
- 07 10 0C 00 00 00 00 00 00 00 00 00 09 00 4D 00
217
- ).join(' ')
218
-
219
- expected_area = %w(
220
- 0A 10 10 00 FF FF FF 00 00 00 00 00 01 00 01 00
221
- 4E 00 4D 00
222
- ).join(' ')
223
-
224
- got_line, got_area = get_chartarea_formats(@chart)
225
-
226
- assert_equal(expected_line, got_line, @embed_caption1)
227
- assert_equal(expected_area, got_area, @embed_caption2)
228
-
229
-
230
- reset_chart(@chart, true)
231
-
232
- @chart.set_chartarea(
233
- :color => 'red',
234
- :line_color => 'black',
235
- :line_pattern => 2,
236
- :line_weight => 3
237
- )
238
-
239
- expected_line = %w(
240
- 07 10 0C 00 00 00 00 00 01 00 01 00 00 00 08 00
241
- ).join(' ')
242
-
243
- expected_area = %w(
244
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
245
- 0A 00 08 00
246
- ).join(' ')
247
-
248
- got_line, got_area = get_chartarea_formats(@chart)
249
-
250
- assert_equal(expected_line, got_line, @embed_caption1)
251
- assert_equal(expected_area, got_area, @embed_caption2)
252
-
253
-
254
- reset_chart(@chart, true)
255
-
256
- @chart.set_chartarea(
257
- :color => 'red'
258
- )
259
-
260
- expected_line = %w(
261
- 07 10 0C 00 00 00 00 00 00 00 FF FF 09 00 4D 00
262
- ).join(' ')
263
-
264
- expected_area = %w(
265
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
266
- 0A 00 08 00
267
- ).join(' ')
268
-
269
- got_line, got_area = get_chartarea_formats(@chart)
270
-
271
- assert_equal(expected_line, got_line, @embed_caption1)
272
- assert_equal(expected_area, got_area, @embed_caption2)
273
-
274
-
275
- reset_chart(@chart, true)
276
-
277
- @chart.set_chartarea(
278
- :line_color => 'red'
279
- )
280
-
281
- expected_line = %w(
282
- 07 10 0C 00 FF 00 00 00 00 00 FF FF 00 00 0A 00
283
- ).join(' ')
284
-
285
- expected_area = %w(
286
- 0A 10 10 00 FF FF FF 00 00 00 00 00 01 00 01 00
287
- 4E 00 4D 00
288
- ).join(' ')
289
-
290
- got_line, got_area = get_chartarea_formats(@chart)
291
-
292
- assert_equal(expected_line, got_line, @embed_caption1)
293
- assert_equal(expected_area, got_area, @embed_caption2)
294
-
295
-
296
- reset_chart(@chart, true)
297
-
298
- @chart.set_chartarea(
299
- :line_pattern => 2
300
- )
301
-
302
- expected_line = %w(
303
- 07 10 0C 00 00 00 00 00 01 00 FF FF 00 00 4F 00
304
- ).join(' ')
305
-
306
- expected_area = %w(
307
- 0A 10 10 00 FF FF FF 00 00 00 00 00 01 00 01 00
308
- 4E 00 4D 00
309
- ).join(' ')
310
-
311
- got_line, got_area = get_chartarea_formats(@chart)
312
-
313
- assert_equal(expected_line, got_line, @embed_caption1)
314
- assert_equal(expected_area, got_area, @embed_caption2)
315
-
316
-
317
- reset_chart(@chart, true)
318
-
319
- @chart.set_chartarea(
320
- :line_weight => 3
321
- )
322
-
323
- expected_line = %w(
324
- 07 10 0C 00 00 00 00 00 00 00 01 00 00 00 4F 00
325
- ).join(' ')
326
-
327
- expected_area = %w(
328
- 0A 10 10 00 FF FF FF 00 00 00 00 00 01 00 01 00
329
- 4E 00 4D 00
330
- ).join(' ')
331
-
332
- got_line, got_area = get_chartarea_formats(@chart)
333
-
334
- assert_equal(expected_line, got_line, @embed_caption1)
335
- assert_equal(expected_area, got_area, @embed_caption2)
336
-
337
-
338
- reset_chart(@chart, true)
339
-
340
- @chart.set_chartarea(
341
- :color => 'red',
342
- :line_color => 'black'
343
- )
344
-
345
- expected_line = %w(
346
- 07 10 0C 00 00 00 00 00 00 00 FF FF 00 00 08 00
347
- ).join(' ')
348
-
349
- expected_area = %w(
350
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
351
- 0A 00 08 00
352
- ).join(' ')
353
-
354
- got_line, got_area = get_chartarea_formats(@chart)
355
-
356
- assert_equal(expected_line, got_line, @embed_caption1)
357
- assert_equal(expected_area, got_area, @embed_caption2)
358
-
359
-
360
- reset_chart(@chart, true)
361
-
362
- @chart.set_chartarea(
363
- :color => 'red',
364
- :line_pattern => 2
365
- )
366
-
367
- expected_line = %w(
368
- 07 10 0C 00 00 00 00 00 01 00 FF FF 00 00 4F 00
369
- ).join(' ')
370
-
371
- expected_area = %w(
372
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
373
- 0A 00 08 00
374
- ).join(' ')
375
-
376
- got_line, got_area = get_chartarea_formats(@chart)
377
-
378
- assert_equal(expected_line, got_line, @embed_caption1)
379
- assert_equal(expected_area, got_area, @embed_caption2)
380
-
381
-
382
- reset_chart(@chart, true)
383
-
384
- @chart.set_chartarea(
385
- :color => 'red',
386
- :line_weight => 3
387
- )
388
-
389
- expected_line = %w(
390
- 07 10 0C 00 00 00 00 00 00 00 01 00 00 00 4F 00
391
- ).join(' ')
392
-
393
- expected_area = %w(
394
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
395
- 0A 00 08 00
396
- ).join(' ')
397
-
398
- got_line, got_area = get_chartarea_formats(@chart)
399
-
400
- assert_equal(expected_line, got_line, @embed_caption1)
401
- assert_equal(expected_area, got_area, @embed_caption2)
402
-
403
-
404
- @chart.embedded = false
405
-
406
- reset_chart(@chart)
407
-
408
- @chart.set_plotarea(
409
- )
410
-
411
- expected_line = %w(
412
- 07 10 0C 00 80 80 80 00 00 00 00 00 00 00 17 00
413
- ).join(' ')
414
-
415
- expected_area = %w(
416
- 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
417
- 16 00 4F 00
418
- ).join(' ')
419
-
420
- got_line, got_area = get_plotarea_formats(@chart)
421
-
422
- assert_equal(expected_line, got_line, @plotarea_caption1)
423
- assert_equal(expected_area, got_area, @plotarea_caption2)
424
-
425
-
426
- reset_chart(@chart)
427
-
428
- @chart.set_plotarea(
429
- :color => 'red',
430
- :line_color => 'black',
431
- :line_pattern => 2,
432
- :line_weight => 3
433
- )
434
-
435
- expected_line = %w(
436
- 07 10 0C 00 00 00 00 00 01 00 01 00 00 00 08 00
437
- ).join(' ')
438
-
439
- expected_area = %w(
440
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
441
- 0A 00 08 00
442
- ).join(' ')
443
-
444
- got_line, got_area = get_plotarea_formats(@chart)
445
-
446
- assert_equal(expected_line, got_line, @plotarea_caption1)
447
- assert_equal(expected_area, got_area, @plotarea_caption2)
448
-
449
-
450
- reset_chart(@chart)
451
-
452
- @chart.set_plotarea(
453
- :color => 'red'
454
- )
455
-
456
- expected_line = %w(
457
- 07 10 0C 00 80 80 80 00 00 00 00 00 00 00 17 00
458
- ).join(' ')
459
-
460
- expected_area = %w(
461
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
462
- 0A 00 08 00
463
- ).join(' ')
464
-
465
- got_line, got_area = get_plotarea_formats(@chart)
466
-
467
- assert_equal(expected_line, got_line, @plotarea_caption1)
468
- assert_equal(expected_area, got_area, @plotarea_caption2)
469
-
470
-
471
- reset_chart(@chart)
472
-
473
- @chart.set_plotarea(
474
- :line_color => 'red'
475
- )
476
-
477
- expected_line = %w(
478
- 07 10 0C 00 FF 00 00 00 00 00 00 00 00 00 0A 00
479
- ).join(' ')
480
-
481
- expected_area = %w(
482
- 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
483
- 16 00 08 00
484
- ).join(' ')
485
-
486
- got_line, got_area = get_plotarea_formats(@chart)
487
-
488
- assert_equal(expected_line, got_line, @plotarea_caption1)
489
- assert_equal(expected_area, got_area, @plotarea_caption2)
490
-
491
-
492
- reset_chart(@chart)
493
-
494
- @chart.set_plotarea(
495
- :line_pattern => 2
496
- )
497
-
498
- expected_line = %w(
499
- 07 10 0C 00 80 80 80 00 01 00 00 00 00 00 17 00
500
- ).join(' ')
501
-
502
- expected_area = %w(
503
- 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
504
- 16 00 08 00
505
- ).join(' ')
506
-
507
- got_line, got_area = get_plotarea_formats(@chart)
508
-
509
- assert_equal(expected_line, got_line, @plotarea_caption1)
510
- assert_equal(expected_area, got_area, @plotarea_caption2)
511
-
512
-
513
- reset_chart(@chart)
514
-
515
- @chart.set_plotarea(
516
- :line_weight => 3
517
- )
518
-
519
- expected_line = %w(
520
- 07 10 0C 00 80 80 80 00 00 00 01 00 00 00 17 00
521
- ).join(' ')
522
-
523
- expected_area = %w(
524
- 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
525
- 16 00 08 00
526
- ).join(' ')
527
-
528
- got_line, got_area = get_plotarea_formats(@chart)
529
-
530
- assert_equal(expected_line, got_line, @plotarea_caption1)
531
- assert_equal(expected_area, got_area, @plotarea_caption2)
532
-
533
-
534
- reset_chart(@chart)
535
-
536
- @chart.set_plotarea(
537
- :color => 'red',
538
- :line_color => 'black'
539
- )
540
-
541
- expected_line = %w(
542
- 07 10 0C 00 00 00 00 00 00 00 00 00 00 00 08 00
543
- ).join(' ')
544
-
545
- expected_area = %w(
546
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
547
- 0A 00 08 00
548
- ).join(' ')
549
-
550
- got_line, got_area = get_plotarea_formats(@chart)
551
-
552
- assert_equal(expected_line, got_line, @plotarea_caption1)
553
- assert_equal(expected_area, got_area, @plotarea_caption2)
554
-
555
-
556
- reset_chart(@chart)
557
-
558
- @chart.set_plotarea(
559
- :color => 'red',
560
- :line_pattern => 2
561
- )
562
-
563
- expected_line = %w(
564
- 07 10 0C 00 80 80 80 00 01 00 00 00 00 00 17 00
565
- ).join(' ')
566
-
567
- expected_area = %w(
568
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
569
- 0A 00 08 00
570
- ).join(' ')
571
-
572
- got_line, got_area = get_plotarea_formats(@chart)
573
-
574
- assert_equal(expected_line, got_line, @plotarea_caption1)
575
- assert_equal(expected_area, got_area, @plotarea_caption2)
576
-
577
-
578
- reset_chart(@chart)
579
-
580
- @chart.set_plotarea(
581
- :color => 'red',
582
- :line_weight => 3
583
- )
584
-
585
- expected_line = %w(
586
- 07 10 0C 00 80 80 80 00 00 00 01 00 00 00 17 00
587
- ).join(' ')
588
-
589
- expected_area = %w(
590
- 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
591
- 0A 00 08 00
592
- ).join(' ')
593
-
594
- got_line, got_area = get_plotarea_formats(@chart)
595
-
596
- assert_equal(expected_line, got_line, @plotarea_caption1)
597
- assert_equal(expected_area, got_area, @plotarea_caption2)
598
- end
599
-
600
-
601
- ###############################################################################
602
- #
603
- # Reset the chart data for testing.
604
- #
605
- def reset_chart(chart, embedded = nil)
606
- # Reset the chart data.
607
- chart.data = ''
608
- chart.set_default_properties
609
-
610
- if embedded
611
- chart.set_embedded_config_data
612
- end
613
- end
614
-
615
- ###############################################################################
616
- #
617
- # Extract Line and Area format records from the Chartarea Frame stream.
618
- #
619
- def get_chartarea_formats(chart)
620
- chart.store_chartarea_frame_stream
621
-
622
- line = unpack_record(chart.data[12, 16])
623
- area = unpack_record(chart.data[28, 20])
624
-
625
- [line, area]
626
- end
627
-
628
- ###############################################################################
629
- #
630
- # Extract Line and Area format records from the Chartarea Frame stream.
631
- #
632
- def get_plotarea_formats(chart)
633
- chart.store_plotarea_frame_stream
634
-
635
- line = unpack_record(chart.data[12, 16])
636
- area = unpack_record(chart.data[28, 20])
637
-
638
- [line, area]
639
- end
640
-
641
- def unpack_record(data)
642
- data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
643
- end
644
- end
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'stringio'
4
+
5
+ ###############################################################################
6
+ #
7
+ # A test for Spreadsheet::WriteExcel::Chart.
8
+ #
9
+ # Tests for the Excel Chart.pm format conversion methods.
10
+ #
11
+ # reverse('ゥ'), January 2010, 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_ChartAreaFormats < Test::Unit::TestCase
17
+ def setup
18
+ @io = StringIO.new
19
+ @workbook = WriteExcel.new(@io)
20
+ @chart = @workbook.add_chart(:type => Chart::Column)
21
+ @chart.using_tmpfile = false
22
+ @caption1 = " \tChart: chartarea format - line";
23
+ @caption2 = " \tChart: chartarea format - area";
24
+ @embed_caption1 = " \tChart: embedded chartarea format - line";
25
+ @embed_caption2 = " \tChart: embedded chartarea format - area";
26
+ @plotarea_caption1 = " \tChart: plotarea format - line";
27
+ @plotarea_caption2 = " \tChart: plotarea format - area";
28
+ end
29
+
30
+ def teardown
31
+ @workbook.close
32
+ end
33
+
34
+ ###############################################################################
35
+ #
36
+ # 1. Test the chartarea format methods. See the set_*area() properties below.
37
+ #
38
+ def test_the_chartarea_format_methods
39
+ reset_chart(@chart)
40
+
41
+ @chart.set_chartarea(
42
+ :color => 'red',
43
+ :line_color => 'black',
44
+ :line_pattern => 2,
45
+ :line_weight => 3
46
+ )
47
+
48
+ expected_line = %w(
49
+ 07 10 0C 00 00 00 00 00 01 00 01 00 00 00 08 00
50
+ ).join(' ')
51
+
52
+ expected_area = %w(
53
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
54
+ 0A 00 08 00
55
+ ).join(' ')
56
+
57
+ got_line, got_area = get_chartarea_formats(@chart)
58
+
59
+ assert_equal(expected_line, got_line, @caption1)
60
+ assert_equal(expected_area, got_area, @caption2)
61
+
62
+
63
+ reset_chart(@chart)
64
+
65
+ @chart.set_chartarea(
66
+ :color => 'red'
67
+ )
68
+
69
+ expected_line = %w(
70
+ 07 10 0C 00 00 00 00 00 05 00 FF FF 08 00 4D 00
71
+ ).join(' ')
72
+
73
+ expected_area = %w(
74
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
75
+ 0A 00 08 00
76
+ ).join(' ')
77
+
78
+ got_line, got_area = get_chartarea_formats(@chart)
79
+
80
+ assert_equal(expected_line, got_line, @caption1)
81
+ assert_equal(expected_area, got_area, @caption2)
82
+
83
+
84
+ reset_chart(@chart)
85
+
86
+ @chart.set_chartarea(
87
+ :line_color => 'red'
88
+ )
89
+
90
+ expected_line = %w(
91
+ 07 10 0C 00 FF 00 00 00 00 00 FF FF 00 00 0A 00
92
+ ).join(' ')
93
+
94
+ expected_area = %w(
95
+ 0A 10 10 00 FF FF FF 00 00 00 00 00 00 00 00 00
96
+ 4E 00 4D 00
97
+ ).join(' ')
98
+
99
+ got_line, got_area = get_chartarea_formats(@chart)
100
+
101
+ assert_equal(expected_line, got_line, @caption1)
102
+ assert_equal(expected_area, got_area, @caption2)
103
+
104
+
105
+ reset_chart(@chart)
106
+
107
+ @chart.set_chartarea(
108
+ :line_pattern => 2
109
+ )
110
+
111
+ expected_line = %w(
112
+ 07 10 0C 00 00 00 00 00 01 00 FF FF 00 00 4F 00
113
+ ).join(' ')
114
+
115
+ expected_area = %w(
116
+ 0A 10 10 00 FF FF FF 00 00 00 00 00 00 00 00 00
117
+ 4E 00 4D 00
118
+ ).join(' ')
119
+
120
+ got_line, got_area = get_chartarea_formats(@chart)
121
+
122
+ assert_equal(expected_line, got_line, @caption1)
123
+ assert_equal(expected_area, got_area, @caption2)
124
+
125
+
126
+ reset_chart(@chart)
127
+
128
+ @chart.set_chartarea(
129
+ :line_weight => 3
130
+ )
131
+
132
+ expected_line = %w(
133
+ 07 10 0C 00 00 00 00 00 00 00 01 00 00 00 4F 00
134
+ ).join(' ')
135
+
136
+ expected_area = %w(
137
+ 0A 10 10 00 FF FF FF 00 00 00 00 00 00 00 00 00
138
+ 4E 00 4D 00
139
+ ).join(' ')
140
+
141
+ got_line, got_area = get_chartarea_formats(@chart)
142
+
143
+ assert_equal(expected_line, got_line, @caption1)
144
+ assert_equal(expected_area, got_area, @caption2)
145
+
146
+
147
+ reset_chart(@chart)
148
+
149
+ @chart.set_chartarea(
150
+ :color => 'red',
151
+ :line_color => 'black'
152
+ )
153
+
154
+ expected_line = %w(
155
+ 07 10 0C 00 00 00 00 00 00 00 FF FF 00 00 08 00
156
+ ).join(' ')
157
+
158
+ expected_area = %w(
159
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
160
+ 0A 00 08 00
161
+ ).join(' ')
162
+
163
+ got_line, got_area = get_chartarea_formats(@chart)
164
+
165
+ assert_equal(expected_line, got_line, @caption1)
166
+ assert_equal(expected_area, got_area, @caption2)
167
+
168
+
169
+ reset_chart(@chart)
170
+
171
+ @chart.set_chartarea(
172
+ :color => 'red',
173
+ :line_pattern => 2
174
+ )
175
+
176
+ expected_line = %w(
177
+ 07 10 0C 00 00 00 00 00 01 00 FF FF 00 00 4F 00
178
+ ).join(' ')
179
+
180
+ expected_area = %w(
181
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
182
+ 0A 00 08 00
183
+ ).join(' ')
184
+
185
+ got_line, got_area = get_chartarea_formats(@chart)
186
+
187
+ assert_equal(expected_line, got_line, @caption1)
188
+ assert_equal(expected_area, got_area, @caption2)
189
+
190
+
191
+ reset_chart(@chart)
192
+
193
+ @chart.set_chartarea(
194
+ :color => 'red',
195
+ :line_weight => 3
196
+ )
197
+
198
+ expected_line = %w(
199
+ 07 10 0C 00 00 00 00 00 00 00 01 00 00 00 4F 00
200
+ ).join(' ')
201
+
202
+ expected_area = %w(
203
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
204
+ 0A 00 08 00
205
+ ).join(' ')
206
+
207
+ got_line, got_area = get_chartarea_formats(@chart)
208
+
209
+ assert_equal(expected_line, got_line, @caption1)
210
+ assert_equal(expected_area, got_area, @caption2)
211
+
212
+
213
+ @chart.embedded = true
214
+
215
+ reset_chart(@chart, true)
216
+
217
+ @chart.set_chartarea(
218
+ )
219
+
220
+ expected_line = %w(
221
+ 07 10 0C 00 00 00 00 00 00 00 00 00 09 00 4D 00
222
+ ).join(' ')
223
+
224
+ expected_area = %w(
225
+ 0A 10 10 00 FF FF FF 00 00 00 00 00 01 00 01 00
226
+ 4E 00 4D 00
227
+ ).join(' ')
228
+
229
+ got_line, got_area = get_chartarea_formats(@chart)
230
+
231
+ assert_equal(expected_line, got_line, @embed_caption1)
232
+ assert_equal(expected_area, got_area, @embed_caption2)
233
+
234
+
235
+ reset_chart(@chart, true)
236
+
237
+ @chart.set_chartarea(
238
+ :color => 'red',
239
+ :line_color => 'black',
240
+ :line_pattern => 2,
241
+ :line_weight => 3
242
+ )
243
+
244
+ expected_line = %w(
245
+ 07 10 0C 00 00 00 00 00 01 00 01 00 00 00 08 00
246
+ ).join(' ')
247
+
248
+ expected_area = %w(
249
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
250
+ 0A 00 08 00
251
+ ).join(' ')
252
+
253
+ got_line, got_area = get_chartarea_formats(@chart)
254
+
255
+ assert_equal(expected_line, got_line, @embed_caption1)
256
+ assert_equal(expected_area, got_area, @embed_caption2)
257
+
258
+
259
+ reset_chart(@chart, true)
260
+
261
+ @chart.set_chartarea(
262
+ :color => 'red'
263
+ )
264
+
265
+ expected_line = %w(
266
+ 07 10 0C 00 00 00 00 00 00 00 FF FF 09 00 4D 00
267
+ ).join(' ')
268
+
269
+ expected_area = %w(
270
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
271
+ 0A 00 08 00
272
+ ).join(' ')
273
+
274
+ got_line, got_area = get_chartarea_formats(@chart)
275
+
276
+ assert_equal(expected_line, got_line, @embed_caption1)
277
+ assert_equal(expected_area, got_area, @embed_caption2)
278
+
279
+
280
+ reset_chart(@chart, true)
281
+
282
+ @chart.set_chartarea(
283
+ :line_color => 'red'
284
+ )
285
+
286
+ expected_line = %w(
287
+ 07 10 0C 00 FF 00 00 00 00 00 FF FF 00 00 0A 00
288
+ ).join(' ')
289
+
290
+ expected_area = %w(
291
+ 0A 10 10 00 FF FF FF 00 00 00 00 00 01 00 01 00
292
+ 4E 00 4D 00
293
+ ).join(' ')
294
+
295
+ got_line, got_area = get_chartarea_formats(@chart)
296
+
297
+ assert_equal(expected_line, got_line, @embed_caption1)
298
+ assert_equal(expected_area, got_area, @embed_caption2)
299
+
300
+
301
+ reset_chart(@chart, true)
302
+
303
+ @chart.set_chartarea(
304
+ :line_pattern => 2
305
+ )
306
+
307
+ expected_line = %w(
308
+ 07 10 0C 00 00 00 00 00 01 00 FF FF 00 00 4F 00
309
+ ).join(' ')
310
+
311
+ expected_area = %w(
312
+ 0A 10 10 00 FF FF FF 00 00 00 00 00 01 00 01 00
313
+ 4E 00 4D 00
314
+ ).join(' ')
315
+
316
+ got_line, got_area = get_chartarea_formats(@chart)
317
+
318
+ assert_equal(expected_line, got_line, @embed_caption1)
319
+ assert_equal(expected_area, got_area, @embed_caption2)
320
+
321
+
322
+ reset_chart(@chart, true)
323
+
324
+ @chart.set_chartarea(
325
+ :line_weight => 3
326
+ )
327
+
328
+ expected_line = %w(
329
+ 07 10 0C 00 00 00 00 00 00 00 01 00 00 00 4F 00
330
+ ).join(' ')
331
+
332
+ expected_area = %w(
333
+ 0A 10 10 00 FF FF FF 00 00 00 00 00 01 00 01 00
334
+ 4E 00 4D 00
335
+ ).join(' ')
336
+
337
+ got_line, got_area = get_chartarea_formats(@chart)
338
+
339
+ assert_equal(expected_line, got_line, @embed_caption1)
340
+ assert_equal(expected_area, got_area, @embed_caption2)
341
+
342
+
343
+ reset_chart(@chart, true)
344
+
345
+ @chart.set_chartarea(
346
+ :color => 'red',
347
+ :line_color => 'black'
348
+ )
349
+
350
+ expected_line = %w(
351
+ 07 10 0C 00 00 00 00 00 00 00 FF FF 00 00 08 00
352
+ ).join(' ')
353
+
354
+ expected_area = %w(
355
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
356
+ 0A 00 08 00
357
+ ).join(' ')
358
+
359
+ got_line, got_area = get_chartarea_formats(@chart)
360
+
361
+ assert_equal(expected_line, got_line, @embed_caption1)
362
+ assert_equal(expected_area, got_area, @embed_caption2)
363
+
364
+
365
+ reset_chart(@chart, true)
366
+
367
+ @chart.set_chartarea(
368
+ :color => 'red',
369
+ :line_pattern => 2
370
+ )
371
+
372
+ expected_line = %w(
373
+ 07 10 0C 00 00 00 00 00 01 00 FF FF 00 00 4F 00
374
+ ).join(' ')
375
+
376
+ expected_area = %w(
377
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
378
+ 0A 00 08 00
379
+ ).join(' ')
380
+
381
+ got_line, got_area = get_chartarea_formats(@chart)
382
+
383
+ assert_equal(expected_line, got_line, @embed_caption1)
384
+ assert_equal(expected_area, got_area, @embed_caption2)
385
+
386
+
387
+ reset_chart(@chart, true)
388
+
389
+ @chart.set_chartarea(
390
+ :color => 'red',
391
+ :line_weight => 3
392
+ )
393
+
394
+ expected_line = %w(
395
+ 07 10 0C 00 00 00 00 00 00 00 01 00 00 00 4F 00
396
+ ).join(' ')
397
+
398
+ expected_area = %w(
399
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
400
+ 0A 00 08 00
401
+ ).join(' ')
402
+
403
+ got_line, got_area = get_chartarea_formats(@chart)
404
+
405
+ assert_equal(expected_line, got_line, @embed_caption1)
406
+ assert_equal(expected_area, got_area, @embed_caption2)
407
+
408
+
409
+ @chart.embedded = false
410
+
411
+ reset_chart(@chart)
412
+
413
+ @chart.set_plotarea(
414
+ )
415
+
416
+ expected_line = %w(
417
+ 07 10 0C 00 80 80 80 00 00 00 00 00 00 00 17 00
418
+ ).join(' ')
419
+
420
+ expected_area = %w(
421
+ 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
422
+ 16 00 4F 00
423
+ ).join(' ')
424
+
425
+ got_line, got_area = get_plotarea_formats(@chart)
426
+
427
+ assert_equal(expected_line, got_line, @plotarea_caption1)
428
+ assert_equal(expected_area, got_area, @plotarea_caption2)
429
+
430
+
431
+ reset_chart(@chart)
432
+
433
+ @chart.set_plotarea(
434
+ :color => 'red',
435
+ :line_color => 'black',
436
+ :line_pattern => 2,
437
+ :line_weight => 3
438
+ )
439
+
440
+ expected_line = %w(
441
+ 07 10 0C 00 00 00 00 00 01 00 01 00 00 00 08 00
442
+ ).join(' ')
443
+
444
+ expected_area = %w(
445
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
446
+ 0A 00 08 00
447
+ ).join(' ')
448
+
449
+ got_line, got_area = get_plotarea_formats(@chart)
450
+
451
+ assert_equal(expected_line, got_line, @plotarea_caption1)
452
+ assert_equal(expected_area, got_area, @plotarea_caption2)
453
+
454
+
455
+ reset_chart(@chart)
456
+
457
+ @chart.set_plotarea(
458
+ :color => 'red'
459
+ )
460
+
461
+ expected_line = %w(
462
+ 07 10 0C 00 80 80 80 00 00 00 00 00 00 00 17 00
463
+ ).join(' ')
464
+
465
+ expected_area = %w(
466
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
467
+ 0A 00 08 00
468
+ ).join(' ')
469
+
470
+ got_line, got_area = get_plotarea_formats(@chart)
471
+
472
+ assert_equal(expected_line, got_line, @plotarea_caption1)
473
+ assert_equal(expected_area, got_area, @plotarea_caption2)
474
+
475
+
476
+ reset_chart(@chart)
477
+
478
+ @chart.set_plotarea(
479
+ :line_color => 'red'
480
+ )
481
+
482
+ expected_line = %w(
483
+ 07 10 0C 00 FF 00 00 00 00 00 00 00 00 00 0A 00
484
+ ).join(' ')
485
+
486
+ expected_area = %w(
487
+ 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
488
+ 16 00 08 00
489
+ ).join(' ')
490
+
491
+ got_line, got_area = get_plotarea_formats(@chart)
492
+
493
+ assert_equal(expected_line, got_line, @plotarea_caption1)
494
+ assert_equal(expected_area, got_area, @plotarea_caption2)
495
+
496
+
497
+ reset_chart(@chart)
498
+
499
+ @chart.set_plotarea(
500
+ :line_pattern => 2
501
+ )
502
+
503
+ expected_line = %w(
504
+ 07 10 0C 00 80 80 80 00 01 00 00 00 00 00 17 00
505
+ ).join(' ')
506
+
507
+ expected_area = %w(
508
+ 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
509
+ 16 00 08 00
510
+ ).join(' ')
511
+
512
+ got_line, got_area = get_plotarea_formats(@chart)
513
+
514
+ assert_equal(expected_line, got_line, @plotarea_caption1)
515
+ assert_equal(expected_area, got_area, @plotarea_caption2)
516
+
517
+
518
+ reset_chart(@chart)
519
+
520
+ @chart.set_plotarea(
521
+ :line_weight => 3
522
+ )
523
+
524
+ expected_line = %w(
525
+ 07 10 0C 00 80 80 80 00 00 00 01 00 00 00 17 00
526
+ ).join(' ')
527
+
528
+ expected_area = %w(
529
+ 0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
530
+ 16 00 08 00
531
+ ).join(' ')
532
+
533
+ got_line, got_area = get_plotarea_formats(@chart)
534
+
535
+ assert_equal(expected_line, got_line, @plotarea_caption1)
536
+ assert_equal(expected_area, got_area, @plotarea_caption2)
537
+
538
+
539
+ reset_chart(@chart)
540
+
541
+ @chart.set_plotarea(
542
+ :color => 'red',
543
+ :line_color => 'black'
544
+ )
545
+
546
+ expected_line = %w(
547
+ 07 10 0C 00 00 00 00 00 00 00 00 00 00 00 08 00
548
+ ).join(' ')
549
+
550
+ expected_area = %w(
551
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
552
+ 0A 00 08 00
553
+ ).join(' ')
554
+
555
+ got_line, got_area = get_plotarea_formats(@chart)
556
+
557
+ assert_equal(expected_line, got_line, @plotarea_caption1)
558
+ assert_equal(expected_area, got_area, @plotarea_caption2)
559
+
560
+
561
+ reset_chart(@chart)
562
+
563
+ @chart.set_plotarea(
564
+ :color => 'red',
565
+ :line_pattern => 2
566
+ )
567
+
568
+ expected_line = %w(
569
+ 07 10 0C 00 80 80 80 00 01 00 00 00 00 00 17 00
570
+ ).join(' ')
571
+
572
+ expected_area = %w(
573
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
574
+ 0A 00 08 00
575
+ ).join(' ')
576
+
577
+ got_line, got_area = get_plotarea_formats(@chart)
578
+
579
+ assert_equal(expected_line, got_line, @plotarea_caption1)
580
+ assert_equal(expected_area, got_area, @plotarea_caption2)
581
+
582
+
583
+ reset_chart(@chart)
584
+
585
+ @chart.set_plotarea(
586
+ :color => 'red',
587
+ :line_weight => 3
588
+ )
589
+
590
+ expected_line = %w(
591
+ 07 10 0C 00 80 80 80 00 00 00 01 00 00 00 17 00
592
+ ).join(' ')
593
+
594
+ expected_area = %w(
595
+ 0A 10 10 00 FF 00 00 00 00 00 00 00 01 00 00 00
596
+ 0A 00 08 00
597
+ ).join(' ')
598
+
599
+ got_line, got_area = get_plotarea_formats(@chart)
600
+
601
+ assert_equal(expected_line, got_line, @plotarea_caption1)
602
+ assert_equal(expected_area, got_area, @plotarea_caption2)
603
+ end
604
+
605
+
606
+ ###############################################################################
607
+ #
608
+ # Reset the chart data for testing.
609
+ #
610
+ def reset_chart(chart, embedded = nil)
611
+ # Reset the chart data.
612
+ chart.data = ''
613
+ chart.set_default_properties
614
+
615
+ if embedded
616
+ chart.set_embedded_config_data
617
+ end
618
+ end
619
+
620
+ ###############################################################################
621
+ #
622
+ # Extract Line and Area format records from the Chartarea Frame stream.
623
+ #
624
+ def get_chartarea_formats(chart)
625
+ chart.store_chartarea_frame_stream
626
+
627
+ line = unpack_record(chart.data[12, 16])
628
+ area = unpack_record(chart.data[28, 20])
629
+
630
+ [line, area]
631
+ end
632
+
633
+ ###############################################################################
634
+ #
635
+ # Extract Line and Area format records from the Chartarea Frame stream.
636
+ #
637
+ def get_plotarea_formats(chart)
638
+ chart.store_plotarea_frame_stream
639
+
640
+ line = unpack_record(chart.data[12, 16])
641
+ area = unpack_record(chart.data[28, 20])
642
+
643
+ [line, area]
644
+ end
645
+
646
+ def unpack_record(data)
647
+ data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
648
+ end
649
+ end