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

filter: Statementstmt 98.6% 71 / 72 Branchbran 83.3% 15 / 18 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 92.7% 103 / 111 CC 12 SCAR 19.9
CC
12
Cov
94%
load_unique_bits
12.1
BEGIN
1.0
BEGIN
1.0
CRAP 7.3
« lib/Spreadsheet/Reader/ExcelXML/XMLReader/NamedStyles.pm ↑ Summary lib/Spreadsheet/Reader/ExcelXML/ZipReader/WorkbookMeta.pm »
1 package Spreadsheet::Reader::ExcelXML::XMLReader::WorkbookMeta;
2 3 our $AUTHORITY = 'cpan:JANDREW';
3 3 ▶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::XMLReader::WorkbookMeta-$VERSION";
5  
6 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 requires qw(
8 advance_element_position parse_element start_the_file_over
9 close_the_file squash_node current_node_parsed
10 next_sibling skip_siblings good_load
11 );
12 3 ▶use Types::Standard qw( Enum ArrayRef HashRef Bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use lib '../../../../../lib',;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 ###LogSD use Log::Shiras::Telephone;
15  
16 #########1 Dispatch Tables 3#########4#########5#########6#########7#########8#########9
17  
18  
19  
20 #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9
21  
22  
23  
24 #########1 Public Methods 3#########4#########5#########6#########7#########8#########9
25  
26 4 ▶sub load_unique_bits{
Subroutine load_unique_bits: called CC=12 SCAR=24.9
Pod documented
27 4 my( $self, ) = @_;
28 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
29 ###LogSD $self->get_all_space . '::load_unique_bits', );
30 ###LogSD $phone->talk( level => 'debug', message => [
31 ###LogSD "Setting the WorkbookMetaInterface unique bits" ] );
32  
33 # Set date epoch
34 4 $self->start_the_file_over;
35 4 my( $result, $node_name, $node_level, $node_ref ) = $self->advance_element_position( 'Date1904' );
36 ###LogSD $phone->talk( level => 'debug', message => [
37 ###LogSD "Apple date search result: " . ($result//'undef') ] );
38 4 my $epoch_start = 1900;
39 4 ▶ if( $result ){
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 3 1 4
40 3 my $workbookPr_ref = $self->parse_element;
41 ###LogSD $phone->talk( level => 'debug', message => [
42 ###LogSD "This is a 1904 epoch sheet" ] );
43 3 $epoch_start = 1904;
44 }
45 ###LogSD $phone->talk( level => 'debug', message => [
46 ###LogSD "Setting epoch start to: $epoch_start" ] );
47 4 $self->_set_epoch_year( $epoch_start );
48 ###LogSD $phone->talk( level => 'trace', message =>[ "Epoch year set" ] );
49  
50 # Build sheet list
51 4 my( $sheet_lookup, $id_lookup, $sheet_list );
52 4 $self->start_the_file_over;
53 4 ( $result, $node_name, $node_level, $node_ref ) = $self->advance_element_position( 'Worksheet' );# Chartsheets don't appear to be allowed in SpreadsheetML format
54 ###LogSD $phone->talk( level => 'debug', message => [
55 ###LogSD "Arrived at node name -$node_name- with result: $result" ] );
56 4 ▶ if( $result ){
Branch: 1 branch
BranchTrueFalseTotal
if ($result) { } 4 0 4
57 4 my $position = 0;
58 4 my $top_ref = $self->current_node_parsed;
59 ###LogSD $phone->talk( level => 'debug', message => [
60 ###LogSD "Current node parsed to:", $top_ref ] );
61 4 ▶ COLLECTSHEETDATA: while( $node_name eq 'Worksheet' ){# Redundant on the first pass
Branch: 1 branch
BranchTrueFalseTotal
if ($node_name eq "Worksheet") 10 0 10
62 10 my $sheet_name = $top_ref->{Worksheet}->{'ss:Name'};
63 10 my $sheet_id = $position + 1;
64 10 push @$sheet_list, $sheet_name;
65 10 $id_lookup->{$sheet_id} = $sheet_name;
66 ###LogSD $phone->talk( level => 'debug', message =>[
67 ###LogSD "Worksheet node named: $sheet_name",
68 ###LogSD "Worksheet position: $position",
69 ###LogSD "Worksheet ID: $sheet_id", $top_ref, $sheet_list, $id_lookup ] );
70 10 ( $result, $node_name, $node_level, $node_ref ) = $self->advance_element_position;
71 ###LogSD $phone->talk( level => 'debug', message => [
72 ###LogSD "Arrived at node name -$node_name- with result: $result" ] );
73 10 ▶ last COLLECTSHEETDATA if !$result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 0 10 10
74 10 my $lower_ref = $self->current_node_parsed;
75 ###LogSD $phone->talk( level => 'debug', message =>[ "Lower node is:", $lower_ref ] );
76 10 ▶ COLLECTWORKSHEETOPTIONS: while( $result and $node_name ne 'WorksheetOptions' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($result and $node_name ne "WorksheetOptions") 10 9 19
Condition66%2/3
$result and $node_name ne "WorksheetOptions"
!ll&&!rl&&r
0910
MC/DC50%1/2
$result and $node_name ne "WorksheetOptions"
$result $node_name ne "WorksheetOptions"
Truth table66%2/3
A and B
A= $resultB= $node_name ne "WorksheetOptions"
ABresult
0X0
100
111
77 10 ( $result, $node_name, $node_level, $node_ref ) = $self->next_sibling;
78 10 ▶ last COLLECTWORKSHEETOPTIONS if !$result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 1 9 10
79 ###LogSD $phone->talk( level => 'debug', message =>[
80 ###LogSD "Next sibling node may be: $node_name", ] );
81 }
82 # Load the sheet settings
83 10 my $options_ref;
84 10 ▶ if( $result ){# For specific settings in the file
Branch: 1 branch
BranchTrueFalseTotal
if ($result) 9 1 10
85 9 $options_ref = $self->squash_node( $self->parse_element );
86 ###LogSD $phone->talk( level => 'trace', message =>[
87 ###LogSD "Fulls WorksheetOptions node:", $options_ref ] );
88 9 delete $options_ref->{raw_text};
89 9 delete $options_ref->{xmlns};
90 }
91 $options_ref->{is_hidden} =
92 10 ▶ (exists $options_ref->{Visible} and $options_ref->{Visible} eq 'SheetHidden') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $options_ref->{'Visible'} && $options_ref->{'Visible'} eq 'SheetHidden' ? : 3 7 10
Condition66%2/3
exists $options_ref->{"Visible"} and $options_ref->{"Visible"} eq "SheetHidden"
!ll&&!rl&&r
703
MC/DC50%1/2
exists $options_ref->{"Visible"} and $options_ref->{"Visible"} eq "SheetHidden"
exists $options_ref->{"Visible"} $options_ref->{"Visible"} eq "SheetHidden"
Truth table66%2/3
A and B
A= exists $options_ref->{"Visible"}B= $options_ref->{"Visible"} eq "SheetHidden"
ABresult
0X0
100
111
93 10 @$options_ref{qw( sheet_id sheet_name sheet_position )} =
94 ( $sheet_id, $sheet_name, $position );
95 ###LogSD $phone->talk( level => 'debug', message =>[
96 ###LogSD "Built sheet data:", $options_ref ] );
97 10 $sheet_lookup->{$sheet_name} = $options_ref;
98 ###LogSD $phone->talk( level => 'trace', message =>[
99 ###LogSD "Updated sheet lookup:", $sheet_lookup, $self->current_node_parsed ] );
100 10 ( $result, $node_name, $node_level, $node_ref ) = $self->advance_element_position( 'Worksheet' );
101 ###LogSD $phone->talk( level => 'debug', message =>[
102 ###LogSD "Advanced to node -$node_name- with the result: " . ($result//'') ] );
103 10 ▶ last COLLECTSHEETDATA if !$result;
Branch: 1 branch
BranchTrueFalseTotal
unless $result 4 6 10
104 6 $top_ref = $self->current_node_parsed;
105 ###LogSD $phone->talk( level => 'debug', message =>[ "Next top node is:", $top_ref] );
106 6 $position++;
107 }
108 ###LogSD $phone->talk( level => 'info', message =>[ "Made it out of COLLECTSHEETDATA" ] );
109 }else{
110 0 confess "Could not find any worksheets";
111 }
112  
113 ###LogSD $phone->talk( level => 'debug', message =>[ "Setting attributes" ] );
114 4 $self->_set_sheet_list( $sheet_list );
115 4 $self->_set_sheet_lookup( $sheet_lookup );
116 4 $self->_set_id_lookup( $id_lookup );
117 4 $self->close_the_file;
118 4 $self->good_load( 1 );
119 ###LogSD $phone->talk( level => 'info', message =>[ "Returning" ] );
120 4 return 1;
121 }
122  
123  
124  
125 #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9
126  
127 3 has _epoch_year =>(
128 isa => Enum[qw( 1900 1904 )],
129 writer => '_set_epoch_year',
130 reader => 'get_epoch_year',
131 default => 1900,
132 );
133  
134 has _sheet_list =>(
135 isa => ArrayRef,
136 traits => ['Array'],
137 writer => '_set_sheet_list',
138 clearer => '_clear_sheet_list',
139 reader => 'get_sheet_list',
140 handles =>{
141 _get_sheet_name => 'get',
142 _sheet_count => 'count',
143 },
144 4 ▶ default => sub{ [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
145 3 );
146  
147 has _sheet_lookup =>(
148 isa => HashRef,
149 traits => ['Hash'],
150 writer => '_set_sheet_lookup',
151 clearer => '_clear_sheet_lookup',
152 reader => 'get_sheet_lookup',
153 handles =>{
154 _get_sheet_info => 'get',
155 _set_sheet_info => 'set',
156 },
157 4 ▶ default => sub{ {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
158 3 );
159  
160 has _rel_lookup =>(
161 isa => HashRef,
162 traits => ['Hash'],
163 writer => '_set_rel_lookup',
164 reader => 'get_rel_lookup',
165 handles =>{
166 _get_rel_info => 'get',
167 },
168 4 ▶ default => sub{ {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
169 3 );
170  
171 has _id_lookup =>(
172 isa => HashRef,
173 traits => ['Hash'],
174 writer => '_set_id_lookup',
175 reader => 'get_id_lookup',
176 handles =>{
177 _get_id_info => 'get',
178 },
179 4 ▶ default => sub{ {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
180 3 );
181  
182 #########1 Private Methods 3#########4#########5#########6#########7#########8#########9
183  
184  
185  
186 #########1 Phinish 3#########4#########5#########6#########7#########8#########9
187  
188 3 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
189 3 1;
190  
191 #########1 Documentation 3#########4#########5#########6#########7#########8#########9
192 __END__
« lib/Spreadsheet/Reader/ExcelXML/XMLReader/NamedStyles.pm ↑ Summary lib/Spreadsheet/Reader/ExcelXML/ZipReader/WorkbookMeta.pm »