我在这里找到了示例代码,这让我得到了答案:
#! /usr/local/bin/perl
use OpenOffice::OODoc;
my $file='asdf.odt';
# odfContainer is a representation of the zipped odf file
# and all of its parts.
my $container = odfContainer("$file");
# We're going to look at the 'style' part of the container,
# because that's where the header is located.
my $style = odfDocument
(
container => $container,
part => 'styles'
);
# masterPageHeader takes the style name as its argument.
# This is not at all clear from the documentation.
my $masterPageHeader = $style->masterPageHeader('Standard');
my $headerText = $style->getText( $masterPageHeader );
print "$headerText\n"
母版页样式定义了文档的外观和感觉——想想 CSS。显然,“标准”是 OpenOffice 创建的文档的母版页样式的默认名称……这是最难破解的问题……一旦我找到示例代码,它就掉在了我的腿上。