#!/usr/bin/perl use warnings; use strict; use OpenOffice::OODoc; # setup file and styles my $file = $ARGV[0]; die "You must supply an odf file name\n" unless $file; print "File: $file\n"; my $container = odfContainer($file) or die "Can't get document $file\n"; my $doc = odfDocument(container => $container, part => 'content') or die "Can't get content in $file\n"; my ($i,$element,$text,$style); for ($i = 0; $i < 10; $i++) { $element = $doc->getElement('//text:p',$i); if ($element) { $text = $doc->getText($element); if ($text) { $style = $doc->getAttribute($element,'style name')||''; if ($style && ($style =~ m/^P\d+$/)) { $style = $doc->getAncestorStyle($style); } print "Paragraph $i: "; print "($style) " if $style; print "$text" if $text; print "\n"; } } }