| 1 | # Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | package | ||||||||||||||||||||||||||||||||||
| 5 | Data::Tabular::Cell; | ||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | #use overload '""' => \&str; | ||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | sub new | ||||||||||||||||||||||||||||||||||
| 12 | 1259 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 13 | 1259 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 1259 | my $args = { @_ }; | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 1259 | ▶ | die "No row" unless ref $args->{row}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 18 | 1259 | ▶ | die "No cell" unless ref $args->{cell} || defined $args->{cell}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $args->{"cell"} or defined $args->{"cell"}
MC/DC0%0/2
ref $args->{"cell"} or defined $args->{"cell"}
ref $args->{"cell"}
defined $args->{"cell"}
Truth table33%1/3
A or B
A= ref $args->{"cell"}B= defined $args->{"cell"}
| |||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | 1259 | my $self = bless($args, $class); | |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | 1259 | $self; | |||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||
| 25 | sub row_id | ||||||||||||||||||||||||||||||||||
| 26 | 440 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
row_id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 27 | 440 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 28 | 440 | $self->row->id() - 1; | |||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | sub col_id | ||||||||||||||||||||||||||||||||||
| 32 | 1344 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
col_id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 33 | 1344 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 34 | 1344 | $self->{id}; | |||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | sub row | ||||||||||||||||||||||||||||||||||
| 38 | 440 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
row: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 39 | 440 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 40 | 440 | $self->{row}; | |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | sub data | ||||||||||||||||||||||||||||||||||
| 44 | 988 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
data: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 45 | 988 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | 988 | my $ret = $self->{row}->get_column($self->{cell}); | |||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | 988 | return $ret; | |||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||
| 52 | sub str | ||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
str: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 54 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 55 | 0 | die "STR " . caller; | |||||||||||||||||||||||||||||||||
| 56 | 0 | 'Cell : '. $self->{cell} . ' ' . $self->html_string; | |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | sub html_string | ||||||||||||||||||||||||||||||||||
| 60 | 271 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
html_string: called CC=9 SCAR=27.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 61 | 271 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | 271 | ▶ | my $ret = $self->{row}->get_column($self->{cell}) || ''; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'row'}->get_column($self->{'cell'}) || ''
MC/DC100%1/1
$self->{'row'}->get_column($self->{'cell'}) || ''
$self->{'row'}->get_column($self->{'cell'})
Truth table100%2/2
A
A= $self->{'row'}->get_column($self->{'cell'})
| |||||||||||||||||||||||||||||||||||
| 64 | 271 | ▶ | if (my $type = ref($ret)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 65 | 267 | ▶ | if ($type eq 'HASH') { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $ret = $ret->{html} || $ret->{text} || $ret->{data}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$ret->{'html'} || $ret->{'text'} || $ret->{'data'}
$ret->{"html"} or $ret->{"text"}
MC/DC0%0/3
$ret->{'html'} || $ret->{'text'} || $ret->{'data'}
$ret->{"html"}
$ret->{"text"}
$ret->{'data'}
Truth table0%0/4
A or B || C
A= $ret->{"html"}B= $ret->{"text"}C= $ret->{'data'}
| |||||||||||||||||||||||||||||||||||
| 67 | } elsif ($type eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||
| 68 | 0 | die 'XXXXX'; | |||||||||||||||||||||||||||||||||
| 69 | } else { | ||||||||||||||||||||||||||||||||||
| 70 | 267 | ▶ | if ($ret->can('bob')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 71 | # we just use it; | ||||||||||||||||||||||||||||||||||
| 72 | } else { | ||||||||||||||||||||||||||||||||||
| 73 | # we just use it; | ||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||||||||||||||
| 77 | # $ret; | ||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||
| 80 | 271 | ▶ | length($ret) ? $ret : ' '; # This is wrong FIXME | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | sub colspan | ||||||||||||||||||||||||||||||||||
| 84 | 288 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
colspan: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 85 | 288 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | 288 | my $colspan = $self->{colspan}; | |||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | 288 | return $colspan; | |||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||
| 92 | sub html_attribute_string | ||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
html_attribute_string: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 94 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 95 | 0 | my $row = $self->{row}; | |||||||||||||||||||||||||||||||||
| 96 | 0 | my $header = $self->{cell}; | |||||||||||||||||||||||||||||||||
| 97 | 0 | my $data = $self->{row}->get_column($self->{cell}); | |||||||||||||||||||||||||||||||||
| 98 | 0 | my $colspan = $self->{colspan}; | |||||||||||||||||||||||||||||||||
| 99 | 0 | warn join ' ', caller; | |||||||||||||||||||||||||||||||||
| 100 | 0 | my $attributes = $row->cell_html_attributes($self); | |||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if ($colspan > 1) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 103 | 0 | $attributes->{colspan} = $colspan, | |||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if (my $type = ref($data)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ({ | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 108 | HASH => 1, | ||||||||||||||||||||||||||||||||||
| 109 | ARRAY => 1, | ||||||||||||||||||||||||||||||||||
| 110 | CODE => 1, | ||||||||||||||||||||||||||||||||||
| 111 | }->{$type}) { | ||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ($type eq 'HASH') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 113 | 0 | $attributes->{bgcolor} = $data->{bgcolor}; | |||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||
| 115 | # don't do anything | ||||||||||||||||||||||||||||||||||
| 116 | } else { | ||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ($data->can('attributes')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 118 | $attributes = { | ||||||||||||||||||||||||||||||||||
| 119 | %$attributes, | ||||||||||||||||||||||||||||||||||
| 120 | 0 | %{$data->attributes()}, | |||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||
| 122 | } else { | ||||||||||||||||||||||||||||||||||
| 123 | 0 | warn 'no attributes ', ref($data); | |||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ($self->{bgcolor}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 128 | 0 | $attributes->{bgcolor} = $self->{bgcolor}; | |||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | 0 | my $ret = ''; # FIXME | |||||||||||||||||||||||||||||||||
| 132 | 0 | for my $attribute (sort keys %$attributes) { | |||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | next unless defined($attributes->{$attribute}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 134 | 0 | $ret .= qq| $attribute="| . $attributes->{$attribute} . qq|"|; | |||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 0 | $ret; | |||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||
| 140 | sub hdr | ||||||||||||||||||||||||||||||||||
| 141 | 288 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
hdr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 142 | 288 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 143 | 288 | $self->{row}->hdr; | |||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | sub name | ||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 148 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 149 | 0 | my $cell = $self->{cell}; | |||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | 0 | $cell; | |||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||
| 154 | sub xls_type | ||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
xls_type: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 156 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | 0 | my $cell = $self->{row}->get_column($self->{cell}); | |||||||||||||||||||||||||||||||||
| 159 | 0 | my $ret = 'text'; | |||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if (my $type = ref($cell)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($type eq 'HASH') { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 162 | } elsif ($type eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||
| 163 | } else { | ||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if ($cell->can('type')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 165 | 0 | $ret = $cell->type; | |||||||||||||||||||||||||||||||||
| 166 | } else { | ||||||||||||||||||||||||||||||||||
| 167 | # we just use it; | ||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||
| 171 | 0 | $ret; | |||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||
| 174 | sub xls_string | ||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
xls_string: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 176 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | 0 | my $ret = $self->{row}->get_column($self->{cell}); | |||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if (my $type = ref($ret)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ($type eq 'HASH') { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $ret = $ret->{html} || $ret->{text}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ret->{'html'} || $ret->{'text'}
MC/DC0%0/2
$ret->{'html'} || $ret->{'text'}
$ret->{'html'}
$ret->{'text'}
Truth table0%0/3
A || B
A= $ret->{'html'}B= $ret->{'text'}
| |||||||||||||||||||||||||||||||||||
| 182 | } elsif ($type eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||
| 183 | 0 | die 'XXXXX'; | |||||||||||||||||||||||||||||||||
| 184 | } else { | ||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if ($ret->can('xls_data')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 186 | # we just use it; | ||||||||||||||||||||||||||||||||||
| 187 | 0 | $ret = $ret->xls_data(); | |||||||||||||||||||||||||||||||||
| 188 | } else { | ||||||||||||||||||||||||||||||||||
| 189 | # we just use it; | ||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||
| 193 | 0 | $ret; | |||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||
| 196 | sub column_name | ||||||||||||||||||||||||||||||||||
| 197 | 288 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
column_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 198 | 288 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||
| 200 | 288 | $self->{cell}; | |||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | sub type | ||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 205 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $self->{type} || 'normal'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||
| 211 | 6 | 1; | |||||||||||||||||||||||||||||||||
| 212 | __END__ | ||||||||||||||||||||||||||||||||||