I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2005-09-17 20:59:58-07 by bob
Using tables (sections) from oowriter templates
Jean Marie,

Thanks for your help and bug fixes.

I set up an oowriter template file containing 2 separate tables and 2 'sections' formatted for 2 or 3 columns.

I thought I could locate the tables by using their names, but that did not work.

I couldn't see how to use getTableList because I could not see how to translate a member of that list to a table name or identify what the elements referred to.

I had to add some text into the table and then use the select ElementsbyContent for example:

my @list = $b_content->selectElementsByContent('4_col);


The only way I could see to find all the components of the template file was by going through the document paragraph by paragraph:

for (0..100) { my $content=$b_content->getParagraphText($_); print "$_ ==> $content\n" if $content;}


Is there a way to access/create a reference to a table by way of its name ?

Is there a way to use the itelms in the getTableList to identify to which table it refers ?

I'm a bit puzzled by appendElement. I used it as in the example:

my $root_element = $content->getBody; $content->appendElement($root_element,$list[0]);


And it appended the table into the middle of my document.

How would I go about appending to some other location in the target document ?

Is there an easier way to transfer an oowriter table from one document to another ?

Finally I did not see anything in the documentation about using 'sections'. I wanted to be able to designate portions of a page or document as having more than column.

When I tried to copy a section template from one document to the next, it did not seem to work as it displayed only 1 column (and not the 2 that I expected).

Are oowriter 'sections' supported ?

Thanks again.
Bob

BTW you are welcome to reply to bob@chicopmr.org. I sure like the idea of the cpanforum, but it needs a bit of work. Posting in HTML is a pain -- as far as I am concerned.
Direct Responses: 1020 | Write a response
Posted on 2005-09-21 21:30:22-07 by mlcohen in response to 1009
Re: Using tables (sections) from oowriter templates
I second that question. I need to get a list of all tables that have names matching a certain regexp. I was able to find all tables with captions matching a regexp, but that way isn't robust since captions aren't linked to a table, they're just the preceding (or following) line. There doesn't seem to be a way to get the "logical name" of a table using the table handle returned by getTable.

I also second Bob's thanks to Jean Marie. Your quick responses have made my life a whole lot easier.

Matt
Direct Responses: 1021 | Write a response
Posted on 2005-09-22 09:59:17-07 by jmgdoc in response to 1020
Re: Using tables (sections) from oowriter templates

When you have a table handle (previously returned by getTable for example) you can get the table name using the generic getAttribute method, knowing that the name attribute is 'table:name'. Ex:
my $t = $doc->getTable($number); my $name = $doc->getAttribute($t, 'table:name');

In a future release, I'll probably introduce a more smart tableName read/write accessor (renameTable is already available).
Direct Responses: 1254 | Write a response
Posted on 2005-10-28 14:51:05-07 by bob in response to 1021
Re: Using tables (sections) from oowriter templates
If I understood Xpath I could probably do this more neatly, but it does return an ordered list of
table names.
sub my_getTableList { my $content=shift; my $count=scalar(($content->getTableList())) - 1; my @tables; for my $n (0 .. $count) { push (@tables, $content->getAttribute($content->getTable($n),'table:name')); } return(@tables); } # my-get-table-list
Direct Responses: 1256 | 1258 | Write a response
Posted on 2005-10-28 15:08:45-07 by bob in response to 1254
Re: Using tables (sections) from oowriter templates
It would be nice if you could edit your posts.

It would probably be less confusing to name that sub 'getTableNameList'
Direct Responses: Write a response
Posted on 2005-10-28 20:20:01-07 by jmgdoc in response to 1254
Re: Using tables (sections) from oowriter templates

With 2.013
$content->getAttribute($content->getTable($n),'table:name'))

can be replaced by
$content->tableName($n)
Direct Responses: Write a response