CPAN::Forum
OpenOffice-OODoc - Re: create a new empty odt file and change the style properties
| Posted on Fri Sep 15 00:17:06 2006 by jmgdoc in response to 3032 (See the whole thread of 3) |
| Re: create a new empty odt file and change the style properties |
|
This second version should work, but it's sub-optimal, due to repeated and useless "saves". It's neither required not useful to immediately save the newly created document, then re-open it in order to update the "Text body" (Text_20_body) style, then to re-save it, then re-open it to append a paragraph using the updated style. The very last save() only is useful (and it could be issued without argument, because the target file is the current one). The $style object should be created as a Document object instance using the same file as the $document object. To do so, the "file" option of ooDocument() should provide, for $style, the reference of the $document object instead of the file name. So, the same example could be rewritten like that:
$document = ooDocument(file => "test.odt", member => "content")
or die "Can't create test.odt\n";
$style = ooDocument(file => $document, member => "styles")
or die "Can't get access to the styles of test.odt (looks strange)\n";
$style->updateStyle
(
"Text_20_body",
properties =>
{
area => "text",
'fo:font-size' => "8pt",
'style:font-name' => 'Verdana'
}
)
or print "Can't updateStyle $LINE!\n";
$document->appendParagraph
(
text => 'Text body content',
style => 'text_20_body'
);
$document->save;
A similar example, and more explanations, are provided in this article, below the section "Content, Styles, and Metadata". |
| Write a response |
(4)
]