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 2008-11-25 14:47:16-08 by dhoworth
infinite loop in normalizeSheet
I tried my script that isolates annotations on a 'real' spreadsheet. It's a megabyte with 20 or 30 worksheets. My script used up all the memory (16 GB) and died. I extracted one worksheet that only has content in (A1 .. C12) and simplified it to pure text in most cells and 1 number and a couple of simple formulas. The problem was still there. I've tracked the problem down to the call to
$doc->normalizeSheet($table, 'full');
If I substitute
$doc->normalizeSheet($table, 13, 4);
everything works fine. I haven't been able to track down the exact issue in normalizeSheet yet (lack of time) and I can't figure out how to post my test spreadsheet here?
Direct Responses: 9431 | Write a response
Posted on 2008-11-26 10:33:58-08 by dhoworth in response to 9422
Re: infinite loop in normalizeSheet
I think I've discovered what's causing the problem. This is the end of the content.xml file:
... <table:table-row table:number-rows-repeated="3" table:style-name="ro7"> <table:table-cell table:style-name="ce13"/> <table:table-cell table:style-name="ce21"/> <table:table-cell table:style-name="ce27"/> <table:table-cell table:style-name="ce31"/> <table:table-cell table:number-columns-repeated="252"/> </table:table-row> <table:table-row table:number-rows-repeated="65488" table:style-name="ro3"> <table:table-cell table:number-columns-repeated="256"/> </table:table-row> <table:table-row table:style-name="ro3"> <table:table-cell table:number-columns-repeated="256"/> </table:table-row> </table:table> </office:spreadsheet> </office:body> </office:document-content>
I'm guessing that the repeat count of 65488 is causing the grief!

But this is extracted from a real document that doesn't cause a problem for oocalc. That number is 65536 - 48 so it may be relevant that the table-row element is row 47.

I've no idea whether this is some strange feature of ODF or evidence of a bug in oocalc.
Direct Responses: 9432 | Write a response
Posted on 2008-11-26 11:23:30-08 by jmgdoc in response to 9431
Re: infinite loop in normalizeSheet

Right, the repeat count of 65488 is causing the grief !

The ODF spec allows the use of cell/row/column repeat attributes but doesn't prevent the applications from using them with fantastic values. ooocalc frequently puts such strange and useless repeat attributes, I don't know why and I can't predict when.

This behaviour was the main reason for me to allow the OODoc applications to perform explicitly "sized" table normalizations through getTable() or normalizeSheet() with optional height/width arguments.
Direct Responses: 9433 | Write a response
Posted on 2008-11-26 12:40:46-08 by dhoworth in response to 9432
Re: infinite loop in normalizeSheet
Thanks for the feedback. The problem with the explicit sizes is that the application has no way of knowing what is a reasonable limit, AFAIK. Since oocalc doesn't crash, I guess it has some logic that copes; maybe I'll take a look at the code. One thought that occurs to me is that it should be possible to write a function that starts from a cell and works back and up through the tree to calculate the position of that cell. I may try writing that. With some cacheing of results, it might even be reasonably efficient.
Direct Responses: 9435 | Write a response
Posted on 2008-11-26 15:54:52-08 by dhoworth in response to 9433
Re: infinite loop in normalizeSheet
I hacked a method together. Here it is in case it's any use:
=head2 position ($row, $col) = $table_cell->position; =cut *OpenOffice::OODoc::Element::position = sub { my $self = shift; confess "$self is wrong class" unless $self->isa('OpenOffice::OODoc::Element'); confess "$self is not a cell (".$self->getName.")" unless $self->getName eq 'table:table-cell' or $self->getName eq 'table:covered-table-cell'; # Get column number # my $col = 1; for my $s ( $self->prev_siblings ) { my $tag = $s->getName; next unless $tag eq 'table:table-cell' or $tag eq 'table:covered-table-cell'; my $attr = $s->getAttribute('table:number-columns-repeated'); $col += $attr ? $attr : 1; } # Get row number # my $row = 1; for my $s ( $self->parent->prev_siblings ) { next unless $s->getName eq 'table:table-row'; my $attr = $s->getAttribute('table:number-rows-repeated'); $row += $attr ? $attr : 1; } return ($row, $col); };
It seems to be working for me with my big SS, but no warranty is expressed or implied :)
Direct Responses: 9438 | Write a response
Posted on 2008-11-26 20:34:07-08 by jmgdoc in response to 9435
Re: infinite loop in normalizeSheet

Than you very much for your proposal!
If you agree, I'll probably adopt the idea and insert it in my todo list for a future release.
Direct Responses: 9444 | Write a response
Posted on 2008-11-27 09:19:02-08 by dhoworth in response to 9438
Re: infinite loop in normalizeSheet
Fine by me.
Direct Responses: Write a response