Document-OOXML

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

examples/replace_text.pl
examples/style.pl
lib/Document/OOXML.pm
lib/Document/OOXML/ContentTypes.pm
lib/Document/OOXML/Document.pm
lib/Document/OOXML/Document/Wordprocessor.pm
lib/Document/OOXML/Part.pm
lib/Document/OOXML/Part/WordprocessingML.pm
lib/Document/OOXML/PartParser.pm
lib/Document/OOXML/Rels.pm
t/0-content-types.t
t/10-document.t
t/20-wordprocessingml.t
t/author-pod-syntax.t
t/release-distmeta.t
t/resources/basic-regular.docx
t/resources/basic-strict.docx
t/resources/multipart-regular.docx
t/resources/multipart-strict.docx
t/resources/not-even-zip.txt
t/resources/not-ooxml.odt

lib/Document/OOXML/ContentTypes.pm  view on Meta::CPAN

use utf8;
package Document::OOXML::ContentTypes;
use Moose;
use namespace::autoclean;

# ABSTRACT: Part to content-type mapping for OOXML

use XML::LibXML;


my $CONTENT_TYPES_NS = 'http://schemas.openxmlformats.org/package/2006/content-types';

has defaults => (
    is => 'ro',
    isa => 'ArrayRef[HashRef]'
);

has overrides => (
    is => 'ro',
    isa => 'ArrayRef[HashRef]'
);

lib/Document/OOXML/ContentTypes.pm  view on Meta::CPAN

__PACKAGE__->meta->make_immutable();

__END__

=pod

=encoding UTF-8

=head1 NAME

Document::OOXML::ContentTypes - Part to content-type mapping for OOXML

=head1 VERSION

version 0.181410

=head1 SYNOPSIS

    my $ct = Document::OOXML::ContentTypes->new_from_xml($xml_data);
    say "The content type of /word/document.xml is " . $ct->get_content_type_for_part('/word/document.xml');

=head1 DESCRIPTION

OOXML files contain a file named '[Content_Types].xml' that describes the
content-types of all the other files in the package.

This class implements a way to look up the content-type for a file name,
given the contents of that file.

=head1 METHODS

=head2 new_from_xml($xml_data)

Creates a new L<Document::OOXML::ContentTypes> instance from the contents
of the C</[Content-Types].xml> file from an OOXML file.

=head2 get_content_type_for_part($part_name)

Returns the content-type of the part with the specified name.

=head1 SEE ALSO

=over

=item * L<Document::OOXML>

=back

=head1 AUTHOR

lib/Document/OOXML/PartParser.pm  view on Meta::CPAN

    my $doc = Document::OOXML::PartParser->parse_part(
        part_name    => '/word/footer1.xml',
        content_type => 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml',
        content      => '<?xml version="1.0"?> ...',
        is_strict    => 1,
    );

=head1 DESCRIPTION

This module provides one method that creates a new L<Document::OOXML::Part> of
the right kind (WordprocessingML, etc.), given a content-type and file
contents.

=head1 METHODS

=head2 parse_part

Parse a part of an OOXML document, and return a L<Document::OOXML::Part>
for it.

=over

t/0-content-types.t  view on Meta::CPAN

use utf8;
use Test::More;

use Document::OOXML::ContentTypes;

my $xml = <<'EOT';
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Types 
    xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
    <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
    <Default Extension="xml" ContentType="application/xml"/>
    <Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
    <Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
    <Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>
    <Override PartName="/word/webSettings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"/>
    <Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/>
    <Override PartName="/word/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>
    <Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
    <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>



( run in 0.804 second using v1.01-cache-2.11-cpan-524268b4103 )