writeexcel 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +26 -31
- data/examples/a_simple.rb +42 -42
- data/examples/{autofilters.rb → autofilter.rb} +264 -266
- data/examples/bigfile.rb +29 -0
- data/examples/chart_area.rb +120 -0
- data/examples/chart_bar.rb +119 -0
- data/examples/chart_column.rb +119 -0
- data/examples/chart_line.rb +119 -0
- data/examples/chart_pie.rb +107 -0
- data/examples/chart_scatter.rb +120 -0
- data/examples/chart_stock.rb +147 -0
- data/examples/copyformat.rb +51 -51
- data/examples/data_validate.rb +278 -278
- data/examples/date_time.rb +86 -86
- data/examples/defined_name.rb +31 -0
- data/examples/demo.rb +120 -118
- data/examples/diag_border.rb +35 -35
- data/examples/formats.rb +489 -489
- data/examples/header.rb +136 -136
- data/examples/hidden.rb +28 -28
- data/examples/hyperlink.rb +42 -42
- data/examples/images.rb +52 -52
- data/examples/merge1.rb +39 -39
- data/examples/merge2.rb +44 -44
- data/examples/merge3.rb +65 -65
- data/examples/merge4.rb +82 -82
- data/examples/merge5.rb +79 -79
- data/examples/properties.rb +33 -0
- data/examples/properties_jp.rb +32 -0
- data/examples/protection.rb +46 -46
- data/examples/regions.rb +52 -52
- data/examples/repeat.rb +42 -42
- data/examples/stats.rb +75 -75
- data/examples/stocks.rb +80 -80
- data/examples/tab_colors.rb +30 -30
- data/examples/write_arrays.rb +82 -0
- data/lib/writeexcel.rb +1134 -18
- data/lib/writeexcel/biffwriter.rb +273 -260
- data/lib/writeexcel/chart.rb +2306 -217
- data/lib/writeexcel/charts/area.rb +152 -0
- data/lib/writeexcel/charts/bar.rb +177 -0
- data/lib/writeexcel/charts/column.rb +156 -0
- data/lib/writeexcel/charts/external.rb +61 -0
- data/lib/writeexcel/charts/line.rb +152 -0
- data/lib/writeexcel/charts/pie.rb +169 -0
- data/lib/writeexcel/charts/scatter.rb +192 -0
- data/lib/writeexcel/charts/stock.rb +211 -0
- data/lib/writeexcel/excelformulaparser.rb +208 -195
- data/lib/writeexcel/format.rb +1697 -1108
- data/lib/writeexcel/formula.rb +1050 -986
- data/lib/writeexcel/olewriter.rb +322 -322
- data/lib/writeexcel/properties.rb +251 -250
- data/lib/writeexcel/storage_lite.rb +968 -0
- data/lib/writeexcel/workbook.rb +3294 -2630
- data/lib/writeexcel/worksheet.rb +9012 -6377
- data/test/excelfile/Chart1.xls +0 -0
- data/test/excelfile/Chart2.xls +0 -0
- data/test/excelfile/Chart3.xls +0 -0
- data/test/excelfile/Chart4.xls +0 -0
- data/test/excelfile/Chart5.xls +0 -0
- data/test/perl_output/Chart1.xls.data +0 -0
- data/test/perl_output/Chart2.xls.data +0 -0
- data/test/perl_output/Chart3.xls.data +0 -0
- data/test/perl_output/Chart4.xls.data +0 -0
- data/test/perl_output/Chart5.xls.data +0 -0
- data/test/perl_output/a_simple.xls +0 -0
- data/test/perl_output/autofilter.xls +0 -0
- data/test/perl_output/chart_area.xls +0 -0
- data/test/perl_output/chart_bar.xls +0 -0
- data/test/perl_output/chart_column.xls +0 -0
- data/test/perl_output/chart_line.xls +0 -0
- data/test/perl_output/data_validate.xls +0 -0
- data/test/perl_output/date_time.xls +0 -0
- data/test/perl_output/demo.xls +0 -0
- data/test/perl_output/demo101.bin +0 -0
- data/test/perl_output/demo201.bin +0 -0
- data/test/perl_output/demo301.bin +0 -0
- data/test/perl_output/demo401.bin +0 -0
- data/test/perl_output/demo501.bin +0 -0
- data/test/perl_output/diag_border.xls +0 -0
- data/test/perl_output/headers.xls +0 -0
- data/test/perl_output/hyperlink.xls +0 -0
- data/test/perl_output/images.xls +0 -0
- data/test/perl_output/merge1.xls +0 -0
- data/test/perl_output/merge2.xls +0 -0
- data/test/perl_output/merge3.xls +0 -0
- data/test/perl_output/merge4.xls +0 -0
- data/test/perl_output/merge5.xls +0 -0
- data/test/perl_output/protection.xls +0 -0
- data/test/perl_output/regions.xls +0 -0
- data/test/perl_output/stats.xls +0 -0
- data/test/perl_output/stocks.xls +0 -0
- data/test/perl_output/tab_colors.xls +0 -0
- data/test/perl_output/unicode_cyrillic.xls +0 -0
- data/test/perl_output/workbook1.xls +0 -0
- data/test/perl_output/workbook2.xls +0 -0
- data/test/tc_all.rb +32 -31
- data/test/tc_biff.rb +104 -104
- data/test/tc_chart.rb +22 -22
- data/test/tc_example_match.rb +1944 -1280
- data/test/tc_format.rb +1254 -1267
- data/test/tc_formula.rb +63 -63
- data/test/tc_ole.rb +110 -110
- data/test/tc_storage_lite.rb +149 -0
- data/test/tc_workbook.rb +140 -115
- data/test/tc_worksheet.rb +115 -115
- data/test/test_00_IEEE_double.rb +14 -14
- data/test/test_01_add_worksheet.rb +12 -12
- data/test/test_02_merge_formats.rb +58 -58
- data/test/test_04_dimensions.rb +397 -397
- data/test/test_05_rows.rb +182 -182
- data/test/test_06_extsst.rb +80 -80
- data/test/test_11_date_time.rb +484 -484
- data/test/test_12_date_only.rb +506 -506
- data/test/test_13_date_seconds.rb +486 -486
- data/test/test_21_escher.rb +642 -629
- data/test/test_22_mso_drawing_group.rb +750 -739
- data/test/test_23_note.rb +78 -78
- data/test/test_24_txo.rb +80 -80
- data/test/test_25_position_object.rb +82 -0
- data/test/test_26_autofilter.rb +327 -327
- data/test/test_27_autofilter.rb +144 -144
- data/test/test_28_autofilter.rb +174 -174
- data/test/test_29_process_jpg.rb +681 -131
- data/test/test_30_validation_dval.rb +82 -82
- data/test/test_31_validation_dv_strings.rb +131 -131
- data/test/test_32_validation_dv_formula.rb +211 -211
- data/test/test_40_property_types.rb +191 -191
- data/test/test_41_properties.rb +238 -238
- data/test/test_42_set_properties.rb +442 -419
- data/test/test_50_name_stored.rb +305 -0
- data/test/test_51_name_print_area.rb +363 -0
- data/test/test_52_name_print_titles.rb +460 -0
- data/test/test_53_autofilter.rb +209 -0
- data/test/test_60_chart_generic.rb +576 -0
- data/test/test_61_chart_subclasses.rb +97 -0
- data/test/test_62_chart_formats.rb +270 -0
- data/test/test_63_chart_area_formats.rb +647 -0
- data/test/test_chartex.rb +35 -0
- data/test/ts_all.rb +46 -34
- data/writeexcel.gemspec +18 -0
- data/writeexcel.rdoc +583 -0
- metadata +162 -108
@@ -0,0 +1,209 @@
|
|
1
|
+
##########################################################################
|
2
|
+
# test_53_autofilter.rb
|
3
|
+
#
|
4
|
+
# Tests for the Excel EXTERNSHEET and NAME records created by print_are()..
|
5
|
+
#
|
6
|
+
# reverse('ゥ'), September 2008, John McNamara, jmcnamara@cpan.org
|
7
|
+
#
|
8
|
+
# original written in Perl by John McNamara
|
9
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
10
|
+
#
|
11
|
+
#########################################################################
|
12
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
13
|
+
require 'test/unit'
|
14
|
+
require 'rubygems'
|
15
|
+
require 'writeexcel'
|
16
|
+
require 'stringio'
|
17
|
+
|
18
|
+
class TC_autofilter < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
@test_file = StringIO.new
|
21
|
+
@workbook = WriteExcel.new(@test_file)
|
22
|
+
@workbook.not_using_tmpfile
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_autofilter_on_one_sheet
|
26
|
+
worksheet1 = @workbook.add_worksheet
|
27
|
+
|
28
|
+
worksheet1.autofilter('A1:C5')
|
29
|
+
|
30
|
+
# Test the EXTERNSHEET record.
|
31
|
+
@workbook.calculate_extern_sizes
|
32
|
+
@workbook.store_externsheet
|
33
|
+
|
34
|
+
target = [%w(
|
35
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
36
|
+
).join('')].pack('H*')
|
37
|
+
|
38
|
+
caption = " \tExternsheet"
|
39
|
+
result = _unpack_externsheet(@workbook.data)
|
40
|
+
target = _unpack_externsheet(target)
|
41
|
+
assert_equal(target, result)
|
42
|
+
|
43
|
+
# Test the NAME record.
|
44
|
+
@workbook.clear_data_for_test
|
45
|
+
@workbook.store_names
|
46
|
+
|
47
|
+
target = [%w(
|
48
|
+
18 00 1B 00 21 00 00 01 0B 00 00 00 01 00 00 00
|
49
|
+
00 00 00 0D 3B 00 00 00 00 04 00 00 00 02 00
|
50
|
+
).join('')].pack('H*')
|
51
|
+
|
52
|
+
caption = " \t+ Name = autofilter ( Sheet1!A1:C5 )";
|
53
|
+
result = _unpack_name(@workbook.data)
|
54
|
+
target = _unpack_name(target)
|
55
|
+
assert_equal(target, result)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_autofilter_on_two_sheets
|
59
|
+
worksheet1 = @workbook.add_worksheet
|
60
|
+
worksheet2 = @workbook.add_worksheet
|
61
|
+
|
62
|
+
worksheet1.autofilter('A1:C5')
|
63
|
+
worksheet2.autofilter('A1:C5')
|
64
|
+
|
65
|
+
# Test the EXTERNSHEET record.
|
66
|
+
@workbook.calculate_extern_sizes
|
67
|
+
@workbook.store_externsheet
|
68
|
+
|
69
|
+
target = [%w(
|
70
|
+
17 00 0E 00 02 00 00 00 00 00 00 00 00 00 01 00
|
71
|
+
01 00
|
72
|
+
).join('')].pack('H*')
|
73
|
+
|
74
|
+
caption = " \tExternsheet"
|
75
|
+
result = _unpack_externsheet(@workbook.data)
|
76
|
+
target = _unpack_externsheet(target)
|
77
|
+
assert_equal(target, result)
|
78
|
+
|
79
|
+
# Test the NAME record.
|
80
|
+
@workbook.clear_data_for_test
|
81
|
+
@workbook.store_names
|
82
|
+
|
83
|
+
target = [%w(
|
84
|
+
18 00 1B 00 21 00 00 01 0B 00 00 00 01 00 00 00
|
85
|
+
00 00 00 0D 3B 00 00 00 00 04 00 00 00 02 00
|
86
|
+
|
87
|
+
18 00 1B 00 21 00 00 01 0B 00 00 00 02 00 00 00
|
88
|
+
00 00 00 0D 3B 01 00 00 00 04 00 00 00 02 00
|
89
|
+
).join('')].pack('H*')
|
90
|
+
|
91
|
+
caption = " \t+ Name = autofilter ( Sheet1!A1:C5, Sheet2!A1:C5 )";
|
92
|
+
result = _unpack_name(@workbook.data)
|
93
|
+
target = _unpack_name(target)
|
94
|
+
assert_equal(target, result)
|
95
|
+
end
|
96
|
+
|
97
|
+
###############################################################################
|
98
|
+
#
|
99
|
+
# Unpack the binary data into a format suitable for printing in tests.
|
100
|
+
#
|
101
|
+
def unpack_record(data)
|
102
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
103
|
+
end
|
104
|
+
|
105
|
+
###############################################################################
|
106
|
+
#
|
107
|
+
# _unpack_externsheet()
|
108
|
+
#
|
109
|
+
# Unpack the EXTERNSHEET recordfor easier comparison.
|
110
|
+
#
|
111
|
+
def _unpack_externsheet(data)
|
112
|
+
externsheet = Hash.new
|
113
|
+
|
114
|
+
externsheet['record'] = data[0, 2].unpack('v')[0]
|
115
|
+
data[0, 2] = ''
|
116
|
+
externsheet['length'] = data[0, 2].unpack('v')[0]
|
117
|
+
data[0, 2] = ''
|
118
|
+
externsheet['count'] = data[0, 2].unpack('v')[0]
|
119
|
+
data[0, 2] = ''
|
120
|
+
externsheet['array'] = [];
|
121
|
+
|
122
|
+
externsheet['count'].times do
|
123
|
+
externsheet['array'] << data[0, 6].unpack('vvv')
|
124
|
+
data[0, 6] = ''
|
125
|
+
end
|
126
|
+
externsheet
|
127
|
+
end
|
128
|
+
|
129
|
+
###############################################################################
|
130
|
+
#
|
131
|
+
# _unpack_name()
|
132
|
+
#
|
133
|
+
# Unpack 1 or more NAME structures into a AoH for easier comparison.
|
134
|
+
#
|
135
|
+
def _unpack_name(data)
|
136
|
+
names = Array.new
|
137
|
+
while data.length > 0
|
138
|
+
name = Hash.new
|
139
|
+
|
140
|
+
name['record'] = data[0, 2].unpack('v')[0]
|
141
|
+
data[0, 2] = ''
|
142
|
+
name['length'] = data[0, 2].unpack('v')[0]
|
143
|
+
data[0, 2] = ''
|
144
|
+
name['flags'] = data[0, 2].unpack('v')[0]
|
145
|
+
data[0, 2] = ''
|
146
|
+
name['shortcut'] = data[0, 1].unpack('C')[0]
|
147
|
+
data[0, 1] = ''
|
148
|
+
name['str_len'] = data[0, 1].unpack('C')[0]
|
149
|
+
data[0, 1] = ''
|
150
|
+
name['formula_len'] = data[0, 2].unpack('v')[0]
|
151
|
+
data[0, 2] = ''
|
152
|
+
name['itals'] = data[0, 2].unpack('v')[0]
|
153
|
+
data[0, 2] = ''
|
154
|
+
name['sheet_index'] = data[0, 2].unpack('v')[0]
|
155
|
+
data[0, 2] = ''
|
156
|
+
name['menu_len'] = data[0, 1].unpack('C')[0]
|
157
|
+
data[0, 1] = ''
|
158
|
+
name['desc_len'] = data[0, 1].unpack('C')[0]
|
159
|
+
data[0, 1] = ''
|
160
|
+
name['help_len'] = data[0, 1].unpack('C')[0]
|
161
|
+
data[0, 1] = ''
|
162
|
+
name['status_len'] = data[0, 1].unpack('C')[0]
|
163
|
+
data[0, 1] = ''
|
164
|
+
name['encoding'] = data[0, 1].unpack('C')[0]
|
165
|
+
data[0, 1] = ''
|
166
|
+
|
167
|
+
# Decode the individual flag fields.
|
168
|
+
flag = Hash.new
|
169
|
+
flag['hidden'] = name['flags'] & 0x0001
|
170
|
+
flag['function'] = name['flags'] & 0x0002
|
171
|
+
flag['vb'] = name['flags'] & 0x0004
|
172
|
+
flag['macro'] = name['flags'] & 0x0008
|
173
|
+
flag['complex'] = name['flags'] & 0x0010
|
174
|
+
flag['builtin'] = name['flags'] & 0x0020
|
175
|
+
flag['group'] = name['flags'] & 0x0FC0
|
176
|
+
flag['binary'] = name['flags'] & 0x1000
|
177
|
+
name['flags'] = flag
|
178
|
+
|
179
|
+
# Decode the string part of the NAME structure.
|
180
|
+
if name['encoding'] == 1
|
181
|
+
# UTF-16 name. Leave in hex.
|
182
|
+
name['string'] = data[0, 2 * name['str_len']].unpack('H*')[0].upcase
|
183
|
+
data[0, 2 * name['str_len']] = ''
|
184
|
+
elsif flag['builtin'] != 0
|
185
|
+
# 1 digit builtin name. Leave in hex.
|
186
|
+
name['string'] = data[0, name['str_len']].unpack('H*')[0].upcase
|
187
|
+
data[0, name['str_len']] = ''
|
188
|
+
else
|
189
|
+
# ASCII name.
|
190
|
+
name['string'] = data[0, name['str_len']].unpack('C*').pack('C*')
|
191
|
+
data[0, name['str_len']] = ''
|
192
|
+
end
|
193
|
+
|
194
|
+
# Keep the formula as a hex string.
|
195
|
+
name['formula'] = data[0, name['formula_len']].unpack('H*')[0].upcase
|
196
|
+
data[0, name['formula_len']] = ''
|
197
|
+
|
198
|
+
names << name
|
199
|
+
end
|
200
|
+
names
|
201
|
+
end
|
202
|
+
|
203
|
+
def assert_hash_equal?(result, target)
|
204
|
+
assert_equal(result.keys.sort, target.keys.sort)
|
205
|
+
result.each_key do |key|
|
206
|
+
assert_equal(result[key], target[key])
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
@@ -0,0 +1,576 @@
|
|
1
|
+
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
2
|
+
|
3
|
+
require "test/unit"
|
4
|
+
require 'writeexcel'
|
5
|
+
require 'stringio'
|
6
|
+
|
7
|
+
###############################################################################
|
8
|
+
#
|
9
|
+
# A test for Chart.
|
10
|
+
#
|
11
|
+
# Tests for the Excel chart.rb methods.
|
12
|
+
#
|
13
|
+
# reverse(''), December 2009, 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
|
+
class TC_ChartGeneric < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
io = StringIO.new
|
21
|
+
workbook = WriteExcel.new(io)
|
22
|
+
@chart = Chart.new('', 'chart', 0, 0, 0, 0, 0, 0, 0, 0)
|
23
|
+
end
|
24
|
+
|
25
|
+
###############################################################################
|
26
|
+
#
|
27
|
+
# Test the _store_fbi method.
|
28
|
+
#
|
29
|
+
def test_store_fbi
|
30
|
+
caption = " \tChart: _store_fbi()"
|
31
|
+
expected = %w(
|
32
|
+
60 10 0A 00 B8 38 A1 22 C8 00 00 00 05 00
|
33
|
+
).join(' ')
|
34
|
+
got = unpack_record(@chart.store_fbi(5, 10, 0x38B8, 0x22A1, 0x0000))
|
35
|
+
assert_equal(expected, got, caption)
|
36
|
+
|
37
|
+
expected = %w(
|
38
|
+
60 10 0A 00 B8 38 A1 22 C8 00 00 00 06 00
|
39
|
+
).join(' ')
|
40
|
+
got = unpack_record(@chart.store_fbi(6, 10, 0x38B8, 0x22A1, 0x0000))
|
41
|
+
assert_equal(expected, got, caption)
|
42
|
+
end
|
43
|
+
|
44
|
+
###############################################################################
|
45
|
+
#
|
46
|
+
# Test the _store_chart method.
|
47
|
+
#
|
48
|
+
def test_store_chart
|
49
|
+
caption = " \tChart: _store_chart()"
|
50
|
+
expected = %w(
|
51
|
+
02 10 10 00 00 00 00 00 00 00 00 00 E0 51 DD 02
|
52
|
+
38 B8 C2 01
|
53
|
+
).join(' ')
|
54
|
+
values = [0x0000, 0x0000, 0x02DD51E0, 0x01C2B838]
|
55
|
+
got = unpack_record(@chart.store_chart(*values))
|
56
|
+
assert_equal(expected, got, caption)
|
57
|
+
end
|
58
|
+
|
59
|
+
###############################################################################
|
60
|
+
#
|
61
|
+
# Test the _store_series method.
|
62
|
+
#
|
63
|
+
def test_store_series
|
64
|
+
caption = " \tChart: _store_series()"
|
65
|
+
expected = %w(
|
66
|
+
03 10 0C 00 01 00 01 00 08 00 08 00 01 00 00 00
|
67
|
+
).join(' ')
|
68
|
+
got = unpack_record(@chart.store_series(8, 8))
|
69
|
+
assert_equal(expected, got, caption)
|
70
|
+
end
|
71
|
+
|
72
|
+
###############################################################################
|
73
|
+
#
|
74
|
+
# Test the _store_begin method.
|
75
|
+
#
|
76
|
+
def test_store_begin
|
77
|
+
caption = " \tChart: _store_begin()"
|
78
|
+
expected = %w(
|
79
|
+
33 10 00 00
|
80
|
+
).join(' ')
|
81
|
+
got = unpack_record(@chart.store_begin)
|
82
|
+
assert_equal(expected, got, caption)
|
83
|
+
end
|
84
|
+
|
85
|
+
###############################################################################
|
86
|
+
#
|
87
|
+
# Test the _store_end method.
|
88
|
+
#
|
89
|
+
def test_store_end
|
90
|
+
caption = " \tChart: _store_end()"
|
91
|
+
expected = %w(
|
92
|
+
34 10 00 00
|
93
|
+
).join(' ')
|
94
|
+
got = unpack_record(@chart.store_end)
|
95
|
+
assert_equal(expected, got, caption)
|
96
|
+
end
|
97
|
+
|
98
|
+
###############################################################################
|
99
|
+
#
|
100
|
+
# Test the _store_ai method.
|
101
|
+
#
|
102
|
+
def test_store_ai
|
103
|
+
caption = " \tChart: _store_ai()"
|
104
|
+
values = [0, 1, '']
|
105
|
+
expected = %w(
|
106
|
+
51 10 08 00 00 01 00 00 00 00 00 00
|
107
|
+
).join(' ')
|
108
|
+
got = unpack_record(@chart.store_ai(*values))
|
109
|
+
assert_equal(expected, got, caption)
|
110
|
+
|
111
|
+
values = [1, 2, ['3B00000000070000000000'].pack('H*')]
|
112
|
+
expected = %w(
|
113
|
+
51 10 13 00 01 02 00 00 00 00 0B 00 3B 00 00 00
|
114
|
+
00 07 00 00 00 00 00
|
115
|
+
).join(' ')
|
116
|
+
got = unpack_record(@chart.store_ai(*values))
|
117
|
+
assert_equal(expected, got, caption)
|
118
|
+
end
|
119
|
+
|
120
|
+
###############################################################################
|
121
|
+
#
|
122
|
+
# Test the _store_dataformat method.
|
123
|
+
#
|
124
|
+
def test_store_dataformat
|
125
|
+
caption = " \tChart: _store_dataformat()"
|
126
|
+
expected = %w(
|
127
|
+
06 10 08 00 FF FF 00 00 00 00 00 00
|
128
|
+
).join(' ')
|
129
|
+
got = unpack_record(@chart.store_dataformat(0, 0, 0xFFFF))
|
130
|
+
assert_equal(expected, got, caption)
|
131
|
+
|
132
|
+
expected = %w(
|
133
|
+
06 10 08 00 00 00 00 00 FD FF 00 00
|
134
|
+
).join(' ')
|
135
|
+
got = unpack_record(@chart.store_dataformat(0, 0xFFFD, 0))
|
136
|
+
assert_equal(expected, got, caption)
|
137
|
+
end
|
138
|
+
|
139
|
+
###############################################################################
|
140
|
+
#
|
141
|
+
# Test the _store_3dbarshape method.
|
142
|
+
#
|
143
|
+
def test_store_3dbarshape
|
144
|
+
caption = " \tChart: _store_3dbarshape()"
|
145
|
+
expected = %w(
|
146
|
+
5F 10 02 00 00 00
|
147
|
+
).join(' ')
|
148
|
+
got = unpack_record(@chart.store_3dbarshape)
|
149
|
+
assert_equal(expected, got, caption)
|
150
|
+
end
|
151
|
+
|
152
|
+
###############################################################################
|
153
|
+
#
|
154
|
+
# Test the _store_sertocrt method.
|
155
|
+
#
|
156
|
+
def test_store_sertocrt
|
157
|
+
caption = " \tChart: _store_sertocrt()"
|
158
|
+
expected = %w(
|
159
|
+
45 10 02 00 00 00
|
160
|
+
).join(' ')
|
161
|
+
got = unpack_record(@chart.store_sertocrt)
|
162
|
+
assert_equal(expected, got, caption)
|
163
|
+
end
|
164
|
+
|
165
|
+
###############################################################################
|
166
|
+
#
|
167
|
+
# Test the _store_shtprops method.
|
168
|
+
#
|
169
|
+
def test_store_shtprops
|
170
|
+
caption = " \tChart: _store_shtprops()"
|
171
|
+
expected = %w(
|
172
|
+
44 10 04 00 0E 00 00 00
|
173
|
+
).join(' ')
|
174
|
+
got = unpack_record(@chart.store_shtprops)
|
175
|
+
assert_equal(expected, got, caption)
|
176
|
+
end
|
177
|
+
|
178
|
+
###############################################################################
|
179
|
+
#
|
180
|
+
# Test the _store_defaulttext method.
|
181
|
+
#
|
182
|
+
def test_store_defaulttext
|
183
|
+
caption = " \tChart: _store_defaulttext()"
|
184
|
+
expected = %w(
|
185
|
+
24 10 02 00 02 00
|
186
|
+
).join(' ')
|
187
|
+
got = unpack_record(@chart.store_defaulttext)
|
188
|
+
assert_equal(expected, got, caption)
|
189
|
+
end
|
190
|
+
|
191
|
+
###############################################################################
|
192
|
+
#
|
193
|
+
# Test the _store_charttext method.
|
194
|
+
#
|
195
|
+
def test_store_charttext
|
196
|
+
caption = " \tChart: _store_charttext()"
|
197
|
+
expected = %w(
|
198
|
+
25 10 20 00 02 02 01 00 00 00 00 00 46 FF FF FF
|
199
|
+
06 FF FF FF 00 00 00 00 00 00 00 00 B1 00 4D 00
|
200
|
+
00 00 00 00
|
201
|
+
).join(' ')
|
202
|
+
got = unpack_record(@chart.store_charttext)
|
203
|
+
assert_equal(expected, got, caption)
|
204
|
+
end
|
205
|
+
|
206
|
+
###############################################################################
|
207
|
+
#
|
208
|
+
# Test the _store_fontx method.
|
209
|
+
#
|
210
|
+
def test_store_fontx
|
211
|
+
caption = " \tChart: _store_fontx()"
|
212
|
+
expected = %w(
|
213
|
+
26 10 02 00 05 00
|
214
|
+
).join(' ')
|
215
|
+
got = unpack_record(@chart.store_fontx(5))
|
216
|
+
assert_equal(expected, got, caption)
|
217
|
+
end
|
218
|
+
|
219
|
+
###############################################################################
|
220
|
+
#
|
221
|
+
# Test the _store_axesused method.
|
222
|
+
#
|
223
|
+
def test_store_axesused
|
224
|
+
caption = " \tChart: _store_axesused()"
|
225
|
+
expected = %w(
|
226
|
+
46 10 02 00 01 00
|
227
|
+
).join(' ')
|
228
|
+
got = unpack_record(@chart.store_axesused(1))
|
229
|
+
assert_equal(expected, got, caption)
|
230
|
+
end
|
231
|
+
|
232
|
+
###############################################################################
|
233
|
+
#
|
234
|
+
# Test the _store_axisparent method.
|
235
|
+
#
|
236
|
+
def test_store_axisparent
|
237
|
+
caption = " \tChart: _store_axisparent()"
|
238
|
+
expected = %w(
|
239
|
+
41 10 12 00 00 00 F8 00 00 00 F5 01 00 00 7F 0E
|
240
|
+
00 00 36 0B 00 00
|
241
|
+
).join(' ')
|
242
|
+
values = [0, 0x00F8, 0x01F5, 0x0E7F, 0x0B36]
|
243
|
+
got = unpack_record(@chart.store_axisparent(*values))
|
244
|
+
assert_equal(expected, got, caption)
|
245
|
+
end
|
246
|
+
|
247
|
+
###############################################################################
|
248
|
+
#
|
249
|
+
# Test the _store_axis method.
|
250
|
+
#
|
251
|
+
def test_store_axis
|
252
|
+
caption = " \tChart: _store_axis()"
|
253
|
+
expected = %w(
|
254
|
+
1D 10 12 00 00 00 00 00 00 00 00 00 00 00 00 00
|
255
|
+
00 00 00 00 00 00
|
256
|
+
).join(' ')
|
257
|
+
got = unpack_record(@chart.store_axis(0))
|
258
|
+
assert_equal(expected, got, caption)
|
259
|
+
end
|
260
|
+
|
261
|
+
###############################################################################
|
262
|
+
#
|
263
|
+
# Test the _store_catserrange method.
|
264
|
+
#
|
265
|
+
def test_store_catserrange
|
266
|
+
caption = " \tChart: _store_catserrange()"
|
267
|
+
expected = %w(
|
268
|
+
20 10 08 00 01 00 01 00 01 00 01 00
|
269
|
+
).join(' ')
|
270
|
+
got = unpack_record(@chart.store_catserrange)
|
271
|
+
assert_equal(expected, got, caption)
|
272
|
+
end
|
273
|
+
|
274
|
+
###############################################################################
|
275
|
+
#
|
276
|
+
# Test the _store_axcext method.
|
277
|
+
#
|
278
|
+
def test_store_axcext
|
279
|
+
caption = " \tChart: _store_axcext()"
|
280
|
+
expected = %w(
|
281
|
+
62 10 12 00 00 00 00 00 01 00 00 00 01 00 00 00
|
282
|
+
00 00 00 00 EF 00
|
283
|
+
).join(' ')
|
284
|
+
got = unpack_record(@chart.store_axcext)
|
285
|
+
assert_equal(expected, got, caption)
|
286
|
+
end
|
287
|
+
|
288
|
+
###############################################################################
|
289
|
+
#
|
290
|
+
# Test the _store_tick method.
|
291
|
+
#
|
292
|
+
def test_store_tick
|
293
|
+
caption = " \tChart: _store_tick()"
|
294
|
+
expected = %w(
|
295
|
+
1E 10 1E 00 02 00 03 01 00 00 00 00 00 00 00 00
|
296
|
+
00 00 00 00 00 00 00 00 00 00 00 00 23 00 4D 00
|
297
|
+
00 00
|
298
|
+
).join(' ')
|
299
|
+
got = unpack_record(@chart.store_tick)
|
300
|
+
assert_equal(expected, got, caption)
|
301
|
+
end
|
302
|
+
|
303
|
+
###############################################################################
|
304
|
+
#
|
305
|
+
# Test the _store_valuerange method.
|
306
|
+
#
|
307
|
+
def test_store_valuerange
|
308
|
+
caption = " \tChart: _store_valuerange()"
|
309
|
+
expected = %w(
|
310
|
+
1F 10 2A 00 00 00 00 00 00 00 00 00 00 00 00 00
|
311
|
+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
312
|
+
00 00 00 00 00 00 00 00 00 00 00 00 1F 01
|
313
|
+
).join(' ')
|
314
|
+
got = unpack_record(@chart.store_valuerange)
|
315
|
+
assert_equal(expected, got, caption)
|
316
|
+
end
|
317
|
+
|
318
|
+
###############################################################################
|
319
|
+
#
|
320
|
+
# Test the _store_axislineformat method.
|
321
|
+
#
|
322
|
+
def test_store_axislineformat
|
323
|
+
caption = " \tChart: _store_axislineformat()"
|
324
|
+
expected = %w(
|
325
|
+
21 10 02 00 01 00
|
326
|
+
).join(' ')
|
327
|
+
got = unpack_record(@chart.store_axislineformat)
|
328
|
+
assert_equal(expected, got, caption)
|
329
|
+
end
|
330
|
+
|
331
|
+
###############################################################################
|
332
|
+
#
|
333
|
+
# Test the _store_lineformat method.
|
334
|
+
#
|
335
|
+
def test_store_lineformat
|
336
|
+
caption = " \tChart: _store_lineformat()"
|
337
|
+
expected = %w(
|
338
|
+
07 10 0C 00 00 00 00 00 00 00 FF FF 09 00 4D 00
|
339
|
+
).join(' ')
|
340
|
+
values = [0x00000000, 0x0000, 0xFFFF, 0x0009, 0x004D]
|
341
|
+
got = unpack_record(@chart.store_lineformat(*values))
|
342
|
+
assert_equal(expected, got, caption)
|
343
|
+
end
|
344
|
+
|
345
|
+
###############################################################################
|
346
|
+
#
|
347
|
+
# Test the _store_frame method.
|
348
|
+
#
|
349
|
+
def test_store_frame
|
350
|
+
caption = " \tChart: _store_frame()"
|
351
|
+
expected = %w(
|
352
|
+
32 10 04 00 00 00 03 00
|
353
|
+
).join(' ')
|
354
|
+
got = unpack_record(@chart.store_frame(0x00, 0x03))
|
355
|
+
assert_equal(expected, got, caption)
|
356
|
+
end
|
357
|
+
|
358
|
+
###############################################################################
|
359
|
+
#
|
360
|
+
# Test the _store_areaformat method.
|
361
|
+
#
|
362
|
+
def test_store_areaformat
|
363
|
+
caption = " \tChart: _store_areaformat()"
|
364
|
+
expected = %w(
|
365
|
+
0A 10 10 00 C0 C0 C0 00 00 00 00 00 01 00 00 00
|
366
|
+
16 00 4F 00
|
367
|
+
).join(' ')
|
368
|
+
values = [0x00C0C0C0, 0x00, 0x01, 0x00, 0x16, 0x4F]
|
369
|
+
got = unpack_record(@chart.store_areaformat(*values))
|
370
|
+
assert_equal(expected, got, caption)
|
371
|
+
end
|
372
|
+
|
373
|
+
###############################################################################
|
374
|
+
#
|
375
|
+
# Test the _store_chartformat method.
|
376
|
+
#
|
377
|
+
def test_store_chartformat
|
378
|
+
caption = " \tChart: _store_chartformat()"
|
379
|
+
expected = %w(
|
380
|
+
14 10 14 00 00 00 00 00 00 00 00 00 00 00 00 00
|
381
|
+
00 00 00 00 00 00 00 00
|
382
|
+
).join(' ')
|
383
|
+
got = unpack_record(@chart.store_chartformat)
|
384
|
+
assert_equal(expected, got, caption)
|
385
|
+
end
|
386
|
+
|
387
|
+
###############################################################################
|
388
|
+
#
|
389
|
+
# Test the _store_legend method.
|
390
|
+
#
|
391
|
+
def test_store_legend
|
392
|
+
caption = " \tChart: _store_legend()"
|
393
|
+
expected = %w(
|
394
|
+
15 10 14 00 F9 05 00 00 E9 0E 00 00 7D 04 00 00
|
395
|
+
9C 00 00 00 00 01 0F 00
|
396
|
+
).join(' ')
|
397
|
+
values = [0x05F9, 0x0EE9, 0x047D, 0x009C, 0x00, 0x01, 0x000F]
|
398
|
+
got = unpack_record(@chart.store_legend(*values))
|
399
|
+
assert_equal(expected, got, caption)
|
400
|
+
end
|
401
|
+
|
402
|
+
###############################################################################
|
403
|
+
#
|
404
|
+
# Test the _store_pos method.
|
405
|
+
#
|
406
|
+
def test_store_pos
|
407
|
+
caption = " \tChart: _store_pos()"
|
408
|
+
expected = %w(
|
409
|
+
4F 10 14 00 05 00 02 00 83 0E 00 00 F9 06 00 00
|
410
|
+
00 00 00 00 00 00 00 00
|
411
|
+
).join(' ')
|
412
|
+
values = [5, 2, 0x0E83, 0x06F9, 0, 0]
|
413
|
+
got = unpack_record(@chart.store_pos(*values))
|
414
|
+
assert_equal(expected, got, caption)
|
415
|
+
end
|
416
|
+
|
417
|
+
###############################################################################
|
418
|
+
#
|
419
|
+
# Test the _store_text method.
|
420
|
+
#
|
421
|
+
def test_store_text
|
422
|
+
caption = " \tChart: _store_text()"
|
423
|
+
expected = %w(
|
424
|
+
25 10 20 00 02 02 01 00 00 00 00 00 46 FF FF FF
|
425
|
+
06 FF FF FF 00 00 00 00 00 00 00 00 B1 00 4D 00
|
426
|
+
20 10 00 00
|
427
|
+
).join(' ')
|
428
|
+
values = [0xFFFFFF46, 0xFFFFFF06, 0, 0, 0x00B1, 0x1020]
|
429
|
+
got = unpack_record(@chart.store_text(*values))
|
430
|
+
assert_equal(expected, got, caption)
|
431
|
+
end
|
432
|
+
|
433
|
+
###############################################################################
|
434
|
+
#
|
435
|
+
# Test the _store_plotgrowth method.
|
436
|
+
#
|
437
|
+
def test_store_plotgrowth
|
438
|
+
caption = " \tChart: _store_plotgrowth()"
|
439
|
+
expected = %w(
|
440
|
+
64 10 08 00 00 00 01 00 00 00 01 00
|
441
|
+
).join(' ')
|
442
|
+
got = unpack_record(@chart.store_plotgrowth)
|
443
|
+
assert_equal(expected, got, caption)
|
444
|
+
end
|
445
|
+
|
446
|
+
###############################################################################
|
447
|
+
#
|
448
|
+
# Test the _store_seriestext method.
|
449
|
+
#
|
450
|
+
def test_store_seriestext
|
451
|
+
caption = " \tChart: _store_seriestext()"
|
452
|
+
expected = %w(
|
453
|
+
0D 10 14 00 00 00 10 00 4E 61 6D 65
|
454
|
+
20 66 6F 72 20 53 65 72
|
455
|
+
69 65 73 31
|
456
|
+
).join(' ')
|
457
|
+
str = 'Name for Series1'
|
458
|
+
got = unpack_record(@chart.store_seriestext(str, 0))
|
459
|
+
assert_equal(expected, got, caption)
|
460
|
+
end
|
461
|
+
|
462
|
+
###############################################################################
|
463
|
+
#
|
464
|
+
# Test the _store_seriestext method.
|
465
|
+
#
|
466
|
+
def test_store_seriestext_utf16
|
467
|
+
caption = " \tChart: _store_seriestext()"
|
468
|
+
expected = %w(
|
469
|
+
0D 10 24 00 00 00 10 01 4E 00 61 00 6D 00 65 00
|
470
|
+
20 00 66 00 6F 00 72 00 20 00 53 00 65 00 72 00
|
471
|
+
69 00 65 00 73 00 31 00
|
472
|
+
).join(' ')
|
473
|
+
str = 'Name for Series1'.unpack('C*').pack('n*')
|
474
|
+
got = unpack_record(@chart.store_seriestext(str, 1))
|
475
|
+
assert_equal(expected, got, caption)
|
476
|
+
end
|
477
|
+
|
478
|
+
###############################################################################
|
479
|
+
#
|
480
|
+
# Test the _store_objectlink method.
|
481
|
+
#
|
482
|
+
def test_store_objectlink
|
483
|
+
caption = " \tChart: _store_objectlink()"
|
484
|
+
expected = %w(
|
485
|
+
27 10 06 00 01 00 00 00 00 00
|
486
|
+
).join(' ')
|
487
|
+
got = unpack_record(@chart.store_objectlink(1))
|
488
|
+
assert_equal(expected, got, caption)
|
489
|
+
end
|
490
|
+
|
491
|
+
###############################################################################
|
492
|
+
#
|
493
|
+
# Test the _store_pieformat method.
|
494
|
+
#
|
495
|
+
def test_store_pieformat
|
496
|
+
caption = " \tChart: _store_pieformat()"
|
497
|
+
expected = %w(
|
498
|
+
0B 10 02 00 00 00
|
499
|
+
).join(' ')
|
500
|
+
got = unpack_record(@chart.store_pieformat)
|
501
|
+
assert_equal(expected, got, caption)
|
502
|
+
end
|
503
|
+
|
504
|
+
###############################################################################
|
505
|
+
#
|
506
|
+
# Test the _store_markerformat method.
|
507
|
+
#
|
508
|
+
def test_store_markerformat
|
509
|
+
caption = " \tChart: _store_markerformat()"
|
510
|
+
expected = %w(
|
511
|
+
09 10 14 00 00 00 00 00 00 00 00 00 02 00 01 00
|
512
|
+
4D 00 4D 00 3C 00 00 00
|
513
|
+
).join(' ')
|
514
|
+
values = [0x00, 0x00, 0x02, 0x01, 0x4D, 0x4D, 0x3C]
|
515
|
+
got = unpack_record(@chart.store_markerformat(*values))
|
516
|
+
assert_equal(expected, got, caption)
|
517
|
+
end
|
518
|
+
|
519
|
+
###############################################################################
|
520
|
+
#
|
521
|
+
# Test the _store_dropbar method.
|
522
|
+
#
|
523
|
+
def test_store_dropbar
|
524
|
+
caption = " \tChart: _store_dropbar()"
|
525
|
+
expected = %w(
|
526
|
+
3D 10 02 00 96 00
|
527
|
+
).join(' ')
|
528
|
+
got = unpack_record(@chart.store_dropbar)
|
529
|
+
assert_equal(expected, got, caption)
|
530
|
+
end
|
531
|
+
|
532
|
+
###############################################################################
|
533
|
+
#
|
534
|
+
# Test the _store_chartline method.
|
535
|
+
#
|
536
|
+
def test_store_chartline
|
537
|
+
caption = " \tChart: _store_chartline()"
|
538
|
+
expected = %w(
|
539
|
+
1C 10 02 00 01 00
|
540
|
+
).join(' ')
|
541
|
+
got = unpack_record(@chart.store_chartline)
|
542
|
+
assert_equal(expected, got, caption)
|
543
|
+
end
|
544
|
+
|
545
|
+
###############################################################################
|
546
|
+
#
|
547
|
+
# Test the _store_serparent method.
|
548
|
+
#
|
549
|
+
def test_store_serparent
|
550
|
+
caption = " \tChart: _store_serparent()"
|
551
|
+
expected = %w(
|
552
|
+
4A 10 02 00 01 00
|
553
|
+
).join(' ')
|
554
|
+
got = unpack_record(@chart.store_serparent(1))
|
555
|
+
assert_equal(expected, got, caption)
|
556
|
+
end
|
557
|
+
|
558
|
+
###############################################################################
|
559
|
+
#
|
560
|
+
# Test the _store_serauxtrend method.
|
561
|
+
#
|
562
|
+
def test_store_serauxtrend
|
563
|
+
caption = " \tChart: _store_serauxtrend()"
|
564
|
+
expected = %w(
|
565
|
+
4B 10 1C 00 00 01 FF FF FF FF 00 01 FF FF 00 00
|
566
|
+
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
567
|
+
).join(' ')
|
568
|
+
values = [0x00, 0x01, 0x00, 0x00]
|
569
|
+
got = unpack_record(@chart.store_serauxtrend(*values))
|
570
|
+
assert_equal(expected, got, caption)
|
571
|
+
end
|
572
|
+
|
573
|
+
def unpack_record(data)
|
574
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
575
|
+
end
|
576
|
+
end
|