Skip Menu |

This queue is for tickets about the OpenOffice-OODoc CPAN distribution.

Report information
The Basics
Id: 14180
Status: resolved
Priority: 0/
Queue: OpenOffice-OODoc

People
Owner: jmgdoc [...] cpan.org
Requestors: spam-cpan-org [...] hostyersite.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.309
Fixed in: 2.003



Subject: Cannot append to tables
Code: my $table = $doc->getTable("InvoiceTable"); my $row1 = $doc->appendRow($table); Output: Use of uninitialized value in list assignment at /usr/lib/perl5/site_perl/5.8.5/XML/Twig.pm line 4537. OOo Error Message: Error loading document file:///blah Read-Error. Format error discovered in the file in sub-document content.xml at 3,32328 (row,col). content.xml at specified location: </table:table-row><table:table-row ="attribute"> It appears that OpenOffice::OODoc is incorrectly adding the ' ="attribute"' part to the file. None of the other pre-existing <table:table-row> tags include this attribute value, with no name. I'm not sure how to debug as this is new terrain, but I'm sure this isn't a user error and is a problem with the module itself.
[guest - Mon Aug 15 22:41:11 2005]: Show quoted text
> Code: > > my $table = $doc->getTable("InvoiceTable"); > my $row1 = $doc->appendRow($table); > > Output: > > Use of uninitialized value in list assignment at > /usr/lib/perl5/site_perl/5.8.5/XML/Twig.pm line 4537. > > OOo Error Message: > > Error loading document file:///blah > Read-Error. > Format error discovered in the file in sub-document content.xml at > 3,32328 (row,col). > > content.xml at specified location: > > </table:table-row><table:table-row ="attribute"> > > It appears that OpenOffice::OODoc is incorrectly adding the ' > ="attribute"' part to the file. None of the other pre-existing > <table:table-row> tags include this attribute value, with no name. > > I'm not sure how to debug as this is new terrain, but I'm sure this > isn't a user error and is a problem with the module itself.
Strange... I can't re-create the issue in my own installation (OpenOffice-OODoc 2.003 with Perl 5.8.5 and XML::Twig 3.17). Even with a loop including hundreds of appendRow() calls, with text documents or spreadsheets. In addition, appendRow() works for me with both OOo 1 and 2 file formats (tested through OOo 1.1.3 and 1.9.122). For example, the script below works well: $doc->ooDocument(file => "data.sxw"); my $t = $doc->getTable("Table1"); for (my $i = 0 ; $i < 1000 ; $i++) { $doc->appendRow($t); } $doc->save; According to the OOo error message, a format error occurs at column 32328. What is the real size of your table ? It's possibly an unnoticed bug in 1.309 that was "silently" fixed in 2.003. So you should try with 2.003 and, if the problem remains, please send me a full example with the script and the target document (jmgdoc[at]cpan.org)
[trev@digitalcon.ca - Tue Aug 16 12:18:00 2005]: Show quoted text
> > [...] > > My table was 18x5 extended to 19x5. The numbers OOo spat out was the > location of it's parse error in content.xml - which seems confusing, > but > after removing the bad attribute value (lacking a name attached to > it), > OOo could process the file fine. > > I just installed the 2.003 version from CPAN and everything seems fine > now. It's just a matter of learning it :) > > I seem to be having problems changing the style of the text that > appears > in my table: ie. OOo has the table, has the row, and has the cell, but > then uses a paragraph style, while thus far I haven't figured out how > to > locate this paragraph element. I can set the style for the table, the > row, and the cell with no problem, but that paragraph style overrides > anything I put there. If you are generous maybe include a quick > script > in the docs to locate a paragrph based on a known cell element, but if > you are like the rest of us and must earn a living I completely > understand. > > Thanks, > Trevor >
Paragraphs contained in cells can't directly be reached with OpenOffice::OODoc methods (the API is designed to process data in documents (or already "styled" templates), and not really to replace OOo... ...however it's easy to get a paragraph based on a known cell, using the "first_child" method from XML::Twig (XML::Twig methods are available with every text element). We must know that 'text:p' is the OOo XML codename for a paragraph. For example, assuming we have table named 'Table1', the paragraph of the [4,2] cell (or 'C5' if you prefer the spreadsheet-like coordinates, allowed by getCell) can be addressed by the following instruction: $p = $doc->getCell('Table1', 'C5')->first_child('text:p'); or $p = $doc->getCell('Table1', 4, 2)->first_child('text:p'); Then $p can be processed as a regular paragraph. In the following example, I create a paragraph style (centered with a yellow background), then I give this new style to the embedded paragraph of a known cell: $doc->createStyle ( 'MyStyle', family => 'paragraph', parent => 'Standard', properties => { 'fo:background-color' => rgb2oo('yellow'), 'fo:text-align' => 'center' } ); my $cell = $doc->getCell('Table1', 'B6'); my $p = $cell->first_child('text:p'); $doc->textStyle($p, 'MyStyle'); I hope that will help... PS: If 2.003 has fixed your appendRow problem, I suppose I can close your first request ?