line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Text::PORE::Table;
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Text::PORE::Object;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
784
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
@Table::ISA = qw (Object);
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
###############################
|
10
|
|
|
|
|
|
|
# Constructor
|
11
|
|
|
|
|
|
|
###############################
|
12
|
|
|
|
|
|
|
sub new
|
13
|
|
|
|
|
|
|
{
|
14
|
0
|
|
|
0
|
0
|
|
my ($type) = shift;
|
15
|
0
|
|
|
|
|
|
my ($self) = new Object(@_);
|
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
bless $self;
|
18
|
0
|
|
|
|
|
|
$self;
|
19
|
|
|
|
|
|
|
}
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub init
|
22
|
|
|
|
|
|
|
{
|
23
|
0
|
|
|
0
|
0
|
|
return new(@_);
|
24
|
|
|
|
|
|
|
}
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#############################################
|
28
|
|
|
|
|
|
|
# return the Html Code of this product according to the template
|
29
|
|
|
|
|
|
|
#############################################
|
30
|
|
|
|
|
|
|
sub ToHtml
|
31
|
|
|
|
|
|
|
{
|
32
|
0
|
|
|
0
|
0
|
|
my($self) = shift;
|
33
|
0
|
|
|
|
|
|
my(%att_table) = @_;
|
34
|
0
|
|
|
|
|
|
my $html_code = '';
|
35
|
0
|
|
|
|
|
|
my @table_items = {};
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# get attributes
|
38
|
0
|
|
|
|
|
|
$self->LoadAttributes(%att_table);
|
39
|
0
|
|
|
|
|
|
my @table_items = @{$self->{table_items}};
|
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $direction = $self->GetAttribute('direction');
|
41
|
0
|
0
|
|
|
|
|
if ($direction =~ /^h/i) {
|
42
|
0
|
|
|
|
|
|
$direction = 'h';
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
else {
|
45
|
0
|
|
|
|
|
|
$direction = 'v'; # default is vertical
|
46
|
|
|
|
|
|
|
}
|
47
|
0
|
|
|
|
|
|
my ($bullet, $bold, $cols, $rows);
|
48
|
|
|
|
|
|
|
# my $bullet = $self->GetAttribute('bullet');
|
49
|
0
|
|
|
|
|
|
my $bold = $self->GetAttribute('bold');
|
50
|
0
|
|
|
|
|
|
my $cols = $self->GetAttribute('cols');
|
51
|
0
|
|
|
|
|
|
my $rows = $self->GetAttribute('rows');
|
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $attr;
|
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $table_attributes = "";
|
56
|
0
|
|
|
|
|
|
foreach $attr ('border', 'width', 'cellspacing', 'cellpadding') {
|
57
|
0
|
0
|
|
|
|
|
if ($self->GetAttribute($attr)) {
|
58
|
0
|
|
|
|
|
|
$table_attributes .= "$attr="
|
59
|
|
|
|
|
|
|
. $self->GetAttribute($attr)
|
60
|
|
|
|
|
|
|
. " ";
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $row_attributes = "";
|
65
|
0
|
|
|
|
|
|
foreach $attr ('align', 'valign') {
|
66
|
0
|
0
|
|
|
|
|
if ($self->GetAttribute($attr)) {
|
67
|
0
|
|
|
|
|
|
$row_attributes .= "$attr="
|
68
|
|
|
|
|
|
|
. $self->GetAttribute($attr)
|
69
|
|
|
|
|
|
|
. " ";
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
0
|
|
|
|
if (!$cols && !$rows) {
|
75
|
0
|
0
|
|
|
|
|
if ($direction eq 'h') {
|
76
|
0
|
|
|
|
|
|
$rows = 1;
|
77
|
|
|
|
|
|
|
}
|
78
|
|
|
|
|
|
|
else {
|
79
|
0
|
|
|
|
|
|
$cols = 1;
|
80
|
|
|
|
|
|
|
}
|
81
|
|
|
|
|
|
|
}
|
82
|
0
|
0
|
|
|
|
|
if (!$rows) {
|
83
|
0
|
|
|
|
|
|
$rows = ($#table_items+1) / $cols;
|
84
|
0
|
0
|
|
|
|
|
$rows = int($rows)+1 if ($rows > int($rows));
|
85
|
|
|
|
|
|
|
}
|
86
|
0
|
0
|
|
|
|
|
if (!$cols) {
|
87
|
0
|
|
|
|
|
|
$cols = ($#table_items+1) / $rows;
|
88
|
0
|
0
|
|
|
|
|
$cols = int($cols)+1 if ($cols > int($cols));
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
### bullet may be an object ###
|
93
|
0
|
0
|
|
|
|
|
if (%$bullet){ $bullet = $bullet->ToHtml . ' '; }
|
|
0
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
######## multiple columns : use table ########
|
96
|
0
|
|
|
|
|
|
my $row_start;
|
97
|
0
|
|
|
|
|
|
$html_code = "\n";
98
|
0
|
|
|
|
|
|
my ($i,$j,$index);
|
99
|
0
|
|
|
|
|
|
for ($i=0; $i<$rows; $i++) {
|
100
|
0
|
|
|
|
|
|
$html_code .= " | ";
101
|
0
|
0
|
|
|
|
|
if ($direction eq 'h') {
|
102
|
0
|
|
|
|
|
|
$row_start = $i*$cols;
|
103
|
0
|
0
|
|
|
|
|
if ($row_start > $#table_items) { last; }
|
|
0
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
}
|
105
|
0
|
|
|
|
|
|
for ($j=0; $j<$cols; $j++) {
|
106
|
0
|
0
|
|
|
|
|
if ($direction eq 'v') {
|
107
|
0
|
|
|
|
|
|
$index = $j*$rows+$i;
|
108
|
|
|
|
|
|
|
}
|
109
|
|
|
|
|
|
|
else {
|
110
|
0
|
|
|
|
|
|
$index = $row_start + $j;
|
111
|
|
|
|
|
|
|
}
|
112
|
0
|
0
|
|
|
|
|
if ($index > $#table_items) { last; }
|
|
0
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
if ($bold) {
|
114
|
0
|
|
|
|
|
|
$html_code .= " | $bullet$table_items[$index]";
|
115
|
|
|
|
|
|
|
}
|
116
|
|
|
|
|
|
|
else {
|
117
|
0
|
|
|
|
|
|
$html_code .= " | $bullet$table_items[$index]";
|
118
|
|
|
|
|
|
|
}
|
119
|
|
|
|
|
|
|
}
|
120
|
0
|
|
|
|
|
|
$html_code .= " | \n";
121
|
|
|
|
|
|
|
}
|
122
|
0
|
|
|
|
|
|
$html_code .= " | \n";
|
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
return $html_code;
|
125
|
|
|
|
|
|
|
}
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1;
|
128
|
|
|
|
|
|
|
__END__
|