writeexcel 0.1.0 → 0.3.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/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
@@ -1,191 +1,191 @@
|
|
1
|
-
##########################################################################
|
2
|
-
# test_40_property_types.rb
|
3
|
-
#
|
4
|
-
# Tests for the basic property types used in OLE property sets.
|
5
|
-
#
|
6
|
-
# reverse('©'), September 2005, 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
|
-
|
14
|
-
require 'test/unit'
|
15
|
-
require 'rubygems'
|
16
|
-
require 'writeexcel'
|
17
|
-
|
18
|
-
class TC_property_types < Test::Unit::TestCase
|
19
|
-
|
20
|
-
def setup
|
21
|
-
@smiley = '☺' # chr 0x263A; in perl
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_pack_a_VT_I2
|
25
|
-
caption = " \tDoc properties: pack_VT_I2(1252)"
|
26
|
-
target = %w(
|
27
|
-
02 00 00 00 E4 04 00 00
|
28
|
-
).join(' ')
|
29
|
-
|
30
|
-
result = unpack_record( pack_VT_I2(1252) )
|
31
|
-
assert_equal(target, result, caption)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_pack_a_VT_LPSTR_string_and_check_for_padding
|
35
|
-
string = ''
|
36
|
-
codepage = 0x04E4
|
37
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
38
|
-
target = %w(
|
39
|
-
1E 00 00 00 01 00 00 00 00 00 00 00
|
40
|
-
).join(' ')
|
41
|
-
|
42
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
43
|
-
assert_equal(target, result, caption)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_pack_a_VT_LPSTR_string_and_check_for_padding_2
|
47
|
-
string = 'a'
|
48
|
-
codepage = 0x04E4
|
49
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
50
|
-
target = %w(
|
51
|
-
1E 00 00 00 02 00 00 00 61 00 00 00
|
52
|
-
).join(' ')
|
53
|
-
|
54
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
55
|
-
assert_equal(target, result, caption)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_pack_a_VT_LPSTR_string_and_check_for_padding_3
|
59
|
-
string = 'bb'
|
60
|
-
codepage = 0x04E4
|
61
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
62
|
-
target = %w(
|
63
|
-
1E 00 00 00 03 00 00 00 62 62 00 00
|
64
|
-
).join(' ')
|
65
|
-
|
66
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
67
|
-
assert_equal(target, result, caption)
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_pack_a_VT_LPSTR_string_and_check_for_padding_4
|
71
|
-
string = 'ccc'
|
72
|
-
codepage = 0x04E4
|
73
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
74
|
-
target = %w(
|
75
|
-
1E 00 00 00 04 00 00 00 63 63 63 00
|
76
|
-
).join(' ')
|
77
|
-
|
78
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
79
|
-
assert_equal(target, result, caption)
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_pack_a_VT_LPSTR_string_and_check_for_padding_5
|
83
|
-
string = 'dddd'
|
84
|
-
codepage = 0x04E4
|
85
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
86
|
-
target = %w(
|
87
|
-
1E 00 00 00 05 00 00 00 64 64 64 64 00 00 00 00
|
88
|
-
).join(' ')
|
89
|
-
|
90
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
91
|
-
assert_equal(target, result, caption)
|
92
|
-
end
|
93
|
-
|
94
|
-
def
|
95
|
-
string = 'Username'
|
96
|
-
codepage = 0x04E4
|
97
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
98
|
-
target = %w(
|
99
|
-
1E 00 00 00 09 00 00 00 55 73 65 72 6E 61 6D 65
|
100
|
-
00 00 00 00
|
101
|
-
).join(' ')
|
102
|
-
|
103
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
104
|
-
assert_equal(target, result, caption)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_pack_a_VT_LPSTR_UTF8_string
|
108
|
-
string = @smiley
|
109
|
-
codepage = 0xFDE9
|
110
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{@smiley}',\t#{codepage}')"
|
111
|
-
target = %w(
|
112
|
-
1E 00 00 00 04 00 00 00 E2 98 BA 00
|
113
|
-
).join(' ')
|
114
|
-
|
115
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
116
|
-
assert_equal(target, result, caption)
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_pack_a_VT_LPSTR_UTF8_string_2
|
120
|
-
string = "a" + @smiley
|
121
|
-
codepage = 0xFDE9
|
122
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('a#{@smiley}',\t#{codepage}')"
|
123
|
-
target = %w(
|
124
|
-
1E 00 00 00 05 00 00 00 61 E2 98 BA 00 00 00 00
|
125
|
-
).join(' ')
|
126
|
-
|
127
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
128
|
-
assert_equal(target, result, caption)
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_pack_a_VT_LPSTR_UTF8_string_3
|
132
|
-
string = "aa" + @smiley
|
133
|
-
codepage = 0xFDE9
|
134
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
135
|
-
target = %w(
|
136
|
-
1E 00 00 00 06 00 00 00 61 61 E2 98 BA 00 00 00
|
137
|
-
).join(' ')
|
138
|
-
|
139
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
140
|
-
assert_equal(target, result, caption)
|
141
|
-
end
|
142
|
-
|
143
|
-
def test_pack_a_VT_LPSTR_UTF8_string_4
|
144
|
-
string = "aaa" + @smiley
|
145
|
-
codepage = 0xFDE9
|
146
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
147
|
-
target = %w(
|
148
|
-
1E 00 00 00 07 00 00 00 61 61 61 E2 98 BA 00 00
|
149
|
-
).join(' ')
|
150
|
-
|
151
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
152
|
-
assert_equal(target, result, caption)
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_pack_a_VT_LPSTR_UTF8_string_5
|
156
|
-
string = "aaaa" + @smiley
|
157
|
-
codepage = 0xFDE9
|
158
|
-
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
159
|
-
target = %w(
|
160
|
-
1E 00 00 00 08 00 00 00 61 61 61 61 E2 98 BA 00
|
161
|
-
).join(' ')
|
162
|
-
|
163
|
-
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
164
|
-
assert_equal(target, result, caption)
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_pack_a_VT_FILETIME
|
168
|
-
# Wed Aug 13 00:40:00 2008
|
169
|
-
# $sec,$min,$hour,$mday,$mon,$year
|
170
|
-
# We normalise the time using timegm() so that the tests don't fail due to
|
171
|
-
# different timezones.
|
172
|
-
filetime = Time.gm(2008,8,13,0,40,0)
|
173
|
-
|
174
|
-
caption = " \tDoc properties: _pack_VT_FILETIME()"
|
175
|
-
target = %w(
|
176
|
-
40 00 00 00 00 70 EB 1D DD FC C8 01
|
177
|
-
).join(' ')
|
178
|
-
|
179
|
-
result = unpack_record( pack_VT_FILETIME(filetime) )
|
180
|
-
assert_equal(target, result, caption)
|
181
|
-
end
|
182
|
-
|
183
|
-
###############################################################################
|
184
|
-
#
|
185
|
-
# Unpack the binary data into a format suitable for printing in tests.
|
186
|
-
#
|
187
|
-
def unpack_record(data)
|
188
|
-
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
189
|
-
end
|
190
|
-
|
191
|
-
end
|
1
|
+
##########################################################################
|
2
|
+
# test_40_property_types.rb
|
3
|
+
#
|
4
|
+
# Tests for the basic property types used in OLE property sets.
|
5
|
+
#
|
6
|
+
# reverse('©'), September 2005, 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
|
+
|
14
|
+
require 'test/unit'
|
15
|
+
require 'rubygems'
|
16
|
+
require 'writeexcel'
|
17
|
+
|
18
|
+
class TC_property_types < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@smiley = '☺' # chr 0x263A; in perl
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_pack_a_VT_I2
|
25
|
+
caption = " \tDoc properties: pack_VT_I2(1252)"
|
26
|
+
target = %w(
|
27
|
+
02 00 00 00 E4 04 00 00
|
28
|
+
).join(' ')
|
29
|
+
|
30
|
+
result = unpack_record( pack_VT_I2(1252) )
|
31
|
+
assert_equal(target, result, caption)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_pack_a_VT_LPSTR_string_and_check_for_padding
|
35
|
+
string = ''
|
36
|
+
codepage = 0x04E4
|
37
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
38
|
+
target = %w(
|
39
|
+
1E 00 00 00 01 00 00 00 00 00 00 00
|
40
|
+
).join(' ')
|
41
|
+
|
42
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
43
|
+
assert_equal(target, result, caption)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_pack_a_VT_LPSTR_string_and_check_for_padding_2
|
47
|
+
string = 'a'
|
48
|
+
codepage = 0x04E4
|
49
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
50
|
+
target = %w(
|
51
|
+
1E 00 00 00 02 00 00 00 61 00 00 00
|
52
|
+
).join(' ')
|
53
|
+
|
54
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
55
|
+
assert_equal(target, result, caption)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_pack_a_VT_LPSTR_string_and_check_for_padding_3
|
59
|
+
string = 'bb'
|
60
|
+
codepage = 0x04E4
|
61
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
62
|
+
target = %w(
|
63
|
+
1E 00 00 00 03 00 00 00 62 62 00 00
|
64
|
+
).join(' ')
|
65
|
+
|
66
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
67
|
+
assert_equal(target, result, caption)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_pack_a_VT_LPSTR_string_and_check_for_padding_4
|
71
|
+
string = 'ccc'
|
72
|
+
codepage = 0x04E4
|
73
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
74
|
+
target = %w(
|
75
|
+
1E 00 00 00 04 00 00 00 63 63 63 00
|
76
|
+
).join(' ')
|
77
|
+
|
78
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
79
|
+
assert_equal(target, result, caption)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_pack_a_VT_LPSTR_string_and_check_for_padding_5
|
83
|
+
string = 'dddd'
|
84
|
+
codepage = 0x04E4
|
85
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
86
|
+
target = %w(
|
87
|
+
1E 00 00 00 05 00 00 00 64 64 64 64 00 00 00 00
|
88
|
+
).join(' ')
|
89
|
+
|
90
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
91
|
+
assert_equal(target, result, caption)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_pack_a_VT_LPSTR_string_and_check_for_padding_6
|
95
|
+
string = 'Username'
|
96
|
+
codepage = 0x04E4
|
97
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
98
|
+
target = %w(
|
99
|
+
1E 00 00 00 09 00 00 00 55 73 65 72 6E 61 6D 65
|
100
|
+
00 00 00 00
|
101
|
+
).join(' ')
|
102
|
+
|
103
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
104
|
+
assert_equal(target, result, caption)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_pack_a_VT_LPSTR_UTF8_string
|
108
|
+
string = @smiley
|
109
|
+
codepage = 0xFDE9
|
110
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{@smiley}',\t#{codepage}')"
|
111
|
+
target = %w(
|
112
|
+
1E 00 00 00 04 00 00 00 E2 98 BA 00
|
113
|
+
).join(' ')
|
114
|
+
|
115
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
116
|
+
assert_equal(target, result, caption)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_pack_a_VT_LPSTR_UTF8_string_2
|
120
|
+
string = "a" + @smiley
|
121
|
+
codepage = 0xFDE9
|
122
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('a#{@smiley}',\t#{codepage}')"
|
123
|
+
target = %w(
|
124
|
+
1E 00 00 00 05 00 00 00 61 E2 98 BA 00 00 00 00
|
125
|
+
).join(' ')
|
126
|
+
|
127
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
128
|
+
assert_equal(target, result, caption)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_pack_a_VT_LPSTR_UTF8_string_3
|
132
|
+
string = "aa" + @smiley
|
133
|
+
codepage = 0xFDE9
|
134
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
135
|
+
target = %w(
|
136
|
+
1E 00 00 00 06 00 00 00 61 61 E2 98 BA 00 00 00
|
137
|
+
).join(' ')
|
138
|
+
|
139
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
140
|
+
assert_equal(target, result, caption)
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_pack_a_VT_LPSTR_UTF8_string_4
|
144
|
+
string = "aaa" + @smiley
|
145
|
+
codepage = 0xFDE9
|
146
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
147
|
+
target = %w(
|
148
|
+
1E 00 00 00 07 00 00 00 61 61 61 E2 98 BA 00 00
|
149
|
+
).join(' ')
|
150
|
+
|
151
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
152
|
+
assert_equal(target, result, caption)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_pack_a_VT_LPSTR_UTF8_string_5
|
156
|
+
string = "aaaa" + @smiley
|
157
|
+
codepage = 0xFDE9
|
158
|
+
caption = " \tDoc properties: _pack_VT_LPSTR('#{string}',\t#{codepage}')"
|
159
|
+
target = %w(
|
160
|
+
1E 00 00 00 08 00 00 00 61 61 61 61 E2 98 BA 00
|
161
|
+
).join(' ')
|
162
|
+
|
163
|
+
result = unpack_record( pack_VT_LPSTR(string, codepage) )
|
164
|
+
assert_equal(target, result, caption)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_pack_a_VT_FILETIME
|
168
|
+
# Wed Aug 13 00:40:00 2008
|
169
|
+
# $sec,$min,$hour,$mday,$mon,$year
|
170
|
+
# We normalise the time using timegm() so that the tests don't fail due to
|
171
|
+
# different timezones.
|
172
|
+
filetime = Time.gm(2008,8,13,0,40,0)
|
173
|
+
|
174
|
+
caption = " \tDoc properties: _pack_VT_FILETIME()"
|
175
|
+
target = %w(
|
176
|
+
40 00 00 00 00 70 EB 1D DD FC C8 01
|
177
|
+
).join(' ')
|
178
|
+
|
179
|
+
result = unpack_record( pack_VT_FILETIME(filetime) )
|
180
|
+
assert_equal(target, result, caption)
|
181
|
+
end
|
182
|
+
|
183
|
+
###############################################################################
|
184
|
+
#
|
185
|
+
# Unpack the binary data into a format suitable for printing in tests.
|
186
|
+
#
|
187
|
+
def unpack_record(data)
|
188
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
data/test/test_41_properties.rb
CHANGED
@@ -1,238 +1,238 @@
|
|
1
|
-
##########################################################################
|
2
|
-
# test_41_properties.rb
|
3
|
-
#
|
4
|
-
# Tests for OLE property sets.
|
5
|
-
#
|
6
|
-
# reverse('©'), September 2005, 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
|
-
|
14
|
-
require 'test/unit'
|
15
|
-
require 'rubygems'
|
16
|
-
require 'writeexcel'
|
17
|
-
|
18
|
-
class TC_properties < Test::Unit::TestCase
|
19
|
-
|
20
|
-
def setup
|
21
|
-
@smiley = '☺' # chr 0x263A; in perl
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_codepage_only
|
25
|
-
properties = [[0x0001, 'VT_I2', 0x04E4]]
|
26
|
-
caption = " \tDoc properties: _create_property_set('Code page')"
|
27
|
-
target = %w(
|
28
|
-
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
29
|
-
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
30
|
-
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
31
|
-
18 00 00 00 01 00 00 00 01 00 00 00 10 00 00 00
|
32
|
-
02 00 00 00 E4 04 00 00
|
33
|
-
).join(' ')
|
34
|
-
|
35
|
-
result = unpack_record( create_summary_property_set(properties))
|
36
|
-
assert_equal(target, result, caption)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_same_as_previous_plus_title
|
40
|
-
properties = [
|
41
|
-
[0x0001, 'VT_I2', 0x04E4 ],
|
42
|
-
[0x0002, 'VT_LPSTR', 'Title'],
|
43
|
-
]
|
44
|
-
caption = " \tDoc properties: _create_property_set('+ Title')"
|
45
|
-
target = %w(
|
46
|
-
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
47
|
-
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
48
|
-
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
49
|
-
30 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
|
50
|
-
02 00 00 00 20 00 00 00 02 00 00 00 E4 04 00 00
|
51
|
-
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
52
|
-
).join(' ')
|
53
|
-
|
54
|
-
result = unpack_record( create_summary_property_set(properties))
|
55
|
-
assert_equal(target, result, caption)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_same_as_previous_plus_subject
|
59
|
-
properties = [
|
60
|
-
[0x0001, 'VT_I2', 0x04E4 ],
|
61
|
-
[0x0002, 'VT_LPSTR', 'Title'],
|
62
|
-
[0x0003, 'VT_LPSTR', 'Subject'],
|
63
|
-
]
|
64
|
-
caption = " \tDoc properties: _create_property_set('+ Subject')"
|
65
|
-
target = %w(
|
66
|
-
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
67
|
-
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
68
|
-
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
69
|
-
48 00 00 00 03 00 00 00 01 00 00 00 20 00 00 00
|
70
|
-
02 00 00 00 28 00 00 00 03 00 00 00 38 00 00 00
|
71
|
-
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
72
|
-
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
73
|
-
53 75 62 6A 65 63 74 00
|
74
|
-
).join(' ')
|
75
|
-
|
76
|
-
result = unpack_record( create_summary_property_set(properties))
|
77
|
-
assert_equal(target, result, caption)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_same_as_previous_plus_author
|
81
|
-
properties = [
|
82
|
-
[0x0001, 'VT_I2', 0x04E4 ],
|
83
|
-
[0x0002, 'VT_LPSTR', 'Title'],
|
84
|
-
[0x0003, 'VT_LPSTR', 'Subject'],
|
85
|
-
[0x0004, 'VT_LPSTR', 'Author' ],
|
86
|
-
]
|
87
|
-
caption = " \tDoc properties: _create_property_set('+ Keywords')"
|
88
|
-
target = %w(
|
89
|
-
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
90
|
-
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
91
|
-
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
92
|
-
60 00 00 00 04 00 00 00 01 00 00 00 28 00 00 00
|
93
|
-
02 00 00 00 30 00 00 00 03 00 00 00 40 00 00 00
|
94
|
-
04 00 00 00 50 00 00 00 02 00 00 00 E4 04 00 00
|
95
|
-
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
96
|
-
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
97
|
-
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
98
|
-
).join(' ')
|
99
|
-
|
100
|
-
result = unpack_record( create_summary_property_set(properties))
|
101
|
-
assert_equal(target, result, caption)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_same_as_previous_plus_keywords
|
105
|
-
properties = [
|
106
|
-
[0x0001, 'VT_I2', 0x04E4 ],
|
107
|
-
[0x0002, 'VT_LPSTR', 'Title'],
|
108
|
-
[0x0003, 'VT_LPSTR', 'Subject'],
|
109
|
-
[0x0004, 'VT_LPSTR', 'Author' ],
|
110
|
-
[0x0005, 'VT_LPSTR', 'Keywords'],
|
111
|
-
]
|
112
|
-
caption = " \tDoc properties: _create_property_set('+ Keywords')"
|
113
|
-
target = %w(
|
114
|
-
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
115
|
-
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
116
|
-
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
117
|
-
7C 00 00 00 05 00 00 00 01 00 00 00 30 00 00 00
|
118
|
-
02 00 00 00 38 00 00 00 03 00 00 00 48 00 00 00
|
119
|
-
04 00 00 00 58 00 00 00 05 00 00 00 68 00 00 00
|
120
|
-
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
121
|
-
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
122
|
-
53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
|
123
|
-
41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
|
124
|
-
4B 65 79 77 6F 72 64 73 00 00 00 00
|
125
|
-
).join(' ')
|
126
|
-
|
127
|
-
result = unpack_record( create_summary_property_set(properties))
|
128
|
-
assert_equal(target, result, caption)
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_same_as_previous_plus_comments
|
132
|
-
properties = [
|
133
|
-
[0x0001, 'VT_I2', 0x04E4 ],
|
134
|
-
[0x0002, 'VT_LPSTR', 'Title'],
|
135
|
-
[0x0003, 'VT_LPSTR', 'Subject'],
|
136
|
-
[0x0004, 'VT_LPSTR', 'Author' ],
|
137
|
-
[0x0005, 'VT_LPSTR', 'Keywords'],
|
138
|
-
[0x0006, 'VT_LPSTR', 'Comments'],
|
139
|
-
]
|
140
|
-
caption = " \tDoc properties: _create_property_set('+ Comments')"
|
141
|
-
target = %w(
|
142
|
-
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
143
|
-
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
144
|
-
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
145
|
-
98 00 00 00 06 00 00 00 01 00 00 00 38 00 00 00
|
146
|
-
02 00 00 00 40 00 00 00 03 00 00 00 50 00 00 00
|
147
|
-
04 00 00 00 60 00 00 00 05 00 00 00 70 00 00 00
|
148
|
-
06 00 00 00 84 00 00 00 02 00 00 00 E4 04 00 00
|
149
|
-
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
150
|
-
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
151
|
-
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
152
|
-
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
153
|
-
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
154
|
-
65 6E 74 73 00 00 00 00
|
155
|
-
).join(' ')
|
156
|
-
|
157
|
-
result = unpack_record( create_summary_property_set(properties))
|
158
|
-
assert_equal(target, result, caption)
|
159
|
-
end
|
160
|
-
|
161
|
-
def test_same_as_previous_plus_last_author
|
162
|
-
properties = [
|
163
|
-
[0x0001, 'VT_I2', 0x04E4 ],
|
164
|
-
[0x0002, 'VT_LPSTR', 'Title'],
|
165
|
-
[0x0003, 'VT_LPSTR', 'Subject'],
|
166
|
-
[0x0004, 'VT_LPSTR', 'Author' ],
|
167
|
-
[0x0005, 'VT_LPSTR', 'Keywords'],
|
168
|
-
[0x0006, 'VT_LPSTR', 'Comments'],
|
169
|
-
[0x0008, 'VT_LPSTR', 'Username'],
|
170
|
-
]
|
171
|
-
caption = " \tDoc properties: _create_property_set('+ Comments')"
|
172
|
-
target = %w(
|
173
|
-
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
174
|
-
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
175
|
-
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
176
|
-
B4 00 00 00 07 00 00 00 01 00 00 00 40 00 00 00
|
177
|
-
02 00 00 00 48 00 00 00 03 00 00 00 58 00 00 00
|
178
|
-
04 00 00 00 68 00 00 00 05 00 00 00 78 00 00 00
|
179
|
-
06 00 00 00 8C 00 00 00 08 00 00 00 A0 00 00 00
|
180
|
-
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
181
|
-
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
182
|
-
53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
|
183
|
-
41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
|
184
|
-
4B 65 79 77 6F 72 64 73 00 00 00 00 1E 00 00 00
|
185
|
-
09 00 00 00 43 6F 6D 6D 65 6E 74 73 00 00 00 00
|
186
|
-
1E 00 00 00 09 00 00 00 55 73 65 72 6E 61 6D 65
|
187
|
-
00 00 00 00
|
188
|
-
).join(' ')
|
189
|
-
|
190
|
-
result = unpack_record( create_summary_property_set(properties))
|
191
|
-
assert_equal(target, result, caption)
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_same_as_previous_plus_creation_date
|
195
|
-
filetime = Time.gm(2008,8,19,23,20,13)
|
196
|
-
properties = [
|
197
|
-
[0x0001, 'VT_I2', 0x04E4 ],
|
198
|
-
[0x0002, 'VT_LPSTR', 'Title'],
|
199
|
-
[0x0003, 'VT_LPSTR', 'Subject'],
|
200
|
-
[0x0004, 'VT_LPSTR', 'Author' ],
|
201
|
-
[0x0005, 'VT_LPSTR', 'Keywords'],
|
202
|
-
[0x0006, 'VT_LPSTR', 'Comments'],
|
203
|
-
[0x0008, 'VT_LPSTR', 'Username'],
|
204
|
-
[0x000C, 'VT_FILETIME', filetime ],
|
205
|
-
]
|
206
|
-
caption = " \tDoc properties: _create_property_set('+ Comments')"
|
207
|
-
target = %w(
|
208
|
-
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
209
|
-
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
210
|
-
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
211
|
-
C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
|
212
|
-
02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
|
213
|
-
04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
|
214
|
-
06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
|
215
|
-
0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
|
216
|
-
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
217
|
-
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
218
|
-
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
219
|
-
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
220
|
-
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
221
|
-
65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
|
222
|
-
55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
|
223
|
-
80 74 89 21 52 02 C9 01
|
224
|
-
).join(' ')
|
225
|
-
|
226
|
-
result = unpack_record( create_summary_property_set(properties))
|
227
|
-
assert_equal(target, result, caption)
|
228
|
-
end
|
229
|
-
|
230
|
-
###############################################################################
|
231
|
-
#
|
232
|
-
# Unpack the binary data into a format suitable for printing in tests.
|
233
|
-
#
|
234
|
-
def unpack_record(data)
|
235
|
-
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
236
|
-
end
|
237
|
-
|
238
|
-
end
|
1
|
+
##########################################################################
|
2
|
+
# test_41_properties.rb
|
3
|
+
#
|
4
|
+
# Tests for OLE property sets.
|
5
|
+
#
|
6
|
+
# reverse('©'), September 2005, 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
|
+
|
14
|
+
require 'test/unit'
|
15
|
+
require 'rubygems'
|
16
|
+
require 'writeexcel'
|
17
|
+
|
18
|
+
class TC_properties < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def setup
|
21
|
+
@smiley = '☺' # chr 0x263A; in perl
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_codepage_only
|
25
|
+
properties = [[0x0001, 'VT_I2', 0x04E4]]
|
26
|
+
caption = " \tDoc properties: _create_property_set('Code page')"
|
27
|
+
target = %w(
|
28
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
29
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
30
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
31
|
+
18 00 00 00 01 00 00 00 01 00 00 00 10 00 00 00
|
32
|
+
02 00 00 00 E4 04 00 00
|
33
|
+
).join(' ')
|
34
|
+
|
35
|
+
result = unpack_record( create_summary_property_set(properties))
|
36
|
+
assert_equal(target, result, caption)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_same_as_previous_plus_title
|
40
|
+
properties = [
|
41
|
+
[0x0001, 'VT_I2', 0x04E4 ],
|
42
|
+
[0x0002, 'VT_LPSTR', 'Title'],
|
43
|
+
]
|
44
|
+
caption = " \tDoc properties: _create_property_set('+ Title')"
|
45
|
+
target = %w(
|
46
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
47
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
48
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
49
|
+
30 00 00 00 02 00 00 00 01 00 00 00 18 00 00 00
|
50
|
+
02 00 00 00 20 00 00 00 02 00 00 00 E4 04 00 00
|
51
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
52
|
+
).join(' ')
|
53
|
+
|
54
|
+
result = unpack_record( create_summary_property_set(properties))
|
55
|
+
assert_equal(target, result, caption)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_same_as_previous_plus_subject
|
59
|
+
properties = [
|
60
|
+
[0x0001, 'VT_I2', 0x04E4 ],
|
61
|
+
[0x0002, 'VT_LPSTR', 'Title'],
|
62
|
+
[0x0003, 'VT_LPSTR', 'Subject'],
|
63
|
+
]
|
64
|
+
caption = " \tDoc properties: _create_property_set('+ Subject')"
|
65
|
+
target = %w(
|
66
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
67
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
68
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
69
|
+
48 00 00 00 03 00 00 00 01 00 00 00 20 00 00 00
|
70
|
+
02 00 00 00 28 00 00 00 03 00 00 00 38 00 00 00
|
71
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
72
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
73
|
+
53 75 62 6A 65 63 74 00
|
74
|
+
).join(' ')
|
75
|
+
|
76
|
+
result = unpack_record( create_summary_property_set(properties))
|
77
|
+
assert_equal(target, result, caption)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_same_as_previous_plus_author
|
81
|
+
properties = [
|
82
|
+
[0x0001, 'VT_I2', 0x04E4 ],
|
83
|
+
[0x0002, 'VT_LPSTR', 'Title'],
|
84
|
+
[0x0003, 'VT_LPSTR', 'Subject'],
|
85
|
+
[0x0004, 'VT_LPSTR', 'Author' ],
|
86
|
+
]
|
87
|
+
caption = " \tDoc properties: _create_property_set('+ Keywords')"
|
88
|
+
target = %w(
|
89
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
90
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
91
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
92
|
+
60 00 00 00 04 00 00 00 01 00 00 00 28 00 00 00
|
93
|
+
02 00 00 00 30 00 00 00 03 00 00 00 40 00 00 00
|
94
|
+
04 00 00 00 50 00 00 00 02 00 00 00 E4 04 00 00
|
95
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
96
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
97
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
98
|
+
).join(' ')
|
99
|
+
|
100
|
+
result = unpack_record( create_summary_property_set(properties))
|
101
|
+
assert_equal(target, result, caption)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_same_as_previous_plus_keywords
|
105
|
+
properties = [
|
106
|
+
[0x0001, 'VT_I2', 0x04E4 ],
|
107
|
+
[0x0002, 'VT_LPSTR', 'Title'],
|
108
|
+
[0x0003, 'VT_LPSTR', 'Subject'],
|
109
|
+
[0x0004, 'VT_LPSTR', 'Author' ],
|
110
|
+
[0x0005, 'VT_LPSTR', 'Keywords'],
|
111
|
+
]
|
112
|
+
caption = " \tDoc properties: _create_property_set('+ Keywords')"
|
113
|
+
target = %w(
|
114
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
115
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
116
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
117
|
+
7C 00 00 00 05 00 00 00 01 00 00 00 30 00 00 00
|
118
|
+
02 00 00 00 38 00 00 00 03 00 00 00 48 00 00 00
|
119
|
+
04 00 00 00 58 00 00 00 05 00 00 00 68 00 00 00
|
120
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
121
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
122
|
+
53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
|
123
|
+
41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
|
124
|
+
4B 65 79 77 6F 72 64 73 00 00 00 00
|
125
|
+
).join(' ')
|
126
|
+
|
127
|
+
result = unpack_record( create_summary_property_set(properties))
|
128
|
+
assert_equal(target, result, caption)
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_same_as_previous_plus_comments
|
132
|
+
properties = [
|
133
|
+
[0x0001, 'VT_I2', 0x04E4 ],
|
134
|
+
[0x0002, 'VT_LPSTR', 'Title'],
|
135
|
+
[0x0003, 'VT_LPSTR', 'Subject'],
|
136
|
+
[0x0004, 'VT_LPSTR', 'Author' ],
|
137
|
+
[0x0005, 'VT_LPSTR', 'Keywords'],
|
138
|
+
[0x0006, 'VT_LPSTR', 'Comments'],
|
139
|
+
]
|
140
|
+
caption = " \tDoc properties: _create_property_set('+ Comments')"
|
141
|
+
target = %w(
|
142
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
143
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
144
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
145
|
+
98 00 00 00 06 00 00 00 01 00 00 00 38 00 00 00
|
146
|
+
02 00 00 00 40 00 00 00 03 00 00 00 50 00 00 00
|
147
|
+
04 00 00 00 60 00 00 00 05 00 00 00 70 00 00 00
|
148
|
+
06 00 00 00 84 00 00 00 02 00 00 00 E4 04 00 00
|
149
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
150
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
151
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
152
|
+
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
153
|
+
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
154
|
+
65 6E 74 73 00 00 00 00
|
155
|
+
).join(' ')
|
156
|
+
|
157
|
+
result = unpack_record( create_summary_property_set(properties))
|
158
|
+
assert_equal(target, result, caption)
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_same_as_previous_plus_last_author
|
162
|
+
properties = [
|
163
|
+
[0x0001, 'VT_I2', 0x04E4 ],
|
164
|
+
[0x0002, 'VT_LPSTR', 'Title'],
|
165
|
+
[0x0003, 'VT_LPSTR', 'Subject'],
|
166
|
+
[0x0004, 'VT_LPSTR', 'Author' ],
|
167
|
+
[0x0005, 'VT_LPSTR', 'Keywords'],
|
168
|
+
[0x0006, 'VT_LPSTR', 'Comments'],
|
169
|
+
[0x0008, 'VT_LPSTR', 'Username'],
|
170
|
+
]
|
171
|
+
caption = " \tDoc properties: _create_property_set('+ Comments')"
|
172
|
+
target = %w(
|
173
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
174
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
175
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
176
|
+
B4 00 00 00 07 00 00 00 01 00 00 00 40 00 00 00
|
177
|
+
02 00 00 00 48 00 00 00 03 00 00 00 58 00 00 00
|
178
|
+
04 00 00 00 68 00 00 00 05 00 00 00 78 00 00 00
|
179
|
+
06 00 00 00 8C 00 00 00 08 00 00 00 A0 00 00 00
|
180
|
+
02 00 00 00 E4 04 00 00 1E 00 00 00 06 00 00 00
|
181
|
+
54 69 74 6C 65 00 00 00 1E 00 00 00 08 00 00 00
|
182
|
+
53 75 62 6A 65 63 74 00 1E 00 00 00 07 00 00 00
|
183
|
+
41 75 74 68 6F 72 00 00 1E 00 00 00 09 00 00 00
|
184
|
+
4B 65 79 77 6F 72 64 73 00 00 00 00 1E 00 00 00
|
185
|
+
09 00 00 00 43 6F 6D 6D 65 6E 74 73 00 00 00 00
|
186
|
+
1E 00 00 00 09 00 00 00 55 73 65 72 6E 61 6D 65
|
187
|
+
00 00 00 00
|
188
|
+
).join(' ')
|
189
|
+
|
190
|
+
result = unpack_record( create_summary_property_set(properties))
|
191
|
+
assert_equal(target, result, caption)
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_same_as_previous_plus_creation_date
|
195
|
+
filetime = Time.gm(2008,8,19,23,20,13)
|
196
|
+
properties = [
|
197
|
+
[0x0001, 'VT_I2', 0x04E4 ],
|
198
|
+
[0x0002, 'VT_LPSTR', 'Title'],
|
199
|
+
[0x0003, 'VT_LPSTR', 'Subject'],
|
200
|
+
[0x0004, 'VT_LPSTR', 'Author' ],
|
201
|
+
[0x0005, 'VT_LPSTR', 'Keywords'],
|
202
|
+
[0x0006, 'VT_LPSTR', 'Comments'],
|
203
|
+
[0x0008, 'VT_LPSTR', 'Username'],
|
204
|
+
[0x000C, 'VT_FILETIME', filetime ],
|
205
|
+
]
|
206
|
+
caption = " \tDoc properties: _create_property_set('+ Comments')"
|
207
|
+
target = %w(
|
208
|
+
FE FF 00 00 05 01 02 00 00 00 00 00 00 00 00 00
|
209
|
+
00 00 00 00 00 00 00 00 01 00 00 00 E0 85 9F F2
|
210
|
+
F9 4F 68 10 AB 91 08 00 2B 27 B3 D9 30 00 00 00
|
211
|
+
C8 00 00 00 08 00 00 00 01 00 00 00 48 00 00 00
|
212
|
+
02 00 00 00 50 00 00 00 03 00 00 00 60 00 00 00
|
213
|
+
04 00 00 00 70 00 00 00 05 00 00 00 80 00 00 00
|
214
|
+
06 00 00 00 94 00 00 00 08 00 00 00 A8 00 00 00
|
215
|
+
0C 00 00 00 BC 00 00 00 02 00 00 00 E4 04 00 00
|
216
|
+
1E 00 00 00 06 00 00 00 54 69 74 6C 65 00 00 00
|
217
|
+
1E 00 00 00 08 00 00 00 53 75 62 6A 65 63 74 00
|
218
|
+
1E 00 00 00 07 00 00 00 41 75 74 68 6F 72 00 00
|
219
|
+
1E 00 00 00 09 00 00 00 4B 65 79 77 6F 72 64 73
|
220
|
+
00 00 00 00 1E 00 00 00 09 00 00 00 43 6F 6D 6D
|
221
|
+
65 6E 74 73 00 00 00 00 1E 00 00 00 09 00 00 00
|
222
|
+
55 73 65 72 6E 61 6D 65 00 00 00 00 40 00 00 00
|
223
|
+
80 74 89 21 52 02 C9 01
|
224
|
+
).join(' ')
|
225
|
+
|
226
|
+
result = unpack_record( create_summary_property_set(properties))
|
227
|
+
assert_equal(target, result, caption)
|
228
|
+
end
|
229
|
+
|
230
|
+
###############################################################################
|
231
|
+
#
|
232
|
+
# Unpack the binary data into a format suitable for printing in tests.
|
233
|
+
#
|
234
|
+
def unpack_record(data)
|
235
|
+
data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|