Ignore:
Timestamp:
2010-08-10T14:31:53+12:00 (14 years ago)
Author:
kjdon
Message:

code tidy up. rearranged how convertbinaryfile plugins set up their secondary plugins - now only set up the options for the one they are using. all subclass specific code moved out of convertbinaryfile.new into the appropriate plugin file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/PowerPointPlugin.pm

    r22515 r22597  
    3434no strict 'subs';
    3535use gsprintf 'gsprintf';
    36 
    37 #sub BEGIN {
    38 #    @PowerPointPlugin::ISA = ('ConvertBinaryFile');
    39 #}
    4036
    4137# @ISA dynamically configured to be either OpenOfficeConverter or ConvertBinaryFile
     
    157153    }
    158154
    159     my $outhandle = $self->{'outhandle'};
    160 
    161155    $self->{'filename_extension'} = "ppt";
    162156    $self->{'file_type'} = "PPT";
     157
     158    if ($self->{'convert_to'} eq "auto") {
     159    if ($self->{'windows_scripting'}) {
     160        $self->{'convert_to'} = "pagedimg_jpg";
     161    }
     162    else {
     163        $self->{'convert_to'} = "html";
     164    }
     165    }
     166
     167   my $outhandle = $self->{'outhandle'};
    163168
    164169    # can't have windows_scripting and openoffice_scripting at the same time
     
    172177    $self->{'convert_options'} = "-windows_scripting" if $self->{'windows_scripting'};
    173178    $self->{'convert_options'} = "-openoffice_scripting" if $self->{'openoffice_scripting'};
     179
     180    # set convert_to_plugin and convert_to_ext
     181    $self->ConvertBinaryFile::set_standard_convert_settings();
     182
     183    my $secondary_plugin_name = $self->{'convert_to_plugin'};
    174184    my $secondary_plugin_options = $self->{'secondary_plugin_options'};
    175185
    176     if ($self->{'windows_scripting'} && ($self->{'convert_to'} =~ m/(pagedimage|pagedimg).*/i)) {
    177     $secondary_plugin_options->{'PagedImagePlugin'} = [];
    178     } else {
    179     $secondary_plugin_options->{'HTMLPlugin'} = [];
    180     $secondary_plugin_options->{'TextPlugin'} = [];
    181     }
    182     my $html_options = $secondary_plugin_options->{'HTMLPlugin'};
    183     my $text_options = $secondary_plugin_options->{'TextPlugin'};
    184     my $pageimg_options = $secondary_plugin_options->{'PagedImagePlugin'};
    185  
    186     if (defined $html_options){
    187     # ppthtml doesn't output utf-8 necessarily - let Greenstone determine the encoding
    188     #push(@$html_options,"-input_encoding", "utf8");
    189     push(@$html_options,"-extract_language") if $self->{'extract_language'};
    190     push(@$html_options,"-file_rename_method", "none");
    191    
    192     push(@$html_options, "-processing_tmp_files");
    193    
    194     # Instruct HTMLPlugin (when eventually accessed through read_into_doc_obj)
    195     # to extract these metadata fields from the HEAD META fields
    196     push(@$html_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
    197     }
    198     if (defined $text_options){
    199     #push(@$text_options,"-input_encoding", "utf8");
    200     push(@$text_options,"-extract_language") if $self->{'extract_language'};
    201     push(@$text_options,"-file_rename_method", "none");
    202     }
    203     if (defined $pageimg_options){
     186    if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
     187    $secondary_plugin_options->{$secondary_plugin_name} = [];
     188    }
     189    my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
     190
     191    push(@$specific_options, "-file_rename_method", "none");
     192    push(@$specific_options, "-extract_language") if $self->{'extract_language'};
     193
     194    if ($secondary_plugin_name eq "HTMLPlugin") {
     195    push(@$specific_options, "-processing_tmp_files");
     196    push(@$specific_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>");
     197    }
     198    elsif ($secondary_plugin_name eq "PagedImagePlugin") {
     199    push(@$specific_options, "-processing_tmp_files");
    204200    #is this true??
    205     push(@$pageimg_options,"-input_encoding", "utf8");
    206     push(@$pageimg_options,"-extract_language") if $self->{'extract_language'};
    207     push(@$pageimg_options,"-file_rename_method", "none");
    208     push(@$pageimg_options, "-processing_tmp_files");
     201    push(@$specific_options,"-input_encoding", "utf8");
    209202    }
    210203
Note: See TracChangeset for help on using the changeset viewer.