writeexcel 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,232 +1,232 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# BIFFwriter - An abstract base class for Excel workbooks and worksheets.
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# Used in conjunction with WriteExcel
|
7
|
-
#
|
8
|
-
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
9
|
-
#
|
10
|
-
# original written in Perl by John McNamara
|
11
|
-
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
require 'tempfile'
|
16
|
-
require 'writeexcel/write_file'
|
17
|
-
|
18
|
-
class BIFFWriter < WriteFile #:nodoc:
|
19
|
-
|
20
|
-
BIFF_Version = 0x0600
|
21
|
-
BigEndian = [1].pack("I") == [1].pack("N")
|
22
|
-
|
23
|
-
attr_reader :byte_order, :data, :datasize
|
24
|
-
|
25
|
-
######################################################################
|
26
|
-
# The args here aren't used by BIFFWriter, but they are needed by its
|
27
|
-
# subclasses. I don't feel like creating multiple constructors.
|
28
|
-
######################################################################
|
29
|
-
|
30
|
-
def initialize
|
31
|
-
set_byte_order
|
32
|
-
@data = ''
|
33
|
-
@datasize = 0
|
34
|
-
@limit = 8224
|
35
|
-
@ignore_continue = 0
|
36
|
-
|
37
|
-
# Open a tmp file to store the majority of the Worksheet data. If this fails,
|
38
|
-
# for example due to write permissions, store the data in memory. This can be
|
39
|
-
# slow for large files.
|
40
|
-
@filehandle = Tempfile.new('writeexcel')
|
41
|
-
@filehandle.binmode
|
42
|
-
|
43
|
-
# failed. store temporary data in memory.
|
44
|
-
@using_tmpfile = @filehandle ? true : false
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
###############################################################################
|
49
|
-
#
|
50
|
-
# _set_byte_order()
|
51
|
-
#
|
52
|
-
# Determine the byte order and store it as class data to avoid
|
53
|
-
# recalculating it for each call to new().
|
54
|
-
#
|
55
|
-
def set_byte_order
|
56
|
-
# Check if "pack" gives the required IEEE 64bit float
|
57
|
-
teststr = [1.2345].pack("d")
|
58
|
-
hexdata = [0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F]
|
59
|
-
number = hexdata.pack("C8")
|
60
|
-
|
61
|
-
if number == teststr
|
62
|
-
@byte_order = 0 # Little Endian
|
63
|
-
elsif number == teststr.reverse
|
64
|
-
@byte_order = 1 # Big Endian
|
65
|
-
else
|
66
|
-
# Give up. I'll fix this in a later version.
|
67
|
-
raise( "Required floating point format not supported " +
|
68
|
-
"on this platform. See the portability section " +
|
69
|
-
"of the documentation."
|
70
|
-
)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
###############################################################################
|
75
|
-
#
|
76
|
-
# get_data().
|
77
|
-
#
|
78
|
-
# Retrieves data from memory in one chunk, or from disk in $buffer
|
79
|
-
# sized chunks.
|
80
|
-
#
|
81
|
-
def get_data
|
82
|
-
buflen = 4096
|
83
|
-
|
84
|
-
# Return data stored in memory
|
85
|
-
unless @data.nil?
|
86
|
-
tmp = @data
|
87
|
-
@data = nil
|
88
|
-
if @using_tmpfile
|
89
|
-
@filehandle.open
|
90
|
-
@filehandle.binmode
|
91
|
-
end
|
92
|
-
return tmp
|
93
|
-
end
|
94
|
-
|
95
|
-
# Return data stored on disk
|
96
|
-
if @using_tmpfile
|
97
|
-
return @filehandle.read(buflen)
|
98
|
-
end
|
99
|
-
|
100
|
-
# No data to return
|
101
|
-
nil
|
102
|
-
end
|
103
|
-
|
104
|
-
###############################################################################
|
105
|
-
#
|
106
|
-
# _store_bof($type)
|
107
|
-
#
|
108
|
-
# $type = 0x0005, Workbook
|
109
|
-
# $type = 0x0010, Worksheet
|
110
|
-
# $type = 0x0020, Chart
|
111
|
-
#
|
112
|
-
# Writes Excel BOF record to indicate the beginning of a stream or
|
113
|
-
# sub-stream in the BIFF file.
|
114
|
-
#
|
115
|
-
def store_bof(type = 0x0005)
|
116
|
-
record = 0x0809 # Record identifier
|
117
|
-
length = 0x0010 # Number of bytes to follow
|
118
|
-
|
119
|
-
# According to the SDK $build and $year should be set to zero.
|
120
|
-
# However, this throws a warning in Excel 5. So, use these
|
121
|
-
# magic numbers.
|
122
|
-
build = 0x0DBB
|
123
|
-
year = 0x07CC
|
124
|
-
|
125
|
-
bfh = 0x00000041
|
126
|
-
sfo = 0x00000006
|
127
|
-
|
128
|
-
header = [record,length].pack("vv")
|
129
|
-
data = [BIFF_Version,type,build,year,bfh,sfo].pack("vvvvVV")
|
130
|
-
|
131
|
-
prepend(header, data)
|
132
|
-
end
|
133
|
-
|
134
|
-
###############################################################################
|
135
|
-
#
|
136
|
-
# _store_eof()
|
137
|
-
#
|
138
|
-
# Writes Excel EOF record to indicate the end of a BIFF stream.
|
139
|
-
#
|
140
|
-
def store_eof
|
141
|
-
record = 0x000A
|
142
|
-
length = 0x0000
|
143
|
-
header = [record,length].pack("vv")
|
144
|
-
|
145
|
-
append(header)
|
146
|
-
end
|
147
|
-
|
148
|
-
###############################################################################
|
149
|
-
#
|
150
|
-
# _add_continue()
|
151
|
-
#
|
152
|
-
# Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
|
153
|
-
# Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
154
|
-
# must be split up into CONTINUE blocks.
|
155
|
-
#
|
156
|
-
# This function take a long BIFF record and inserts CONTINUE records as
|
157
|
-
# necessary.
|
158
|
-
#
|
159
|
-
# Some records have their own specialised Continue blocks so there is also an
|
160
|
-
# option to bypass this function.
|
161
|
-
#
|
162
|
-
def add_continue(data)
|
163
|
-
record = 0x003C # Record identifier
|
164
|
-
|
165
|
-
# Skip this if another method handles the continue blocks.
|
166
|
-
return data if @ignore_continue != 0
|
167
|
-
|
168
|
-
# The first 2080/8224 bytes remain intact. However, we have to change
|
169
|
-
# the length field of the record.
|
170
|
-
#
|
171
|
-
|
172
|
-
# in perl
|
173
|
-
# $tmp = substr($data, 0, $limit, "");
|
174
|
-
if data.bytesize > @limit
|
175
|
-
tmp = data[0, @limit]
|
176
|
-
data[0, @limit] = ''
|
177
|
-
else
|
178
|
-
tmp = data.dup
|
179
|
-
data = ''
|
180
|
-
end
|
181
|
-
|
182
|
-
tmp[2, 2] = [@limit-4].pack('v')
|
183
|
-
|
184
|
-
# Strip out chunks of 2080/8224 bytes +4 for the header.
|
185
|
-
while (data.bytesize > @limit)
|
186
|
-
header = [record, @limit].pack("vv")
|
187
|
-
tmp += header + data[0, @limit]
|
188
|
-
data[0, @limit] = ''
|
189
|
-
end
|
190
|
-
|
191
|
-
# Mop up the last of the data
|
192
|
-
header = [record, data.bytesize].pack("vv")
|
193
|
-
tmp += header + data
|
194
|
-
end
|
195
|
-
|
196
|
-
###############################################################################
|
197
|
-
#
|
198
|
-
# _add_mso_generic()
|
199
|
-
# my $type = $_[0];
|
200
|
-
# my $version = $_[1];
|
201
|
-
# my $instance = $_[2];
|
202
|
-
# my $data = $_[3];
|
203
|
-
#
|
204
|
-
# Create a mso structure that is part of an Escher drawing object. These are
|
205
|
-
# are used for images, comments and filters. This generic method is used by
|
206
|
-
# other methods to create specific mso records.
|
207
|
-
#
|
208
|
-
# Returns the packed record.
|
209
|
-
#
|
210
|
-
def add_mso_generic(type, version, instance, data, length = nil)
|
211
|
-
length ||= data.bytesize
|
212
|
-
|
213
|
-
# The header contains version and instance info packed into 2 bytes.
|
214
|
-
header = version | (instance << 4)
|
215
|
-
|
216
|
-
record = [header, type, length].pack('vvV') + data
|
217
|
-
end
|
218
|
-
|
219
|
-
def not_using_tmpfile
|
220
|
-
@filehandle.close(true) if @filehandle
|
221
|
-
@filehandle = nil
|
222
|
-
@using_tmpfile = nil
|
223
|
-
end
|
224
|
-
|
225
|
-
def clear_data_for_test # :nodoc:
|
226
|
-
@data = ''
|
227
|
-
end
|
228
|
-
|
229
|
-
def cleanup # :nodoc:
|
230
|
-
@filehandle.close(true) if @filehandle
|
231
|
-
end
|
232
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# BIFFwriter - An abstract base class for Excel workbooks and worksheets.
|
4
|
+
#
|
5
|
+
#
|
6
|
+
# Used in conjunction with WriteExcel
|
7
|
+
#
|
8
|
+
# Copyright 2000-2010, John McNamara, jmcnamara@cpan.org
|
9
|
+
#
|
10
|
+
# original written in Perl by John McNamara
|
11
|
+
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
|
12
|
+
#
|
13
|
+
|
14
|
+
|
15
|
+
require 'tempfile'
|
16
|
+
require 'writeexcel/write_file'
|
17
|
+
|
18
|
+
class BIFFWriter < WriteFile #:nodoc:
|
19
|
+
|
20
|
+
BIFF_Version = 0x0600
|
21
|
+
BigEndian = [1].pack("I") == [1].pack("N")
|
22
|
+
|
23
|
+
attr_reader :byte_order, :data, :datasize
|
24
|
+
|
25
|
+
######################################################################
|
26
|
+
# The args here aren't used by BIFFWriter, but they are needed by its
|
27
|
+
# subclasses. I don't feel like creating multiple constructors.
|
28
|
+
######################################################################
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
set_byte_order
|
32
|
+
@data = ''
|
33
|
+
@datasize = 0
|
34
|
+
@limit = 8224
|
35
|
+
@ignore_continue = 0
|
36
|
+
|
37
|
+
# Open a tmp file to store the majority of the Worksheet data. If this fails,
|
38
|
+
# for example due to write permissions, store the data in memory. This can be
|
39
|
+
# slow for large files.
|
40
|
+
@filehandle = Tempfile.new('writeexcel')
|
41
|
+
@filehandle.binmode
|
42
|
+
|
43
|
+
# failed. store temporary data in memory.
|
44
|
+
@using_tmpfile = @filehandle ? true : false
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
###############################################################################
|
49
|
+
#
|
50
|
+
# _set_byte_order()
|
51
|
+
#
|
52
|
+
# Determine the byte order and store it as class data to avoid
|
53
|
+
# recalculating it for each call to new().
|
54
|
+
#
|
55
|
+
def set_byte_order
|
56
|
+
# Check if "pack" gives the required IEEE 64bit float
|
57
|
+
teststr = [1.2345].pack("d")
|
58
|
+
hexdata = [0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F]
|
59
|
+
number = hexdata.pack("C8")
|
60
|
+
|
61
|
+
if number == teststr
|
62
|
+
@byte_order = 0 # Little Endian
|
63
|
+
elsif number == teststr.reverse
|
64
|
+
@byte_order = 1 # Big Endian
|
65
|
+
else
|
66
|
+
# Give up. I'll fix this in a later version.
|
67
|
+
raise( "Required floating point format not supported " +
|
68
|
+
"on this platform. See the portability section " +
|
69
|
+
"of the documentation."
|
70
|
+
)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
###############################################################################
|
75
|
+
#
|
76
|
+
# get_data().
|
77
|
+
#
|
78
|
+
# Retrieves data from memory in one chunk, or from disk in $buffer
|
79
|
+
# sized chunks.
|
80
|
+
#
|
81
|
+
def get_data
|
82
|
+
buflen = 4096
|
83
|
+
|
84
|
+
# Return data stored in memory
|
85
|
+
unless @data.nil?
|
86
|
+
tmp = @data
|
87
|
+
@data = nil
|
88
|
+
if @using_tmpfile
|
89
|
+
@filehandle.open
|
90
|
+
@filehandle.binmode
|
91
|
+
end
|
92
|
+
return tmp
|
93
|
+
end
|
94
|
+
|
95
|
+
# Return data stored on disk
|
96
|
+
if @using_tmpfile
|
97
|
+
return @filehandle.read(buflen)
|
98
|
+
end
|
99
|
+
|
100
|
+
# No data to return
|
101
|
+
nil
|
102
|
+
end
|
103
|
+
|
104
|
+
###############################################################################
|
105
|
+
#
|
106
|
+
# _store_bof($type)
|
107
|
+
#
|
108
|
+
# $type = 0x0005, Workbook
|
109
|
+
# $type = 0x0010, Worksheet
|
110
|
+
# $type = 0x0020, Chart
|
111
|
+
#
|
112
|
+
# Writes Excel BOF record to indicate the beginning of a stream or
|
113
|
+
# sub-stream in the BIFF file.
|
114
|
+
#
|
115
|
+
def store_bof(type = 0x0005)
|
116
|
+
record = 0x0809 # Record identifier
|
117
|
+
length = 0x0010 # Number of bytes to follow
|
118
|
+
|
119
|
+
# According to the SDK $build and $year should be set to zero.
|
120
|
+
# However, this throws a warning in Excel 5. So, use these
|
121
|
+
# magic numbers.
|
122
|
+
build = 0x0DBB
|
123
|
+
year = 0x07CC
|
124
|
+
|
125
|
+
bfh = 0x00000041
|
126
|
+
sfo = 0x00000006
|
127
|
+
|
128
|
+
header = [record,length].pack("vv")
|
129
|
+
data = [BIFF_Version,type,build,year,bfh,sfo].pack("vvvvVV")
|
130
|
+
|
131
|
+
prepend(header, data)
|
132
|
+
end
|
133
|
+
|
134
|
+
###############################################################################
|
135
|
+
#
|
136
|
+
# _store_eof()
|
137
|
+
#
|
138
|
+
# Writes Excel EOF record to indicate the end of a BIFF stream.
|
139
|
+
#
|
140
|
+
def store_eof
|
141
|
+
record = 0x000A
|
142
|
+
length = 0x0000
|
143
|
+
header = [record,length].pack("vv")
|
144
|
+
|
145
|
+
append(header)
|
146
|
+
end
|
147
|
+
|
148
|
+
###############################################################################
|
149
|
+
#
|
150
|
+
# _add_continue()
|
151
|
+
#
|
152
|
+
# Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
|
153
|
+
# Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
154
|
+
# must be split up into CONTINUE blocks.
|
155
|
+
#
|
156
|
+
# This function take a long BIFF record and inserts CONTINUE records as
|
157
|
+
# necessary.
|
158
|
+
#
|
159
|
+
# Some records have their own specialised Continue blocks so there is also an
|
160
|
+
# option to bypass this function.
|
161
|
+
#
|
162
|
+
def add_continue(data)
|
163
|
+
record = 0x003C # Record identifier
|
164
|
+
|
165
|
+
# Skip this if another method handles the continue blocks.
|
166
|
+
return data if @ignore_continue != 0
|
167
|
+
|
168
|
+
# The first 2080/8224 bytes remain intact. However, we have to change
|
169
|
+
# the length field of the record.
|
170
|
+
#
|
171
|
+
|
172
|
+
# in perl
|
173
|
+
# $tmp = substr($data, 0, $limit, "");
|
174
|
+
if data.bytesize > @limit
|
175
|
+
tmp = data[0, @limit]
|
176
|
+
data[0, @limit] = ''
|
177
|
+
else
|
178
|
+
tmp = data.dup
|
179
|
+
data = ''
|
180
|
+
end
|
181
|
+
|
182
|
+
tmp[2, 2] = [@limit-4].pack('v')
|
183
|
+
|
184
|
+
# Strip out chunks of 2080/8224 bytes +4 for the header.
|
185
|
+
while (data.bytesize > @limit)
|
186
|
+
header = [record, @limit].pack("vv")
|
187
|
+
tmp += header + data[0, @limit]
|
188
|
+
data[0, @limit] = ''
|
189
|
+
end
|
190
|
+
|
191
|
+
# Mop up the last of the data
|
192
|
+
header = [record, data.bytesize].pack("vv")
|
193
|
+
tmp += header + data
|
194
|
+
end
|
195
|
+
|
196
|
+
###############################################################################
|
197
|
+
#
|
198
|
+
# _add_mso_generic()
|
199
|
+
# my $type = $_[0];
|
200
|
+
# my $version = $_[1];
|
201
|
+
# my $instance = $_[2];
|
202
|
+
# my $data = $_[3];
|
203
|
+
#
|
204
|
+
# Create a mso structure that is part of an Escher drawing object. These are
|
205
|
+
# are used for images, comments and filters. This generic method is used by
|
206
|
+
# other methods to create specific mso records.
|
207
|
+
#
|
208
|
+
# Returns the packed record.
|
209
|
+
#
|
210
|
+
def add_mso_generic(type, version, instance, data, length = nil)
|
211
|
+
length ||= data.bytesize
|
212
|
+
|
213
|
+
# The header contains version and instance info packed into 2 bytes.
|
214
|
+
header = version | (instance << 4)
|
215
|
+
|
216
|
+
record = [header, type, length].pack('vvV') + data
|
217
|
+
end
|
218
|
+
|
219
|
+
def not_using_tmpfile
|
220
|
+
@filehandle.close(true) if @filehandle
|
221
|
+
@filehandle = nil
|
222
|
+
@using_tmpfile = nil
|
223
|
+
end
|
224
|
+
|
225
|
+
def clear_data_for_test # :nodoc:
|
226
|
+
@data = ''
|
227
|
+
end
|
228
|
+
|
229
|
+
def cleanup # :nodoc:
|
230
|
+
@filehandle.close(true) if @filehandle
|
231
|
+
end
|
232
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
module CallerInfo
|
3
|
-
#
|
4
|
-
# return stack trace info if defined?($debug).
|
5
|
-
#
|
6
|
-
def caller_info
|
7
|
-
caller(3).collect { |info|
|
8
|
-
file = File.expand_path(info.sub(/:(\d+)[^\d`]*(`([^']+)')?/, ''))
|
9
|
-
{ :file => file, :line => $1, :method => $3 }
|
10
|
-
}.select { |info| info[:method] } # delete if info[:method] == nil
|
11
|
-
end
|
12
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module CallerInfo
|
3
|
+
#
|
4
|
+
# return stack trace info if defined?($debug).
|
5
|
+
#
|
6
|
+
def caller_info
|
7
|
+
caller(3).collect { |info|
|
8
|
+
file = File.expand_path(info.sub(/:(\d+)[^\d`]*(`([^']+)')?/, ''))
|
9
|
+
{ :file => file, :line => $1, :method => $3 }
|
10
|
+
}.select { |info| info[:method] } # delete if info[:method] == nil
|
11
|
+
end
|
12
|
+
end
|