line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookProps; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:JANDREW'; |
3
|
3
|
|
|
3
|
|
10309
|
use version; our $VERSION = version->declare('v0.16.8'); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
23
|
|
4
|
|
|
|
|
|
|
###LogSD warn "You uncovered internal logging statements for Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookProps-$VERSION"; |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
299
|
use Moose::Role; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
requires qw( |
8
|
|
|
|
|
|
|
current_node_parsed good_load close_the_file |
9
|
|
|
|
|
|
|
parse_element squash_node advance_element_position |
10
|
|
|
|
|
|
|
); |
11
|
3
|
|
|
3
|
|
11140
|
use Types::Standard qw( is_HashRef StrMatch Str ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
24
|
|
12
|
|
|
|
|
|
|
###LogSD use Log::Shiras::Telephone; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#########1 Dispatch Tables 3#########4#########5#########6#########7#########8#########9 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $method_lookup = { |
17
|
|
|
|
|
|
|
Author => '_set_creator', |
18
|
|
|
|
|
|
|
LastAuthor => '_set_modified_by', |
19
|
|
|
|
|
|
|
Created => '_set_date_created', |
20
|
|
|
|
|
|
|
LastSaved => '_set_date_modified', |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#########1 Public Attributes 3#########4#########5#########6#########7#########8#########9 |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#########1 Public Methods 3#########4#########5#########6#########7#########8#########9 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub load_unique_bits{ |
30
|
4
|
|
|
4
|
1
|
10
|
my( $self, ) = @_; |
31
|
|
|
|
|
|
|
###LogSD my $phone = Log::Shiras::Telephone->new( name_space => |
32
|
|
|
|
|
|
|
###LogSD $self->get_all_space . '::_load_unique_bits', ); |
33
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'debug', message => [ |
34
|
|
|
|
|
|
|
###LogSD "Setting the WorkbookPropsInterface unique bits" ] ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# turn workbook properties into a hashref |
37
|
4
|
50
|
33
|
|
|
8
|
if( (keys %{$self->current_node_parsed})[0] eq 'DocumentProperties' or $self->advance_element_position( 'DocumentProperties' ) ){ |
|
4
|
|
|
|
|
21
|
|
38
|
4
|
|
|
|
|
25
|
my $properties = $self->squash_node( $self->parse_element ); |
39
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'trace', message =>[ |
40
|
|
|
|
|
|
|
###LogSD "The parsed properties are:", $properties ] ); |
41
|
4
|
|
|
|
|
13
|
for my $header ( keys %$properties ){ |
42
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'debug', message => [ |
43
|
|
|
|
|
|
|
###LogSD "processing header: $header" ] ); |
44
|
21
|
100
|
|
|
|
36
|
if( exists $method_lookup->{$header} ){ |
45
|
12
|
|
|
|
|
14
|
my $method = $method_lookup->{$header}; |
46
|
|
|
|
|
|
|
my $value = is_HashRef( $properties->{$header} ) ? |
47
|
12
|
50
|
|
|
|
21
|
$properties->{$header}->{raw_text} : $properties->{$header}; |
48
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'trace', message => [ |
49
|
|
|
|
|
|
|
###LogSD "Implementing -$method- with value: $value" ] ); |
50
|
12
|
|
|
|
|
382
|
$self->$method( $value ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
4
|
|
|
|
|
137
|
$self->good_load( 1 ); |
54
|
|
|
|
|
|
|
}else{ |
55
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'warn', message =>[ "no cp:coreProperties found" ] ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
###LogSD $phone->talk( level => 'debug', message => [ |
59
|
|
|
|
|
|
|
###LogSD "Closing out the xml file" ] ); |
60
|
4
|
|
|
|
|
26
|
$self->close_the_file; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#########1 Private Attributes 3#########4#########5#########6#########7#########8#########9 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has _file_creator =>( |
66
|
|
|
|
|
|
|
isa => Str, |
67
|
|
|
|
|
|
|
reader => 'get_creator', |
68
|
|
|
|
|
|
|
writer => '_set_creator', |
69
|
|
|
|
|
|
|
clearer => '_clear_creator', |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has _file_modified_by =>( |
73
|
|
|
|
|
|
|
isa => Str, |
74
|
|
|
|
|
|
|
reader => 'get_modified_by', |
75
|
|
|
|
|
|
|
writer => '_set_modified_by', |
76
|
|
|
|
|
|
|
clearer => '_clear_modified_by', |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has _file_date_created =>( |
80
|
|
|
|
|
|
|
isa => StrMatch[qr/^\d{4}\-\d{2}\-\d{2}/], |
81
|
|
|
|
|
|
|
reader => 'get_date_created', |
82
|
|
|
|
|
|
|
writer => '_set_date_created', |
83
|
|
|
|
|
|
|
clearer => '_clear_date_created', |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
has _file_date_modified =>( |
87
|
|
|
|
|
|
|
isa => StrMatch[qr/^\d{4}\-\d{2}\-\d{2}/], |
88
|
|
|
|
|
|
|
reader => 'get_date_modified', |
89
|
|
|
|
|
|
|
writer => '_set_date_modified', |
90
|
|
|
|
|
|
|
clearer => '_clear_date_modified', |
91
|
|
|
|
|
|
|
); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#########1 Private Methods 3#########4#########5#########6#########7#########8#########9 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#########1 Phinish 3#########4#########5#########6#########7#########8#########9 |
98
|
|
|
|
|
|
|
|
99
|
3
|
|
|
3
|
|
2772
|
no Moose::Role; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
14
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#########1 Documentation 3#########4#########5#########6#########7#########8#########9 |
103
|
|
|
|
|
|
|
__END__ |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 NAME |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookProps - Workbook docProps XML file unique reader |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SYNOPSIS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
#!/usr/bin/env perl |
112
|
|
|
|
|
|
|
use MooseX::ShortCut::BuildInstance qw( build_instance ); |
113
|
|
|
|
|
|
|
use Types::Standard qw( HashRef ); |
114
|
|
|
|
|
|
|
use Spreadsheet::Reader::ExcelXML::XMLReader; |
115
|
|
|
|
|
|
|
use Spreadsheet::Reader::ExcelXML::WorkbookFileInterface; |
116
|
|
|
|
|
|
|
use Spreadsheet::Reader::ExcelXML::ZipReader::WorkbookProps; |
117
|
|
|
|
|
|
|
use Spreadsheet::Reader::ExcelXML::WorkbookPropsInterface; |
118
|
|
|
|
|
|
|
my $extractor_instance = build_instance( |
119
|
|
|
|
|
|
|
superclasses => ['Spreadsheet::Reader::ExcelXML::XMLReader'], |
120
|
|
|
|
|
|
|
package => 'ExtractorInstance', |
121
|
|
|
|
|
|
|
file => '../../../../t/test_files/TestBook.xml', |
122
|
|
|
|
|
|
|
add_roles_in_sequence =>[ |
123
|
|
|
|
|
|
|
'Spreadsheet::Reader::ExcelXML::WorkbookFileInterface', |
124
|
|
|
|
|
|
|
], |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
my $file_handle = $extractor_instance->extract_file( qw( DocumentProperties ) ); |
127
|
|
|
|
|
|
|
my $test_instance = build_instance( |
128
|
|
|
|
|
|
|
superclasses => ['Spreadsheet::Reader::ExcelXML::XMLReader'], |
129
|
|
|
|
|
|
|
package => 'WorkbookPropsInterface', |
130
|
|
|
|
|
|
|
add_roles_in_sequence =>[ |
131
|
|
|
|
|
|
|
'Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookProps', |
132
|
|
|
|
|
|
|
'Spreadsheet::Reader::ExcelXML::WorkbookPropsInterface', |
133
|
|
|
|
|
|
|
], |
134
|
|
|
|
|
|
|
file => $file_handle, |
135
|
|
|
|
|
|
|
); |
136
|
|
|
|
|
|
|
print $test_instance->$get_date_created . "\n"; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
########################### |
139
|
|
|
|
|
|
|
# SYNOPSIS Screen Output |
140
|
|
|
|
|
|
|
# 01: 2013-11-10T08:27:01Z |
141
|
|
|
|
|
|
|
########################### |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 DESCRIPTION |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This documentation is written to explain ways to use this module when writing your own |
146
|
|
|
|
|
|
|
excel parser. To use the general package for excel parsing out of the box please review |
147
|
|
|
|
|
|
|
the documentation for L<Workbooks|Spreadsheet::Reader::ExcelXML>, |
148
|
|
|
|
|
|
|
L<Worksheets|Spreadsheet::Reader::ExcelXML::Worksheet>, and |
149
|
|
|
|
|
|
|
L<Cells|Spreadsheet::Reader::ExcelXML::Cell> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is the XML based file adaptor for reading the workbook docProps data and then |
152
|
|
|
|
|
|
|
updating the general workbook metadata. The extracted data is accessible through |
153
|
|
|
|
|
|
|
L<Methods|/Methods>. The goal of this module is to standardize the outputs of this |
154
|
|
|
|
|
|
|
metadata from non standard inputs. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 Required Methods |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
These are the methods required by the role. A link to the default implementation of |
159
|
|
|
|
|
|
|
these methods is provided. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML::XMLReader/advance_element_position( $element, [$iterations] )> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML::XMLReader/good_load( $state )> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML::XMLReader/close_the_file> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML::XMLReader/parse_element( [$depth] )> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML::XMLReader/squash_node( $node )> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 Methods |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
These are the methods provided by this role (only). |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head3 load_unique_bits |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=over |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
B<Definition:> This role is meant to run on top of L<Spreadsheet::Reader::ExcelXML::XMLReader>. |
180
|
|
|
|
|
|
|
When it does the reader will call this function as available when it first starts the file. |
181
|
|
|
|
|
|
|
Therefore this is where the unique Metadata for this file is found and stored. (in the |
182
|
|
|
|
|
|
|
attributes) |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
B<Accepts:> nothing |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
B<Returns:> nothing |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=back |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head3 get_creator |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=over |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
B<Definition:> This returns the string stored in the file by Excel for the file creator. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
B<Accepts:> nothing |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
B<Returns:> the creator identification string |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=back |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head3 get_modified_by |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=over |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
B<Definition:> This returns the string stored in the file by Excel for the last file |
207
|
|
|
|
|
|
|
modification entity. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
B<Accepts:> nothing |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
B<Returns:> the identification string for the last entity to modify the file |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=back |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head3 get_date_created |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=over |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
B<Definition:> returns the date string for when the file was created in Excel |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
B<Accepts:> nothing |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
B<Returns:> a date string |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=back |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head3 get_date_modified |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=over |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
B<Definition:> returns the date string for when the file was last modified in Excel |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
B<Accepts:> nothing |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
B<Returns:> a date string |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=back |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head1 SUPPORT |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=over |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
L<github Spreadsheet::Reader::ExcelXML/issues |
244
|
|
|
|
|
|
|
|https://github.com/jandrew/p5-spreadsheet-reader-excelxml/issues> |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=back |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 TODO |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=over |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
B<1.> Nothing currently |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=back |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 AUTHOR |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=over |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=item Jed Lund |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=item jandrew@cpan.org |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=back |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head1 COPYRIGHT |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
This program is free software; you can redistribute |
269
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
The full text of the license can be found in the |
272
|
|
|
|
|
|
|
LICENSE file included with this module. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This software is copyrighted (c) 2016 by Jed Lund |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=over |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
L<Spreadsheet::Reader::ExcelXML> - the package |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=back |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 SEE ALSO |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=over |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
L<Spreadsheet::Read> - generic Spreadsheet reader |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
L<Spreadsheet::ParseExcel> - Excel binary version 2003 and earlier (.xls files) |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
L<Spreadsheet::XLSX> - Excel version 2007 and later |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
L<Spreadsheet::ParseXLSX> - Excel version 2007 and later |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
L<Log::Shiras|https://github.com/jandrew/Log-Shiras> |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=over |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
All lines in this package that use Log::Shiras are commented out |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=back |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=back |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=cut |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
#########1#########2 main pod documentation end 5#########6#########7#########8#########9 |