- Timestamp:
- 2010-08-10T14:31:53+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/ConvertBinaryFile.pm
r22504 r22597 95 95 my ($class,$input_args,$hashArgOptLists) = @_; 96 96 97 my @convert_to_list = split(",",$self->{'convert_to '});97 my @convert_to_list = split(",",$self->{'convert_to_plugin'}); 98 98 my $secondary_plugins = {}; 99 99 # find the plugin … … 101 101 foreach my $convert_to (@convert_to_list) { 102 102 # load in "convert_to" plugin package 103 my $plugin_class = $convert_to ."Plugin";103 my $plugin_class = $convert_to; 104 104 my $plugin_package = $plugin_class.".pm"; 105 105 … … 143 143 144 144 my $self = new AutoExtractMetadata($pluginlist, $inputargs, $hashArgOptLists); 145 146 if ($self->{'info_only'}) { 147 # don't worry about any options etc 148 return bless $self, $class; 149 } 150 151 my $convert_to_type = $self->{'convert_to'}; 152 if (!defined $convert_to_type || $convert_to_type eq "") { 153 $convert_to_type = "auto"; 154 } 155 my $windows_scripting = $self->{'windows_scripting'}; 156 $windows_scripting = 0 unless defined $windows_scripting; 157 if ($classPluginName eq "PDFPlugin") { 158 if ($convert_to_type eq "text" && 159 $ENV{'GSDLOS'} =~ /^windows$/i) { 160 print STDERR "Windows does not support pdf to text. PDFs will be converted to HTML instead\n"; 161 $convert_to_type = "html"; 162 } 163 } elsif ($classPluginName eq "WordPlugin") { 164 if (($windows_scripting && $ENV{'GSDLOS'} =~ /^windows$/i && $convert_to_type =~ /^(html|auto)$/) || defined $self->{'openoffice_scripting'}) { 165 # we use structured HTML, not normal html 166 $convert_to_type = "structuredhtml"; 167 } 168 } elsif ($classPluginName eq "PowerPointPlugin") { 169 if ($windows_scripting && $ENV{'GSDLOS'} =~ /^windows$/i && $convert_to_type eq "auto") { 170 # we use paged img 171 $convert_to_type = "pagedimg_jpg"; 172 } 173 } elsif ($classPluginName eq "PostScriptPlugin") { 174 if ($convert_to_type eq "auto") { 175 # we use text 176 $convert_to_type = "text"; 177 } 178 } 179 180 if ($convert_to_type eq "auto") { 181 # choose html for now - should choose a format based on doc type 182 $convert_to_type = "html"; 183 } 184 185 if ($convert_to_type eq "html") { 186 $self->{'convert_to'} = "HTML"; 145 146 return bless $self, $class; 147 } 148 149 # should be called by subclasses after checking and setting 150 # $self->{'convert_to'} 151 sub set_standard_convert_settings { 152 my $self =shift (@_); 153 154 my $convert_to = $self->{'convert_to'}; 155 if ($convert_to eq "auto") { 156 $convert_to = "html"; 157 $self->{'convert_to'} = "html"; 158 } 159 160 if ($convert_to eq "html") { 161 $self->{'convert_to_plugin'} = "HTMLPlugin"; 187 162 $self->{'convert_to_ext'} = "html"; 188 } elsif ($convert_to _typeeq "text") {189 $self->{'convert_to '} = "Text";163 } elsif ($convert_to eq "text") { 164 $self->{'convert_to_plugin'} = "TextPlugin"; 190 165 $self->{'convert_to_ext'} = "txt"; 191 } elsif ($convert_to _typeeq "structuredhtml") {192 $self->{'convert_to '} = "StructuredHTML";166 } elsif ($convert_to eq "structuredhtml") { 167 $self->{'convert_to_plugin'} = "StructuredHTMLPlugin"; 193 168 $self->{'convert_to_ext'} = "html"; 194 } elsif ($convert_to _type=~ /^pagedimg/) {195 $self->{'convert_to '} = "PagedImage";196 my ($convert_to_ext) = $convert_to _type=~ /pagedimg\_(jpg|gif|png)/i;169 } elsif ($convert_to =~ /^pagedimg/) { 170 $self->{'convert_to_plugin'} = "PagedImagePlugin"; 171 my ($convert_to_ext) = $convert_to =~ /pagedimg\_(jpg|gif|png)/i; 197 172 $convert_to_ext = 'jpg' unless defined $convert_to_ext; 198 173 $self->{'convert_to_ext'} = $convert_to_ext; 199 174 } 200 201 return bless $self, $class; 202 } 203 204 175 176 } 205 177 sub init { 206 178 my $self = shift (@_); … … 316 288 # Execute the conversion command and get the type of the result, 317 289 # making sure the converter gives us the appropriate output type 318 my $output_type= "";319 if ($convert_to =~ m/PagedImage/i) {320 $output_type = lc($convert_to)."_".lc($convert_to_ext);321 } else {322 $output_type = lc($convert_to);323 }290 my $output_type=$self->{'convert_to'}; 291 # if ($convert_to =~ m/PagedImage/i) { 292 # $output_type = lc($convert_to)."_".lc($convert_to_ext); 293 # } else { 294 # $output_type = lc($convert_to); 295 # } 324 296 325 297 my $cmd = "perl -S gsConvert.pl -verbose $verbosity "; … … 331 303 } 332 304 $cmd .= "-errlog \"$errlog\" -output $output_type \"$tmp_filename\""; 333 305 print STDERR "calling cmd $cmd\n"; 334 306 $output_type = `$cmd`; 335 307
Note:
See TracChangeset
for help on using the changeset viewer.