Apache-AxKit-Provider-OpenOffice

 view release on metacpan or  search on metacpan

OpenOffice.pm  view on Meta::CPAN


sub _error_handler {
    my $error = shift;
    AxKit::Debug(3, $error);
}

sub get_fh {
    my $self = shift;
    my $zip = Archive::Zip->new();
    if ($zip->read($self->{file}) != AZ_OK) {
        throw Apache::AxKit::Exception::IO (-text => "Couldn't read OpenOffice file '$self->{file}'");
    }
    my $r = $self->apache_request;
    my $member;
    
    my $path_info = $r->path_info;
    $path_info =~ s|^/||;


    if ($path_info) {
        AxKit::Debug(7, "[OpenOffice]: path info found in get_fh: $path_info" );

OpenOffice.pm  view on Meta::CPAN

    $member->extractToFileHandle($fh);
    seek($fh, 0, 0);
    return $fh;
}

sub get_strref {
    my $self = shift;

    my $zip = Archive::Zip->new();
    if ($zip->read($self->{file}) != AZ_OK) {
        throw Apache::AxKit::Exception::IO (-text => "Couldn't read OpenOffice file '$self->{file}'");
    }
    my $r = $self->apache_request;
    my $member;
    
    my $path_info = $r->path_info;
    $path_info =~ s|^/||;

    if ($path_info) {
        AxKit::Debug(7, "[OpenOffice]: path info found in get_strref: $path_info" );
        # probably need to get smarter here at some point...
        return \"" if $path_info eq 'office.dtd';

        $member = $zip->memberNamed($path_info);
    }
    else {
        $member = $zip->memberNamed('content.xml') || $zip->memberNamed('Content.xml');
    }
    my ($data, $status) = $member->contents();
    if ($status != AZ_OK) {
        throw Apache::AxKit::Exception::Error(
                -text => "Contents.xml could not be retrieved from $self->{file}"
                );
    }

    if ( $path_info =~ /\.(png|gif|jpg)$/ ) {
        my $image_type = $1;
        $r->content_type( 'image/' . $image_type );
        $r->send_http_header();
        $r->print( $data );
        throw Apache::AxKit::Exception::Declined(
                -text => "[OpenOffice] Image detected, skipping further processing."
                );
    }

    return \$data;
}

sub __process {
    my $self = shift;
    



( run in 0.278 second using v1.01-cache-2.11-cpan-496ff517765 )