Perl OpenOffice::OODoc - accessing header/footer elements

倖福魔咒の 提交于 2019-12-11 11:10:22

问题


How do you get elements in a header/footer of a odt doc?

for example I have:

use OpenOffice::OODoc;    
my $doc = odfDocument(file => 'whatever.odt');
    my $t=0;
    while (my $table = $doc->getTable($t))
    {
       print "Table $t exists\n";
       $t++;
    }

When I check the tables they are all from the body. I can't seem to find elements for anything in the header or footer?


回答1:


I found sample code here which led me to the answer:

#! /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"

The master page style defines the look and feel of the document -- think CSS. Apparently 'Standard' is the default name for the master page style of a document created by OpenOffice... that was the toughest nut to crack... once I found the example code, that fell out in my lap.



来源:https://stackoverflow.com/questions/10021610/perl-openofficeoodoc-accessing-header-footer-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!