source: main/trunk/greenstone2/perllib/plugins/PowerPointPlugin.pm@ 21958

Last change on this file since 21958 was 21958, checked in by kjdon, 14 years ago

ppthtml and xslhtml don't seem to output utf8, so remove the input_encoding option to html/txt secondary plugins so that it will use textcat to work it out itself.

  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1###########################################################################
2#
3# PowerPointPlugin.pm -- plugin for importing Microsoft PowerPoint files.
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
28package PowerPointPlugin;
29
30use ConvertBinaryFile;
31
32use strict;
33no strict 'refs'; # allow filehandles to be variables and viceversa
34
35sub BEGIN {
36 @PowerPointPlugin::ISA = ('ConvertBinaryFile');
37}
38
39my $convert_to_list =
40 [ { 'name' => "auto",
41 'desc' => "{ConvertBinaryFile.convert_to.auto}" },
42 { 'name' => "html",
43 'desc' => "{ConvertBinaryFile.convert_to.html}" },
44 { 'name' => "text",
45 'desc' => "{ConvertBinaryFile.convert_to.text}" },
46 { 'name' => "pagedimg_jpg",
47 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_jpg}" },
48 { 'name' => "pagedimg_gif",
49 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_gif}" },
50 { 'name' => "pagedimg_png",
51 'desc' => "{ConvertBinaryFile.convert_to.pagedimg_png}" }
52 ];
53
54my $arguments =
55 [ { 'name' => "process_exp",
56 'desc' => "{BasePlugin.process_exp}",
57 'type' => "regexp",
58 'reqd' => "no",
59 'deft' => &get_default_process_exp()}
60 ];
61
62my $options = { 'name' => "PowerPointPlugin",
63 'desc' => "{PowerPointPlugin.desc}",
64 'abstract' => "no",
65 'inherits' => "yes",
66 'srcreplaceable' => "yes", # Source docs in PPT format can be replaced with GS-generated html
67 'args' => $arguments };
68
69sub new {
70 my ($class) = shift (@_);
71 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
72 push(@$pluginlist, $class);
73
74 if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
75 my $ws_arg =[{ 'name' => "convert_to",
76 'desc' => "{ConvertBinaryFile.convert_to}",
77 'type' => "enum",
78 'reqd' => "yes",
79 'list' => $convert_to_list,
80 'deft' => "html" },
81 { 'name' => "windows_scripting",
82 'desc' => "{PowerPointPlugin.windows_scripting}",
83 'type' => "flag",
84 'reqd' => "no" }
85 ];
86 push(@$arguments,@$ws_arg);
87 }
88
89 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
90 push(@{$hashArgOptLists->{"OptList"}},$options);
91
92
93 my $self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
94
95 if ($self->{'info_only'}) {
96 # don't worry about any options etc
97 return bless $self, $class;
98 }
99
100 $self->{'filename_extension'} = "ppt";
101 $self->{'file_type'} = "PPT";
102
103 #these are passed through to gsConvert.pl by ConvertBinaryFile.pm
104 $self->{'convert_options'} = "-windows_scripting" if $self->{'windows_scripting'};
105 my $secondary_plugin_options = $self->{'secondary_plugin_options'};
106
107 if ($self->{'windows_scripting'} && ($self->{'convert_to'} =~ m/(pagedimage|pagedimg).*/i)) {
108 $secondary_plugin_options->{'PagedImagePlugin'} = [];
109 } else {
110 $secondary_plugin_options->{'HTMLPlugin'} = [];
111 $secondary_plugin_options->{'TextPlugin'} = [];
112 }
113 my $html_options = $secondary_plugin_options->{'HTMLPlugin'};
114 my $text_options = $secondary_plugin_options->{'TextPlugin'};
115 my $pageimg_options = $secondary_plugin_options->{'PagedImagePlugin'};
116
117 if (defined $html_options){
118 # ppthtml doesn't output utf-8 necessarily - let Greenstone determine the encoding
119 #push(@$html_options,"-input_encoding", "utf8");
120 push(@$html_options,"-extract_language") if $self->{'extract_language'};
121 push(@$html_options,"-file_rename_method", "none");
122
123 push(@$html_options, "-processing_tmp_files");
124
125 # Instruct HTMLPlugin (when eventually accessed through read_into_doc_obj)
126 # to extract these metadata fields from the HEAD META fields
127 push(@$html_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
128 }
129 if (defined $text_options){
130 #push(@$text_options,"-input_encoding", "utf8");
131 push(@$text_options,"-extract_language") if $self->{'extract_language'};
132 push(@$text_options,"-file_rename_method", "none");
133 }
134 if (defined $pageimg_options){
135 #is this true??
136 push(@$pageimg_options,"-input_encoding", "utf8");
137 push(@$pageimg_options,"-extract_language") if $self->{'extract_language'};
138 push(@$pageimg_options,"-file_rename_method", "none");
139 push(@$pageimg_options, "-processing_tmp_files");
140 }
141
142 $self = bless $self, $class;
143
144 $self->load_secondary_plugins($class,$secondary_plugin_options,$hashArgOptLists);
145 return $self;
146}
147
148sub get_default_process_exp {
149 my $self = shift (@_);
150 return q^(?i)\.ppt$^;
151}
152
1531;
154
Note: See TracBrowser for help on using the repository browser.