Subject: | expandTable() doesn't expand columns of first N-1 rows |
expandTable() should also add cells to the first N-1 rows when expanding
a table of N rows. The following rewrite of expandTable() fixes this.
The internal method _expand_table()/_expand_columns() are probably
similarly afflicted.
sub OpenOffice::OODoc::Text::expandTable2
{
my $self = shift;
my $table = shift;
my $length = shift || 0;
my $width = shift || 0;
my $context = shift;
my ($old_length, $old_width) = $self->getTableSize($table);
$table = $self->normalizeSheet($table, 'full');
unless ($table)
{
warn "[" . __PACKAGE__ . "::expandTable] " .
"Unknown or badly formed table\n";
return undef;
}
my $last_col = $self->getTableColumn($table, -1);
my $last_row = $self->getRow($table, -1);
my $i = 0;
my $j = 0;
## Expand col declarations
for ($i = $old_width; $i < $width; $i++)
{
$last_col = $last_col->replicateNode;
}
## Expand existing rows
for ($i = 0; $i < $old_length; $i++)
{
my $row =$self->getRow($table, $i);
my $last_cell = $self->getCell($row, -1);
for ($j = $old_width; $j < $width; $j++)
{
$last_cell = $last_cell->replicateNode;
}
}
for ($i = $old_length; $i < $length; $i++)
{
$last_row = $last_row->replicateNode;
}
return wantarray ? $self->getTableSize($table) : $table;
}