line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormatTableCellNroff; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
HTML::FormatTableCellNroff - Format HTML Table entry |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require HTML::FormatTableCellNroff; |
10
|
|
|
|
|
|
|
$cell = new HTML::FormatTableCellNroff(%attr); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
The HTML::FormatTableCellNroff is used to record information |
15
|
|
|
|
|
|
|
about a table entry and produce format information about the entry. |
16
|
|
|
|
|
|
|
It is used by FormatTableNroff to process HTML tables. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
require 5.004; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
require HTML::FormatTableCell; |
25
|
|
|
|
|
|
|
@ISA=qw(HTML::FormatTableCell); |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
708
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
68
|
|
28
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1012
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $_max_tbl_cell = 300; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %_formats = ( |
33
|
|
|
|
|
|
|
left => "l", |
34
|
|
|
|
|
|
|
center => "c", |
35
|
|
|
|
|
|
|
right => "r", |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 $nroff_cell->format_str($width); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Produce a tbl format specification for the current cell, consisting of |
41
|
|
|
|
|
|
|
an alignment character, width (in inches), and any subsequent colspan |
42
|
|
|
|
|
|
|
specifications. An example is "cw(2i)". |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub format_str { |
47
|
1
|
|
|
1
|
1
|
6
|
my($self, $width) = @_; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
3
|
my $result = $_formats{ $self->{'align'} }; |
50
|
1
|
50
|
|
|
|
4
|
if($width) { $result .= "w(" . $width . "i)"; } |
|
0
|
|
|
|
|
0
|
|
51
|
1
|
|
|
|
|
2
|
my $cnt = $self->{'colspan'}; |
52
|
1
|
|
|
|
|
5
|
while($cnt > 1) { |
53
|
1
|
|
|
|
|
2
|
$result .= " s"; |
54
|
1
|
|
|
|
|
3
|
$cnt--; |
55
|
|
|
|
|
|
|
} |
56
|
1
|
|
|
|
|
4
|
return $result; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 $nroff_cell->output($formatter); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Output a table cell entry using the formatter defined by $formatter. |
62
|
|
|
|
|
|
|
The nroff |
63
|
|
|
|
|
|
|
T{ |
64
|
|
|
|
|
|
|
.ad 1 |
65
|
|
|
|
|
|
|
.fi |
66
|
|
|
|
|
|
|
contents |
67
|
|
|
|
|
|
|
.nf |
68
|
|
|
|
|
|
|
}T |
69
|
|
|
|
|
|
|
construct is used to format text inside a cell. Bold is used for a table |
70
|
|
|
|
|
|
|
header. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub output { |
75
|
0
|
|
|
0
|
1
|
|
my($self, $formatter) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$formatter->out("T{\n.ad l\n.fi\n"); |
78
|
0
|
0
|
|
|
|
|
if($self->{'header'} eq 'header') { |
79
|
0
|
|
|
|
|
|
$formatter->font_start('B'); |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
my $text = $self->{'text'}; |
82
|
0
|
|
|
|
|
|
$text =~ s/ +/ /; |
83
|
|
|
|
|
|
|
# need to split to avoid buffer overrun in tbl, using $_max_tbl_cell as magic number |
84
|
0
|
|
|
|
|
|
my $len = length($text); |
85
|
0
|
|
|
|
|
|
while($len > 0) { |
86
|
0
|
0
|
|
|
|
|
if($len < $_max_tbl_cell) { |
87
|
0
|
|
|
|
|
|
$formatter->out($text); |
88
|
0
|
|
|
|
|
|
$len = 0; |
89
|
|
|
|
|
|
|
} else { |
90
|
0
|
|
|
|
|
|
my $place = index($text, " ", $_max_tbl_cell/2); |
91
|
0
|
|
|
|
|
|
$formatter->out(substr($text, 0, $place)); |
92
|
0
|
|
|
|
|
|
$formatter->out("\n"); |
93
|
0
|
|
|
|
|
|
$text = substr($text, $place + 1); |
94
|
0
|
|
|
|
|
|
$len = length($text); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
if($self->{'header'} eq 'header') { |
99
|
0
|
|
|
|
|
|
$formatter->font_end(); |
100
|
|
|
|
|
|
|
} |
101
|
0
|
|
|
|
|
|
$formatter->out("\n.nf\nT}"); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L, |
107
|
|
|
|
|
|
|
L, |
108
|
|
|
|
|
|
|
L, |
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 COPYRIGHT |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Copyright (c) 1997 Frederick Hirsch. All rights reserved. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or |
116
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Frederick Hirsch |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|