Thread

Posted on Sat Oct 15 16:14:16 2005 by bob
Delete-to-End of Document
I've found it useful to be able to add a marker/phrase to a document
which indicates everything that follows, which might consist of various
elements such as paragraphs or tables, is to be deleted.

Is there a way to do this in OODoc ?

I expect it's by way of path/position but what those mean is
unclear to me. Are those concepts part of the OpenOffice document definition ?
Direct Responses: 1245 | Write a response
Posted on Thu Oct 27 04:41:34 2005 by bob in response to 1171
Re: Delete-to-End of Document
Works for me:
my $delete_rest; my @paragraphs=$content->getParagraphList(); #need to save the first few in order to preserve headers and footers @paras=@paragraphs[4..$#paragraphs]; for my $para (@paragraphs) { my $text= $content->getText($para); $delete_rest++ if $text=~/DELETE TO END/; next unless $delete_rest; $content->removeParagraph($para); } $content->save
Direct Responses: 1255 | Write a response
Posted on Fri Oct 28 18:05:54 2005 by bob in response to 1245
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