2012-04-05 9 views
1

odt文書のヘッダー/フッターにどのように要素を取得しますか?Perl OpenOffice :: OODoc - ヘッダー/フッター要素へのアクセス

は、例えば私が持っている:

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

私は、彼らがすべての身体からあるテーブルをチェック

。ヘッダーやフッターの要素を見つけることができないようですか?

+0

完全な答えはわかりませんが、.odtファイルを解凍すると 'content.xml'というファイルが作成されます。 xmlを見ると(xmltidyの使用が助かります)。これにより、odfドキュメントの構造が表示されます。 OpenOffice :: OODocオブジェクト内のデータ構造は、xmlのxpath構造を反映しています。ヘッダー内のテキストを見つけて、その周りのタグを読んでください。OODocオブジェクトでどこを探すべきかを理解できるはずです。 –

+0

私はOpenOffice :: OODoc :: Text perldocを見ただけで、 "styles.xml"にヘッダとフッタを定義できると述べています。 –

答えて

1

私は答えに私を導いたサンプルコードhereが見つかりました:

#! /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を考えます。どうやら 'Standard'は、OpenOfficeによって作成されたドキュメントのマスターページスタイルのデフォルト名です。これは、ラップで落ちたサンプルコードを見つけたら、ひどいナットでした。

関連する問題