CPAN::Forum
OpenOffice-OODoc - Re: Delete-to-End of Document
| Posted on Fri Oct 28 18:05:54 2005 by bob in response to 1245 (See the whole thread of 3) |
| Re: Delete-to-End of Document |
|
Here's a way to delete all the tables including and following a table named 'DELETE'.
sub my_delete_tables {
my $content=shift;
# create an ordered list of table names
my @tables=my_getTableNameList($content);
my ($i, $match_idx);
# Go through the table names an find the index to the desired table
for ($i = 0; $i < @tables; $i++) {
if ($tables[$i]=~/^DELETE$/) {
$match_idx = $i; # save the index
last;
}
}
return($content) unless $match_idx;
# Remove all the tables including and following the indexed one
for ($i = $match_idx + 1; $i < @tables; $i++) {
my $table=$content->getTable($tables[$i]);
$content->removeParagraph($table);
}
return($content);
} # my_delete_tables
sub my_getTableNameList {
my $content=shift;
my $count=scalar(($content->getTableList())) - 1;
my @tables;
for my $n (0 .. $count) {
# getAttribute() stuff from a post by JMG
push (@tables, $content->getAttribute($content->getTable($n),'table:name'));
}
return(@tables);
} # my-get-table-name-list
|
| Write a response |
(4)
]