[2981] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
[17722] | 3 | # PowerPointPlugin.pm -- plugin for importing Microsoft PowerPoint files.
|
---|
[2981] | 4 | # (currently only versions 95 and 97)
|
---|
| 5 | #
|
---|
| 6 | # A component of the Greenstone digital library software
|
---|
| 7 | # from the New Zealand Digital Library Project at the
|
---|
| 8 | # University of Waikato, New Zealand.
|
---|
| 9 | #
|
---|
| 10 | # Copyright (C) 2002 New Zealand Digital Library Project
|
---|
| 11 | #
|
---|
| 12 | # This program is free software; you can redistribute it and/or modify
|
---|
| 13 | # it under the terms of the GNU General Public License as published by
|
---|
| 14 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | # (at your option) any later version.
|
---|
| 16 | #
|
---|
| 17 | # This program is distributed in the hope that it will be useful,
|
---|
| 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | # GNU General Public License for more details.
|
---|
| 21 | #
|
---|
| 22 | # You should have received a copy of the GNU General Public License
|
---|
| 23 | # along with this program; if not, write to the Free Software
|
---|
| 24 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 25 | #
|
---|
| 26 | ###########################################################################
|
---|
| 27 |
|
---|
[17722] | 28 | package PowerPointPlugin;
|
---|
[2981] | 29 |
|
---|
[15872] | 30 | use ConvertBinaryFile;
|
---|
| 31 |
|
---|
[10254] | 32 | use strict;
|
---|
| 33 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
[2981] | 34 |
|
---|
| 35 | sub BEGIN {
|
---|
[17735] | 36 | @PowerPointPlugin::ISA = ('ConvertBinaryFile');
|
---|
[2981] | 37 | }
|
---|
| 38 |
|
---|
[10466] | 39 | my $convert_to_list =
|
---|
| 40 | [ { 'name' => "auto",
|
---|
[15872] | 41 | 'desc' => "{ConvertBinaryFile.convert_to.auto}" },
|
---|
[10466] | 42 | { 'name' => "html",
|
---|
[15872] | 43 | 'desc' => "{ConvertBinaryFile.convert_to.html}" },
|
---|
[10466] | 44 | { 'name' => "text",
|
---|
[15872] | 45 | 'desc' => "{ConvertBinaryFile.convert_to.text}" },
|
---|
[10466] | 46 | { 'name' => "pagedimg_jpg",
|
---|
[15872] | 47 | 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_jpg}" },
|
---|
[10466] | 48 | { 'name' => "pagedimg_gif",
|
---|
[15872] | 49 | 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_gif}" },
|
---|
[10466] | 50 | { 'name' => "pagedimg_png",
|
---|
[15872] | 51 | 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_png}" }
|
---|
[10466] | 52 | ];
|
---|
| 53 |
|
---|
[6408] | 54 | my $arguments =
|
---|
| 55 | [ { 'name' => "process_exp",
|
---|
[15872] | 56 | 'desc' => "{BasePlugin.process_exp}",
|
---|
[6408] | 57 | 'type' => "regexp",
|
---|
| 58 | 'reqd' => "no",
|
---|
[10275] | 59 | 'deft' => &get_default_process_exp()}
|
---|
[6408] | 60 | ];
|
---|
| 61 |
|
---|
[17722] | 62 | my $options = { 'name' => "PowerPointPlugin",
|
---|
[17744] | 63 | 'desc' => "{PowerPointPlugin.desc}",
|
---|
[6408] | 64 | 'abstract' => "no",
|
---|
[11679] | 65 | 'inherits' => "yes",
|
---|
[15114] | 66 | 'srcreplaceable' => "yes", # Source docs in PPT format can be replaced with GS-generated html
|
---|
[6408] | 67 | 'args' => $arguments };
|
---|
[4744] | 68 |
|
---|
[2981] | 69 | sub new {
|
---|
[10218] | 70 | my ($class) = shift (@_);
|
---|
| 71 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 72 | push(@$pluginlist, $class);
|
---|
[2981] | 73 |
|
---|
[10275] | 74 | if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
|
---|
[10466] | 75 | my $ws_arg =[{ 'name' => "convert_to",
|
---|
[15872] | 76 | 'desc' => "{ConvertBinaryFile.convert_to}",
|
---|
[10466] | 77 | 'type' => "enum",
|
---|
| 78 | 'reqd' => "yes",
|
---|
| 79 | 'list' => $convert_to_list,
|
---|
| 80 | 'deft' => "html" },
|
---|
| 81 | { 'name' => "windows_scripting",
|
---|
[17744] | 82 | 'desc' => "{PowerPointPlugin.windows_scripting}",
|
---|
[10275] | 83 | 'type' => "flag",
|
---|
[10466] | 84 | 'reqd' => "no" }
|
---|
| 85 | ];
|
---|
| 86 | push(@$arguments,@$ws_arg);
|
---|
[10275] | 87 | }
|
---|
| 88 |
|
---|
[15872] | 89 | push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
|
---|
| 90 | push(@{$hashArgOptLists->{"OptList"}},$options);
|
---|
[10218] | 91 |
|
---|
[10427] | 92 |
|
---|
[15872] | 93 | my $self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
|
---|
[10275] | 94 |
|
---|
[10580] | 95 | if ($self->{'info_only'}) {
|
---|
| 96 | # don't worry about any options etc
|
---|
| 97 | return bless $self, $class;
|
---|
| 98 | }
|
---|
| 99 |
|
---|
[15872] | 100 | $self->{'filename_extension'} = "ppt";
|
---|
| 101 | $self->{'file_type'} = "PPT";
|
---|
| 102 |
|
---|
[10275] | 103 | # ppthtml outputs utf-8 already.
|
---|
[15872] | 104 | #these are passed through to gsConvert.pl by ConvertBinaryFile.pm
|
---|
[10491] | 105 | $self->{'convert_options'} = "-windows_scripting" if $self->{'windows_scripting'};
|
---|
[10275] | 106 | my $secondary_plugin_options = $self->{'secondary_plugin_options'};
|
---|
[10218] | 107 |
|
---|
[18406] | 108 | if ($self->{'windows_scripting'} && ($self->{'convert_to'} =~ m/(pagedimage|pagedimg).*/i)) {
|
---|
[15872] | 109 | $secondary_plugin_options->{'PagedImagePlugin'} = [];
|
---|
[10275] | 110 | } else {
|
---|
[15872] | 111 | $secondary_plugin_options->{'HTMLPlugin'} = [];
|
---|
[18406] | 112 | $secondary_plugin_options->{'TextPlugin'} = [];
|
---|
[10275] | 113 | }
|
---|
[15872] | 114 | my $html_options = $secondary_plugin_options->{'HTMLPlugin'};
|
---|
[18406] | 115 | my $text_options = $secondary_plugin_options->{'TextPlugin'};
|
---|
[15872] | 116 | my $pageimg_options = $secondary_plugin_options->{'PagedImagePlugin'};
|
---|
[16021] | 117 |
|
---|
[18406] | 118 | if (defined $html_options){
|
---|
[15903] | 119 | push(@$html_options,"-input_encoding", "utf8");
|
---|
| 120 | push(@$html_options,"-extract_language") if $self->{'extract_language'};
|
---|
[18406] | 121 | push(@$html_options,"-file_rename_method", "none");
|
---|
[15903] | 122 |
|
---|
| 123 | # Instruct HTMLPlugin (when eventually accessed through read_into_doc_obj)
|
---|
| 124 | # to extract these metadata fields from the HEAD META fields
|
---|
| 125 | push(@$html_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
|
---|
| 126 | }
|
---|
[18406] | 127 | if (defined $text_options){
|
---|
| 128 | push(@$text_options,"-input_encoding", "utf8");
|
---|
| 129 | push(@$text_options,"-extract_language") if $self->{'extract_language'};
|
---|
| 130 | push(@$text_options,"-file_rename_method", "none");
|
---|
| 131 | }
|
---|
| 132 | if (defined $pageimg_options){
|
---|
[15903] | 133 | push(@$pageimg_options,"-input_encoding", "utf8");
|
---|
[18406] | 134 | push(@$pageimg_options,"-extract_language") if $self->{'extract_language'};
|
---|
| 135 | push(@$pageimg_options,"-file_rename_method", "none");
|
---|
[15903] | 136 | }
|
---|
[2981] | 137 |
|
---|
[10275] | 138 | $self = bless $self, $class;
|
---|
| 139 |
|
---|
[10427] | 140 | $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
|
---|
[10275] | 141 | return $self;
|
---|
[2981] | 142 | }
|
---|
| 143 |
|
---|
| 144 | sub get_default_process_exp {
|
---|
| 145 | my $self = shift (@_);
|
---|
| 146 | return q^(?i)\.ppt$^;
|
---|
| 147 | }
|
---|
[10275] | 148 |
|
---|
[2981] | 149 | 1;
|
---|
[10275] | 150 |
|
---|