| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (C) 2003-2007, G. Allen Morris III, all rights reserved |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
120
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Data::Tabular::Output::HTML; |
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use base 'Data::Tabular::Output'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
813
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
12
|
use Carp qw (croak); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
129
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
11
|
use overload '""' => \&_render; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
2
|
|
|
2
|
1
|
7
|
my $class = shift; |
|
16
|
2
|
|
|
|
|
8
|
my $args = { @_ }; |
|
17
|
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
9
|
my $self = bless {}, $class; |
|
19
|
|
|
|
|
|
|
|
|
20
|
2
|
50
|
|
|
|
12
|
die 'No table' unless $args->{table}; |
|
21
|
2
|
|
|
|
|
159
|
$self->{table} = $args->{table}; |
|
22
|
2
|
50
|
|
|
|
11
|
die 'No output config' unless $args->{output}; |
|
23
|
2
|
50
|
|
|
|
9
|
die 'No output config' unless ref $args->{output}; |
|
24
|
2
|
50
|
|
|
|
22
|
die 'No output config' unless $args->{output}->isa('Data::Tabular::Config::Output'); |
|
25
|
2
|
|
|
|
|
7
|
$self->{output} = $args->{output}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
12
|
$self; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _render |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
|
33
|
2
|
|
|
|
|
7
|
$self->html; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
{ |
|
37
|
|
|
|
|
|
|
package Data::Tabular::_Type::Text; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub new |
|
40
|
|
|
|
|
|
|
{ |
|
41
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
bless { |
|
44
|
|
|
|
|
|
|
@_ |
|
45
|
|
|
|
|
|
|
}, $class; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub html_text |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
sprintf($self->{format}, $self->{data}); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub html |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
2
|
|
|
2
|
1
|
4
|
my $self = shift; |
|
59
|
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
16
|
my $output = $self->output; |
|
61
|
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
13
|
my $attributes = $output->html_attribute_string; |
|
63
|
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
5
|
$attributes .= ''; |
|
65
|
2
|
|
|
|
|
6
|
my $ret = "\n";
|
66
|
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
5
|
$ret .= " \n"; |
|
68
|
2
|
|
|
|
|
16
|
for my $col ($self->columns()) { |
|
69
|
21
|
|
|
|
|
54
|
my $attribute = $col->align(); |
|
70
|
|
|
|
|
|
|
|
|
71
|
21
|
|
|
|
|
56
|
$ret .= " \n"; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
2
|
|
|
|
|
30
|
$ret .= " \n"; |
|
74
|
2
|
|
|
|
|
4
|
my @table; |
|
75
|
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
17
|
for my $row ($self->rows()) { |
|
77
|
44
|
|
|
|
|
236
|
my $attribute = $row->html_attribute_string(); |
|
78
|
44
|
|
|
|
|
165
|
push(@table, " | \n");
|
79
|
|
|
|
|
|
|
|
|
80
|
44
|
|
|
|
|
182
|
for my $cell ($row->cells()) { |
|
81
|
288
|
|
|
|
|
1489
|
my $data = $cell->data; |
|
82
|
288
|
|
|
|
|
961
|
my $type = $self->output->type($cell->column_name); |
|
83
|
288
|
50
|
|
|
|
1786
|
unless (ref $data) { |
|
84
|
0
|
|
|
|
|
0
|
warn "ASDF"; |
|
85
|
0
|
|
|
|
|
0
|
$data = Data::Tabular::Type::Text->new( |
|
86
|
|
|
|
|
|
|
data => '[' . $data . ']', |
|
87
|
|
|
|
|
|
|
format => $self->output->get_column_format($cell->column_name), |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
288
|
|
|
|
|
426
|
my $attributes = ''; |
|
92
|
288
|
50
|
|
|
|
827
|
if (my $cs = $cell->colspan) { |
|
93
|
288
|
100
|
|
|
|
783
|
if ($cs > 1) { |
|
94
|
27
|
|
|
|
|
198
|
$attributes.= sprintf(' colspan="%s"', $cs); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
288
|
50
|
33
|
|
|
1225
|
if ($type eq 'dollar' or $type eq 'number') { |
|
99
|
0
|
|
|
|
|
0
|
$attributes.= ' align="right"'; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
288
|
|
|
|
|
860
|
my $hdr = $cell->hdr; |
|
103
|
288
|
|
|
|
|
366
|
$hdr = 0; |
|
104
|
288
|
50
|
|
|
|
504
|
if ($hdr) { |
|
105
|
0
|
|
|
|
|
0
|
push(@table, " | ");
|
|
106
|
|
|
|
|
|
|
} else { |
|
107
|
288
|
|
|
|
|
1470
|
push(@table, " | "); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
288
|
|
|
|
|
792
|
my $cell_data = $data->html_text; |
|
110
|
|
|
|
|
|
|
|
|
111
|
288
|
100
|
|
|
|
973
|
if (length($cell_data) == 0) { |
|
112
|
5
|
|
|
|
|
11
|
$cell_data = ' '; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
288
|
|
|
|
|
492
|
push(@table, $cell_data); |
|
115
|
288
|
50
|
|
|
|
461
|
if ($hdr) { |
|
116
|
0
|
|
|
|
|
0
|
push(@table, "\n"); |
|
117
|
|
|
|
|
|
|
} else { |
|
118
|
288
|
|
|
|
|
2080
|
push(@table, " | \n");
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
} |
|
121
|
44
|
|
|
|
|
376
|
push(@table, " | \n");
|
122
|
|
|
|
|
|
|
} |
|
123
|
2
|
|
|
|
|
139
|
$ret .= join('', @table); |
|
124
|
2
|
|
|
|
|
26
|
$ret .= " | \n"; |
|
125
|
2
|
|
|
|
|
1025
|
$ret; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
|
129
|
|
|
|
|
|
|
__END__ |