1

odt ドキュメントのヘッダー/フッターの要素をどのように取得しますか?

たとえば、私は持っています:

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

テーブルを確認すると、それらはすべて本体からのものです。ヘッダーまたはフッターの要素が見つからないようです。

4

1 に答える 1

1

ここでサンプルコードを見つけて、答えにたどり着きました:

#! /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 によって作成されたドキュメントのマスター ページ スタイルのデフォルト名です...これを解読するのが最も困難でした...サンプル コードを見つけたら、ひざに落ちました。

于 2012-04-05T13:05:35.083 に答える