Bundle-PBib
view release on metacpan or search on metacpan
lib/PBib/Document/OpenOffice.pm view on Meta::CPAN
# --*-Perl-*-- coding: utf-8
# $Id: OpenOffice.pm 13 2004-11-27 08:58:44Z tandler $
#
=head1 NAME
PBib::Document::OpenOffice - Base Class for OpenOffice documents
=head1 SYNOPSIS
use PBib::Document;
my $doc = new PBib::Document(
'filename' => 'test.sxw',
'mode' => 'r',
);
print $doc->filename();
my @paragraphs = $doc->paragraphs();
$doc->close();
=head1 DESCRIPTION
Base class for OpenOffice documents.
All OpenOffice documents have a similar structure: They are a zip archive that contains a content.xml file with the content.
=cut
package PBib::Document::OpenOffice;
use 5.008; # for Unicode / utf-8 support
use strict;
use warnings;
use charnames ':full'; # enable \N{unicode char name} in strings
# use English;
# for debug:
use Data::Dumper;
BEGIN {
use vars qw($Revision $VERSION);
my $major = 1; q$Revision: 13 $ =~ /: (\d+)/; my ($minor) = ($1); $VERSION = "$major." . ($minor<10 ? '0' : '') . $minor;
}
# superclass
use base qw(PBib::Document::XML);
# used modules
use Carp::Assert;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
# used own modules
# module variables
#use vars qw(mmmm);
use constant {
CONTENTNAME => 'content.xml',
};
# Unicode chars, see http://www.unicode.org/charts/
my $EM_DASH = "\N{EM DASH}"; # = \x{2014}
my $EN_DASH = "\N{EN DASH}"; # = \x{2013}
my $FIG_DASH = "\N{FIGURE DASH}"; # 20 12
my $NB_HYPHEN = "\N{NON-BREAKING HYPHEN}"; # 20 11
my $HYPHEN = "\N{HYPHEN}"; # 20 10 (difference to "hypen-minus"?)
my $OPT_HYPHEN = "\N{SOFT HYPHEN}"; # 00 AD
my $LDBLQUOTE_EN = "\N{LEFT DOUBLE QUOTATION MARK}"; # 20 1C
my $RDBLQUOTE_EN = "\N{RIGHT DOUBLE QUOTATION MARK}"; # 20 1D
my $LQUOTE_EN = "\N{LEFT SINGLE QUOTATION MARK}"; # 20 18
my $RQUOTE_EN = "\N{RIGHT SINGLE QUOTATION MARK}"; # 20 19
my $LDBLQUOTE_DE = "\N{DOUBLE LOW-9 QUOTATION MARK}"; # 20 1E
# "\N{DOUBLE HIGH-REVERSED-9 QUOTATION MARK}"; # 20 1F
my $RDBLQUOTE_DE = "\N{LEFT DOUBLE QUOTATION MARK}"; # 20 1C
my $LQUOTE_DE = "\N{SINGLE LOW-9 QUOTATION MARK}"; # 20 1A
my $RQUOTE_DE = "\N{LEFT SINGLE QUOTATION MARK}"; # 20 18
# \N{SINGLE HIGH-REVERSED-9 QUOTATION MARK} # 20 1B
my $NB_SPACE = "\N{NO-BREAK SPACE}"; # 00 A0 = \N{NBSP}
my $EM_SPACE = "\N{EM SPACE}"; # 20 03
my $EN_SPACE = "\N{EN SPACE}"; # 20 02
my $ELLIPSIS = "\{HORIZONTAL ELLIPSIS}"; # 20 26
=head1 METHODS
=cut
=head1 File Handling Methods
=over
=cut
=item $doc->zip()
Handle to Archive::Zip, used to (de)compress the OpenOffice file.
=cut
sub zip {
my $self = shift;
my $zip = $self->{'zip'};
unless( $zip ) {
my $filename = $self->filename() or return undef;
$zip = Archive::Zip->new() or return undef;
$self->{'zip'} = $zip;
}
return $zip;
}
=item $doc->close();
Close the file. Does nothing?
=cut
sub close {
# close file ... must the zip be closed???
( run in 0.668 second using v1.01-cache-2.11-cpan-39bf76dae61 )