writeexcel 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitattributes +1 -1
- data/.gitignore +24 -24
- data/README.rdoc +34 -55
- data/VERSION +1 -1
- data/charts/chartex.rb +316 -316
- data/charts/demo1.rb +46 -46
- data/charts/demo2.rb +65 -65
- data/charts/demo3.rb +117 -117
- data/charts/demo4.rb +119 -119
- data/charts/demo5.rb +48 -48
- data/examples/a_simple.rb +43 -43
- data/examples/autofilter.rb +265 -265
- data/examples/bigfile.rb +30 -30
- data/examples/chart_area.rb +121 -121
- data/examples/chart_bar.rb +120 -120
- data/examples/chart_column.rb +120 -120
- data/examples/chart_line.rb +120 -120
- data/examples/chart_pie.rb +108 -108
- data/examples/chart_scatter.rb +121 -121
- data/examples/chart_stock.rb +148 -148
- data/examples/chess.rb +142 -142
- data/examples/colors.rb +129 -129
- data/examples/comments1.rb +27 -27
- data/examples/comments2.rb +352 -352
- data/examples/copyformat.rb +52 -52
- data/examples/data_validate.rb +279 -279
- data/examples/date_time.rb +87 -87
- data/examples/defined_name.rb +32 -32
- data/examples/demo.rb +124 -124
- data/examples/diag_border.rb +36 -36
- data/examples/formats.rb +490 -490
- data/examples/formula_result.rb +30 -30
- data/examples/header.rb +137 -137
- data/examples/hide_sheet.rb +29 -29
- data/examples/hyperlink.rb +43 -43
- data/examples/images.rb +63 -63
- data/examples/indent.rb +31 -31
- data/examples/merge1.rb +40 -40
- data/examples/merge2.rb +45 -45
- data/examples/merge3.rb +66 -66
- data/examples/merge4.rb +83 -83
- data/examples/merge5.rb +80 -80
- data/examples/merge6.rb +67 -67
- data/examples/outline.rb +255 -255
- data/examples/outline_collapsed.rb +209 -209
- data/examples/panes.rb +113 -113
- data/examples/properties.rb +34 -34
- data/examples/properties_jp.rb +33 -33
- data/examples/protection.rb +47 -47
- data/examples/regions.rb +53 -53
- data/examples/repeat.rb +43 -43
- data/examples/right_to_left.rb +27 -27
- data/examples/row_wrap.rb +53 -53
- data/examples/stats.rb +74 -74
- data/examples/stocks.rb +81 -81
- data/examples/tab_colors.rb +31 -31
- data/examples/utf8.rb +15 -15
- data/examples/write_arrays.rb +83 -83
- data/lib/writeexcel/biffwriter.rb +232 -232
- data/lib/writeexcel/caller_info.rb +12 -12
- data/lib/writeexcel/chart.rb +2190 -2177
- data/lib/writeexcel/charts/area.rb +154 -154
- data/lib/writeexcel/charts/bar.rb +177 -177
- data/lib/writeexcel/charts/column.rb +156 -156
- data/lib/writeexcel/charts/external.rb +66 -66
- data/lib/writeexcel/charts/line.rb +154 -154
- data/lib/writeexcel/charts/pie.rb +169 -169
- data/lib/writeexcel/charts/scatter.rb +192 -192
- data/lib/writeexcel/charts/stock.rb +213 -213
- data/lib/writeexcel/colors.rb +64 -64
- data/lib/writeexcel/compatibility.rb +0 -255
- data/lib/writeexcel/debug_info.rb +37 -33
- data/lib/writeexcel/excelformulaparser.rb +587 -587
- data/lib/writeexcel/format.rb +13 -4
- data/lib/writeexcel/formula.rb +26 -9
- data/lib/writeexcel/helper.rb +68 -64
- data/lib/writeexcel/olewriter.rb +311 -311
- data/lib/writeexcel/properties.rb +242 -240
- data/lib/writeexcel/storage_lite.rb +984 -978
- data/lib/writeexcel/workbook.rb +3210 -3192
- data/lib/writeexcel/worksheet.rb +143 -51
- data/lib/writeexcel/write_file.rb +44 -40
- data/lib/writeexcel.rb +1159 -1159
- data/test/helper.rb +31 -28
- data/test/perl_output/README +31 -31
- data/test/test_00_IEEE_double.rb +13 -13
- data/test/test_01_add_worksheet.rb +10 -10
- data/test/test_02_merge_formats.rb +53 -53
- data/test/test_04_dimensions.rb +392 -392
- data/test/test_05_rows.rb +179 -179
- data/test/test_06_extsst.rb +77 -77
- data/test/test_11_date_time.rb +479 -479
- data/test/test_12_date_only.rb +501 -501
- data/test/test_13_date_seconds.rb +481 -481
- data/test/test_21_escher.rb +637 -637
- data/test/test_22_mso_drawing_group.rb +745 -745
- data/test/test_23_note.rb +73 -73
- data/test/test_24_txo.rb +75 -75
- data/test/test_25_position_object.rb +84 -84
- data/test/test_26_autofilter.rb +314 -314
- data/test/test_27_autofilter.rb +131 -131
- data/test/test_28_autofilter.rb +161 -161
- data/test/test_29_process_jpg.rb +683 -683
- data/test/test_30_validation_dval.rb +77 -77
- data/test/test_31_validation_dv_strings.rb +126 -126
- data/test/test_32_validation_dv_formula.rb +206 -206
- data/test/test_40_property_types.rb +188 -188
- data/test/test_41_properties.rb +235 -235
- data/test/test_42_set_properties.rb +437 -437
- data/test/test_50_name_stored.rb +299 -299
- data/test/test_51_name_print_area.rb +357 -357
- data/test/test_52_name_print_titles.rb +454 -454
- data/test/test_53_autofilter.rb +203 -203
- data/test/test_60_chart_generic.rb +578 -578
- data/test/test_61_chart_subclasses.rb +95 -95
- data/test/test_62_chart_formats.rb +272 -272
- data/test/test_63_chart_area_formats.rb +649 -649
- data/test/test_biff.rb +75 -75
- data/test/test_compatibility.rb +12 -627
- data/test/test_example_match.rb +3144 -3144
- data/test/test_formula.rb +61 -61
- data/test/test_ole.rb +106 -106
- data/test/test_storage_lite.rb +125 -125
- data/test/test_workbook.rb +139 -139
- data/test/test_worksheet.rb +110 -110
- data/utils/add_magic_comment.rb +80 -80
- data/writeexcel.gemspec +4 -6
- data/writeexcel.rdoc +58 -15
- metadata +9 -6
- data/test/test_new_encoding.rb +0 -205
@@ -1,454 +1,454 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
##########################################################################
|
3
|
-
# test_52_name_print_titles.rb
|
4
|
-
#
|
5
|
-
# Tests for the Excel EXTERNSHEET and NAME records created by print_are()..
|
6
|
-
#
|
7
|
-
# reverse('ゥ'), September 2008, John McNamara, jmcnamara@cpan.org
|
8
|
-
#
|
9
|
-
# original written in Perl by John McNamara
|
10
|
-
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
11
|
-
#
|
12
|
-
#########################################################################
|
13
|
-
require 'helper'
|
14
|
-
require 'stringio'
|
15
|
-
|
16
|
-
class TC_Name_Print_Titles < Test::Unit::TestCase
|
17
|
-
def setup
|
18
|
-
@test_file = StringIO.new
|
19
|
-
@workbook = WriteExcel.new(@test_file)
|
20
|
-
@workbook.not_using_tmpfile
|
21
|
-
end
|
22
|
-
|
23
|
-
def teardown
|
24
|
-
@workbook.close
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_repeat_rows_for_top_row_only
|
28
|
-
worksheet1 = @workbook.add_worksheet
|
29
|
-
|
30
|
-
worksheet1.repeat_rows(0)
|
31
|
-
|
32
|
-
# Test the EXTERNSHEET record.
|
33
|
-
@workbook.calculate_extern_sizes
|
34
|
-
@workbook.store_externsheet
|
35
|
-
|
36
|
-
target = [%w(
|
37
|
-
17 00 08 00 01 00 00 00 00 00 00 00
|
38
|
-
).join('')].pack('H*')
|
39
|
-
|
40
|
-
caption = " \tExternsheet"
|
41
|
-
result = _unpack_externsheet(@workbook.data)
|
42
|
-
target = _unpack_externsheet(target)
|
43
|
-
assert_equal(target, result)
|
44
|
-
|
45
|
-
# Test the NAME record.
|
46
|
-
@workbook.clear_data_for_test
|
47
|
-
@workbook.store_names
|
48
|
-
|
49
|
-
target = [%w(
|
50
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
51
|
-
00 00 00 07 3B 00 00 00 00 00 00 00 00 FF 00
|
52
|
-
).join('')].pack('H*')
|
53
|
-
|
54
|
-
caption = " \t+ Name repeats ( Sheet1!1:1 )";
|
55
|
-
result = _unpack_name(@workbook.data)
|
56
|
-
target = _unpack_name(target)
|
57
|
-
assert_equal(target, result)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_repeat_rows_for_top_10_rows
|
61
|
-
worksheet1 = @workbook.add_worksheet
|
62
|
-
|
63
|
-
worksheet1.repeat_rows(0, 9)
|
64
|
-
|
65
|
-
# Test the EXTERNSHEET record.
|
66
|
-
@workbook.calculate_extern_sizes
|
67
|
-
@workbook.store_externsheet
|
68
|
-
|
69
|
-
target = [%w(
|
70
|
-
17 00 08 00 01 00 00 00 00 00 00 00
|
71
|
-
).join('')].pack('H*')
|
72
|
-
|
73
|
-
caption = " \tExternsheet"
|
74
|
-
result = _unpack_externsheet(@workbook.data)
|
75
|
-
target = _unpack_externsheet(target)
|
76
|
-
assert_equal(target, result)
|
77
|
-
|
78
|
-
# Test the NAME record.
|
79
|
-
@workbook.clear_data_for_test
|
80
|
-
@workbook.store_names
|
81
|
-
|
82
|
-
target = [%w(
|
83
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
84
|
-
00 00 00 07 3B 00 00 00 00 09 00 00 00 FF 00
|
85
|
-
).join('')].pack('H*')
|
86
|
-
|
87
|
-
caption = " \t+ Name repeats ( Sheet1!1:10 )";
|
88
|
-
result = _unpack_name(@workbook.data)
|
89
|
-
target = _unpack_name(target)
|
90
|
-
assert_equal(target, result)
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_repeat_columns_for_a_single_column
|
94
|
-
worksheet1 = @workbook.add_worksheet
|
95
|
-
|
96
|
-
worksheet1.repeat_columns(0)
|
97
|
-
|
98
|
-
# Test the EXTERNSHEET record.
|
99
|
-
@workbook.calculate_extern_sizes
|
100
|
-
@workbook.store_externsheet
|
101
|
-
|
102
|
-
target = [%w(
|
103
|
-
17 00 08 00 01 00 00 00 00 00 00 00
|
104
|
-
).join('')].pack('H*')
|
105
|
-
|
106
|
-
caption = " \tExternsheet"
|
107
|
-
result = _unpack_externsheet(@workbook.data)
|
108
|
-
target = _unpack_externsheet(target)
|
109
|
-
assert_equal(target, result)
|
110
|
-
|
111
|
-
# Test the NAME record.
|
112
|
-
@workbook.clear_data_for_test
|
113
|
-
@workbook.store_names
|
114
|
-
|
115
|
-
target = [%w(
|
116
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
117
|
-
00 00 00 07 3B 00 00 00 00 FF FF 00 00 00 00
|
118
|
-
).join('')].pack('H*')
|
119
|
-
|
120
|
-
caption = " \t+ Name repeats ( Sheet1!A:A )";
|
121
|
-
result = _unpack_name(@workbook.data)
|
122
|
-
target = _unpack_name(target)
|
123
|
-
assert_equal(target, result)
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_repeat_columns_for_a_single_column_A1_notation
|
127
|
-
worksheet1 = @workbook.add_worksheet
|
128
|
-
|
129
|
-
worksheet1.repeat_columns('A:A')
|
130
|
-
|
131
|
-
# Test the EXTERNSHEET record.
|
132
|
-
@workbook.calculate_extern_sizes
|
133
|
-
@workbook.store_externsheet
|
134
|
-
|
135
|
-
target = [%w(
|
136
|
-
17 00 08 00 01 00 00 00 00 00 00 00
|
137
|
-
).join('')].pack('H*')
|
138
|
-
|
139
|
-
caption = " \tExternsheet"
|
140
|
-
result = _unpack_externsheet(@workbook.data)
|
141
|
-
target = _unpack_externsheet(target)
|
142
|
-
assert_equal(target, result)
|
143
|
-
|
144
|
-
# Test the NAME record.
|
145
|
-
@workbook.clear_data_for_test
|
146
|
-
@workbook.store_names
|
147
|
-
|
148
|
-
target = [%w(
|
149
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
150
|
-
00 00 00 07 3B 00 00 00 00 FF FF 00 00 00 00
|
151
|
-
).join('')].pack('H*')
|
152
|
-
|
153
|
-
caption = " \t+ Name repeats ( Sheet1!A:A )";
|
154
|
-
result = _unpack_name(@workbook.data)
|
155
|
-
target = _unpack_name(target)
|
156
|
-
assert_equal(target, result)
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_repeat_columns_for_a_10_columns
|
160
|
-
worksheet1 = @workbook.add_worksheet
|
161
|
-
|
162
|
-
worksheet1.repeat_columns(0, 9)
|
163
|
-
|
164
|
-
# Test the EXTERNSHEET record.
|
165
|
-
@workbook.calculate_extern_sizes
|
166
|
-
@workbook.store_externsheet
|
167
|
-
|
168
|
-
target = [%w(
|
169
|
-
17 00 08 00 01 00 00 00 00 00 00 00
|
170
|
-
).join('')].pack('H*')
|
171
|
-
|
172
|
-
caption = " \tExternsheet"
|
173
|
-
result = _unpack_externsheet(@workbook.data)
|
174
|
-
target = _unpack_externsheet(target)
|
175
|
-
assert_equal(target, result)
|
176
|
-
|
177
|
-
# Test the NAME record.
|
178
|
-
@workbook.clear_data_for_test
|
179
|
-
@workbook.store_names
|
180
|
-
|
181
|
-
target = [%w(
|
182
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
183
|
-
00 00 00 07 3B 00 00 00 00 FF FF 00 00 09 00
|
184
|
-
).join('')].pack('H*')
|
185
|
-
|
186
|
-
caption = " \t+ Name repeats ( Sheet1!A:J )";
|
187
|
-
result = _unpack_name(@workbook.data)
|
188
|
-
target = _unpack_name(target)
|
189
|
-
assert_equal(target, result)
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_repeat_columns_for_a_10_columns_A1_notation
|
193
|
-
worksheet1 = @workbook.add_worksheet
|
194
|
-
|
195
|
-
worksheet1.repeat_columns('A:J')
|
196
|
-
|
197
|
-
# Test the EXTERNSHEET record.
|
198
|
-
@workbook.calculate_extern_sizes
|
199
|
-
@workbook.store_externsheet
|
200
|
-
|
201
|
-
target = [%w(
|
202
|
-
17 00 08 00 01 00 00 00 00 00 00 00
|
203
|
-
).join('')].pack('H*')
|
204
|
-
|
205
|
-
caption = " \tExternsheet"
|
206
|
-
result = _unpack_externsheet(@workbook.data)
|
207
|
-
target = _unpack_externsheet(target)
|
208
|
-
assert_equal(target, result)
|
209
|
-
|
210
|
-
# Test the NAME record.
|
211
|
-
@workbook.clear_data_for_test
|
212
|
-
@workbook.store_names
|
213
|
-
|
214
|
-
target = [%w(
|
215
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
216
|
-
00 00 00 07 3B 00 00 00 00 FF FF 00 00 09 00
|
217
|
-
).join('')].pack('H*')
|
218
|
-
|
219
|
-
caption = " \t+ Name repeats ( Sheet1!A:J )";
|
220
|
-
result = _unpack_name(@workbook.data)
|
221
|
-
target = _unpack_name(target)
|
222
|
-
assert_equal(target, result)
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_repeat_rows_on_multiple_sheets
|
226
|
-
worksheet1 = @workbook.add_worksheet
|
227
|
-
worksheet2 = @workbook.add_worksheet
|
228
|
-
worksheet3 = @workbook.add_worksheet
|
229
|
-
|
230
|
-
worksheet1.repeat_rows(0, 1)
|
231
|
-
worksheet2.repeat_rows(3, 4)
|
232
|
-
worksheet3.repeat_rows(6, 7)
|
233
|
-
|
234
|
-
# Test the EXTERNSHEET record.
|
235
|
-
@workbook.calculate_extern_sizes
|
236
|
-
@workbook.store_externsheet
|
237
|
-
|
238
|
-
target = [%w(
|
239
|
-
17 00 14 00 03 00 00 00 00 00 00 00 00 00 01 00
|
240
|
-
01 00 00 00 02 00 02 00
|
241
|
-
).join('')].pack('H*')
|
242
|
-
|
243
|
-
caption = " \tExternsheet"
|
244
|
-
result = _unpack_externsheet(@workbook.data)
|
245
|
-
target = _unpack_externsheet(target)
|
246
|
-
assert_equal(target, result)
|
247
|
-
|
248
|
-
# Test the NAME record.
|
249
|
-
@workbook.clear_data_for_test
|
250
|
-
@workbook.store_names
|
251
|
-
|
252
|
-
target = [%w(
|
253
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
254
|
-
00 00 00 07 3B 00 00 00 00 01 00 00 00 FF 00
|
255
|
-
|
256
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 02 00 00 00
|
257
|
-
00 00 00 07 3B 01 00 03 00 04 00 00 00 FF 00
|
258
|
-
|
259
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 03 00 00 00
|
260
|
-
00 00 00 07 3B 02 00 06 00 07 00 00 00 FF 00
|
261
|
-
).join('')].pack('H*')
|
262
|
-
|
263
|
-
caption = " \t+ Name repeats ( Sheet1!1:2, Sheet2!4:5, Sheet3!7:8 )";
|
264
|
-
result = _unpack_name(@workbook.data)
|
265
|
-
target = _unpack_name(target)
|
266
|
-
assert_equal(target, result)
|
267
|
-
end
|
268
|
-
|
269
|
-
def test_repeat_rows_on_multiple_sheets_with_sheets_spaced_out
|
270
|
-
worksheet1 = @workbook.add_worksheet
|
271
|
-
worksheet2 = @workbook.add_worksheet
|
272
|
-
worksheet3 = @workbook.add_worksheet
|
273
|
-
worksheet4 = @workbook.add_worksheet
|
274
|
-
worksheet5 = @workbook.add_worksheet
|
275
|
-
|
276
|
-
worksheet1.repeat_rows(0, 1)
|
277
|
-
worksheet3.repeat_rows(3, 4)
|
278
|
-
worksheet5.repeat_rows(6, 7)
|
279
|
-
|
280
|
-
# Test the EXTERNSHEET record.
|
281
|
-
@workbook.calculate_extern_sizes
|
282
|
-
@workbook.store_externsheet
|
283
|
-
|
284
|
-
target = [%w(
|
285
|
-
17 00 14 00 03 00 00 00 00 00 00 00 00 00 02 00
|
286
|
-
02 00 00 00 04 00 04 00
|
287
|
-
).join('')].pack('H*')
|
288
|
-
|
289
|
-
caption = " \tExternsheet"
|
290
|
-
result = _unpack_externsheet(@workbook.data)
|
291
|
-
target = _unpack_externsheet(target)
|
292
|
-
assert_equal(target, result)
|
293
|
-
|
294
|
-
# Test the NAME record.
|
295
|
-
@workbook.clear_data_for_test
|
296
|
-
@workbook.store_names
|
297
|
-
|
298
|
-
target = [%w(
|
299
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
300
|
-
00 00 00 07 3B 00 00 00 00 01 00 00 00 FF 00
|
301
|
-
|
302
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 03 00 00 00
|
303
|
-
00 00 00 07 3B 01 00 03 00 04 00 00 00 FF 00
|
304
|
-
|
305
|
-
18 00 1B 00 20 00 00 01 0B 00 00 00 05 00 00 00
|
306
|
-
00 00 00 07 3B 02 00 06 00 07 00 00 00 FF 00
|
307
|
-
).join('')].pack('H*')
|
308
|
-
|
309
|
-
caption = " \t+ Name repeats ( Sheet1!1:2, Sheet3!4:5, Sheet5!7:8 )";
|
310
|
-
result = _unpack_name(@workbook.data)
|
311
|
-
target = _unpack_name(target)
|
312
|
-
assert_equal(target, result)
|
313
|
-
end
|
314
|
-
|
315
|
-
def test_repeat_rows_and_repeat_columns_together
|
316
|
-
worksheet1 = @workbook.add_worksheet
|
317
|
-
|
318
|
-
worksheet1.repeat_rows(1, 2)
|
319
|
-
worksheet1.repeat_columns(3, 4)
|
320
|
-
|
321
|
-
# Test the EXTERNSHEET record.
|
322
|
-
@workbook.calculate_extern_sizes
|
323
|
-
@workbook.store_externsheet
|
324
|
-
|
325
|
-
target = [%w(
|
326
|
-
17 00 08 00 01 00 00 00 00 00 00 00
|
327
|
-
).join('')].pack('H*')
|
328
|
-
|
329
|
-
caption = " \tExternsheet"
|
330
|
-
result = _unpack_externsheet(@workbook.data)
|
331
|
-
target = _unpack_externsheet(target)
|
332
|
-
assert_equal(target, result)
|
333
|
-
|
334
|
-
# Test the NAME record.
|
335
|
-
@workbook.clear_data_for_test
|
336
|
-
@workbook.store_names
|
337
|
-
|
338
|
-
target = [%w(
|
339
|
-
18 00 2A 00 20 00 00 01 1A 00 00 00 01 00 00 00
|
340
|
-
00 00 00 07 29 17 00 3B 00 00 00 00 FF FF 03 00
|
341
|
-
04 00 3B 00 00 01 00 02 00 00 00 FF 00 10
|
342
|
-
).join('')].pack('H*')
|
343
|
-
|
344
|
-
caption = " \t+ Name repeats ( Sheet1!2:3, Sheet1!D:E )";
|
345
|
-
result = _unpack_name(@workbook.data)
|
346
|
-
target = _unpack_name(target)
|
347
|
-
assert_equal(target, result)
|
348
|
-
end
|
349
|
-
|
350
|
-
###############################################################################
|
351
|
-
#
|
352
|
-
# _unpack_externsheet()
|
353
|
-
#
|
354
|
-
# Unpack the EXTERNSHEET recordfor easier comparison.
|
355
|
-
#
|
356
|
-
def _unpack_externsheet(data)
|
357
|
-
externsheet = Hash.new
|
358
|
-
|
359
|
-
externsheet['record'] = data[0, 2].unpack('v')[0]
|
360
|
-
data[0, 2] = ''
|
361
|
-
externsheet['length'] = data[0, 2].unpack('v')[0]
|
362
|
-
data[0, 2] = ''
|
363
|
-
externsheet['count'] = data[0, 2].unpack('v')[0]
|
364
|
-
data[0, 2] = ''
|
365
|
-
externsheet['array'] = [];
|
366
|
-
|
367
|
-
externsheet['count'].times do
|
368
|
-
externsheet['array'] << data[0, 6].unpack('vvv')
|
369
|
-
data[0, 6] = ''
|
370
|
-
end
|
371
|
-
externsheet
|
372
|
-
end
|
373
|
-
|
374
|
-
###############################################################################
|
375
|
-
#
|
376
|
-
# _unpack_name()
|
377
|
-
#
|
378
|
-
# Unpack 1 or more NAME structures into a AoH for easier comparison.
|
379
|
-
#
|
380
|
-
def _unpack_name(data)
|
381
|
-
names = Array.new
|
382
|
-
while data.length > 0
|
383
|
-
name = Hash.new
|
384
|
-
|
385
|
-
name['record'] = data[0, 2].unpack('v')[0]
|
386
|
-
data[0, 2] = ''
|
387
|
-
name['length'] = data[0, 2].unpack('v')[0]
|
388
|
-
data[0, 2] = ''
|
389
|
-
name['flags'] = data[0, 2].unpack('v')[0]
|
390
|
-
data[0, 2] = ''
|
391
|
-
name['shortcut'] = data[0, 1].unpack('C')[0]
|
392
|
-
data[0, 1] = ''
|
393
|
-
name['str_len'] = data[0, 1].unpack('C')[0]
|
394
|
-
data[0, 1] = ''
|
395
|
-
name['formula_len'] = data[0, 2].unpack('v')[0]
|
396
|
-
data[0, 2] = ''
|
397
|
-
name['itals'] = data[0, 2].unpack('v')[0]
|
398
|
-
data[0, 2] = ''
|
399
|
-
name['sheet_index'] = data[0, 2].unpack('v')[0]
|
400
|
-
data[0, 2] = ''
|
401
|
-
name['menu_len'] = data[0, 1].unpack('C')[0]
|
402
|
-
data[0, 1] = ''
|
403
|
-
name['desc_len'] = data[0, 1].unpack('C')[0]
|
404
|
-
data[0, 1] = ''
|
405
|
-
name['help_len'] = data[0, 1].unpack('C')[0]
|
406
|
-
data[0, 1] = ''
|
407
|
-
name['status_len'] = data[0, 1].unpack('C')[0]
|
408
|
-
data[0, 1] = ''
|
409
|
-
name['encoding'] = data[0, 1].unpack('C')[0]
|
410
|
-
data[0, 1] = ''
|
411
|
-
|
412
|
-
# Decode the individual flag fields.
|
413
|
-
flag = Hash.new
|
414
|
-
flag['hidden'] = name['flags'] & 0x0001
|
415
|
-
flag['function'] = name['flags'] & 0x0002
|
416
|
-
flag['vb'] = name['flags'] & 0x0004
|
417
|
-
flag['macro'] = name['flags'] & 0x0008
|
418
|
-
flag['complex'] = name['flags'] & 0x0010
|
419
|
-
flag['builtin'] = name['flags'] & 0x0020
|
420
|
-
flag['group'] = name['flags'] & 0x0FC0
|
421
|
-
flag['binary'] = name['flags'] & 0x1000
|
422
|
-
name['flags'] = flag
|
423
|
-
|
424
|
-
# Decode the string part of the NAME structure.
|
425
|
-
if name['encoding'] == 1
|
426
|
-
# UTF-16 name. Leave in hex.
|
427
|
-
name['string'] = data[0, 2 * name['str_len']].unpack('H*')[0].upcase
|
428
|
-
data[0, 2 * name['str_len']] = ''
|
429
|
-
elsif flag['builtin'] != 0
|
430
|
-
# 1 digit builtin name. Leave in hex.
|
431
|
-
name['string'] = data[0, name['str_len']].unpack('H*')[0].upcase
|
432
|
-
data[0, name['str_len']] = ''
|
433
|
-
else
|
434
|
-
# ASCII name.
|
435
|
-
name['string'] = data[0, name['str_len']].unpack('C*').pack('C*')
|
436
|
-
data[0, name['str_len']] = ''
|
437
|
-
end
|
438
|
-
|
439
|
-
# Keep the formula as a hex string.
|
440
|
-
name['formula'] = data[0, name['formula_len']].unpack('H*')[0].upcase
|
441
|
-
data[0, name['formula_len']] = ''
|
442
|
-
|
443
|
-
names << name
|
444
|
-
end
|
445
|
-
names
|
446
|
-
end
|
447
|
-
|
448
|
-
def assert_hash_equal?(result, target)
|
449
|
-
assert_equal(result.keys.sort, target.keys.sort)
|
450
|
-
result.each_key do |key|
|
451
|
-
assert_equal(result[key], target[key])
|
452
|
-
end
|
453
|
-
end
|
454
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
##########################################################################
|
3
|
+
# test_52_name_print_titles.rb
|
4
|
+
#
|
5
|
+
# Tests for the Excel EXTERNSHEET and NAME records created by print_are()..
|
6
|
+
#
|
7
|
+
# reverse('ゥ'), September 2008, John McNamara, jmcnamara@cpan.org
|
8
|
+
#
|
9
|
+
# original written in Perl by John McNamara
|
10
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
11
|
+
#
|
12
|
+
#########################################################################
|
13
|
+
require 'helper'
|
14
|
+
require 'stringio'
|
15
|
+
|
16
|
+
class TC_Name_Print_Titles < Test::Unit::TestCase
|
17
|
+
def setup
|
18
|
+
@test_file = StringIO.new
|
19
|
+
@workbook = WriteExcel.new(@test_file)
|
20
|
+
@workbook.not_using_tmpfile
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
@workbook.close
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_repeat_rows_for_top_row_only
|
28
|
+
worksheet1 = @workbook.add_worksheet
|
29
|
+
|
30
|
+
worksheet1.repeat_rows(0)
|
31
|
+
|
32
|
+
# Test the EXTERNSHEET record.
|
33
|
+
@workbook.calculate_extern_sizes
|
34
|
+
@workbook.store_externsheet
|
35
|
+
|
36
|
+
target = [%w(
|
37
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
38
|
+
).join('')].pack('H*')
|
39
|
+
|
40
|
+
caption = " \tExternsheet"
|
41
|
+
result = _unpack_externsheet(@workbook.data)
|
42
|
+
target = _unpack_externsheet(target)
|
43
|
+
assert_equal(target, result)
|
44
|
+
|
45
|
+
# Test the NAME record.
|
46
|
+
@workbook.clear_data_for_test
|
47
|
+
@workbook.store_names
|
48
|
+
|
49
|
+
target = [%w(
|
50
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
51
|
+
00 00 00 07 3B 00 00 00 00 00 00 00 00 FF 00
|
52
|
+
).join('')].pack('H*')
|
53
|
+
|
54
|
+
caption = " \t+ Name repeats ( Sheet1!1:1 )";
|
55
|
+
result = _unpack_name(@workbook.data)
|
56
|
+
target = _unpack_name(target)
|
57
|
+
assert_equal(target, result)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_repeat_rows_for_top_10_rows
|
61
|
+
worksheet1 = @workbook.add_worksheet
|
62
|
+
|
63
|
+
worksheet1.repeat_rows(0, 9)
|
64
|
+
|
65
|
+
# Test the EXTERNSHEET record.
|
66
|
+
@workbook.calculate_extern_sizes
|
67
|
+
@workbook.store_externsheet
|
68
|
+
|
69
|
+
target = [%w(
|
70
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
71
|
+
).join('')].pack('H*')
|
72
|
+
|
73
|
+
caption = " \tExternsheet"
|
74
|
+
result = _unpack_externsheet(@workbook.data)
|
75
|
+
target = _unpack_externsheet(target)
|
76
|
+
assert_equal(target, result)
|
77
|
+
|
78
|
+
# Test the NAME record.
|
79
|
+
@workbook.clear_data_for_test
|
80
|
+
@workbook.store_names
|
81
|
+
|
82
|
+
target = [%w(
|
83
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
84
|
+
00 00 00 07 3B 00 00 00 00 09 00 00 00 FF 00
|
85
|
+
).join('')].pack('H*')
|
86
|
+
|
87
|
+
caption = " \t+ Name repeats ( Sheet1!1:10 )";
|
88
|
+
result = _unpack_name(@workbook.data)
|
89
|
+
target = _unpack_name(target)
|
90
|
+
assert_equal(target, result)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_repeat_columns_for_a_single_column
|
94
|
+
worksheet1 = @workbook.add_worksheet
|
95
|
+
|
96
|
+
worksheet1.repeat_columns(0)
|
97
|
+
|
98
|
+
# Test the EXTERNSHEET record.
|
99
|
+
@workbook.calculate_extern_sizes
|
100
|
+
@workbook.store_externsheet
|
101
|
+
|
102
|
+
target = [%w(
|
103
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
104
|
+
).join('')].pack('H*')
|
105
|
+
|
106
|
+
caption = " \tExternsheet"
|
107
|
+
result = _unpack_externsheet(@workbook.data)
|
108
|
+
target = _unpack_externsheet(target)
|
109
|
+
assert_equal(target, result)
|
110
|
+
|
111
|
+
# Test the NAME record.
|
112
|
+
@workbook.clear_data_for_test
|
113
|
+
@workbook.store_names
|
114
|
+
|
115
|
+
target = [%w(
|
116
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
117
|
+
00 00 00 07 3B 00 00 00 00 FF FF 00 00 00 00
|
118
|
+
).join('')].pack('H*')
|
119
|
+
|
120
|
+
caption = " \t+ Name repeats ( Sheet1!A:A )";
|
121
|
+
result = _unpack_name(@workbook.data)
|
122
|
+
target = _unpack_name(target)
|
123
|
+
assert_equal(target, result)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_repeat_columns_for_a_single_column_A1_notation
|
127
|
+
worksheet1 = @workbook.add_worksheet
|
128
|
+
|
129
|
+
worksheet1.repeat_columns('A:A')
|
130
|
+
|
131
|
+
# Test the EXTERNSHEET record.
|
132
|
+
@workbook.calculate_extern_sizes
|
133
|
+
@workbook.store_externsheet
|
134
|
+
|
135
|
+
target = [%w(
|
136
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
137
|
+
).join('')].pack('H*')
|
138
|
+
|
139
|
+
caption = " \tExternsheet"
|
140
|
+
result = _unpack_externsheet(@workbook.data)
|
141
|
+
target = _unpack_externsheet(target)
|
142
|
+
assert_equal(target, result)
|
143
|
+
|
144
|
+
# Test the NAME record.
|
145
|
+
@workbook.clear_data_for_test
|
146
|
+
@workbook.store_names
|
147
|
+
|
148
|
+
target = [%w(
|
149
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
150
|
+
00 00 00 07 3B 00 00 00 00 FF FF 00 00 00 00
|
151
|
+
).join('')].pack('H*')
|
152
|
+
|
153
|
+
caption = " \t+ Name repeats ( Sheet1!A:A )";
|
154
|
+
result = _unpack_name(@workbook.data)
|
155
|
+
target = _unpack_name(target)
|
156
|
+
assert_equal(target, result)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_repeat_columns_for_a_10_columns
|
160
|
+
worksheet1 = @workbook.add_worksheet
|
161
|
+
|
162
|
+
worksheet1.repeat_columns(0, 9)
|
163
|
+
|
164
|
+
# Test the EXTERNSHEET record.
|
165
|
+
@workbook.calculate_extern_sizes
|
166
|
+
@workbook.store_externsheet
|
167
|
+
|
168
|
+
target = [%w(
|
169
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
170
|
+
).join('')].pack('H*')
|
171
|
+
|
172
|
+
caption = " \tExternsheet"
|
173
|
+
result = _unpack_externsheet(@workbook.data)
|
174
|
+
target = _unpack_externsheet(target)
|
175
|
+
assert_equal(target, result)
|
176
|
+
|
177
|
+
# Test the NAME record.
|
178
|
+
@workbook.clear_data_for_test
|
179
|
+
@workbook.store_names
|
180
|
+
|
181
|
+
target = [%w(
|
182
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
183
|
+
00 00 00 07 3B 00 00 00 00 FF FF 00 00 09 00
|
184
|
+
).join('')].pack('H*')
|
185
|
+
|
186
|
+
caption = " \t+ Name repeats ( Sheet1!A:J )";
|
187
|
+
result = _unpack_name(@workbook.data)
|
188
|
+
target = _unpack_name(target)
|
189
|
+
assert_equal(target, result)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_repeat_columns_for_a_10_columns_A1_notation
|
193
|
+
worksheet1 = @workbook.add_worksheet
|
194
|
+
|
195
|
+
worksheet1.repeat_columns('A:J')
|
196
|
+
|
197
|
+
# Test the EXTERNSHEET record.
|
198
|
+
@workbook.calculate_extern_sizes
|
199
|
+
@workbook.store_externsheet
|
200
|
+
|
201
|
+
target = [%w(
|
202
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
203
|
+
).join('')].pack('H*')
|
204
|
+
|
205
|
+
caption = " \tExternsheet"
|
206
|
+
result = _unpack_externsheet(@workbook.data)
|
207
|
+
target = _unpack_externsheet(target)
|
208
|
+
assert_equal(target, result)
|
209
|
+
|
210
|
+
# Test the NAME record.
|
211
|
+
@workbook.clear_data_for_test
|
212
|
+
@workbook.store_names
|
213
|
+
|
214
|
+
target = [%w(
|
215
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
216
|
+
00 00 00 07 3B 00 00 00 00 FF FF 00 00 09 00
|
217
|
+
).join('')].pack('H*')
|
218
|
+
|
219
|
+
caption = " \t+ Name repeats ( Sheet1!A:J )";
|
220
|
+
result = _unpack_name(@workbook.data)
|
221
|
+
target = _unpack_name(target)
|
222
|
+
assert_equal(target, result)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_repeat_rows_on_multiple_sheets
|
226
|
+
worksheet1 = @workbook.add_worksheet
|
227
|
+
worksheet2 = @workbook.add_worksheet
|
228
|
+
worksheet3 = @workbook.add_worksheet
|
229
|
+
|
230
|
+
worksheet1.repeat_rows(0, 1)
|
231
|
+
worksheet2.repeat_rows(3, 4)
|
232
|
+
worksheet3.repeat_rows(6, 7)
|
233
|
+
|
234
|
+
# Test the EXTERNSHEET record.
|
235
|
+
@workbook.calculate_extern_sizes
|
236
|
+
@workbook.store_externsheet
|
237
|
+
|
238
|
+
target = [%w(
|
239
|
+
17 00 14 00 03 00 00 00 00 00 00 00 00 00 01 00
|
240
|
+
01 00 00 00 02 00 02 00
|
241
|
+
).join('')].pack('H*')
|
242
|
+
|
243
|
+
caption = " \tExternsheet"
|
244
|
+
result = _unpack_externsheet(@workbook.data)
|
245
|
+
target = _unpack_externsheet(target)
|
246
|
+
assert_equal(target, result)
|
247
|
+
|
248
|
+
# Test the NAME record.
|
249
|
+
@workbook.clear_data_for_test
|
250
|
+
@workbook.store_names
|
251
|
+
|
252
|
+
target = [%w(
|
253
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
254
|
+
00 00 00 07 3B 00 00 00 00 01 00 00 00 FF 00
|
255
|
+
|
256
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 02 00 00 00
|
257
|
+
00 00 00 07 3B 01 00 03 00 04 00 00 00 FF 00
|
258
|
+
|
259
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 03 00 00 00
|
260
|
+
00 00 00 07 3B 02 00 06 00 07 00 00 00 FF 00
|
261
|
+
).join('')].pack('H*')
|
262
|
+
|
263
|
+
caption = " \t+ Name repeats ( Sheet1!1:2, Sheet2!4:5, Sheet3!7:8 )";
|
264
|
+
result = _unpack_name(@workbook.data)
|
265
|
+
target = _unpack_name(target)
|
266
|
+
assert_equal(target, result)
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_repeat_rows_on_multiple_sheets_with_sheets_spaced_out
|
270
|
+
worksheet1 = @workbook.add_worksheet
|
271
|
+
worksheet2 = @workbook.add_worksheet
|
272
|
+
worksheet3 = @workbook.add_worksheet
|
273
|
+
worksheet4 = @workbook.add_worksheet
|
274
|
+
worksheet5 = @workbook.add_worksheet
|
275
|
+
|
276
|
+
worksheet1.repeat_rows(0, 1)
|
277
|
+
worksheet3.repeat_rows(3, 4)
|
278
|
+
worksheet5.repeat_rows(6, 7)
|
279
|
+
|
280
|
+
# Test the EXTERNSHEET record.
|
281
|
+
@workbook.calculate_extern_sizes
|
282
|
+
@workbook.store_externsheet
|
283
|
+
|
284
|
+
target = [%w(
|
285
|
+
17 00 14 00 03 00 00 00 00 00 00 00 00 00 02 00
|
286
|
+
02 00 00 00 04 00 04 00
|
287
|
+
).join('')].pack('H*')
|
288
|
+
|
289
|
+
caption = " \tExternsheet"
|
290
|
+
result = _unpack_externsheet(@workbook.data)
|
291
|
+
target = _unpack_externsheet(target)
|
292
|
+
assert_equal(target, result)
|
293
|
+
|
294
|
+
# Test the NAME record.
|
295
|
+
@workbook.clear_data_for_test
|
296
|
+
@workbook.store_names
|
297
|
+
|
298
|
+
target = [%w(
|
299
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 01 00 00 00
|
300
|
+
00 00 00 07 3B 00 00 00 00 01 00 00 00 FF 00
|
301
|
+
|
302
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 03 00 00 00
|
303
|
+
00 00 00 07 3B 01 00 03 00 04 00 00 00 FF 00
|
304
|
+
|
305
|
+
18 00 1B 00 20 00 00 01 0B 00 00 00 05 00 00 00
|
306
|
+
00 00 00 07 3B 02 00 06 00 07 00 00 00 FF 00
|
307
|
+
).join('')].pack('H*')
|
308
|
+
|
309
|
+
caption = " \t+ Name repeats ( Sheet1!1:2, Sheet3!4:5, Sheet5!7:8 )";
|
310
|
+
result = _unpack_name(@workbook.data)
|
311
|
+
target = _unpack_name(target)
|
312
|
+
assert_equal(target, result)
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_repeat_rows_and_repeat_columns_together
|
316
|
+
worksheet1 = @workbook.add_worksheet
|
317
|
+
|
318
|
+
worksheet1.repeat_rows(1, 2)
|
319
|
+
worksheet1.repeat_columns(3, 4)
|
320
|
+
|
321
|
+
# Test the EXTERNSHEET record.
|
322
|
+
@workbook.calculate_extern_sizes
|
323
|
+
@workbook.store_externsheet
|
324
|
+
|
325
|
+
target = [%w(
|
326
|
+
17 00 08 00 01 00 00 00 00 00 00 00
|
327
|
+
).join('')].pack('H*')
|
328
|
+
|
329
|
+
caption = " \tExternsheet"
|
330
|
+
result = _unpack_externsheet(@workbook.data)
|
331
|
+
target = _unpack_externsheet(target)
|
332
|
+
assert_equal(target, result)
|
333
|
+
|
334
|
+
# Test the NAME record.
|
335
|
+
@workbook.clear_data_for_test
|
336
|
+
@workbook.store_names
|
337
|
+
|
338
|
+
target = [%w(
|
339
|
+
18 00 2A 00 20 00 00 01 1A 00 00 00 01 00 00 00
|
340
|
+
00 00 00 07 29 17 00 3B 00 00 00 00 FF FF 03 00
|
341
|
+
04 00 3B 00 00 01 00 02 00 00 00 FF 00 10
|
342
|
+
).join('')].pack('H*')
|
343
|
+
|
344
|
+
caption = " \t+ Name repeats ( Sheet1!2:3, Sheet1!D:E )";
|
345
|
+
result = _unpack_name(@workbook.data)
|
346
|
+
target = _unpack_name(target)
|
347
|
+
assert_equal(target, result)
|
348
|
+
end
|
349
|
+
|
350
|
+
###############################################################################
|
351
|
+
#
|
352
|
+
# _unpack_externsheet()
|
353
|
+
#
|
354
|
+
# Unpack the EXTERNSHEET recordfor easier comparison.
|
355
|
+
#
|
356
|
+
def _unpack_externsheet(data)
|
357
|
+
externsheet = Hash.new
|
358
|
+
|
359
|
+
externsheet['record'] = data[0, 2].unpack('v')[0]
|
360
|
+
data[0, 2] = ''
|
361
|
+
externsheet['length'] = data[0, 2].unpack('v')[0]
|
362
|
+
data[0, 2] = ''
|
363
|
+
externsheet['count'] = data[0, 2].unpack('v')[0]
|
364
|
+
data[0, 2] = ''
|
365
|
+
externsheet['array'] = [];
|
366
|
+
|
367
|
+
externsheet['count'].times do
|
368
|
+
externsheet['array'] << data[0, 6].unpack('vvv')
|
369
|
+
data[0, 6] = ''
|
370
|
+
end
|
371
|
+
externsheet
|
372
|
+
end
|
373
|
+
|
374
|
+
###############################################################################
|
375
|
+
#
|
376
|
+
# _unpack_name()
|
377
|
+
#
|
378
|
+
# Unpack 1 or more NAME structures into a AoH for easier comparison.
|
379
|
+
#
|
380
|
+
def _unpack_name(data)
|
381
|
+
names = Array.new
|
382
|
+
while data.length > 0
|
383
|
+
name = Hash.new
|
384
|
+
|
385
|
+
name['record'] = data[0, 2].unpack('v')[0]
|
386
|
+
data[0, 2] = ''
|
387
|
+
name['length'] = data[0, 2].unpack('v')[0]
|
388
|
+
data[0, 2] = ''
|
389
|
+
name['flags'] = data[0, 2].unpack('v')[0]
|
390
|
+
data[0, 2] = ''
|
391
|
+
name['shortcut'] = data[0, 1].unpack('C')[0]
|
392
|
+
data[0, 1] = ''
|
393
|
+
name['str_len'] = data[0, 1].unpack('C')[0]
|
394
|
+
data[0, 1] = ''
|
395
|
+
name['formula_len'] = data[0, 2].unpack('v')[0]
|
396
|
+
data[0, 2] = ''
|
397
|
+
name['itals'] = data[0, 2].unpack('v')[0]
|
398
|
+
data[0, 2] = ''
|
399
|
+
name['sheet_index'] = data[0, 2].unpack('v')[0]
|
400
|
+
data[0, 2] = ''
|
401
|
+
name['menu_len'] = data[0, 1].unpack('C')[0]
|
402
|
+
data[0, 1] = ''
|
403
|
+
name['desc_len'] = data[0, 1].unpack('C')[0]
|
404
|
+
data[0, 1] = ''
|
405
|
+
name['help_len'] = data[0, 1].unpack('C')[0]
|
406
|
+
data[0, 1] = ''
|
407
|
+
name['status_len'] = data[0, 1].unpack('C')[0]
|
408
|
+
data[0, 1] = ''
|
409
|
+
name['encoding'] = data[0, 1].unpack('C')[0]
|
410
|
+
data[0, 1] = ''
|
411
|
+
|
412
|
+
# Decode the individual flag fields.
|
413
|
+
flag = Hash.new
|
414
|
+
flag['hidden'] = name['flags'] & 0x0001
|
415
|
+
flag['function'] = name['flags'] & 0x0002
|
416
|
+
flag['vb'] = name['flags'] & 0x0004
|
417
|
+
flag['macro'] = name['flags'] & 0x0008
|
418
|
+
flag['complex'] = name['flags'] & 0x0010
|
419
|
+
flag['builtin'] = name['flags'] & 0x0020
|
420
|
+
flag['group'] = name['flags'] & 0x0FC0
|
421
|
+
flag['binary'] = name['flags'] & 0x1000
|
422
|
+
name['flags'] = flag
|
423
|
+
|
424
|
+
# Decode the string part of the NAME structure.
|
425
|
+
if name['encoding'] == 1
|
426
|
+
# UTF-16 name. Leave in hex.
|
427
|
+
name['string'] = data[0, 2 * name['str_len']].unpack('H*')[0].upcase
|
428
|
+
data[0, 2 * name['str_len']] = ''
|
429
|
+
elsif flag['builtin'] != 0
|
430
|
+
# 1 digit builtin name. Leave in hex.
|
431
|
+
name['string'] = data[0, name['str_len']].unpack('H*')[0].upcase
|
432
|
+
data[0, name['str_len']] = ''
|
433
|
+
else
|
434
|
+
# ASCII name.
|
435
|
+
name['string'] = data[0, name['str_len']].unpack('C*').pack('C*')
|
436
|
+
data[0, name['str_len']] = ''
|
437
|
+
end
|
438
|
+
|
439
|
+
# Keep the formula as a hex string.
|
440
|
+
name['formula'] = data[0, name['formula_len']].unpack('H*')[0].upcase
|
441
|
+
data[0, name['formula_len']] = ''
|
442
|
+
|
443
|
+
names << name
|
444
|
+
end
|
445
|
+
names
|
446
|
+
end
|
447
|
+
|
448
|
+
def assert_hash_equal?(result, target)
|
449
|
+
assert_equal(result.keys.sort, target.keys.sort)
|
450
|
+
result.each_key do |key|
|
451
|
+
assert_equal(result[key], target[key])
|
452
|
+
end
|
453
|
+
end
|
454
|
+
end
|