请看
extendText()
和
setSpan()
在文档中。
下面是一个执行您所需操作的示例:
use OpenOffice::OODoc;
my $doc = odfDocument(file=> 'outputfile.odt',create=> 'text');
$doc->createStyle(
"strong",
family => "text",
properties => { "fo:font-weight" => "bold" }
);
$doc->createStyle(
"em",
family => "text",
properties => { "fo:font-style" => "italic" }
);
my $p = $doc->appendParagraph(text => "", style => "optionalParagraphStyle");
$doc->extendText($p, "John Smith");
$doc->extendText($p, " 200 Main Street", "strong");
$doc->extendText($p, " single", "em");
my $p = $doc->appendParagraph(text => "John Smith 200 Main Street single", style => "optionalParagraphStyle");
$doc->setSpan($p, "200 Main Street", "strong");
$doc->setSpan($p, "single", "em");
$doc->save;