line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
21
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
149
|
|
4
|
|
|
|
|
|
|
package |
5
|
|
|
|
|
|
|
Data::Tabular::Row::Function; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
17
|
use base 'Data::Tabular::Row'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
324
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
18
|
use Carp qw(croak carp); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
2535
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new |
12
|
|
|
|
|
|
|
{ |
13
|
20
|
|
|
20
|
0
|
33
|
my $class = shift; |
14
|
20
|
|
|
|
|
96
|
my $self = $class->SUPER::new(@_); |
15
|
|
|
|
|
|
|
|
16
|
20
|
50
|
|
|
|
62
|
die unless $self->table; |
17
|
20
|
50
|
|
|
|
61
|
die "Need sum_list" unless $self->{sum_list}; |
18
|
|
|
|
|
|
|
|
19
|
20
|
|
|
|
|
114
|
$self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub cells |
23
|
|
|
|
|
|
|
{ |
24
|
20
|
|
|
20
|
0
|
38
|
my $self = shift; |
25
|
20
|
|
|
|
|
54
|
my @ret = (); |
26
|
20
|
|
|
|
|
101
|
my @headers = $self->headers(); |
27
|
|
|
|
|
|
|
|
28
|
20
|
|
|
|
|
74
|
my $offset = 0; |
29
|
20
|
|
|
|
|
38
|
my $hash; |
30
|
20
|
50
|
|
|
|
43
|
for my $x ( @{$self->{sum_list} || []} ) { |
|
20
|
|
|
|
|
103
|
|
31
|
94
|
|
|
|
|
315
|
$hash->{$x} = { sum => 1 }; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
20
|
|
|
|
|
44
|
my $start; |
35
|
20
|
|
|
|
|
45
|
my $x = 0; |
36
|
20
|
|
|
|
|
59
|
my $state = 0; |
37
|
20
|
|
|
|
|
34
|
my $cols = 1; |
38
|
20
|
|
|
|
|
75
|
while (my $column_name = shift @headers) { |
39
|
222
|
100
|
|
|
|
467
|
if ($state == 0) { |
40
|
30
|
100
|
66
|
|
|
272
|
if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) { |
|
|
|
66
|
|
|
|
|
41
|
10
|
|
|
|
|
52
|
push(@ret, |
42
|
|
|
|
|
|
|
Data::Tabular::Cell->new( |
43
|
|
|
|
|
|
|
row => $self, |
44
|
|
|
|
|
|
|
cell => $column_name, |
45
|
|
|
|
|
|
|
colspan => 1, |
46
|
|
|
|
|
|
|
id => $x, |
47
|
|
|
|
|
|
|
), |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
} else { |
50
|
20
|
|
|
|
|
39
|
$state++; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
222
|
100
|
|
|
|
487
|
if ($state == 1) { |
54
|
80
|
100
|
66
|
|
|
482
|
if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) { |
|
|
|
66
|
|
|
|
|
55
|
20
|
|
|
|
|
176
|
push(@ret, |
56
|
|
|
|
|
|
|
Data::Tabular::Cell->new( |
57
|
|
|
|
|
|
|
row => $self, |
58
|
|
|
|
|
|
|
cell => '_description', |
59
|
|
|
|
|
|
|
colspan => $cols - 1, |
60
|
|
|
|
|
|
|
id => $x - ($cols - 1), |
61
|
|
|
|
|
|
|
), |
62
|
|
|
|
|
|
|
); |
63
|
20
|
|
|
|
|
39
|
$cols = 1; |
64
|
20
|
|
|
|
|
36
|
$state++; |
65
|
|
|
|
|
|
|
} else { |
66
|
60
|
|
|
|
|
125
|
$cols++; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
222
|
100
|
|
|
|
932
|
if ($state == 2) { |
70
|
152
|
100
|
66
|
|
|
979
|
if ($column_name && $hash->{$column_name} && $hash->{$column_name}->{sum}) { |
|
|
|
66
|
|
|
|
|
71
|
84
|
100
|
|
|
|
179
|
if ($cols > 1) { |
72
|
18
|
|
|
|
|
98
|
push(@ret, |
73
|
|
|
|
|
|
|
Data::Tabular::Cell->new( |
74
|
|
|
|
|
|
|
row => $self, |
75
|
|
|
|
|
|
|
cell => '_filler', |
76
|
|
|
|
|
|
|
colspan => $cols - 1, |
77
|
|
|
|
|
|
|
id => $x, |
78
|
|
|
|
|
|
|
), |
79
|
|
|
|
|
|
|
); |
80
|
18
|
|
|
|
|
36
|
$cols = 1; |
81
|
|
|
|
|
|
|
} |
82
|
84
|
|
|
|
|
293
|
push(@ret, |
83
|
|
|
|
|
|
|
Data::Tabular::Cell->new( |
84
|
|
|
|
|
|
|
row => $self, |
85
|
|
|
|
|
|
|
cell => $column_name, |
86
|
|
|
|
|
|
|
colspan => $cols, |
87
|
|
|
|
|
|
|
id => $x, |
88
|
|
|
|
|
|
|
), |
89
|
|
|
|
|
|
|
); |
90
|
84
|
|
|
|
|
154
|
$cols = 1; |
91
|
|
|
|
|
|
|
} else { |
92
|
68
|
|
|
|
|
92
|
$cols++; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
222
|
50
|
|
|
|
476
|
die if ($state >= 3); |
96
|
222
|
|
|
|
|
25699
|
$x++; |
97
|
|
|
|
|
|
|
} |
98
|
20
|
100
|
|
|
|
66
|
if ($cols > 1) { |
99
|
2
|
|
|
|
|
8
|
push(@ret, |
100
|
|
|
|
|
|
|
Data::Tabular::Cell->new( |
101
|
|
|
|
|
|
|
row => $self, |
102
|
|
|
|
|
|
|
cell => '_filler', |
103
|
|
|
|
|
|
|
colspan => $cols, |
104
|
|
|
|
|
|
|
id => $x - 1, |
105
|
|
|
|
|
|
|
), |
106
|
|
|
|
|
|
|
); |
107
|
2
|
|
|
|
|
4
|
$cols = 1; |
108
|
|
|
|
|
|
|
} |
109
|
20
|
50
|
|
|
|
49
|
die $cols if $cols > 1; |
110
|
20
|
|
|
|
|
145
|
@ret; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub sum_list |
114
|
|
|
|
|
|
|
{ |
115
|
114
|
|
|
114
|
0
|
173
|
my $self = shift; |
116
|
|
|
|
|
|
|
|
117
|
114
|
|
|
|
|
2190
|
$self->{sum_list}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub get_column |
121
|
|
|
|
|
|
|
{ |
122
|
0
|
|
|
0
|
0
|
|
die 'Virtual'; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub extra_column |
126
|
|
|
|
|
|
|
{ |
127
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
128
|
0
|
|
|
|
|
|
my $row = shift; |
129
|
0
|
|
|
|
|
|
my $key = shift; |
130
|
0
|
|
|
|
|
|
die "EXTRA"; |
131
|
0
|
|
|
|
|
|
my $extra = $self->{extra}->{columns}; |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my $ret = undef; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $x = $self->extra_package->new(row => $row, table => $self); |
136
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if (ref($extra->{$key}) eq 'CODE') { |
138
|
0
|
|
|
|
|
|
eval { |
139
|
0
|
|
|
|
|
|
$ret = $extra->{$key}->($x); |
140
|
|
|
|
|
|
|
}; |
141
|
0
|
0
|
|
|
|
|
if ($@) { |
142
|
0
|
|
|
|
|
|
die $@; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} else { |
145
|
0
|
|
|
|
|
|
die 'only know how to deal with code'; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
$ret; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |
152
|
|
|
|
|
|
|
__END__ |