[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 |
|
---|
[10254] | 30 | use strict;
|
---|
| 31 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
[22515] | 32 | no strict 'subs';
|
---|
[22705] | 33 |
|
---|
[22515] | 34 | use gsprintf 'gsprintf';
|
---|
[2981] | 35 |
|
---|
[22705] | 36 | use AutoloadConverterScripting;
|
---|
[2981] | 37 |
|
---|
[22705] | 38 | @PowerPointPlugin::ISA = ('AutoloadConverterScripting');
|
---|
| 39 |
|
---|
| 40 |
|
---|
[22515] | 41 | my $windows_convert_to_list =
|
---|
[10466] | 42 | [ { 'name' => "auto",
|
---|
[15872] | 43 | 'desc' => "{ConvertBinaryFile.convert_to.auto}" },
|
---|
[10466] | 44 | { 'name' => "html",
|
---|
[15872] | 45 | 'desc' => "{ConvertBinaryFile.convert_to.html}" },
|
---|
[10466] | 46 | { 'name' => "text",
|
---|
[15872] | 47 | 'desc' => "{ConvertBinaryFile.convert_to.text}" },
|
---|
[10466] | 48 | { 'name' => "pagedimg_jpg",
|
---|
[15872] | 49 | 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_jpg}" },
|
---|
[10466] | 50 | { 'name' => "pagedimg_gif",
|
---|
[15872] | 51 | 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_gif}" },
|
---|
[10466] | 52 | { 'name' => "pagedimg_png",
|
---|
[15872] | 53 | 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_png}" }
|
---|
[10466] | 54 | ];
|
---|
| 55 |
|
---|
[6408] | 56 | my $arguments =
|
---|
| 57 | [ { 'name' => "process_exp",
|
---|
[15872] | 58 | 'desc' => "{BasePlugin.process_exp}",
|
---|
[6408] | 59 | 'type' => "regexp",
|
---|
| 60 | 'reqd' => "no",
|
---|
[10275] | 61 | 'deft' => &get_default_process_exp()}
|
---|
[6408] | 62 | ];
|
---|
| 63 |
|
---|
[22515] | 64 | my $opt_windows_args =
|
---|
| 65 | [ { 'name' => "convert_to",
|
---|
| 66 | 'desc' => "{ConvertBinaryFile.convert_to}",
|
---|
| 67 | 'type' => "enum",
|
---|
| 68 | 'reqd' => "yes",
|
---|
| 69 | 'list' => $windows_convert_to_list,
|
---|
| 70 | 'deft' => "html" },
|
---|
| 71 | { 'name' => "windows_scripting",
|
---|
| 72 | 'desc' => "{PowerPointPlugin.windows_scripting}",
|
---|
| 73 | 'type' => "flag",
|
---|
| 74 | 'reqd' => "no" }
|
---|
| 75 | ];
|
---|
| 76 |
|
---|
[17722] | 77 | my $options = { 'name' => "PowerPointPlugin",
|
---|
[17744] | 78 | 'desc' => "{PowerPointPlugin.desc}",
|
---|
[6408] | 79 | 'abstract' => "no",
|
---|
[11679] | 80 | 'inherits' => "yes",
|
---|
[15114] | 81 | 'srcreplaceable' => "yes", # Source docs in PPT format can be replaced with GS-generated html
|
---|
[6408] | 82 | 'args' => $arguments };
|
---|
[4744] | 83 |
|
---|
[2981] | 84 | sub new {
|
---|
[10218] | 85 | my ($class) = shift (@_);
|
---|
| 86 | my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
|
---|
| 87 | push(@$pluginlist, $class);
|
---|
[2981] | 88 |
|
---|
[10275] | 89 | if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
|
---|
[22515] | 90 | push(@$arguments,@$opt_windows_args);
|
---|
[10275] | 91 | }
|
---|
[22515] | 92 |
|
---|
[15872] | 93 | push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
|
---|
| 94 | push(@{$hashArgOptLists->{"OptList"}},$options);
|
---|
[10218] | 95 |
|
---|
[10427] | 96 |
|
---|
[22705] | 97 | my $self
|
---|
| 98 | = new AutoloadConverterScripting("OpenOfficeConverter",
|
---|
| 99 | $pluginlist, $inputargs,
|
---|
| 100 | $hashArgOptLists);
|
---|
[10275] | 101 |
|
---|
[10580] | 102 | if ($self->{'info_only'}) {
|
---|
| 103 | # don't worry about any options etc
|
---|
| 104 | return bless $self, $class;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
[15872] | 107 | $self->{'filename_extension'} = "ppt";
|
---|
| 108 | $self->{'file_type'} = "PPT";
|
---|
| 109 |
|
---|
[22597] | 110 | if ($self->{'convert_to'} eq "auto") {
|
---|
| 111 | if ($self->{'windows_scripting'}) {
|
---|
| 112 | $self->{'convert_to'} = "pagedimg_jpg";
|
---|
| 113 | }
|
---|
| 114 | else {
|
---|
| 115 | $self->{'convert_to'} = "html";
|
---|
| 116 | }
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | my $outhandle = $self->{'outhandle'};
|
---|
| 120 |
|
---|
[22515] | 121 | # can't have windows_scripting and openoffice_scripting at the same time
|
---|
| 122 | if ($self->{'windows_scripting'} && $self->{'openoffice_scripting'}) {
|
---|
| 123 | print $outhandle "Warning: Cannot have -windows_scripting and -openoffice_scripting\n";
|
---|
| 124 | print $outhandle " on at the same time. Defaulting to -windows_scripting\n";
|
---|
| 125 | $self->{'openoffice_scripting'} = 0;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[15872] | 128 | #these are passed through to gsConvert.pl by ConvertBinaryFile.pm
|
---|
[10491] | 129 | $self->{'convert_options'} = "-windows_scripting" if $self->{'windows_scripting'};
|
---|
[22597] | 130 |
|
---|
| 131 | # set convert_to_plugin and convert_to_ext
|
---|
[22640] | 132 | $self->set_standard_convert_settings();
|
---|
[22597] | 133 |
|
---|
| 134 | my $secondary_plugin_name = $self->{'convert_to_plugin'};
|
---|
[10275] | 135 | my $secondary_plugin_options = $self->{'secondary_plugin_options'};
|
---|
[10218] | 136 |
|
---|
[22597] | 137 | if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
|
---|
| 138 | $secondary_plugin_options->{$secondary_plugin_name} = [];
|
---|
[10275] | 139 | }
|
---|
[22597] | 140 | my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
|
---|
| 141 |
|
---|
| 142 | push(@$specific_options, "-file_rename_method", "none");
|
---|
| 143 | push(@$specific_options, "-extract_language") if $self->{'extract_language'};
|
---|
| 144 |
|
---|
| 145 | if ($secondary_plugin_name eq "HTMLPlugin") {
|
---|
| 146 | push(@$specific_options, "-processing_tmp_files");
|
---|
| 147 | push(@$specific_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
|
---|
[18406] | 148 | }
|
---|
[22597] | 149 | elsif ($secondary_plugin_name eq "PagedImagePlugin") {
|
---|
| 150 | push(@$specific_options, "-processing_tmp_files");
|
---|
[21958] | 151 | #is this true??
|
---|
[22597] | 152 | push(@$specific_options,"-input_encoding", "utf8");
|
---|
[15903] | 153 | }
|
---|
[2981] | 154 |
|
---|
[10275] | 155 | $self = bless $self, $class;
|
---|
| 156 |
|
---|
[10427] | 157 | $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
|
---|
[10275] | 158 | return $self;
|
---|
[2981] | 159 | }
|
---|
| 160 |
|
---|
| 161 | sub get_default_process_exp {
|
---|
| 162 | my $self = shift (@_);
|
---|
| 163 | return q^(?i)\.ppt$^;
|
---|
| 164 | }
|
---|
[10275] | 165 |
|
---|
[2981] | 166 | 1;
|
---|
[10275] | 167 |
|
---|