change_style - Merging content & presentation from different files
Sample program creating a new document merging the content and the presentation of two existing documents
Usage: change_style -content file1.sxw -style file2.sxw -target file3.sxw
You could produce the same result, without using any XML API, by a direct zip extraction and copy of the 'styles.xml' member from $style_file to $content_file. But using OpenOffice::OODoc::XPath, you can ensure $target_file is a well formed XML OpenOffice.org document. And, in a real application, you should do more sophisticated, XML-aware controls and transformations in the document.
Take care: If the imported style definitions include external objects (ex: images in the page background or in headers/footers), you have to ensure the corresponding URLs will be made available from within the target file before editing/printing. And the named style invocations from within the text content of $content_file must be consistent with the named style definitions of $style_file. All that could be controlled by a more realistic program.
This sample script is of no effect on automatic styles; it plays only with the content of 'styles.xml' (i.e. page presentation and named styles definitions.
To install OpenOffice::OODoc, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenOffice::OODoc
CPAN shell
perl -MCPAN -e shell install OpenOffice::OODoc
For more information on module installation, please visit the detailed CPAN module installation guide.