HTML::FormatTableRow - Format HTML Table row


FormatNroff documentation Contained in the FormatNroff distribution.

Index


Code Index:

NAME

Top

HTML::FormatTableRow - Format HTML Table row

SYNOPSIS

Top

 require HTML::FormatTableRow;
 @ISA = qw(HTML::FormatTableRow);

DESCRIPTION

Top

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'

METHODS

Top

$table_row = new HTML::FormatTableRow(%attr);

The following attributes are supported: align: 'left','center', or 'right' alignment of table row entries valign: vertical alignment, 'top' or 'middle'

$table_row->add_element(%attr);

Add table element - should be subclassed.

$table_row->end_element();

End table element - should be subclassed.

$table_row->add_text($text);

Add text to cell.

$table_row->text();

Return text associated with current table cell.

$table_row->widths($final, $array_ref);

push the array of cell widths (in characters) onto the array specified using the array reference $array_ref.

$table_row->output($final, $formatter, $tab);

Output the row data using the $formatter to do the output, and separating each cell using the $tab character. $final is not used.

SEE ALSO

Top

HTML::FormatTable

COPYRIGHT

Top

AUTHOR

Top

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;