Template/Element/Cell.pm

filter: Statementstmt 24.4% 12 / 49 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 3 totaltotal 19.0% 16 / 84 CC 11 SCAR 41.3
CC
11
Cov
17%
render
110.0
_get_text
6.0
new
2.0
CRAP 62.2
« Template/Format.pm ↑ Summary Template/Container/Worksheet.pm »
1 package Excel::Template::Element::Cell;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 BEGIN {
6 1 ▶ use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶ @ISA = qw(Excel::Template::Element);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶ use Excel::Template::Element;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 }
11  
12 sub new
13 {
14 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
15 0 my $self = $class->SUPER::new(@_);
16  
17 0 $self->{TXTOBJ} = Excel::Template::Factory->_create('TEXTOBJECT');
18  
19 0 return $self;
20 }
21  
22 sub _get_text
23 {
24 0 ▶ my $self = shift;
Subroutine _get_text: not called CC=2 SCAR=17.9
25 0 my ($context) = @_;
26  
27 0 my $txt = $context->get($self, 'TEXT');
28 0 ▶ if (defined $txt)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $txt) { } 0 0 0
29 {
30 0 my $txt_obj = Excel::Template::Factory->_create('TEXTOBJECT');
31 0 push @{$txt_obj->{STACK}}, $txt;
32 0 $txt = $txt_obj->resolve($context);
33 }
34 else
35 {
36 0 $txt = $self->{TXTOBJ}->resolve($context)
37 }
38  
39 0 return $txt;
40 }
41  
42 1 my %legal_types = (
43 'blank' => 'write_blank',
44 'formula' => 'write_formula',
45 'number' => 'write_number',
46 'string' => 'write_string',
47 'url' => 'write_url',
48 'date_time' => 'write_date_time',
49 );
50  
51 sub render
52 {
53 0 ▶ my $self = shift;
Subroutine render: not called CC=10 SCAR=47.0
Pod undocumented
54 0 my ($context, $method) = @_;
55  
56 0 ▶ unless ( $method )
Branch: 1 branch
BranchTrueFalseTotal
unless ($method) 0 0 0
57 {
58 0 my $type = $context->get( $self, 'TYPE' );
59 0 ▶ if ( defined $type )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $type) 0 0 0
60 {
61 0 my $type = lc $type;
62  
63 0 ▶ if ( exists $legal_types{ $type } )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $legal_types{$type}) { } 0 0 0
64 {
65 0 $method = $legal_types{ $type };
66 }
67 else
68 {
69 0 ▶ warn "'$type' is not a legal cell type.\n"
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
70 if $^W;
71 }
72 }
73 }
74  
75 0 ▶ $method ||= 'write';
Condition0%0/2
$method ||= "write"
l!l
00
MC/DC0%0/1
$method ||= "write"
$method
Truth table0%0/2
A
A= $method
Aresult
11
00
76  
77 0 my ($row, $col) = map { $context->get($self, $_) } qw(ROW COL);
78  
79 0 my $ref = $context->get( $self, 'REF' );
80 0 ▶ if (defined $ref && length $ref)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ref and length $ref) 0 0 0
Condition0%0/3
defined $ref and length $ref
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ref and length $ref
defined $ref length $ref
Truth table0%0/3
A and B
A= defined $refB= length $ref
ABresult
0X0
100
111
81 {
82 0 $context->add_reference( uc( $ref ), $row, $col );
83 }
84  
85 # Apply the cell width to the current column
86 0 ▶ if (my $width = $context->get($self, 'WIDTH'))
Branch: 1 branch
BranchTrueFalseTotal
if (my $width = $context->get($self, "WIDTH")) 0 0 0
87 {
88 0 $width =~ s/[^\d.]//g;
89 0 $width *= 1;
90 0 ▶ if ($width > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($width > 0) 0 0 0
91 {
92 0 $context->active_worksheet->set_column($col, $col, $width);
93 }
94 }
95  
96 0 $context->active_worksheet->$method(
97 $row, $col,
98 $self->_get_text($context),
99 $context->active_format,
100 );
101  
102 0 return 1;
103 }
104  
105 sub deltas
106 {
107 return {
108 0 ▶ COL => +1,
Subroutine deltas: not called CC=1 SCAR=6.9
Pod undocumented
109 };
110 }
111  
112 1 1;
113 __END__
« Template/Format.pm ↑ Summary Template/Container/Worksheet.pm »