[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 ?