lib/Spreadsheet/Reader/ExcelXML/ZipReader/WorkbookMeta.pm

filter: Statementstmt 100% 60 / 60 Branchbran 68.7% 11 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 94.1% 81 / 86 CC 11 SCAR 19.3
CC
11
Cov
93%
load_unique_bits
11.1
BEGIN
1.0
BEGIN
1.0
CRAP 6.9
« lib/Spreadsheet/Reader/ExcelXML/XMLReader/WorkbookMeta.pm ↑ Summary lib/Spreadsheet/Reader/ExcelXML/ZipReader/WorkbookRels.pm »
1 package Spreadsheet::Reader::ExcelXML::ZipReader::WorkbookMeta;
2 14 our $AUTHORITY = 'cpan:JANDREW';
3 14 ▶use version; our $VERSION = version->declare('v0.16.8');
Subroutine BEGIN: called CC=1 SCAR=0.0
4 ###LogSD warn "You uncovered internal logging statements for Spreadsheet::Reader::ExcelXML::ZipReader::WorkbookMeta-$VERSION";
5  
6 14 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 requires qw(
8 advance_element_position parse_element start_the_file_over
9 close_the_file squash_node good_load
10 );
11 14 ▶use Types::Standard qw( Enum ArrayRef HashRef Bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 ###LogSD use Log::Shiras::Telephone;
13  
14 #########1 Dispatch Tables 3#########4#########5#########6#########7#########8#########9
15  
16  
17  
18 #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9
19  
20  
21  
22 #########1 Public Methods 3#########4#########5#########6#########7#########8#########9
23  
24 17 ▶sub load_unique_bits{
Subroutine load_unique_bits: called CC=11 SCAR=24.1
Pod documented
25 17 my( $self, ) = @_;
26 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
27 ###LogSD $self->get_all_space . '::load_unique_bits', );
28 ###LogSD $phone->talk( level => 'debug', message => [
29 ###LogSD "Setting the WorkbookMetaInterface unique bits" ] );
30  
31 # Set date epoch
32 #~ $self->start_the_file_over;
33 17 my( $result, $node_name, $node_level, $result_ref ) = $self->advance_element_position( 'workbookPr' );
34 17 my $epoch_start = 1900;
35 17 ▶ if( $result ){
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 17 0 17
36 17 my $workbookPr_ref = $self->squash_node( $self->parse_element );
37 ###LogSD $phone->talk( level => 'debug', message => [
38 ###LogSD "parsed workbookPr ref is:", $workbookPr_ref ] );
39 17 ▶ $epoch_start = $workbookPr_ref->{date1904} ? 1904 : 1900;
Branch: 1 branch
BranchTrueFalseTotal
$workbookPr_ref->{'date1904'} ? : 9 8 17
40 }
41 ###LogSD $phone->talk( level => 'debug', message => [
42 ###LogSD "Setting epoch start to: $epoch_start" ] );
43 17 $self->_set_epoch_year( $epoch_start );
44  
45 # Build sheet list
46 17 $result = undef;
47 17 for my $top_node (qw( sheets ) ){
48 ###LogSD $phone->talk( level => 'debug', message => [
49 ###LogSD "Attempting to match the workbook node to: $top_node" ] );
50 17 $self->start_the_file_over;
51 17 ( $result, $node_name, $node_level, $result_ref ) = $self->advance_element_position( $top_node );
52 17 ▶ last if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 17 0 17
53 }
54 17 ▶ confess "Could not find any sheets" if !$result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 17 17
55  
56 # pull sheet list to perl ref
57 17 my $sheets_node = $self->squash_node( $self->parse_element );
58 ###LogSD $phone->talk( level => 'debug', message => [
59 ###LogSD "parsed sheets ref is:", $sheets_node ] );
60  
61 # handle single sheet
62 17 ▶ if( (keys %$sheets_node)[0] eq 'sheet' ){
Branch: 1 branch
BranchTrueFalseTotal
if ((keys %$sheets_node)[0] eq "sheet") 4 13 17
63 4 $sheets_node->{list} = [ $sheets_node->{sheet} ];
64 4 delete $sheets_node->{sheet};
65 ###LogSD $phone->talk( level => 'debug', message => [
66 ###LogSD "after handling a single sheet case the sheets ref is:", $sheets_node ] );
67 }
68  
69 # Scrub worksheet and chartsheet level
70 17 my $x = 0;
71 17 my ( $list, $rel_lookup, $id_lookup, $new_sheet_ref );
72 17 for my $sheet ( @{$sheets_node->{list}} ){
73 ###LogSD $phone->talk( level => 'debug', message => [
74 ###LogSD "Processing sheet position -$x- with:", $sheet, ] );
75 41 ▶ $sheet->{sheetId} = ($x + 1) if !exists $sheet->{sheetId};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $sheet->{"sheetId"} 0 41 41
76 41 ▶ $sheet->{'r:id'} = 'rId' . ($x + 1) if !exists $sheet->{'r:id'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $sheet->{"r:id"} 0 41 41
77 41 push @$list, $sheet->{name};
78 41 @{$new_sheet_ref->{$sheet->{name}}}{ 'sheet_id', 'sheet_rel_id', 'sheet_position', 'is_hidden', 'sheet_name' } = (
79 $sheet->{sheetId}, $sheet->{'r:id'}, $x, (exists $sheet->{state} ? 1 : 0), $sheet->{name},
80 41 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
exists $sheet->{'state'} ? : 10 31 41
81 #~ $new_sheet_ref->{$sheet->{name}}->{sheet_type} = $sheet->{sheet_type} if exists $sheet->{sheet_type}; # This seems like something I want but I don't know why
82 41 $rel_lookup->{$sheet->{'r:id'}} = $sheet->{name};
83 41 $id_lookup->{$sheet->{sheetId}} = $sheet->{name};
84 41 $x++;
85 }
86 ###LogSD $phone->talk( level => 'debug', message => [
87 ###LogSD "updated sheet ref is:", $new_sheet_ref,
88 ###LogSD "sheet list is:", $list,
89 ###LogSD "rel lookup is:", $rel_lookup,
90 ###LogSD "id lookup is:", $id_lookup ] );
91  
92 #~ # Add pivot cache lookups
93 #~ $self->start_the_file_over;
94 #~ $result = $self->advance_element_position( 'pivotCaches' );;
95 #~ my $pivot_ref = $self->parse_element;
96 #~ ###LogSD $phone->talk( level => 'debug', message => [
97 #~ ###LogSD "parsed pivot ref is:", $pivot_ref ] );
98  
99 #~ # Clean up xml ref as needed
100 #~ if( exists $pivot_ref->{pivotCache} ){
101 #~ push @{$pivot_ref->{list}}, clone( $pivot_ref->{pivotCache} );
102 #~ delete $pivot_ref->{pivotCache};
103 #~ ###LogSD $phone->talk( level => 'debug', message => [
104 #~ ###LogSD "updated pivot ref is:", $pivot_ref ] );
105 #~ }
106 #~ if( exists $pivot_ref->{list} ){
107 #~ for my $pivot ( @{$pivot_ref->{list}} ){
108 #~ ###LogSD $phone->talk( level => 'debug', message => [
109 #~ ###LogSD "Processing pivot:", $pivot] );
110 #~ $pivot->{cacheId} = $x if !exists $pivot->{cacheId};
111 #~ $pivot->{'r:id'} = "rId$x" if !exists $pivot->{'r:id'};
112 #~ $rel_lookup->{$pivot->{'r:id'}} = $pivot->{cacheId};
113 #~ $id_lookup->{$pivot->{cacheId}} = $pivot->{'r:id'};
114 #~ $x++;
115 #~ }
116 #~ ###LogSD $phone->talk( level => 'debug', message => [
117 #~ ###LogSD "final rel lookup is:", $rel_lookup,
118 #~ ###LogSD "final id lookup is:", $id_lookup ] );
119 #~ }
120  
121 17 $self->_set_sheet_list( $list );
122 17 $self->_set_sheet_lookup( $new_sheet_ref );
123 17 $self->_set_rel_lookup( $rel_lookup );
124 17 $self->_set_id_lookup( $id_lookup );
125 17 $self->close_the_file;
126 17 $self->good_load( 1 );# exit 1;
127 }
128  
129 #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9
130  
131 14 has _epoch_year =>(
132 isa => Enum[qw( 1900 1904 )],
133 writer => '_set_epoch_year',
134 reader => 'get_epoch_year',
135 default => 1900,
136 );
137  
138 has _sheet_list =>(
139 isa => ArrayRef,
140 traits => ['Array'],
141 writer => '_set_sheet_list',
142 clearer => '_clear_sheet_list',
143 reader => 'get_sheet_list',
144 handles =>{
145 _get_sheet_name => 'get',
146 _sheet_count => 'count',
147 },
148 17 ▶ default => sub{ [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
149 14 );
150  
151 has _sheet_lookup =>(
152 isa => HashRef,
153 traits => ['Hash'],
154 writer => '_set_sheet_lookup',
155 clearer => '_clear_sheet_lookup',
156 reader => 'get_sheet_lookup',
157 handles =>{
158 _get_sheet_info => 'get',
159 _set_sheet_info => 'set',
160 },
161 17 ▶ default => sub{ {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
162 14 );
163  
164 has _rel_lookup =>(
165 isa => HashRef,
166 traits => ['Hash'],
167 writer => '_set_rel_lookup',
168 reader => 'get_rel_lookup',
169 handles =>{
170 _get_rel_info => 'get',
171 },
172 17 ▶ default => sub{ {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
173 14 );
174  
175 has _id_lookup =>(
176 isa => HashRef,
177 traits => ['Hash'],
178 writer => '_set_id_lookup',
179 reader => 'get_id_lookup',
180 handles =>{
181 _get_id_info => 'get',
182 },
183 17 ▶ default => sub{ {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
184 14 );
185  
186 #########1 Private Methods 3#########4#########5#########6#########7#########8#########9
187  
188  
189  
190 #########1 Phinish 3#########4#########5#########6#########7#########8#########9
191  
192 14 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
193 14 1;
194  
195 #########1 Documentation 3#########4#########5#########6#########7#########8#########9
196 __END__
« lib/Spreadsheet/Reader/ExcelXML/XMLReader/WorkbookMeta.pm ↑ Summary lib/Spreadsheet/Reader/ExcelXML/ZipReader/WorkbookRels.pm »