[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 |
|
---|
[22640] | 30 | use OOConvertBinaryFile;
|
---|
[15872] | 31 |
|
---|
[10254] | 32 | use strict;
|
---|
| 33 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
[22515] | 34 | no strict 'subs';
|
---|
| 35 | use gsprintf 'gsprintf';
|
---|
[2981] | 36 |
|
---|
| 37 | sub BEGIN {
|
---|
[22640] | 38 | @PowerPointPlugin::ISA = ('OOConvertBinaryFile');
|
---|
[2981] | 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 |
|
---|
[22640] | 97 | my $self = new OOConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
|
---|
[10275] | 98 |
|
---|
[10580] | 99 | if ($self->{'info_only'}) {
|
---|
| 100 | # don't worry about any options etc
|
---|
| 101 | return bless $self, $class;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[15872] | 104 | $self->{'filename_extension'} = "ppt";
|
---|
| 105 | $self->{'file_type'} = "PPT";
|
---|
| 106 |
|
---|
[22597] | 107 | if ($self->{'convert_to'} eq "auto") {
|
---|
| 108 | if ($self->{'windows_scripting'}) {
|
---|
| 109 | $self->{'convert_to'} = "pagedimg_jpg";
|
---|
| 110 | }
|
---|
| 111 | else {
|
---|
| 112 | $self->{'convert_to'} = "html";
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | my $outhandle = $self->{'outhandle'};
|
---|
| 117 |
|
---|
[22515] | 118 | # can't have windows_scripting and openoffice_scripting at the same time
|
---|
| 119 | if ($self->{'windows_scripting'} && $self->{'openoffice_scripting'}) {
|
---|
| 120 | print $outhandle "Warning: Cannot have -windows_scripting and -openoffice_scripting\n";
|
---|
| 121 | print $outhandle " on at the same time. Defaulting to -windows_scripting\n";
|
---|
| 122 | $self->{'openoffice_scripting'} = 0;
|
---|
| 123 | }
|
---|
| 124 |
|
---|
[15872] | 125 | #these are passed through to gsConvert.pl by ConvertBinaryFile.pm
|
---|
[10491] | 126 | $self->{'convert_options'} = "-windows_scripting" if $self->{'windows_scripting'};
|
---|
[22597] | 127 |
|
---|
| 128 | # set convert_to_plugin and convert_to_ext
|
---|
[22640] | 129 | $self->set_standard_convert_settings();
|
---|
[22597] | 130 |
|
---|
| 131 | my $secondary_plugin_name = $self->{'convert_to_plugin'};
|
---|
[10275] | 132 | my $secondary_plugin_options = $self->{'secondary_plugin_options'};
|
---|
[10218] | 133 |
|
---|
[22597] | 134 | if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
|
---|
| 135 | $secondary_plugin_options->{$secondary_plugin_name} = [];
|
---|
[10275] | 136 | }
|
---|
[22597] | 137 | my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
|
---|
| 138 |
|
---|
| 139 | push(@$specific_options, "-file_rename_method", "none");
|
---|
| 140 | push(@$specific_options, "-extract_language") if $self->{'extract_language'};
|
---|
| 141 |
|
---|
| 142 | if ($secondary_plugin_name eq "HTMLPlugin") {
|
---|
| 143 | push(@$specific_options, "-processing_tmp_files");
|
---|
| 144 | push(@$specific_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
|
---|
[18406] | 145 | }
|
---|
[22597] | 146 | elsif ($secondary_plugin_name eq "PagedImagePlugin") {
|
---|
| 147 | push(@$specific_options, "-processing_tmp_files");
|
---|
[21958] | 148 | #is this true??
|
---|
[22597] | 149 | push(@$specific_options,"-input_encoding", "utf8");
|
---|
[15903] | 150 | }
|
---|
[2981] | 151 |
|
---|
[10275] | 152 | $self = bless $self, $class;
|
---|
| 153 |
|
---|
[10427] | 154 | $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
|
---|
[10275] | 155 | return $self;
|
---|
[2981] | 156 | }
|
---|
| 157 |
|
---|
| 158 | sub get_default_process_exp {
|
---|
| 159 | my $self = shift (@_);
|
---|
| 160 | return q^(?i)\.ppt$^;
|
---|
| 161 | }
|
---|
[10275] | 162 |
|
---|
[2981] | 163 | 1;
|
---|
[10275] | 164 |
|
---|