line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Excel::Writer::XLSX::Package::Core; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Core - A class for writing the Excel XLSX core.xml file. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Used in conjunction with Excel::Writer::XLSX |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Copyright 2000-2020, John McNamara, jmcnamara@cpan.org |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Documentation after __END__ |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# perltidy with the following options: -mbl=2 -pt=0 -nola |
15
|
|
|
|
|
|
|
|
16
|
1081
|
|
|
1081
|
|
17695
|
use 5.008002; |
|
1081
|
|
|
|
|
3586
|
|
17
|
1081
|
|
|
1081
|
|
7720
|
use strict; |
|
1081
|
|
|
|
|
2042
|
|
|
1081
|
|
|
|
|
20665
|
|
18
|
1081
|
|
|
1081
|
|
7169
|
use warnings; |
|
1081
|
|
|
|
|
3316
|
|
|
1081
|
|
|
|
|
23611
|
|
19
|
1081
|
|
|
1081
|
|
7493
|
use Carp; |
|
1081
|
|
|
|
|
3568
|
|
|
1081
|
|
|
|
|
54392
|
|
20
|
1081
|
|
|
1081
|
|
9327
|
use Excel::Writer::XLSX::Package::XMLwriter; |
|
1081
|
|
|
|
|
3652
|
|
|
1081
|
|
|
|
|
907910
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our @ISA = qw(Excel::Writer::XLSX::Package::XMLwriter); |
23
|
|
|
|
|
|
|
our $VERSION = '1.07'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
############################################################################### |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
# Public and private API methods. |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
############################################################################### |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# new() |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# Constructor. |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
sub new { |
40
|
|
|
|
|
|
|
|
41
|
852
|
|
|
852
|
0
|
4227
|
my $class = shift; |
42
|
852
|
|
|
|
|
1641
|
my $fh = shift; |
43
|
852
|
|
|
|
|
3158
|
my $self = Excel::Writer::XLSX::Package::XMLwriter->new( $fh ); |
44
|
|
|
|
|
|
|
|
45
|
852
|
|
|
|
|
2713
|
$self->{_properties} = {}; |
46
|
852
|
|
|
|
|
6291
|
$self->{_createtime} = [ gmtime() ]; |
47
|
|
|
|
|
|
|
|
48
|
852
|
|
|
|
|
2330
|
bless $self, $class; |
49
|
|
|
|
|
|
|
|
50
|
852
|
|
|
|
|
2545
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
############################################################################### |
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
# _assemble_xml_file() |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
# Assemble and write the XML file. |
59
|
|
|
|
|
|
|
# |
60
|
|
|
|
|
|
|
sub _assemble_xml_file { |
61
|
|
|
|
|
|
|
|
62
|
851
|
|
|
851
|
|
2116
|
my $self = shift; |
63
|
|
|
|
|
|
|
|
64
|
851
|
|
|
|
|
7157
|
$self->xml_declaration; |
65
|
851
|
|
|
|
|
4885
|
$self->_write_cp_core_properties(); |
66
|
851
|
|
|
|
|
4381
|
$self->_write_dc_title(); |
67
|
851
|
|
|
|
|
3925
|
$self->_write_dc_subject(); |
68
|
851
|
|
|
|
|
4037
|
$self->_write_dc_creator(); |
69
|
851
|
|
|
|
|
4384
|
$self->_write_cp_keywords(); |
70
|
851
|
|
|
|
|
3630
|
$self->_write_dc_description(); |
71
|
851
|
|
|
|
|
3550
|
$self->_write_cp_last_modified_by(); |
72
|
851
|
|
|
|
|
4051
|
$self->_write_dcterms_created(); |
73
|
851
|
|
|
|
|
4009
|
$self->_write_dcterms_modified(); |
74
|
851
|
|
|
|
|
4511
|
$self->_write_cp_category(); |
75
|
851
|
|
|
|
|
4809
|
$self->_write_cp_content_status(); |
76
|
|
|
|
|
|
|
|
77
|
851
|
|
|
|
|
6190
|
$self->xml_end_tag( 'cp:coreProperties' ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Close the XML writer filehandle. |
80
|
851
|
|
|
|
|
5957
|
$self->xml_get_fh()->close(); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
############################################################################### |
85
|
|
|
|
|
|
|
# |
86
|
|
|
|
|
|
|
# _set_properties() |
87
|
|
|
|
|
|
|
# |
88
|
|
|
|
|
|
|
# Set the document properties. |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
sub _set_properties { |
91
|
|
|
|
|
|
|
|
92
|
851
|
|
|
851
|
|
2158
|
my $self = shift; |
93
|
851
|
|
|
|
|
1833
|
my $properties = shift; |
94
|
|
|
|
|
|
|
|
95
|
851
|
|
|
|
|
6453
|
$self->{_properties} = $properties; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
############################################################################### |
100
|
|
|
|
|
|
|
# |
101
|
|
|
|
|
|
|
# Internal methods. |
102
|
|
|
|
|
|
|
# |
103
|
|
|
|
|
|
|
############################################################################### |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
############################################################################### |
107
|
|
|
|
|
|
|
# |
108
|
|
|
|
|
|
|
# _datetime_to_iso8601_date() |
109
|
|
|
|
|
|
|
# |
110
|
|
|
|
|
|
|
# Convert a gmtime/localtime() date to a ISO 8601 style "2010-01-01T00:00:00Z" |
111
|
|
|
|
|
|
|
# date. Excel always treats this as a utc date/time. |
112
|
|
|
|
|
|
|
# |
113
|
|
|
|
|
|
|
sub _datetime_to_iso8601_date { |
114
|
|
|
|
|
|
|
|
115
|
1702
|
|
|
1702
|
|
3489
|
my $self = shift; |
116
|
1702
|
|
66
|
|
|
8449
|
my $gmtime = shift || $self->{_createtime}; |
117
|
|
|
|
|
|
|
|
118
|
1702
|
|
|
|
|
5472
|
my ( $seconds, $minutes, $hours, $day, $month, $year ) = @$gmtime; |
119
|
|
|
|
|
|
|
|
120
|
1702
|
|
|
|
|
3047
|
$month++; |
121
|
1702
|
|
|
|
|
4805
|
$year += 1900; |
122
|
|
|
|
|
|
|
|
123
|
1702
|
|
|
|
|
10538
|
my $date = sprintf "%4d-%02d-%02dT%02d:%02d:%02dZ", $year, $month, $day, |
124
|
|
|
|
|
|
|
$hours, $minutes, $seconds; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
############################################################################### |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
# XML writing methods. |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
############################################################################### |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
############################################################################### |
136
|
|
|
|
|
|
|
# |
137
|
|
|
|
|
|
|
# _write_cp_core_properties() |
138
|
|
|
|
|
|
|
# |
139
|
|
|
|
|
|
|
# Write the element. |
140
|
|
|
|
|
|
|
# |
141
|
|
|
|
|
|
|
sub _write_cp_core_properties { |
142
|
|
|
|
|
|
|
|
143
|
851
|
|
|
851
|
|
2413
|
my $self = shift; |
144
|
851
|
|
|
|
|
3114
|
my $xmlns_cp = |
145
|
|
|
|
|
|
|
'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'; |
146
|
851
|
|
|
|
|
1782
|
my $xmlns_dc = 'http://purl.org/dc/elements/1.1/'; |
147
|
851
|
|
|
|
|
1736
|
my $xmlns_dcterms = 'http://purl.org/dc/terms/'; |
148
|
851
|
|
|
|
|
1953
|
my $xmlns_dcmitype = 'http://purl.org/dc/dcmitype/'; |
149
|
851
|
|
|
|
|
1720
|
my $xmlns_xsi = 'http://www.w3.org/2001/XMLSchema-instance'; |
150
|
|
|
|
|
|
|
|
151
|
851
|
|
|
|
|
4092
|
my @attributes = ( |
152
|
|
|
|
|
|
|
'xmlns:cp' => $xmlns_cp, |
153
|
|
|
|
|
|
|
'xmlns:dc' => $xmlns_dc, |
154
|
|
|
|
|
|
|
'xmlns:dcterms' => $xmlns_dcterms, |
155
|
|
|
|
|
|
|
'xmlns:dcmitype' => $xmlns_dcmitype, |
156
|
|
|
|
|
|
|
'xmlns:xsi' => $xmlns_xsi, |
157
|
|
|
|
|
|
|
); |
158
|
|
|
|
|
|
|
|
159
|
851
|
|
|
|
|
5965
|
$self->xml_start_tag( 'cp:coreProperties', @attributes ); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
############################################################################### |
164
|
|
|
|
|
|
|
# |
165
|
|
|
|
|
|
|
# _write_dc_creator() |
166
|
|
|
|
|
|
|
# |
167
|
|
|
|
|
|
|
# Write the element. |
168
|
|
|
|
|
|
|
# |
169
|
|
|
|
|
|
|
sub _write_dc_creator { |
170
|
|
|
|
|
|
|
|
171
|
851
|
|
|
851
|
|
2242
|
my $self = shift; |
172
|
851
|
|
100
|
|
|
6933
|
my $data = $self->{_properties}->{author} || ''; |
173
|
|
|
|
|
|
|
|
174
|
851
|
|
|
|
|
6127
|
$self->xml_data_element( 'dc:creator', $data ); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
############################################################################### |
179
|
|
|
|
|
|
|
# |
180
|
|
|
|
|
|
|
# _write_cp_last_modified_by() |
181
|
|
|
|
|
|
|
# |
182
|
|
|
|
|
|
|
# Write the element. |
183
|
|
|
|
|
|
|
# |
184
|
|
|
|
|
|
|
sub _write_cp_last_modified_by { |
185
|
|
|
|
|
|
|
|
186
|
851
|
|
|
851
|
|
2154
|
my $self = shift; |
187
|
851
|
|
100
|
|
|
6341
|
my $data = $self->{_properties}->{author} || ''; |
188
|
|
|
|
|
|
|
|
189
|
851
|
|
|
|
|
3795
|
$self->xml_data_element( 'cp:lastModifiedBy', $data ); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
############################################################################### |
194
|
|
|
|
|
|
|
# |
195
|
|
|
|
|
|
|
# _write_dcterms_created() |
196
|
|
|
|
|
|
|
# |
197
|
|
|
|
|
|
|
# Write the element. |
198
|
|
|
|
|
|
|
# |
199
|
|
|
|
|
|
|
sub _write_dcterms_created { |
200
|
|
|
|
|
|
|
|
201
|
851
|
|
|
851
|
|
2619
|
my $self = shift; |
202
|
851
|
|
|
|
|
2714
|
my $date = $self->{_properties}->{created}; |
203
|
851
|
|
|
|
|
2021
|
my $xsi_type = 'dcterms:W3CDTF'; |
204
|
|
|
|
|
|
|
|
205
|
851
|
|
|
|
|
3834
|
$date = $self->_datetime_to_iso8601_date( $date ); |
206
|
|
|
|
|
|
|
|
207
|
851
|
|
|
|
|
3931
|
my @attributes = ( 'xsi:type' => $xsi_type, ); |
208
|
|
|
|
|
|
|
|
209
|
851
|
|
|
|
|
4455
|
$self->xml_data_element( 'dcterms:created', $date, @attributes ); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
############################################################################### |
214
|
|
|
|
|
|
|
# |
215
|
|
|
|
|
|
|
# _write_dcterms_modified() |
216
|
|
|
|
|
|
|
# |
217
|
|
|
|
|
|
|
# Write the element. |
218
|
|
|
|
|
|
|
# |
219
|
|
|
|
|
|
|
sub _write_dcterms_modified { |
220
|
|
|
|
|
|
|
|
221
|
851
|
|
|
851
|
|
3574
|
my $self = shift; |
222
|
851
|
|
|
|
|
3191
|
my $date = $self->{_properties}->{created}; |
223
|
851
|
|
|
|
|
3401
|
my $xsi_type = 'dcterms:W3CDTF'; |
224
|
|
|
|
|
|
|
|
225
|
851
|
|
|
|
|
3731
|
$date = $self->_datetime_to_iso8601_date( $date ); |
226
|
|
|
|
|
|
|
|
227
|
851
|
|
|
|
|
3735
|
my @attributes = ( 'xsi:type' => $xsi_type, ); |
228
|
|
|
|
|
|
|
|
229
|
851
|
|
|
|
|
4454
|
$self->xml_data_element( 'dcterms:modified', $date, @attributes ); |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
############################################################################## |
234
|
|
|
|
|
|
|
# |
235
|
|
|
|
|
|
|
# _write_dc_title() |
236
|
|
|
|
|
|
|
# |
237
|
|
|
|
|
|
|
# Write the element. |
238
|
|
|
|
|
|
|
# |
239
|
|
|
|
|
|
|
sub _write_dc_title { |
240
|
|
|
|
|
|
|
|
241
|
851
|
|
|
851
|
|
2239
|
my $self = shift; |
242
|
851
|
|
|
|
|
2255
|
my $data = $self->{_properties}->{title}; |
243
|
|
|
|
|
|
|
|
244
|
851
|
100
|
|
|
|
3445
|
return unless $data; |
245
|
|
|
|
|
|
|
|
246
|
2
|
|
|
|
|
10
|
$self->xml_data_element( 'dc:title', $data ); |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
############################################################################## |
251
|
|
|
|
|
|
|
# |
252
|
|
|
|
|
|
|
# _write_dc_subject() |
253
|
|
|
|
|
|
|
# |
254
|
|
|
|
|
|
|
# Write the element. |
255
|
|
|
|
|
|
|
# |
256
|
|
|
|
|
|
|
sub _write_dc_subject { |
257
|
|
|
|
|
|
|
|
258
|
851
|
|
|
851
|
|
2459
|
my $self = shift; |
259
|
851
|
|
|
|
|
2787
|
my $data = $self->{_properties}->{subject}; |
260
|
|
|
|
|
|
|
|
261
|
851
|
100
|
|
|
|
3741
|
return unless $data; |
262
|
|
|
|
|
|
|
|
263
|
2
|
|
|
|
|
13
|
$self->xml_data_element( 'dc:subject', $data ); |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
############################################################################## |
268
|
|
|
|
|
|
|
# |
269
|
|
|
|
|
|
|
# _write_cp_keywords() |
270
|
|
|
|
|
|
|
# |
271
|
|
|
|
|
|
|
# Write the element. |
272
|
|
|
|
|
|
|
# |
273
|
|
|
|
|
|
|
sub _write_cp_keywords { |
274
|
|
|
|
|
|
|
|
275
|
851
|
|
|
851
|
|
2351
|
my $self = shift; |
276
|
851
|
|
|
|
|
2419
|
my $data = $self->{_properties}->{keywords}; |
277
|
|
|
|
|
|
|
|
278
|
851
|
100
|
|
|
|
3546
|
return unless $data; |
279
|
|
|
|
|
|
|
|
280
|
2
|
|
|
|
|
5
|
$self->xml_data_element( 'cp:keywords', $data ); |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
############################################################################## |
285
|
|
|
|
|
|
|
# |
286
|
|
|
|
|
|
|
# _write_dc_description() |
287
|
|
|
|
|
|
|
# |
288
|
|
|
|
|
|
|
# Write the element. |
289
|
|
|
|
|
|
|
# |
290
|
|
|
|
|
|
|
sub _write_dc_description { |
291
|
|
|
|
|
|
|
|
292
|
851
|
|
|
851
|
|
2067
|
my $self = shift; |
293
|
851
|
|
|
|
|
2211
|
my $data = $self->{_properties}->{comments}; |
294
|
|
|
|
|
|
|
|
295
|
851
|
100
|
|
|
|
3514
|
return unless $data; |
296
|
|
|
|
|
|
|
|
297
|
2
|
|
|
|
|
7
|
$self->xml_data_element( 'dc:description', $data ); |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
############################################################################## |
302
|
|
|
|
|
|
|
# |
303
|
|
|
|
|
|
|
# _write_cp_category() |
304
|
|
|
|
|
|
|
# |
305
|
|
|
|
|
|
|
# Write the element. |
306
|
|
|
|
|
|
|
# |
307
|
|
|
|
|
|
|
sub _write_cp_category { |
308
|
|
|
|
|
|
|
|
309
|
851
|
|
|
851
|
|
2636
|
my $self = shift; |
310
|
851
|
|
|
|
|
2835
|
my $data = $self->{_properties}->{category}; |
311
|
|
|
|
|
|
|
|
312
|
851
|
100
|
|
|
|
4245
|
return unless $data; |
313
|
|
|
|
|
|
|
|
314
|
2
|
|
|
|
|
7
|
$self->xml_data_element( 'cp:category', $data ); |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
############################################################################## |
319
|
|
|
|
|
|
|
# |
320
|
|
|
|
|
|
|
# _write_cp_content_status() |
321
|
|
|
|
|
|
|
# |
322
|
|
|
|
|
|
|
# Write the element. |
323
|
|
|
|
|
|
|
# |
324
|
|
|
|
|
|
|
sub _write_cp_content_status { |
325
|
|
|
|
|
|
|
|
326
|
851
|
|
|
851
|
|
2224
|
my $self = shift; |
327
|
851
|
|
|
|
|
2397
|
my $data = $self->{_properties}->{status}; |
328
|
|
|
|
|
|
|
|
329
|
851
|
100
|
|
|
|
3703
|
return unless $data; |
330
|
|
|
|
|
|
|
|
331
|
2
|
|
|
|
|
6
|
$self->xml_data_element( 'cp:contentStatus', $data ); |
332
|
|
|
|
|
|
|
} |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
1; |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
__END__ |