lib/Spreadsheet/Reader/ExcelXML/Worksheet.pm

filter: Statementstmt 91.4% 331 / 362 Branchbran 82.6% 205 / 248 Conditioncond 67.3% 101 / 150 MC/DCmcdc 51.2% 41 / 80 Subroutinesub 100% 29 / 29 Podpod 94.1% 16 / 17 totaltotal 81.6% 723 / 886 CC 187 SCAR 36.9
CC
187
Cov
84%
_build_out_the_cell
88.7
set_custom_formats
30.0
get_next_value
21.9
CRAP 40.2
« lib/Spreadsheet/Reader/ExcelXML/XMLReader/NamedWorksheet.pm ↑ Summary lib/Spreadsheet/Reader/ExcelXML/XMLReader/PositionSharedStrings.pm »
1 package Spreadsheet::Reader::ExcelXML::Worksheet;
2 18 our $AUTHORITY = 'cpan:JANDREW';
3 18 ▶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::Worksheet-$VERSION";
5  
6 18 ▶use Modern::Perl;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Carp 'confess';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 requires qw(
10 set_error parse_excel_format_string get_used_position
11 get_excel_position _min_row _max_row
12 _max_col _min_col get_merge_map
13 get_custom_column_data parse_column_row _parse_column_row
14 get_custom_row_data get_group_return_type change_output_encoding
15 get_error_inst has_styles_interface has_max_row
16 get_new_column is_empty_the_end go_to_or_past_row
17 boundary_flag_setting has_max_col get_format
18 get_new_next_value has_new_row_inst get_values_only
19 get_new_row_all get_new_row_number
20 );
21 ###LogSD requires 'get_log_space', 'get_all_space';
22 18 ▶use Types::Standard qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
23 Bool HasMethods Enum
24 Int is_Int ArrayRef
25 is_ArrayRef HashRef is_HashRef
26 is_Object Str is_Str
27 18 );# Int
28 18 ▶use lib '../../../../lib',;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 ###LogSD use Log::Shiras::Telephone;
30  
31 18 ▶use Spreadsheet::Reader::ExcelXML::Cell;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 18 ▶use Spreadsheet::Reader::ExcelXML::Types qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
33 SpecialDecimal SpecialZeroScientific
34 SpecialOneScientific SpecialTwoScientific
35 SpecialThreeScientific SpecialFourScientific
36 SpecialFiveScientific
37 18 );
38  
39 #########1 Dispatch Tables 3#########4#########5#########6#########7#########8#########9
40  
41 18 my $format_headers =[ qw(
42 cell_font cell_border cell_style
43 cell_fill cell_coercion cell_alignment
44 ) ];
45  
46 #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9
47  
48 18 has sheet_type =>(
49 isa => Enum[ 'worksheet' ],
50 default => 'worksheet',
51 reader => 'get_sheet_type',
52 );
53  
54 18 has sheet_rel_id =>(
55 isa => Str,
56 reader => 'rel_id',
57 );
58  
59 18 has sheet_id =>(
60 isa => Int,
61 reader => 'sheet_id',
62 );
63  
64 18 has sheet_position =>(# XML position
65 isa => Int,
66 reader => 'position',
67 );
68  
69 18 has sheet_name =>(
70 isa => Str,
71 reader => 'get_name',
72 predicate => '_has_name',
73 );
74  
75 18 has min_header_col =>(
76 isa => Int,
77 reader => 'get_min_header_col',
78 writer => 'set_min_header_col',
79 clearer => 'clear_min_header_col',
80 predicate => 'has_min_header_col'
81 );
82  
83 18 has max_header_col =>(
84 isa => Int,
85 reader => 'get_max_header_col',
86 writer => 'set_max_header_col',
87 clearer => 'clear_max_header_col',
88 predicate => 'has_max_header_col'
89 );
90  
91 #########1 Public Methods 3#########4#########5#########6#########7#########8#########9
92  
93 ###LogSD sub get_class_space{ 'Worksheet' }
94  
95 1 ▶sub min_row{
Subroutine min_row: called CC=1 SCAR=0.0
Pod documented
96 1 my( $self ) = @_;
97 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
98 ###LogSD $self->get_all_space . '::row_bound::min_row', );
99 ###LogSD $phone->talk( level => 'debug', message => [
100 ###LogSD "Returning the minimum row" ] );
101 1 my $code_min = $self->_min_row;
102 # Convert to user numbers
103 1 my $user_min = $self->get_used_position( $code_min );
104 ###LogSD $phone->talk( level => 'debug', message =>[
105 ###LogSD "Returning -$user_min- for row: $code_min" ] );
106 1 return $user_min;
107 }
108  
109 2 ▶sub max_row{
Subroutine max_row: called CC=2 SCAR=6.9
Pod documented
110 2 my( $self ) = @_;
111 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
112 ###LogSD $self->get_all_space . '::row_bound::max_row', );
113 ###LogSD $phone->talk( level => 'debug', message => [
114 ###LogSD "Returning the maximum row" ] );
115 2 my $code_max = $self->_max_row;
116 2 ▶ if( defined $code_max ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code_max) { } 1 1 2
117 # Convert to user numbers
118 1 my $user_max = $self->get_used_position( $code_max );
119 ###LogSD $phone->talk( level => 'debug', message =>[
120 ###LogSD "Returning -$user_max- for row: $code_max" ] );
121 1 return $user_max;
122 }else{
123 ###LogSD $phone->talk( level => 'debug', message =>[
124 ###LogSD "No stored value for max row" ] );
125 1 return undef;
126 }
127 }
128  
129 11 ▶sub min_col{
Subroutine min_col: called CC=1 SCAR=0.0
Pod documented
130 11 my( $self ) = @_;
131 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
132 ###LogSD $self->get_all_space . '::row_bound::min_col', );
133 ###LogSD $phone->talk( level => 'debug', message => [
134 ###LogSD "Returning the minimum column" ] );
135 11 my $code_min = $self->_min_col;
136 # Convert to user numbers
137 11 my $user_min = $self->get_used_position( $code_min );
138 ###LogSD $phone->talk( level => 'debug', message =>[
139 ###LogSD "Returning -$user_min- for column: $code_min" ] );
140 11 return $user_min;
141 }
142  
143 75 ▶sub max_col{
Subroutine max_col: called CC=2 SCAR=6.9
Pod documented
144 75 my( $self ) = @_;
145 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
146 ###LogSD $self->get_all_space . '::row_bound::max_col', );
147 ###LogSD $phone->talk( level => 'debug', message => [
148 ###LogSD "Returning the maximum column" ] );
149 75 my $code_max = $self->_max_col;
150 75 ▶ if( defined $code_max ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code_max) { } 74 1 75
151 # Convert to user numbers
152 74 my $user_max = $self->get_used_position( $code_max );
153 ###LogSD $phone->talk( level => 'debug', message =>[
154 ###LogSD "Returning -$user_max- for column: $code_max" ] );
155 74 return $user_max;
156 }else{
157 ###LogSD $phone->talk( level => 'debug', message =>[
158 ###LogSD "No stored value for max column" ] );
159 1 return undef;
160 }
161 }
162  
163 10 ▶sub row_range{
Subroutine row_range: called CC=2 SCAR=6.9
Pod documented
164 10 my( $self ) = @_;
165 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
166 ###LogSD $self->get_all_space . '::row_bound::row_range', );
167 ###LogSD $phone->talk( level => 'debug', message => [
168 ###LogSD "Returning row range" ] );
169 10 my $code_min = $self->_min_row;
170 # Convert to user numbers
171 10 my $user_min = $self->get_used_position( $code_min );
172 ###LogSD $phone->talk( level => 'debug', message =>[
173 ###LogSD "Returning -$user_min- for row: $code_min" ] );
174 10 my $code_max = $self->_max_row;
175 10 my $user_max;
176 10 ▶ if( defined $code_max ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code_max) { } 9 1 10
177 # Convert to user numbers
178 9 $user_max = $self->get_used_position( $code_max );
179 ###LogSD $phone->talk( level => 'debug', message =>[
180 ###LogSD "Returning -$user_max- for row: $code_max" ] );
181 }else{
182 ###LogSD $phone->talk( level => 'debug', message =>[
183 ###LogSD "No stored value for max row" ] );
184 }
185 10 return( $user_min, $user_max );
186 }
187  
188 10 ▶sub col_range{
Subroutine col_range: called CC=2 SCAR=6.9
Pod documented
189 10 my( $self ) = @_;
190 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
191 ###LogSD $self->get_all_space . '::row_bound::col_range', );
192 ###LogSD $phone->talk( level => 'debug', message => [
193 ###LogSD "Returning col range" ] );
194 10 my $code_min = $self->_min_col;
195 # Convert to user numbers
196 10 my $user_min = $self->get_used_position( $code_min );
197 ###LogSD $phone->talk( level => 'debug', message =>[
198 ###LogSD "Returning -$user_min- for column: $code_min" ] );
199 10 my $code_max = $self->_max_col;
200 10 my $user_max;
201 10 ▶ if( defined $code_max ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code_max) { } 9 1 10
202 # Convert to user numbers
203 9 $user_max = $self->get_used_position( $code_max );
204 ###LogSD $phone->talk( level => 'debug', message =>[
205 ###LogSD "Returning -$user_max- for column: $code_max" ] );
206 }else{
207 ###LogSD $phone->talk( level => 'debug', message =>[
208 ###LogSD "No stored value for max row" ] );
209 }
210 10 return( $user_min, $user_max );
211 }
212  
213 1 ▶sub get_merged_areas{
Subroutine get_merged_areas: called CC=7 SCAR=19.5
Pod documented
214 1 my( $self, ) = @_;
215 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
216 ###LogSD $self->get_all_space . '::get_merged_areas', );
217 ###LogSD $phone->talk( level => 'debug', message => [
218 ###LogSD 'Pulling the merge map ParseExcel style' ] );
219  
220 # Get the raw merge map
221 1 my $raw_map = $self->get_merge_map;
222 ###LogSD $phone->talk( level => 'trace', message =>[
223 ###LogSD "Raw merge row map;", $raw_map] );
224 1 my ( $new_map, $dup_ref );
225 #parse out the empty rows
226 1 for my $row ( @$raw_map ){
227 4 ▶ next if !$row;
Branch: 1 branch
BranchTrueFalseTotal
unless $row 1 3 4
228 ###LogSD $phone->talk( level => 'trace', message =>[
229 ###LogSD "Processing the merge row data:", $row] );
230 3 for my $merge_cell ( @$row ){
231 10 ▶ next if !$merge_cell;
Branch: 1 branch
BranchTrueFalseTotal
unless $merge_cell 4 6 10
232 6 ▶ next if exists $dup_ref->{$merge_cell};
Branch: 1 branch
BranchTrueFalseTotal
if exists $dup_ref->{$merge_cell} 4 2 6
233 ###LogSD $phone->talk( level => 'trace', message =>[
234 ###LogSD "Processing the merge row data: $merge_cell"] );
235 2 my $merge_ref;
236 2 for my $cell ( split /:/, $merge_cell ){
237 4 my ( $column, $row ) = $self->parse_column_row( $cell );
238 4 push @$merge_ref, $row, $column;
239 ###LogSD $phone->talk( level => 'trace', message =>[
240 ###LogSD "Updated merge ref:", $merge_ref] );
241 }
242 2 $dup_ref->{$merge_cell} = 1;
243 2 push @$new_map, $merge_ref;
244 ###LogSD $phone->talk( level => 'trace', message =>[
245 ###LogSD "Updated merge areas:", $new_map] );
246 }
247 }
248 ###LogSD $phone->talk( level => 'info', message =>[
249 ###LogSD "Final merge areas:", $new_map] );
250 1 return $new_map;
251 }
252  
253 2 ▶sub is_column_hidden{
Subroutine is_column_hidden: called CC=9 SCAR=22.2
Pod documented
254 2 my( $self, @column_requests ) = @_;
255 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
256 ###LogSD $self->get_all_space . '::is_column_hidden', );
257 ###LogSD $phone->talk( level => 'debug', message => [
258 ###LogSD 'Pulling the hidden state for the columns:', @column_requests ] );
259  
260 2 my @result_list;
261 2 for my $item ( @column_requests ){
262 12 my $column;
263 12 ▶ if( is_Int( $item ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (&is_Int($item)) { } 6 6 12
264 6 $column = $self->get_excel_position( $item );
265 }else{
266 6 ( $column, my $dummy_row ) = $self->_parse_column_row( $item );
267 ###LogSD $phone->talk( level => 'trace', message => [
268 ###LogSD "Parsed -$item- to column number: $column" ] );
269 }
270 12 my $column_formats = $self->get_custom_column_data( $column );
271 push @result_list,
272 ( $column < $self->_min_col or $self->_max_col < $column ) ? undef :
273 12 ▶ ( $column_formats and exists $column_formats->{hidden}) ? $column_formats->{hidden} : 0;
Branch: 2 branches
BranchTrueFalseTotal
$column < $self->_min_col || $self->_max_col < $column ? : 0 12 12
$column_formats && exists $column_formats->{'hidden'} ? : 4 8 12
Condition66%4/6
$column < $self->_min_col or $self->_max_col < $column
l!l&&r!l&&!r
0012
$column_formats and exists $column_formats->{"hidden"}
!ll&&!rl&&r
444
MC/DC0%0/2
$column < $self->_min_col or $self->_max_col < $column
$column < $self->_min_col $self->_max_col < $column
MC/DC100%2/2
$column_formats and exists $column_formats->{"hidden"}
$column_formats exists $column_formats->{"hidden"}
Truth table33%1/3
A or B
A= $column < $self->_min_colB= $self->_max_col < $column
ABresult
1X1
011
000
Truth table100%3/3
A and B
A= $column_formatsB= exists $column_formats->{"hidden"}
ABresult
0X0
100
111
274 }
275 2 my $true = 0;
276 2 ▶ map{ $true = 1 if $_ } @result_list;
Branch: 1 branch
BranchTrueFalseTotal
if $_ 4 8 12
277 ###LogSD $phone->talk( level => 'info', message =>[
278 ###LogSD "Final column hidden state is -$true- with list:", @result_list ] );
279 2 ▶ return wantarray ? @result_list : $true;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 0 2
280 }
281  
282 1 ▶sub is_row_hidden{
Subroutine is_row_hidden: called CC=8 SCAR=20.8
Pod documented
283 1 my( $self, @row_requests ) = @_;
284 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
285 ###LogSD $self->get_all_space . '::is_row_hidden', );
286 ###LogSD $phone->talk( level => 'debug', message => [
287 ###LogSD 'Pulling the hidden state for the rows:', [@row_requests] ] );
288  
289 1 my @result_list;
290 1 for my $row ( @row_requests ){
291 16 my $code_row = $self->get_excel_position( $row );
292 ###LogSD $phone->talk( level => 'debug', message =>[
293 ###LogSD "Sending excel row -$code_row- for used row: $row" ] );
294 16 my $row_formats = $self->get_custom_row_data( $code_row );
295 ###LogSD $phone->talk( level => 'debug', message =>[
296 ###LogSD "Returned row formats:", $row_formats ] );
297 push @result_list,
298 ( $code_row < $self->_min_row or $self->_max_row < $code_row ) ? undef :
299 16 ▶ ($row_formats and exists $row_formats->{hidden}) ? $row_formats->{hidden} : 0;
Branch: 2 branches
BranchTrueFalseTotal
$code_row < $self->_min_row || $self->_max_row < $code_row ? : 2 14 16
$row_formats && exists $row_formats->{'hidden'} ? : 5 9 14
Condition83%5/6
$code_row < $self->_min_row or $self->_max_row < $code_row
l!l&&r!l&&!r
0214
$row_formats and exists $row_formats->{"hidden"}
!ll&&!rl&&r
455
MC/DC50%1/2
$code_row < $self->_min_row or $self->_max_row < $code_row
$code_row < $self->_min_row $self->_max_row < $code_row
MC/DC100%2/2
$row_formats and exists $row_formats->{"hidden"}
$row_formats exists $row_formats->{"hidden"}
Truth table66%2/3
A or B
A= $code_row < $self->_min_rowB= $self->_max_row < $code_row
ABresult
1X1
011
000
Truth table100%3/3
A and B
A= $row_formatsB= exists $row_formats->{"hidden"}
ABresult
0X0
100
111
300 }
301 1 my $true = 0;
302 1 ▶ map{ $true = 1 if $_ } @result_list;
Branch: 1 branch
BranchTrueFalseTotal
if $_ 5 11 16
303 ###LogSD $phone->talk( level => 'info', message =>[
304 ###LogSD "Final row hidden state is -$true- with list:", @result_list] );
305 1 ▶ return wantarray ? @result_list : $true;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 0 1
306 }
307  
308 356 ▶sub get_cell{
Subroutine get_cell: called CC=18 SCAR=29.4
Pod documented
309 356 my ( $self, $requested_row, $requested_column ) = @_;
310 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
311 ###LogSD $self->get_all_space . '::get_cell', );
312 ###LogSD $phone->talk( level => 'info', message =>[
313 ###LogSD "Arrived at get_cell with: ",
314 ###LogSD "Requested row: " . (defined( $requested_row ) ? $requested_row : ''),
315 ###LogSD "Requested column: " . (defined( $requested_column ) ? $requested_column : '' ),] );
316  
317 # Ensure we have a good column and row to work from
318 356 my( $excel_requested_column, $excel_requested_row );
319 356 ▶ if( !defined $requested_row ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $requested_row) { } 0 356 356
320 0 $self->set_error( "No row provided" );
321 0 return undef;
322 }else{
323 356 $excel_requested_row = $self->get_excel_position( $requested_row );
324 ###LogSD $phone->talk( level => 'info', message =>[
325 ###LogSD "Updated row to (count from 1): $excel_requested_row", ] );
326 }
327 356 ▶ if( !defined $requested_column ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $requested_column) { } 0 356 356
328 0 $self->set_error( "No column provided" );
329 0 return undef;
330 }else{
331 356 $excel_requested_column = $self->get_excel_position( $requested_column );
332 ###LogSD $phone->talk( level => 'info', message =>[
333 ###LogSD "Updated column to (count from 1): $excel_requested_column", ] );
334 }
335  
336 # Get information
337 ###LogSD $phone->talk( level => 'trace', message =>[
338 ###LogSD 'Requesting [ $column, $row ]: [ ' . $excel_requested_column . ', ' . $excel_requested_row . ' ]' ] );
339 356 my $current_row = $self->go_to_or_past_row( $excel_requested_row );
340 356 my $current_column;
341 356 ▶ if( is_Int( $current_row ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (&is_Int($current_row)) { } 348 8 356
342 ###LogSD $phone->talk( level => 'trace', message =>[
343 ###LogSD "Arrived at row: $current_row", "..searching for column: $excel_requested_column" ] );
344 348 ▶ $current_column =
Branch: 2 branches
BranchTrueFalseTotal
$current_row == $excel_requested_row ? : 295 53 348
$self->has_max_col && $requested_column > $self->max_col ? : 7 46 53
Condition66%2/3
$self->has_max_col and $requested_column > $self->max_col
!ll&&!rl&&r
0467
MC/DC50%1/2
$self->has_max_col and $requested_column > $self->max_col
$self->has_max_col $requested_column > $self->max_col
Truth table66%2/3
A and B
A= $self->has_max_colB= $requested_column > $self->max_col
ABresult
0X0
100
111
345 ( $current_row == $excel_requested_row ) ? $self->get_new_column( $excel_requested_column ) :
346 ( $self->has_max_col and $requested_column > $self->max_col) ? 'EOR' : undef ;
347 ###LogSD $phone->talk( level => 'trace', message =>[
348 ###LogSD "Column search result: ", ($current_column//'undef') ] );
349 }else{
350 ###LogSD $phone->talk( level => 'trace', message =>[
351 ###LogSD "Requested a row past the end of the file" ] );
352 }
353  
354 # Handle returns including EOF EOD and EOR flags
355 356 my $return = undef;
356 356 ▶ if( $current_column and is_HashRef( $current_column ) ){
Branch: 1 branch
BranchTrueFalseTotal
if ($current_column and &is_HashRef($current_column)) { } 190 166 356
Condition100%3/3
$current_column and &is_HashRef($current_column)
!ll&&!rl&&r
8878190
MC/DC100%2/2
$current_column and &is_HashRef($current_column)
$current_column &is_HashRef($current_column)
Truth table100%3/3
A and B
A= $current_columnB= &is_HashRef($current_column)
ABresult
0X0
100
111
357 ###LogSD $phone->talk( level => 'trace', message =>[ 'Got a cell to build and return' ] );
358 190 $return = $self->_build_out_the_cell( $current_column );
359 }else{
360 166 ▶ $return =
Branch: 2 branches
BranchTrueFalseTotal
$current_column ? : 78 88 166
&is_Int($current_row) ? : 80 8 88
361 $current_column ? $current_column :
362 is_Int( $current_row ) ? undef : $current_row;
363 ###LogSD $phone->talk( level => 'trace', message =>[ "Initial boundary flag: " . ($return//'undef') ] );
364 166 ▶ if( $return ){# Handle some exceptions
Branch: 1 branch
BranchTrueFalseTotal
if ($return) 86 80 166
365 86 ▶ if( $return eq 'EOD' ){# End of data equals end of row exception
Branch: 1 branch
BranchTrueFalseTotal
if ($return eq "EOD") 58 28 86
366 58 ▶ if( $self->is_empty_the_end ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_empty_the_end) { } 0 58 58
367 ###LogSD $phone->talk( level => 'trace', message =>[ "Changing End Of Data to EOR" ] );
368 0 $return = 'EOR';
369 }else{
370 ###LogSD $phone->talk( level => 'trace', message =>[ "Clearing EOD" ] );
371 58 $return = undef;
372 }
373 }
374 #~ if( $return eq 'EOR' and $self->has_max_row and $self->max_row == $requested_row ){# EOR is EOF exception
375 #~ ###LogSD $phone->talk( level => 'trace', message =>[ "Changing EOR to EOF" ] );
376 #~ $return = 'EOF';
377 #~ } # Should return EOF from the file reader here?
378 # Adjust reported row column
379 86 ▶ ( $excel_requested_column, $excel_requested_row ) =
Branch: 2 branches
BranchTrueFalseTotal
!$return ? : 58 28 86
$return eq 'EOF' ? : 8 20 28
380 !$return ? ( $excel_requested_column, $excel_requested_row ) :
381 $return eq 'EOF' ? ( 0, 0 ) :
382 ( 0, $excel_requested_row + 1 ) ;
383 }
384 # Clear boundary flags per request
385 166 ▶ if( $return and !$self->boundary_flag_setting ){
Branch: 1 branch
BranchTrueFalseTotal
if ($return and not $self->boundary_flag_setting) 2 164 166
Condition100%3/3
$return and not $self->boundary_flag_setting
!ll&&!rl&&r
138262
MC/DC100%2/2
$return and not $self->boundary_flag_setting
$return not $self->boundary_flag_setting
Truth table100%3/3
A and not(B)
A= $returnB= not $self->boundary_flag_setting
ABresult
0X0
100
111
386 ###LogSD $phone->talk( level => 'trace', message =>[ "No boundary flag settings desired" ] );
387 2 $return = undef;
388 }
389 }
390 ###LogSD $phone->talk( level => 'trace', message =>[ "Cell search returning:", $return ] );
391  
392 356 $self->_set_reported_row_col( [ $excel_requested_row, $excel_requested_column ] );
393 ###LogSD $phone->talk( level => 'debug', message =>[
394 ###LogSD "Set the reported [ row, col ] to: [ $excel_requested_row, $excel_requested_column ]", ] );
395 ###LogSD $phone->talk( level => 'trace', message =>[ 'Final return:', $return ] );
396 356 return $return;
397 }
398  
399 76 ▶sub get_next_value{
Subroutine get_next_value: called CC=21 SCAR=30.9
Pod documented
400 76 my ( $self, ) = @_;
401 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
402 ###LogSD $self->get_all_space . '::get_next_value', );
403 ###LogSD $phone->talk( level => 'info', message =>[ 'Arrived at get_next_value', ] );
404  
405 # Get next position
406 76 my $next_cell;
407 76 ▶ if( $self->has_new_row_inst ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_new_row_inst) { } 70 6 76
408 ###LogSD $phone->talk( level => 'info', message =>[
409 ###LogSD "Current row number: " . $self->get_new_row_number, ] );
410 70 ▶ while( !$next_cell ){# To handle values only in a pre-cached environment
Branch: 1 branch
BranchTrueFalseTotal
unless ($next_cell) 72 70 142
411 72 $next_cell = $self->get_new_next_value;
412 ###LogSD $phone->talk( level => 'debug', message =>[
413 ###LogSD 'Returned from next search with cell:', $next_cell ] );
414 72 ▶ if( $self->get_values_only and is_HashRef( $next_cell ) and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_values_only and &is_HashRef($next_cell) and !(exists $next_cell->{"cell_xml_value"} || exists $next_cell->{"cell_unformatted"}) || exists $next_cell->{"cell_xml_value"} && length $next_cell->{"cell_xml_value"} == 0) 2 70 72
Condition73%11/15
$self->get_values_only and &is_HashRef($next_cell) and !(exists $next_cell->{"cell_xml_value"} || exists $next_cell->{"cell_unformatted"}) || exists $next_cell->{"cell_xml_value"} && length $next_cell->{"cell_xml_value"} == 0
!ll&&!rl&&r
42282
$self->get_values_only and &is_HashRef($next_cell)
!ll&&!rl&&r
301230
not exists $next_cell->{"cell_xml_value"} || exists $next_cell->{"cell_unformatted"} or exists $next_cell->{"cell_xml_value"} and length $next_cell->{"cell_xml_value"} == 0
l!l&&r!l&&!r
2028
exists $next_cell->{'cell_xml_value'} || exists $next_cell->{'cell_unformatted'}
l!l&&r!l&&!r
2802
exists $next_cell->{"cell_xml_value"} and length $next_cell->{"cell_xml_value"} == 0
!ll&&!rl&&r
0280
MC/DC50%3/6
$self->get_values_only and &is_HashRef($next_cell) and !(exists $next_cell->{"cell_xml_value"} || exists $next_cell->{"cell_unformatted"}) || exists $next_cell->{"cell_xml_value"} && length $next_cell->{"cell_xml_value"} == 0
$self->get_values_only &is_HashRef($next_cell) exists $next_cell->{'cell_xml_value'} exists $next_cell->{'cell_unformatted'} exists $next_cell->{"cell_xml_value"} length $next_cell->{"cell_xml_value"} == 0
Truth table44%4/9
A and B and not(C || D) or E and F
A= $self->get_values_onlyB= &is_HashRef($next_cell)C= exists $next_cell->{'cell_xml_value'}D= exists $next_cell->{'cell_unformatted'}E= exists $next_cell->{"cell_xml_value"}F= length $next_cell->{"cell_xml_value"} == 0
ABCDEFresult
0XXXXX0
10XXXX0
111X0X0
111X100
11010X0
1101100
1100XX1
111X111
1101111
415 ( (!exists $next_cell->{cell_xml_value} and !exists $next_cell->{cell_unformatted}) or
416 (exists $next_cell->{cell_xml_value} and length( $next_cell->{cell_xml_value} ) == 0 ) ) ){
417 2 $next_cell = undef;
418 ###LogSD $phone->talk( level => 'debug', message =>[ 'Deleting this cell since it is empty' ] );
419 }
420 }
421 }else{
422 ###LogSD $phone->talk( level => 'debug', message =>[
423 ###LogSD 'No row instance currently loaded' ] );
424 }
425 76 ▶ if( !$next_cell or $next_cell eq 'EOR' ){ # Handle no current row or no cell left case
Branch: 1 branch
BranchTrueFalseTotal
if (not $next_cell or $next_cell eq "EOR") 34 42 76
Condition100%3/3
not $next_cell or $next_cell eq "EOR"
l!l&&r!l&&!r
62842
MC/DC100%2/2
not $next_cell or $next_cell eq "EOR"
not $next_cell $next_cell eq "EOR"
Truth table100%3/3
not(A) or B
A= not $next_cellB= $next_cell eq "EOR"
ABresult
1X1
011
000
426 34 $next_cell = undef;# Clear 'EOR'
427 34 my $current_row = $self->go_to_or_past_row;
428 ###LogSD $phone->talk( level => 'debug', message =>[
429 ###LogSD 'Updated Row: ' . $current_row] );
430 34 ▶ while( !$next_cell ){# To handle values only in a pre-cached environment
Branch: 1 branch
BranchTrueFalseTotal
unless ($next_cell) 35 28 63
431 35 ▶ $next_cell = $current_row eq 'EOF' ? 'EOF' : $self->get_new_next_value;
Branch: 1 branch
BranchTrueFalseTotal
$current_row eq 'EOF' ? : 6 29 35
432 ###LogSD $phone->talk( level => 'debug', message =>[
433 ###LogSD 'Returned from next search with cell:', $next_cell ] );
434  
435 # Handle EOF here
436 35 ▶ if( $next_cell eq 'EOF' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($next_cell eq "EOF") 6 29 35
437 ###LogSD $phone->talk( level => 'debug', message =>[ 'Reached the EOF' ] );
438 6 $self->_set_reported_row_col( [ 0, 0 ] );
439 6 ▶ return $self->boundary_flag_setting ? $next_cell : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->boundary_flag_setting ? : 5 1 6
440 }
441  
442 # Skip empty cells based on get_values_only
443 29 ▶ if( $self->get_values_only and is_HashRef( $next_cell ) and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_values_only and &is_HashRef($next_cell) and !(exists $next_cell->{"cell_xml_value"} || exists $next_cell->{"cell_unformatted"}) || exists $next_cell->{"cell_xml_value"} && length $next_cell->{"cell_xml_value"} == 0) 1 28 29
Condition66%10/15
$self->get_values_only and &is_HashRef($next_cell) and !(exists $next_cell->{"cell_xml_value"} || exists $next_cell->{"cell_unformatted"}) || exists $next_cell->{"cell_xml_value"} && length $next_cell->{"cell_xml_value"} == 0
!ll&&!rl&&r
16121
$self->get_values_only and &is_HashRef($next_cell)
!ll&&!rl&&r
16013
not exists $next_cell->{"cell_xml_value"} || exists $next_cell->{"cell_unformatted"} or exists $next_cell->{"cell_xml_value"} and length $next_cell->{"cell_xml_value"} == 0
l!l&&r!l&&!r
1012
exists $next_cell->{'cell_xml_value'} || exists $next_cell->{'cell_unformatted'}
l!l&&r!l&&!r
1201
exists $next_cell->{"cell_xml_value"} and length $next_cell->{"cell_xml_value"} == 0
!ll&&!rl&&r
0120
MC/DC33%2/6
$self->get_values_only and &is_HashRef($next_cell) and !(exists $next_cell->{"cell_xml_value"} || exists $next_cell->{"cell_unformatted"}) || exists $next_cell->{"cell_xml_value"} && length $next_cell->{"cell_xml_value"} == 0
$self->get_values_only &is_HashRef($next_cell) exists $next_cell->{'cell_xml_value'} exists $next_cell->{'cell_unformatted'} exists $next_cell->{"cell_xml_value"} length $next_cell->{"cell_xml_value"} == 0
Truth table33%3/9
A and B and not(C || D) or E and F
A= $self->get_values_onlyB= &is_HashRef($next_cell)C= exists $next_cell->{'cell_xml_value'}D= exists $next_cell->{'cell_unformatted'}E= exists $next_cell->{"cell_xml_value"}F= length $next_cell->{"cell_xml_value"} == 0
ABCDEFresult
0XXXXX0
10XXXX0
111X0X0
111X100
11010X0
1101100
1100XX1
111X111
1101111
444 ( (!exists $next_cell->{cell_xml_value} and !exists $next_cell->{cell_unformatted}) or
445 (exists $next_cell->{cell_xml_value} and length( $next_cell->{cell_xml_value} ) == 0 ) ) ){
446 1 $next_cell = undef;
447 ###LogSD $phone->talk( level => 'debug', message =>[ 'Deleting this cell since it is empty' ] );
448 }
449 }
450 }
451  
452 # Build out the cell
453 ###LogSD $phone->talk( level => 'trace', message =>[
454 ###LogSD 'Reporting the current row col for cell:', $next_cell ] );
455 70 $self->_set_reported_row_col( [ $next_cell->{cell_row}, $next_cell->{cell_col} ] );
456 70 my $cell_instance = $self->_build_out_the_cell( $next_cell );
457 ###LogSD $phone->talk( level => 'trace', message =>[
458 ###LogSD 'Built cell instance:', $cell_instance ] );
459  
460 70 return $cell_instance;
461 }
462  
463 148 ▶sub fetchrow_arrayref{
Subroutine fetchrow_arrayref: called CC=16 SCAR=30.0
Pod documented
464 148 my ( $self, $row ) = @_;
465 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
466 ###LogSD $self->get_all_space . '::fetchrow_arrayref', );
467 ###LogSD $phone->talk( level => 'info', message =>[
468 ###LogSD "Arrived at fetchrow_arrayref for row: " . ((defined $row) ? $row : ''), ] );
469  
470 # Handle an implied next
471 148 ▶ if( !defined $row ){
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $row) { } 138 10 148
472 138 my $last_row = $self->_get_reported_row;
473 138 $row = $last_row + 1;# Even if a cell is not at the end was last reported
474 ###LogSD $phone->talk( level => 'debug', message =>[
475 ###LogSD "Resolved an implied 'next' row request to row: $row", ] );
476 }else{
477 10 $row = $self->get_excel_position( $row );
478 ###LogSD $phone->talk( level => 'info', message =>[
479 ###LogSD "Updated row to (count from 1): $row", ] );
480 }
481  
482 # Advance to the proper row
483 ###LogSD $phone->talk( level => 'trace', message =>[
484 ###LogSD "Requesting row: $row" ] );
485 148 my $current_row = $self->go_to_or_past_row( $row );
486 ###LogSD $phone->talk( level => 'trace', message =>[
487 ###LogSD "Arrived at row: $current_row" ] );
488  
489 # Pull the data
490 148 ▶ my $result =
Branch: 2 branches
BranchTrueFalseTotal
&is_Int($current_row) && $current_row == $row ? : 111 37 148
$current_row eq 'EOF' ? : 14 23 37
Condition100%3/3
&is_Int($current_row) and $current_row == $row
!ll&&!rl&&r
1423111
MC/DC100%2/2
&is_Int($current_row) and $current_row == $row
&is_Int($current_row) $current_row == $row
Truth table100%3/3
A and B
A= &is_Int($current_row)B= $current_row == $row
ABresult
0X0
100
111
491 (is_Int( $current_row) and $current_row == $row) ? $self->get_new_row_all :
492 $current_row eq 'EOF' ? 'EOF' : undef;
493 ###LogSD $phone->talk( level => 'debug', message =>[ 'Returned row ref;', $result ] );
494  
495 # Build the return
496 148 my $return = [];
497 148 my ( $reported_row, $reported_col ) = ( $row, undef );
498 148 ▶ if( $result ){
Branch: 1 branch
BranchTrueFalseTotal
if ($result) { } 125 23 148
499 125 ▶ if( is_ArrayRef( $result ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (&is_ArrayRef($result)) { } 111 14 125
500 111 for my $cell ( @$result ){
501 446 ▶ if( is_HashRef( $cell ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (&is_HashRef($cell)) { } 354 92 446
502 ###LogSD $phone->talk( level => 'debug', message =>[
503 ###LogSD 'Building out the cell:', $cell ] );
504 354 $reported_col = $cell->{cell_col};
505  
506 # Skip empty cells based on get_values_only
507 354 ▶ if( $self->get_values_only and is_HashRef( $cell ) and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_values_only and &is_HashRef($cell) and !(exists $cell->{'cell_xml_value'} || exists $cell->{'cell_unformatted'}) || exists $cell->{'cell_xml_value'} && length $cell->{'cell_xml_value'} == 0) { } 0 354 354
Condition13%2/15
$self->get_values_only and &is_HashRef($cell) and !(exists $cell->{"cell_xml_value"} || exists $cell->{"cell_unformatted"}) || exists $cell->{"cell_xml_value"} && length $cell->{"cell_xml_value"} == 0
!ll&&!rl&&r
35400
$self->get_values_only and &is_HashRef($cell)
!ll&&!rl&&r
35400
not exists $cell->{"cell_xml_value"} || exists $cell->{"cell_unformatted"} or exists $cell->{"cell_xml_value"} and length $cell->{"cell_xml_value"} == 0
l!l&&r!l&&!r
000
exists $cell->{'cell_xml_value'} || exists $cell->{'cell_unformatted'}
l!l&&r!l&&!r
000
exists $cell->{"cell_xml_value"} and length $cell->{"cell_xml_value"} == 0
!ll&&!rl&&r
000
MC/DC0%0/6
$self->get_values_only and &is_HashRef($cell) and !(exists $cell->{"cell_xml_value"} || exists $cell->{"cell_unformatted"}) || exists $cell->{"cell_xml_value"} && length $cell->{"cell_xml_value"} == 0
$self->get_values_only &is_HashRef($cell) exists $cell->{'cell_xml_value'} exists $cell->{'cell_unformatted'} exists $cell->{"cell_xml_value"} length $cell->{"cell_xml_value"} == 0
Truth table11%1/9
A and B and not(C || D) or E and F
A= $self->get_values_onlyB= &is_HashRef($cell)C= exists $cell->{'cell_xml_value'}D= exists $cell->{'cell_unformatted'}E= exists $cell->{"cell_xml_value"}F= length $cell->{"cell_xml_value"} == 0
ABCDEFresult
0XXXXX0
10XXXX0
111X0X0
111X100
11010X0
1101100
1100XX1
111X111
1101111
508 ( (!exists $cell->{cell_xml_value} and !exists $cell->{cell_unformatted}) or
509 (exists $cell->{cell_xml_value} and length( $cell->{cell_xml_value} ) == 0 ) ) ){
510 ###LogSD $phone->talk( level => 'debug', message =>[ 'Deleting this cell since it is empty' ] );
511 }else{
512 354 push @$return, $self->_build_out_the_cell( $cell, );
513 }
514 }else{
515 92 push @$return, $cell;
516 }
517 }
518 }else{# Handle EOF flag
519 14 ▶ $return = $self->boundary_flag_setting ? $result : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->boundary_flag_setting ? : 13 1 14
520 ###LogSD $phone->talk( level => 'debug', message =>[
521 ###LogSD "Based on boundary flag setting EOF state returning: $return" ] );
522 14 ( $reported_row, $reported_col ) = ( 0, 0 );
523 }
524 }else{
525 23 $reported_col = $self->_max_col;
526 }
527  
528 # Handle full rows with empty_is_end = 0
529 148 $self->_set_reported_row_col( [ $reported_row, $reported_col ] );
530 ###LogSD $phone->talk( level => 'debug', message =>[
531 ###LogSD "Set the reported [ row, col ] to: [ $reported_row, $reported_col ]", ] );
532 ###LogSD $phone->talk( level => 'trace', message =>[ 'Final return:', $return ] );
533  
534 148 return $return;
535 }
536  
537 15 ▶sub fetchrow_array{
Subroutine fetchrow_array: called CC=3 SCAR=11.0
Pod documented
538 15 my ( $self, $row ) = @_;
539 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
540 ###LogSD $self->get_all_space . '::fetchrow_array', );
541 ###LogSD $phone->talk( level => 'info', message =>[
542 ###LogSD "Arrived at fetchrow_array for row: " . ((defined $row) ? $row : ''), ] );
543 15 my $array_ref = $self->fetchrow_arrayref( $row );
544 ###LogSD $phone->talk( level => 'trace', message =>[ 'Initial return:', $array_ref ] );
545 15 ▶ my @return =
Branch: 2 branches
BranchTrueFalseTotal
&is_ArrayRef($array_ref) ? : 14 1 15
&is_Str($array_ref) ? : 1 0 1
546 is_ArrayRef( $array_ref ) ? @$array_ref :
547 is_Str( $array_ref ) ? $array_ref : ();
548 ###LogSD $phone->talk( level => 'trace', message =>[ 'Final return:', @return ] );
549 15 return @return;
550 }
551  
552 2 ▶sub set_headers{
Subroutine set_headers: called CC=11 SCAR=28.4
Pod documented
553 2 my ( $self, @header_row_list ) = @_;
554 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
555 ###LogSD $self->get_all_space . '::set_headers', );
556 ###LogSD $phone->talk( level => 'info', message =>[
557 ###LogSD "Arrived at set_headers for row: ", @header_row_list, ] );
558 2 my $header_ref;
559 2 $self->_clear_last_header_row;
560 2 $self->_clear_header_ref;
561 2 my $old_output = $self->get_group_return_type;
562 ###LogSD $phone->talk( level => 'info', message =>[
563 ###LogSD "Old output type: $old_output", ] );
564 2 my $new_output = $old_output;
565 2 ▶ if( $old_output eq 'instance' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($old_output eq 'instance') { } 0 2 2
566 0 $self->set_group_return_type( 'value' );
567 0 $new_output = 'value';
568 }else{
569 2 $old_output = undef;
570 }
571 ###LogSD $phone->talk( level => 'info', message =>[
572 ###LogSD "New output type: $new_output", ] );
573 2 ▶ if( scalar( @header_row_list ) == 0 ){
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @header_row_list == 0) 0 2 2
574 0 $self->set_error( "No row numbers passed to use as headers" );
575 0 return undef;
576 }
577 2 my $last_header_row = 0;
578 2 my $code_ref;
579 2 for my $row ( @header_row_list ){
580 2 ▶ if( ref( $row ) ){
Branch: 1 branch
BranchTrueFalseTotal
if (ref $row) 0 2 2
581 0 $code_ref = $row;
582 ###LogSD $phone->talk( level => 'info', message =>[
583 ###LogSD "Found header manipulation code: ", $code_ref, ] );
584 0 next;
585 }
586 2 ▶ $last_header_row = $row if $row > $last_header_row;
Branch: 1 branch
BranchTrueFalseTotal
if $row > $last_header_row 2 0 2
587 2 my $array_ref = $self->fetchrow_arrayref( $row );
588 ###LogSD $phone->talk( level => 'info', message =>[
589 ###LogSD "Retreived header row -$row- with values: ", $array_ref, ] );
590 2 for my $x ( 0..$#$array_ref ){
591 10 ▶ $header_ref->[$x] = $array_ref->[$x] if !defined $header_ref->[$x];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $header_ref->[$x] 10 0 10
592 }
593 ###LogSD $phone->talk( level => 'info', message =>[
594 ###LogSD "Updated header ref: ", $header_ref, ] );
595 }
596 2 ▶ if( $code_ref ){
Branch: 1 branch
BranchTrueFalseTotal
if ($code_ref) 0 2 2
597 0 my $scrubbed_headers;
598 0 for my $header ( @$header_ref ){
599 0 push @$scrubbed_headers, $code_ref->( $header );
600 }
601 ###LogSD $phone->talk( level => 'info', message =>[
602 ###LogSD "scrubbed header ref: ", $scrubbed_headers, ] );
603 0 $header_ref = $scrubbed_headers;
604 }
605 2 $self->_set_last_header_row( $last_header_row );
606 2 $self->_set_header_ref( $header_ref );
607 2 ▶ $self->set_group_return_type( $old_output ) if $old_output;
Branch: 1 branch
BranchTrueFalseTotal
if $old_output 0 2 2
608 2 return $header_ref;
609 }
610  
611 16 ▶sub fetchrow_hashref{
Subroutine fetchrow_hashref: called CC=13 SCAR=26.3
Pod documented
612 16 my ( $self, $row ) = @_;
613 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
614 ###LogSD $self->get_all_space . '::fetchrow_hashref', );
615 ###LogSD $phone->talk( level => 'info', message =>[
616 ###LogSD "Arrived at fetchrow_hashref for row: " . ((defined $row) ? $row : ''), ] );
617 # Check that the headers are set
618 16 ▶ if( !$self->_has_header_ref ){
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->_has_header_ref) { } 2 14 16
elsif (defined $row and $row <= $self->get_last_header_row) { } 2 22 24
619 2 $self->set_error( "Headers must be set prior to calling fetchrow_hashref" );
620 2 return undef;
621 ▶ }elsif( defined $row and $row <= $self->get_last_header_row ){
Condition100%3/3
defined $row and $row <= $self->get_last_header_row
!ll&&!rl&&r
1022
MC/DC100%2/2
defined $row and $row <= $self->get_last_header_row
defined $row $row <= $self->get_last_header_row
Truth table100%3/3
A and B
A= defined $rowB= $row <= $self->get_last_header_row
ABresult
0X0
100
111
622 2 $self->set_error(
623 "The requested row -$row- is at or above the bottom of the header rows ( " .
624 $self->get_last_header_row . ' )'
625 );
626 2 return undef;
627 }
628 12 my $array_ref = $self->fetchrow_arrayref( $row );
629 12 ▶ return $array_ref if !$array_ref or $array_ref eq 'EOF';
Branch: 1 branch
BranchTrueFalseTotal
if not $array_ref or $array_ref eq "EOF" 2 10 12
Condition66%2/3
not $array_ref or $array_ref eq "EOF"
l!l&&r!l&&!r
0210
MC/DC50%1/2
not $array_ref or $array_ref eq "EOF"
not $array_ref $array_ref eq "EOF"
Truth table66%2/3
not(A) or B
A= not $array_refB= $array_ref eq "EOF"
ABresult
1X1
011
000
630 10 my $header_ref = $self->_get_header_ref;
631 10 my ( $start, $end ) = ( $self->min_col, $self->max_col );
632 10 my ( $min_col, $max_col ) = ( $self->get_min_header_col, $self->get_max_header_col );
633 ###LogSD $phone->talk( level => 'info', message =>[
634 ###LogSD ((defined $min_col) ? "Minimum header column: $min_col" : undef),
635 ###LogSD ((defined $max_col) ? "Maximum header column: $max_col" : undef), ] );
636 10 ▶ $min_col = ($min_col and $min_col>$start) ? $min_col - $start : 0;
Branch: 1 branch
BranchTrueFalseTotal
$min_col && $min_col > $start ? : 0 10 10
Condition33%1/3
$min_col and $min_col > $start
!ll&&!rl&&r
1000
MC/DC0%0/2
$min_col and $min_col > $start
$min_col $min_col > $start
Truth table33%1/3
A and B
A= $min_colB= $min_col > $start
ABresult
0X0
100
111
637 10 ▶ $max_col = ($max_col and $max_col<$end) ? $end - $max_col : 0;
Branch: 1 branch
BranchTrueFalseTotal
$max_col && $max_col < $end ? : 10 0 10
Condition33%1/3
$max_col and $max_col < $end
!ll&&!rl&&r
0010
MC/DC0%0/2
$max_col and $max_col < $end
$max_col $max_col < $end
Truth table33%1/3
A and B
A= $max_colB= $max_col < $end
ABresult
0X0
100
111
638 ###LogSD $phone->talk( level => 'info', message =>[
639 ###LogSD ((defined $min_col) ? "Minimum header column offset: $min_col" : undef),
640 ###LogSD ((defined $max_col) ? "Maximum header column offset: $max_col" : undef), ] );
641  
642 # Build the ref
643 10 my $return;
644 10 my $blank_count = 0;
645 10 for my $x ( (0+$min_col)..($self->max_col-$max_col) ){
646 40 ▶ my $header = defined( $header_ref->[$x] ) ? $header_ref->[$x] : 'blank_header_' . $blank_count++;
Branch: 1 branch
BranchTrueFalseTotal
defined $header_ref->[$x] ? : 40 0 40
647 ###LogSD $phone->talk( level => 'info', message =>[
648 ###LogSD "Possibly adding value for header: $header" ] );
649 40 ▶ if( defined $array_ref->[$x] ){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $array_ref->[$x]) 30 10 40
650 ###LogSD $phone->talk( level => 'info', message =>[
651 ###LogSD "Adding value: $array_ref->[$x]" ] );
652 30 $return->{$header} = $array_ref->[$x];
653 }
654 }
655  
656 10 return $return;
657 }
658  
659 3 ▶sub set_custom_formats{
Subroutine set_custom_formats: called CC=12 SCAR=34.0
Pod documented
660 3 my ( $self, @input_args ) = @_;
661 3 my $args;
662 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
663 ###LogSD $self->get_all_space . '::set_custom_formats', );
664 ###LogSD $phone->talk( level => 'info', message =>[
665 ###LogSD "Arrived at set_custom_formats with: ", @input_args, ] );
666 3 my $worksheet_custom = 0;
667 3 ▶ if( !@input_args ){
Branch: 3 branches
BranchTrueFalseTotal
if (not @input_args) { } 0 3 3
elsif (&is_HashRef($input_args[0]) and @input_args == 1) { } 0 3 3
elsif (@input_args % 2 == 0) { } 3 0 3
668 0 $self->( "The input args to 'set_custom_formts' are empty - no op" );
669 0 return undef;
670 ▶ }elsif( is_HashRef( $input_args[0] ) and @input_args == 1 ){
Condition33%1/3
&is_HashRef($input_args[0]) and @input_args == 1
!ll&&!rl&&r
300
MC/DC0%0/2
&is_HashRef($input_args[0]) and @input_args == 1
&is_HashRef($input_args[0]) @input_args == 1
Truth table33%1/3
A and B
A= &is_HashRef($input_args[0])B= @input_args == 1
ABresult
0X0
100
111
671 0 $args = $input_args[0];
672 }elsif( @input_args % 2 == 0 ){
673 3 $args = { @input_args };
674 }else{
675 0 $self->set_error( "Unable to coerce input args to a hashref: " . join( '~|~', @input_args ) );
676 0 return undef;
677 }
678 ###LogSD $phone->talk( level => 'info', message =>[
679 ###LogSD "Now acting on: ", $args ] );
680 3 my $final_load;
681 3 for my $key ( keys %$args ){
682 9 my $new_coercion;
683 9 ▶ if( $key eq '' or $key !~ /[A-Z]{0,3}(\d*)/ ){
Branch: 2 branches
BranchTrueFalseTotal
if ($key eq '' or not $key =~ /[A-Z]{0,3}(\d*)/u) { } 0 9 9
elsif (&is_Object($args->{$key})) { } 0 9 9
Condition33%1/3
$key eq "" or not $key =~ /[A-Z]{0,3}(\d*)/u
l!l&&r!l&&!r
009
MC/DC0%0/2
$key eq "" or not $key =~ /[A-Z]{0,3}(\d*)/u
$key eq "" not $key =~ /[A-Z]{0,3}(\d*)/u
Truth table33%1/3
A or not(B)
A= $key eq ""B= not $key =~ /[A-Z]{0,3}(\d*)/u
ABresult
1X1
011
000
684 0 $self->set_error( "-$key- is not an allowed custom format key" );
685 0 next;
686 }elsif( is_Object( $args->{$key} ) ){
687 ###LogSD $phone->talk( level => 'info', message =>[
688 ###LogSD "Key -$key- already has an object" ] );
689 0 $new_coercion = $args->{$key};
690 }else{
691 ###LogSD $phone->talk( level => 'info', message =>[
692 ###LogSD "Trying to build a new coercion for -$key- with: $args->{$key}" ] );
693 9 $new_coercion = $self->parse_excel_format_string( $args->{$key}, "Worksheet_Custom_" . $worksheet_custom++ );
694 9 ▶ if( !$new_coercion ){
Branch: 1 branch
BranchTrueFalseTotal
unless ($new_coercion) 0 9 9
695 0 $self->set_error( "No custom coercion could be built for -$key- with: $args->{$key}" );
696 0 next;
697 }
698 ###LogSD $phone->talk( level => 'info', message =>[
699 ###LogSD "Built possible new coercion for -$key-" ] );
700 }
701 9 ▶ if( !$new_coercion->can( 'assert_coerce' ) ){
Branch: 2 branches
BranchTrueFalseTotal
if (not $new_coercion->can('assert_coerce')) { } 0 9 9
elsif (not $new_coercion->can('display_name')) { } 0 9 9
702 0 $self->set_error( "The identified coercion for -$key- cannot 'assert_coerce'" );
703 }elsif( !$new_coercion->can( 'display_name' ) ){
704 0 $self->set_error( "The custom coercion for -$key- cannot 'display_name'" );
705 }else{
706 ###LogSD $phone->talk( level => 'info', message =>[
707 ###LogSD "Loading -$key- with coercion: " . $new_coercion->display_name ] );
708 9 $final_load->{$key} = $new_coercion;
709 }
710 }
711 3 $self->_set_custom_format( %$final_load );
712 }
713  
714 #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9
715  
716 18 has _last_header_row =>(
717 isa => Int,
718 reader => 'get_last_header_row',
719 writer => '_set_last_header_row',
720 clearer => '_clear_last_header_row',
721 predicate => 'header_row_set'
722 );
723  
724 has _custom_formats =>(
725 isa => HashRef[ HasMethods[ 'assert_coerce', 'display_name' ] ],
726 traits => ['Hash'],
727 reader => 'get_custom_formats',
728 34 ▶ default => sub{ {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
729 18 clearer => '_clear_custom_formats',
730 handles =>{
731 has_custom_format => 'exists',
732 get_custom_format => 'get',
733 _set_custom_format => 'set',
734 },
735 );
736  
737 18 has _header_ref =>(
738 isa => ArrayRef,
739 writer => '_set_header_ref',
740 reader => '_get_header_ref',
741 clearer => '_clear_header_ref',
742 predicate => '_has_header_ref',
743 );
744  
745 has _reported_row_col =>(# Manage (store and retreive) in count from 1 mode
746 isa => ArrayRef[Int],
747 traits => ['Array'],
748 writer => '_set_reported_row_col',
749 reader => '_get_reported_row_col',
750 34 ▶ default => sub{ [ 0, 0 ] },# Pre-row and pre-col
Subroutine __ANON__: called CC=1 SCAR=0.0
751 18 handles =>{
752 _get_reported_row => [ get => 0 ],
753 _get_reported_col => [ get => 1 ],
754 },
755 );
756  
757 #########1 Private Methods 3#########4#########5#########6#########7#########8#########9
758  
759 614 ▶sub _build_out_the_cell{
Subroutine _build_out_the_cell: called CC=74 SCAR=44.8
760 614 my ( $self, $result, ) = @_;
761 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
762 ###LogSD $self->get_all_space . '::_hidden::_build_out_the_cell', );
763 ###LogSD $phone->talk( level => 'debug', message =>[
764 ###LogSD "Building out the cell ref:", $result, "..with results as: ". $self->get_group_return_type, ] );
765 614 my ( $return, $hidden_format );
766 614 ▶ if( is_HashRef( $result ) ){
Branch: 2 branches
BranchTrueFalseTotal
if (&is_HashRef($result)) { } 614 0 614
elsif ($result) { } 0 0 0
767 614 ▶ $return->{cell_xml_value} = $result->{cell_xml_value} if exists $result->{cell_xml_value} and defined $result->{cell_xml_value};
Branch: 1 branch
BranchTrueFalseTotal
if exists $result->{"cell_xml_value"} and defined $result->{"cell_xml_value"} 573 41 614
Condition66%2/3
exists $result->{"cell_xml_value"} and defined $result->{"cell_xml_value"}
!ll&&!rl&&r
410573
MC/DC50%1/2
exists $result->{"cell_xml_value"} and defined $result->{"cell_xml_value"}
exists $result->{"cell_xml_value"} defined $result->{"cell_xml_value"}
Truth table66%2/3
A and B
A= exists $result->{"cell_xml_value"}B= defined $result->{"cell_xml_value"}
ABresult
0X0
100
111
768 614 ▶ $return->{cell_unformatted} = $result->{cell_unformatted} if exists $result->{cell_unformatted} and defined $result->{cell_unformatted};
Branch: 1 branch
BranchTrueFalseTotal
if exists $result->{"cell_unformatted"} and defined $result->{"cell_unformatted"} 20 594 614
Condition66%2/3
exists $result->{"cell_unformatted"} and defined $result->{"cell_unformatted"}
!ll&&!rl&&r
594020
MC/DC50%1/2
exists $result->{"cell_unformatted"} and defined $result->{"cell_unformatted"}
exists $result->{"cell_unformatted"} defined $result->{"cell_unformatted"}
Truth table66%2/3
A and B
A= exists $result->{"cell_unformatted"}B= defined $result->{"cell_unformatted"}
ABresult
0X0
100
111
769 ###LogSD $phone->talk( level => 'debug', message =>[
770 ###LogSD "processing cell object from cell ref:", $result ] );
771 614 my $scientific_format;
772 614 ▶ if( !exists $return->{cell_unformatted} and exists $return->{cell_xml_value} and #Implement implied output formatting intrensic to Excel for scientific notiation
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $return->{"cell_unformatted"} and exists $return->{"cell_xml_value"} and $return->{"cell_xml_value"} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/u and $2 and $6 and $6 < 309) 31 583 614
Condition93%14/15
not exists $return->{"cell_unformatted"} and exists $return->{"cell_xml_value"} and $return->{"cell_xml_value"} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/u and $2 and $6 and $6 < 309
!ll&&!rl&&r
581231
not exists $return->{"cell_unformatted"} and exists $return->{"cell_xml_value"} and $return->{"cell_xml_value"} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/u and $2 and $6
!ll&&!rl&&r
581033
not exists $return->{"cell_unformatted"} and exists $return->{"cell_xml_value"} and $return->{"cell_xml_value"} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/u and $2
!ll&&!rl&&r
580133
not exists $return->{"cell_unformatted"} and exists $return->{"cell_xml_value"} and $return->{"cell_xml_value"} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/u
!ll&&!rl&&r
6151934
not exists $return->{"cell_unformatted"} and exists $return->{"cell_xml_value"}
!ll&&!rl&&r
2041553
MC/DC83%5/6
not exists $return->{"cell_unformatted"} and exists $return->{"cell_xml_value"} and $return->{"cell_xml_value"} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/u and $2 and $6 and $6 < 309
not exists $return->{"cell_unformatted"} exists $return->{"cell_xml_value"} $return->{"cell_xml_value"} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/u $2 $6 $6 < 309
Truth table85%6/7
not(A) and B and C and D and E and F
A= not exists $return->{"cell_unformatted"}B= exists $return->{"cell_xml_value"}C= $return->{"cell_xml_value"} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/uD= $2E= $6F= $6 < 309
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
773 $return->{cell_xml_value} =~ /^(\-)?((\d{1,3})?(\.\d+)?)[Ee](\-)?(\d+)$/ and $2 and $6 and $6 < 309){# Maximum Excel value 1.79769313486232E+308 -> https://support.microsoft.com/en-us/kb/78113
774 #~ warn $return->{cell_xml_value};
775 ###LogSD $phone->talk( level => 'trace', message =>[
776 ###LogSD "Found special scientific notation case were stored values and visible values possibly differ" ] );
777 31 ▶ my $dec_sign = $1 ? $1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 31 31
778 31 my $decimal = $2;
779 31 ▶ my $exp_sign = $5 ? $5 : '';
Branch: 1 branch
BranchTrueFalseTotal
$5 ? : 31 0 31
780 31 my $exponent = $6;
781 31 $decimal = sprintf '%.14f', $decimal;
782 31 $decimal =~ /([1-9])?\.(.*[1-9])?(0*)$/;
783 31 ▶ my $last_sig_digit =
Branch: 2 branches
BranchTrueFalseTotal
!$2 ? : 26 5 31
defined $3 ? : 5 0 5
784 !$2 ? 0 :
785 defined $3 ? 14 - length( $3 ) : 14 ;
786 31 ▶ my $initial_significant_digits = length( $exp_sign ) > 0 ? ($last_sig_digit + $exponent) : ($last_sig_digit - $exponent);
Branch: 1 branch
BranchTrueFalseTotal
length $exp_sign > 0 ? : 31 0 31
787 ###LogSD $phone->talk( level => 'debug', message =>[
788 ###LogSD "Processing decimal : $decimal",
789 ###LogSD "Final significant digit of the decimal is at: $last_sig_digit",
790 ###LogSD "Total significant digits : $initial_significant_digits", ] );
791 31 ▶ if( $initial_significant_digits > 19 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($initial_significant_digits > 19) { } 3 28 31
792 ###LogSD $phone->talk( level => 'debug', message =>[
793 ###LogSD "Attempting to use sprintf: %.${last_sig_digit}f", ] );
794 3 $return->{cell_unformatted} = $dec_sign . sprintf "%.${last_sig_digit}f", $decimal;
795 3 $return->{cell_unformatted} .= 'E' . $exp_sign . sprintf '%02d', $exponent;
796 ###LogSD $phone->talk( level => 'debug', message =>[
797 ###LogSD "Found the unformatted scientific notation case with result: $return->{cell_unformatted}"] );
798 }else{
799 #~ warn $initial_significant_digits if $initial_significant_digits < 0;# Uncomment here and26 lines up to validate the test 05-bad_xml_example_bug.t
800 28 ▶ $initial_significant_digits = $initial_significant_digits > -1 ? $initial_significant_digits : 0 ;# Fix 05-bad_xml_example_bug.t bug
Branch: 1 branch
BranchTrueFalseTotal
$initial_significant_digits > -1 ? : 28 0 28
801 ###LogSD $phone->talk( level => 'info', message =>[
802 ###LogSD "Attempting to use sprintf: %.${initial_significant_digits}f", ] );
803 28 $return->{cell_unformatted} = sprintf "%.${initial_significant_digits}f", $return->{cell_xml_value};
804 ###LogSD $phone->talk( level => 'debug', message =>[
805 ###LogSD "Found the unformatted decimal case with output: $return->{cell_unformatted}"] );
806 }
807 31 my $short_decimal = sprintf '%.5f', $decimal;
808 31 $short_decimal =~ /([1-9])?\.(.*[1-9])?(0*)$/;
809 31 ▶ my $short_sig_digit =
Branch: 2 branches
BranchTrueFalseTotal
!$2 ? : 28 3 31
defined $3 ? : 3 0 3
810 !$2 ? 0 :
811 defined $3 ? 5 - length( $3 ) : 5 ;
812  
813 31 ▶ $scientific_format =
Branch: 7 branches
BranchTrueFalseTotal
$initial_significant_digits < 10 ? : 23 8 31
$short_sig_digit == 0 ? : 5 3 8
$short_sig_digit == 1 ? : 1 2 3
$short_sig_digit == 2 ? : 0 2 2
$short_sig_digit == 3 ? : 1 1 2
$short_sig_digit == 4 ? : 0 1 1
$short_sig_digit == 5 ? : 1 0 1
814 ( $initial_significant_digits < 10 ) ? SpecialDecimal :
815 ( $short_sig_digit == 0 ) ? SpecialZeroScientific :
816 ( $short_sig_digit == 1 ) ? SpecialOneScientific :
817 ( $short_sig_digit == 2 ) ? SpecialTwoScientific :
818 ( $short_sig_digit == 3 ) ? SpecialThreeScientific :
819 ( $short_sig_digit == 4 ) ? SpecialFourScientific :
820 ( $short_sig_digit == 5 ) ? SpecialFiveScientific :
821 SpecialZeroScientific ;
822 ###LogSD $phone->talk( level => 'debug', message =>[
823 ###LogSD "Resolved the final formatted output to formatter: " . $scientific_format->display_name ] );
824 }
825  
826 614 $return->{cell_type} = $result->{cell_type};
827 614 $return->{r} = $result->{r};
828 614 ▶ $return->{cell_merge} = $result->{cell_merge} if exists $result->{cell_merge};
Branch: 1 branch
BranchTrueFalseTotal
if exists $result->{"cell_merge"} 37 577 614
829 614 ▶ $return->{cell_hidden} = $result->{cell_hidden} if exists $result->{cell_hidden};
Branch: 1 branch
BranchTrueFalseTotal
if exists $result->{"cell_hidden"} 229 385 614
830 614 ▶ if( !exists $return->{cell_unformatted} and exists $result->{cell_xml_value} ){
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $return->{"cell_unformatted"} and exists $result->{"cell_xml_value"}) 522 92 614
Condition100%3/3
not exists $return->{"cell_unformatted"} and exists $result->{"cell_xml_value"}
!ll&&!rl&&r
5141522
MC/DC100%2/2
not exists $return->{"cell_unformatted"} and exists $result->{"cell_xml_value"}
not exists $return->{"cell_unformatted"} exists $result->{"cell_xml_value"}
Truth table100%3/3
not(A) and B
A= not exists $return->{"cell_unformatted"}B= exists $result->{"cell_xml_value"}
ABresult
0X0
100
111
831 522 @$return{qw( cell_unformatted rich_text )} = @$result{qw( cell_xml_value rich_text )};
832 522 ▶ delete $return->{rich_text} if !$return->{rich_text};
Branch: 1 branch
BranchTrueFalseTotal
unless $return->{"rich_text"} 516 6 522
833 ###LogSD $phone->talk( level => 'debug', message =>[
834 ###LogSD "No crazy number stuff the unformatted value is: $return->{cell_unformatted}"] );
835 }
836  
837 #Implement user defined changes in encoding
838 ###LogSD $phone->talk( level => 'debug', message =>[ "Current cell: ", $return ] );
839 614 ▶ if( $return->{cell_unformatted} and length( $return->{cell_unformatted} ) > 0 ){
Branch: 1 branch
BranchTrueFalseTotal
if ($return->{"cell_unformatted"} and length $return->{"cell_unformatted"} > 0) 548 66 614
Condition66%2/3
$return->{"cell_unformatted"} and length $return->{"cell_unformatted"} > 0
!ll&&!rl&&r
660548
MC/DC50%1/2
$return->{"cell_unformatted"} and length $return->{"cell_unformatted"} > 0
$return->{"cell_unformatted"} length $return->{"cell_unformatted"} > 0
Truth table66%2/3
A and B
A= $return->{"cell_unformatted"}B= length $return->{"cell_unformatted"} > 0
ABresult
0X0
100
111
840 548 $return->{cell_unformatted} = $self->change_output_encoding( $return->{cell_unformatted} );
841 ###LogSD $phone->talk( level => 'debug', message =>[
842 ###LogSD "Unformatted with output encoding changed: " . $return->{cell_unformatted} ] );# if defined $return->{cell_unformatted};
843 }
844 614 ▶ if( $self->get_group_return_type eq 'unformatted' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_group_return_type eq "unformatted") 49 565 614
845 ###LogSD $phone->talk( level => 'debug', message =>[
846 ###LogSD "Sending back just the unformatted value: " . ($return->{cell_unformatted}//'') ] ) ;
847 49 return $return->{cell_unformatted};
848 }
849 565 ▶ if( $return->{cell_xml_value} and length( $return->{cell_xml_value} ) > 0 ){#Implement user defined changes in encoding
Branch: 1 branch
BranchTrueFalseTotal
if ($return->{"cell_xml_value"} and length $return->{"cell_xml_value"} > 0) 505 60 565
Condition66%2/3
$return->{"cell_xml_value"} and length $return->{"cell_xml_value"} > 0
!ll&&!rl&&r
600505
MC/DC50%1/2
$return->{"cell_xml_value"} and length $return->{"cell_xml_value"} > 0
$return->{"cell_xml_value"} length $return->{"cell_xml_value"} > 0
Truth table66%2/3
A and B
A= $return->{"cell_xml_value"}B= length $return->{"cell_xml_value"} > 0
ABresult
0X0
100
111
850 505 $return->{cell_xml_value} = $self->change_output_encoding( $return->{cell_xml_value} );
851 ###LogSD $phone->talk( level => 'debug', message =>[
852 ###LogSD "XML with output encoding changed: " . $return->{cell_xml_value} ] );# if defined $return->{cell_unformatted};
853 }
854 565 ▶ if( $self->get_group_return_type eq 'xml_value' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_group_return_type eq "xml_value") 0 565 565
855 ###LogSD $phone->talk( level => 'debug', message =>[
856 ###LogSD "Sending back just the unformatted value: " . ($return->{cell_xml_value}//'') ] ) ;
857 0 return $return->{cell_xml_value};
858 }
859  
860 # Get any relevant custom format
861 565 my $custom_format;
862 565 ▶ if( $self->has_custom_format( $result->{r} ) ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_custom_format($result->{'r'})) { } 6 559 565
863 ###LogSD $phone->talk( level => 'debug', message =>[
864 ###LogSD "Custom format exists for: $result->{r}",] );
865 6 $custom_format = $self->get_custom_format( $result->{r} );
866 }else{
867 559 $result->{r} =~ /([A-Z]+)(\d+)/;
868 559 my ( $col_letter, $excel_row ) = ( $1, $2 );
869 559 ▶ if( $self->has_custom_format( $col_letter ) ){
Branch: 2 branches
BranchTrueFalseTotal
if ($self->has_custom_format($col_letter)) { } 0 559 559
elsif ($self->has_custom_format($excel_row)) { } 6 553 559
870 ###LogSD $phone->talk( level => 'debug', message =>[
871 ###LogSD "Custom format exists for column: $col_letter",] );
872 0 $custom_format = $self->get_custom_format( $col_letter );
873 }elsif( $self->has_custom_format( $excel_row ) ){
874 ###LogSD $phone->talk( level => 'debug', message =>[
875 ###LogSD "Custom format exists for row: $excel_row",] );
876 6 $custom_format = $self->get_custom_format( $excel_row );
877 }
878 }
879  
880 # Initial check for return of value only (custom format case)
881 565 ▶ if( $custom_format ){
Branch: 1 branch
BranchTrueFalseTotal
if ($custom_format) 12 553 565
882 ###LogSD $phone->talk( level => 'debug', message =>[
883 ###LogSD 'Cell custom_format is:', $custom_format ] );
884 12 ▶ if( $self->get_group_return_type eq 'value' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_group_return_type eq "value") 0 12 12
885 ###LogSD $phone->talk( level => 'debug', message =>[
886 ###LogSD 'Applying custom format to: ' . $return->{cell_unformatted} ] );
887 ###LogSD $phone->talk( level => 'trace', message =>[
888 ###LogSD 'Returning value coerced by custom format:', $custom_format ] );
889 return Spreadsheet::Reader::ExcelXML::Cell->_return_value_only(
890 $return->{cell_unformatted},
891 0 $custom_format,
892 $self->get_error_inst,
893 ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only',
894 );
895 }
896 12 $return->{cell_coercion} = $custom_format;
897 12 $return->{cell_type} = 'Custom';
898 }
899  
900 # handle the formula
901 565 ▶ if( exists $result->{cell_formula} and defined $result->{cell_formula} and length( $result->{cell_formula} ) > 0 ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result->{"cell_formula"} and defined $result->{"cell_formula"} and length $result->{"cell_formula"} > 0) 48 517 565
Condition66%4/6
exists $result->{"cell_formula"} and defined $result->{"cell_formula"} and length $result->{"cell_formula"} > 0
!ll&&!rl&&r
517048
exists $result->{"cell_formula"} and defined $result->{"cell_formula"}
!ll&&!rl&&r
517048
MC/DC33%1/3
exists $result->{"cell_formula"} and defined $result->{"cell_formula"} and length $result->{"cell_formula"} > 0
exists $result->{"cell_formula"} defined $result->{"cell_formula"} length $result->{"cell_formula"} > 0
Truth table50%2/4
A and B and C
A= exists $result->{"cell_formula"}B= defined $result->{"cell_formula"}C= length $result->{"cell_formula"} > 0
ABCresult
0XX0
10X0
1100
1111
902 48 $return->{cell_formula} = $result->{cell_formula};
903 }
904  
905 # convert the row column to user defined
906 565 $return->{cell_row} = $self->get_used_position( $result->{cell_row} );
907 565 $return->{cell_col} = $self->get_used_position( $result->{cell_col} );
908 ###LogSD $phone->talk( level => 'debug', message =>[
909 ###LogSD "Cell args to this point:", $return] );
910  
911 565 ▶ if( exists $result->{s} ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result->{"s"}) 370 195 565
912 370 ▶ my $header = ($self->get_group_return_type eq 'value') ? 'cell_coercion' : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->get_group_return_type eq 'value' ? : 198 172 370
913 370 ▶ my $exclude_header = ($custom_format) ? 'cell_coercion' : undef;
Branch: 1 branch
BranchTrueFalseTotal
$custom_format ? : 12 358 370
914 370 my $format;
915 370 ▶ if( $header and $exclude_header and $header eq $exclude_header ){
Branch: 2 branches
BranchTrueFalseTotal
if ($header and $exclude_header and $header eq $exclude_header) { } 0 370 370
elsif ($self->has_styles_interface) { } 346 24 370
Condition50%3/6
$header and $exclude_header and $header eq $exclude_header
!ll&&!rl&&r
37000
$header and $exclude_header
!ll&&!rl&&r
1721980
MC/DC0%0/3
$header and $exclude_header and $header eq $exclude_header
$header $exclude_header $header eq $exclude_header
Truth table50%2/4
A and B and C
A= $headerB= $exclude_headerC= $header eq $exclude_header
ABCresult
0XX0
10X0
1100
1111
916 ###LogSD $phone->talk( level => 'info', message =>[
917 ###LogSD "It looks like you just want to just return the formatted value but there is already a custom format" ] );
918 }elsif( $self->has_styles_interface ){
919 ###LogSD $phone->talk( level => 'debug', message =>[
920 ###LogSD "Pulling formats with:", $result->{s}, $header, $exclude_header, ] );
921 346 $format = $self->get_format( $result->{s}, $header, $exclude_header );
922 ###LogSD $phone->talk( level => 'trace', message =>[
923 ###LogSD "format is:", $format ] );
924 }else{
925 24 $self->set_error( "'s' element called out but the style file is not available!" );
926 }
927 ###LogSD $phone->talk( level => 'debug', message =>[
928 ###LogSD "Checking if the defined number format needs replacing with:", $custom_format, $scientific_format] );
929 370 ▶ if( $custom_format ){
Branch: 2 branches
BranchTrueFalseTotal
if ($custom_format) { } 12 358 370
elsif ($scientific_format and !exists $format->{'cell_coercion'} || $format->{'cell_coercion'}->display_name eq 'Excel_number_0' || $format->{'cell_coercion'}->display_name eq 'Excel_text_0') { } 10 678 688
930 ###LogSD $phone->talk( level => 'debug', message =>[
931 ###LogSD "Custom formats override this cell", $custom_format->display_name] );
932 12 delete $format->{cell_coercion};
933 ▶ }elsif( $scientific_format and
Condition66%6/9
$scientific_format and !exists $format->{"cell_coercion"} || $format->{"cell_coercion"}->display_name eq "Excel_number_0" || $format->{"cell_coercion"}->display_name eq "Excel_text_0"
!ll&&!rl&&r
3301810
not exists $format->{"cell_coercion"} or $format->{"cell_coercion"}->display_name eq "Excel_number_0" or $format->{"cell_coercion"}->display_name eq "Excel_text_0"
l!l&&r!l&&!r
01018
not exists $format->{"cell_coercion"} or $format->{"cell_coercion"}->display_name eq "Excel_number_0"
l!l&&r!l&&!r
0028
MC/DC50%2/4
$scientific_format and !exists $format->{"cell_coercion"} || $format->{"cell_coercion"}->display_name eq "Excel_number_0" || $format->{"cell_coercion"}->display_name eq "Excel_text_0"
$scientific_format not exists $format->{"cell_coercion"} $format->{"cell_coercion"}->display_name eq "Excel_number_0" $format->{"cell_coercion"}->display_name eq "Excel_text_0"
Truth table60%3/5
A and not(B) or C or D
A= $scientific_formatB= not exists $format->{"cell_coercion"}C= $format->{"cell_coercion"}->display_name eq "Excel_number_0"D= $format->{"cell_coercion"}->display_name eq "Excel_text_0"
ABCDresult
0XXX0
10000
11XX1
101X1
10011
934 ( !exists $format->{cell_coercion} or
935 $format->{cell_coercion}->display_name eq 'Excel_number_0' or
936 $format->{cell_coercion}->display_name eq 'Excel_text_0' ) ){
937 ###LogSD $phone->talk( level => 'debug', message =>[
938 ###LogSD "The generic number case will implement a hidden scientific format", $scientific_format] );
939 10 $return->{cell_coercion} = $scientific_format;
940 10 delete $format->{cell_coercion};
941 }
942 # Second check for value only - for the general number case not just custom formats
943 370 ▶ if( $self->get_group_return_type eq 'value' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_group_return_type eq "value") 198 172 370
944 ###LogSD $phone->talk( level => 'debug', message =>[
945 ###LogSD 'Applying (a possible) regular format to: ' . ($return->{cell_unformatted}//''), $return, $format ] );
946 return Spreadsheet::Reader::ExcelXML::Cell->_return_value_only(
947 $return->{cell_unformatted},
948 $return->{cell_coercion} // $format->{cell_coercion},
949 198 ▶ $self->get_error_inst,
Condition66%2/3
$return->{"cell_coercion"} // $format->{"cell_coercion"}
l!l&&r!l&&!r
015048
MC/DC50%1/2
$return->{"cell_coercion"} // $format->{"cell_coercion"}
$return->{"cell_coercion"} $format->{"cell_coercion"}
Truth table66%2/3
A // B
A= $return->{"cell_coercion"}B= $format->{"cell_coercion"}
ABresult
1X1
011
000
950 ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only',
951 );
952 }
953 172 ▶ if( $self->has_styles_interface ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_styles_interface) 148 24 172
954 ###LogSD $phone->talk( level => 'debug', message =>[
955 ###LogSD "Format headers are:", $format_headers ] );
956 148 for my $header ( @$format_headers ){
957 888 ▶ if( exists $format->{$header} ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $format->{$header}) 597 291 888
958 ###LogSD $phone->talk( level => 'trace', message =>[
959 ###LogSD "Transferring styles header -$header- to the cell", ] );
960 597 $return->{$header} = $format->{$header};
961 597 ▶ if( $header eq 'cell_coercion' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($header eq "cell_coercion") 126 471 597
962 126 ▶ if( $return->{cell_type} eq 'Numeric' and
Branch: 1 branch
BranchTrueFalseTotal
if ($return->{"cell_type"} eq "Numeric" and $format->{$header}->name =~ /date/iu) 22 104 126
Condition100%3/3
$return->{"cell_type"} eq "Numeric" and $format->{$header}->name =~ /date/iu
!ll&&!rl&&r
426222
MC/DC100%2/2
$return->{"cell_type"} eq "Numeric" and $format->{$header}->name =~ /date/iu
$return->{"cell_type"} eq "Numeric" $format->{$header}->name =~ /date/iu
Truth table100%3/3
A and B
A= $return->{"cell_type"} eq "Numeric"B= $format->{$header}->name =~ /date/iu
ABresult
0X0
100
111
963 $format->{$header}->name =~ /date/i){
964 ###LogSD $phone->talk( level => 'trace', message =>[
965 ###LogSD "Found a -Date- cell", ] );
966 22 $return->{cell_type} = 'Date';
967 }
968 }
969 }
970 }
971 ###LogSD $phone->talk( level => 'trace', message =>[
972 ###LogSD "Practice special old spreadsheet magic here as needed - for now only single quote in the formula bar", ] );
973 148 ▶ if( exists $format->{quotePrefix} ){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $format->{"quotePrefix"}) 1 147 148
974 ###LogSD $phone->talk( level => 'debug', message =>[
975 ###LogSD "Found the single quote in the formula bar case", ] );# Other similar cases include carat and double quote in the formula bar (middle and right justified)
976 1 $return->{cell_alignment}->{horizontal} = 'left';
977 1 ▶ $return->{cell_formula} = $return->{cell_formula} ? ("'" . $return->{cell_formula}) : "'";
Branch: 1 branch
BranchTrueFalseTotal
$return->{'cell_formula'} ? : 0 1 1
978 }
979  
980 }
981 }
982 ###LogSD $phone->talk( level => 'debug', message =>[
983 ###LogSD "Checking if a scientific format should be used", $scientific_format] );
984 367 ▶ if( $scientific_format and !exists $return->{cell_coercion} ){
Branch: 1 branch
BranchTrueFalseTotal
if ($scientific_format and not exists $return->{"cell_coercion"}) 3 364 367
Condition100%3/3
$scientific_format and not exists $return->{"cell_coercion"}
!ll&&!rl&&r
336283
MC/DC100%2/2
$scientific_format and not exists $return->{"cell_coercion"}
$scientific_format not exists $return->{"cell_coercion"}
Truth table100%3/3
A and not(B)
A= $scientific_formatB= not exists $return->{"cell_coercion"}
ABresult
0X0
100
111
985 ###LogSD $phone->talk( level => 'debug', message =>[
986 ###LogSD "The generic number case will implement a hidden scientific format", $scientific_format] );
987 3 $return->{cell_coercion} = $scientific_format;
988 }
989  
990 ###LogSD $phone->talk( level => 'trace', message =>[
991 ###LogSD "Checking return type: " . $self->get_group_return_type, ] );
992 # Final check for value only - for the text case
993 367 ▶ if( $self->get_group_return_type eq 'value' ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_group_return_type eq "value") 118 249 367
994 ###LogSD $phone->talk( level => 'debug', message =>[
995 ###LogSD 'Applying (a possible) regular format to: |' . ($return->{cell_unformatted}//'') . '|' ] );
996 return Spreadsheet::Reader::ExcelXML::Cell->_return_value_only(
997 $return->{cell_unformatted},
998 $return->{cell_coercion},
999 118 $self->get_error_inst,
1000 ###LogSD $self->get_log_space . '::Cell::_hidden::_return_value_only',
1001 );
1002 }
1003 249 $return->{error_inst} = $self->get_error_inst;
1004 ###LogSD $phone->talk( level => 'debug', message =>[
1005 ###LogSD "Current args ref is:", $return] );
1006 }elsif( $result ){
1007 0 confess "I don't know how I got here: $result";
1008 }
1009  
1010 # build a cell
1011 249 ▶ delete $return->{cell_coercion} if !$return->{cell_coercion};#
Branch: 1 branch
BranchTrueFalseTotal
unless $return->{"cell_coercion"} 98 151 249
1012 ###LogSD $return->{log_space} = $self->get_log_space;
1013 ###LogSD $phone->talk( level => 'debug', message =>[
1014 ###LogSD "Building cell with:", $return] );
1015 249 my $cell = Spreadsheet::Reader::ExcelXML::Cell->new( %$return );
1016 ###LogSD $phone->talk( level => 'debug', message =>[
1017 ###LogSD "Cell is:", $cell ] );
1018 249 return $cell;
1019 }
1020  
1021 31 ▶sub DEMOLISH{
Subroutine DEMOLISH: called CC=2 SCAR=6.9
Pod undocumented
1022 31 my ( $self ) = @_;
1023 ###LogSD my $phone = Log::Shiras::Telephone->new( name_space =>
1024 ###LogSD $self->get_all_space . '::_hidden::DEMOLISH', );
1025 ###LogSD if( $self->_has_name ){
1026 ###LogSD $phone->talk( level => 'debug', message =>[
1027 ###LogSD "Cleaning up worksheet: " . $self->get_name ] );
1028 ###LogSD }
1029 31 ▶ if( $self->has_file ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_file) 19 12 31
1030 ###LogSD $phone->talk( level => 'debug', message =>[
1031 ###LogSD "Need to clear the file" ] );
1032 19 $self->clear_file;
1033 ###LogSD $phone->talk( level => 'debug', message =>[ "File cleared" ] );
1034 }
1035 }
1036  
1037 #########1 Phinish 3#########4#########5#########6#########7#########8#########9
1038  
1039 18 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
1040 18 1;
1041  
1042 #########1 Documentation 3#########4#########5#########6#########7#########8#########9
1043 __END__
« lib/Spreadsheet/Reader/ExcelXML/XMLReader/NamedWorksheet.pm ↑ Summary lib/Spreadsheet/Reader/ExcelXML/XMLReader/PositionSharedStrings.pm »