| FormatNroff documentation | Contained in the FormatNroff distribution. |
HTML::FormatTableRow - Format HTML Table row
require HTML::FormatTableRow; @ISA = qw(HTML::FormatTableRow);
The HTML::FormatTableRow is used to record information and process a table row. This is a base class.
The following attributes are supported: align: 'left','center', or 'right' alignment of table row entries valign: vertical alignment, 'top' or 'middle'
The following attributes are supported: align: 'left','center', or 'right' alignment of table row entries valign: vertical alignment, 'top' or 'middle'
Add table element - should be subclassed.
End table element - should be subclassed.
Add text to cell.
Return text associated with current table cell.
push the array of cell widths (in characters) onto the array specified using the array reference $array_ref.
Output the row data using the $formatter to do the output, and separating each cell using the $tab character. $final is not used.
Copyright (c) 1997 Frederick Hirsch. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Frederick Hirsch <f.hirsch@opengroup.org>
| FormatNroff documentation | Contained in the FormatNroff distribution. |
package HTML::FormatTableRow;
require 5.004; use strict; use Carp;
sub new { my($class, %attr) = @_; my $self = bless { align => $attr{'align'} || 'left', valign => $attr{'valign'} || 'middle', current_cell => undef, ended => 1, cells => [], }, $class; return $self; }
sub add_element { my($self, %attr) = @_; croak "Should be subclassed.\n"; }
sub end_element { my($self) = @_; croak "Should be subclassed.\n"; }
sub add_text { my($self, $text) = @_; if($self->{'ended'} != 0) { return; } my $cell = $self->{'current_cell'}; if(defined($cell)) { $cell->add_text($text); } else { return 0; } }
sub text { my($self) = @_; my $cell = $self->{'current_cell'}; if(defined($cell)) { return $cell->text(); } else { return 0; } }
sub widths { my($self, $final, $array_ref) = @_; my @widths; my $cell; foreach $cell ( @{ $self->{'cells'} }) { push(@widths, $cell->width()); } $cell = $self->{'current_cell'}; if(defined($cell)) { push(@widths, $cell->width()); } push(@$array_ref, [ @widths ]); }
sub output { my($self, $final, $formatter, $tab) = @_; my $cell; foreach $cell ( @{ $self->{'cells'} }) { $cell->output($formatter); $formatter->out("$tab"); } if(defined($self->{'current_cell'})) { $self->{'current_cell'}->output($formatter); } $formatter->out("\n.sp\n"); }
1;