Problem using Openoffice::OODoc

D

Dave

In the following test script I am expecting the second sentence in paragraph
2 to be in the Emphasis style (italicised), but it remains in the default
style. Does anyone know why? I think that I am following the documentation
correctly. (Perl 5.8.7, Openoffice::OODoc 2.02 on Windows XP with OpenOffice
2.0).

use strict;
use warnings;
use OpenOffice::OODoc;

my $document = ooDocument(file => 'test.odt', create => 'text');

my $para1 = $document->appendParagraph( text => 'Heading',
style => 'Heading 1'
);

my $para2 = $document->appendParagraph( text => 'First sentence para2. ',
style => 'default'
);

my $para3 = $document->appendParagraph( text => 'First sentence para3. ',
style => 'default'
);

$document->extendText($para2, 'Second sentence para2.', 'Emphasis');

$document->save;
 
D

Dave

Christian Winter said:
It seems that either the behaviour of the extendText method has changed
with Version 2.222 or the documentation is inconsistent (I'll asume the
first). While the 2.222 documentation on CPAN lists an
extendText(element,style) method, my local installation (Version 2.219)
only has the following two:
extendText(path, position, text)
extendText(element, text)
so I guess that it silently discards the third parameter.

To assign a different style to a subset of a paragraph you can use the
setSpan() method:

$document->extendText($para2, ' Second sentence para2.' );
$document->setSpan( $para2, 'Second.*para2.', 'Emphasis' );

HTH
-Chris

Thanks. Yes I got version 2.021 from ppm, but I had been reading the lastest
version of the docs from CPAN. I updated Text.pm and XPath.pm by copying the
files from CPAN and it now works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top