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/PostScriptPlugin.pm

    r20790 r22597  
    8888    push(@$pluginlist, $class);
    8989
    90     #push(@$inputargs,"-convert_to");
    91     #push(@$inputargs,"text");
    9290    push(@$inputargs,"-title_sub");
    9391    push(@$inputargs,'^(Page\s+\d+)?(\s*1\s+)?');
     
    106104    $self->{'file_type'} = "PS";
    107105
     106    if ($self->{'convert_to'} eq "auto") {
     107    $self->{'convert_to'} = "text";
     108    }
     109
     110    # set convert_to_plugin and convert_to_ext
     111    $self->ConvertBinaryFile::set_standard_convert_settings();
     112    my $secondary_plugin_name = $self->{'convert_to_plugin'};
    108113    my $secondary_plugin_options = $self->{'secondary_plugin_options'};
    109114
    110     if (!defined $secondary_plugin_options->{'TextPlugin'}) {
    111     $secondary_plugin_options->{'TextPlugin'} = [];
    112     }
    113 
    114     if (!defined $secondary_plugin_options->{'HTMLPlugin'}) {
    115     $secondary_plugin_options->{'HTMLPlugin'} = [];
    116     }
    117 
    118     my $text_options = $secondary_plugin_options->{'TextPlugin'};
    119     my $html_options = $secondary_plugin_options->{'HTMLPlugin'};
    120 
    121     if (defined $self->{'convert_to'} && $self->{'convert_to'} =~ m/(pagedimage|pagedimg).*/i) {
    122     if (!defined $secondary_plugin_options->{'PagedImagePlugin'}){
    123         $secondary_plugin_options->{'PagedImagePlugin'} = [];
    124         my $pagedimg_options = $secondary_plugin_options->{'PagedImagePlugin'};
    125         push(@$pagedimg_options, "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?');
    126         push(@$pagedimg_options, "-file_rename_method", "none");
    127         push(@$pagedimg_options, "-processing_tmp_files");
    128     }
    129     }
     115    if (!defined $secondary_plugin_options->{$secondary_plugin_name}) {
     116    $secondary_plugin_options->{$secondary_plugin_name} = [];
     117    }
     118    my $specific_options = $secondary_plugin_options->{$secondary_plugin_name};
     119
    130120    # following title_sub removes "Page 1" added by ps2ascii, and a leading
    131121    # "1", which is often the page number at the top of the page. Bad Luck
    132122    # if your document title actually starts with "1 " - is there a better way?
    133     #$self->{'input_encoding'} = "utf8";
    134     #$self->{'extract_language'} = 1;
    135     push(@$text_options, "-input_encoding", "utf8");
    136     push(@$text_options,"-extract_language") if $self->{'extract_language'};
    137     push(@$text_options , "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?');
    138 
    139     push(@$text_options, "-file_rename_method", "none");
    140     push(@$html_options, "-file_rename_method", "none");
    141    
    142     # tell the secondary plugins that they are processing tmp files
    143     push(@$html_options, "-processing_tmp_files");
     123    push(@$specific_options, "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?');
     124    push(@$specific_options, "-file_rename_method", "none");
     125   
     126    if ($secondary_plugin_name eq "TextPlugin") {
     127    push(@$specific_options, "-input_encoding", "utf8");
     128    push(@$specific_options,"-extract_language") if $self->{'extract_language'};
     129    } elsif ($secondary_plugin_name eq "PagedImagePlugin") {
     130    push(@$specific_options, "-processing_tmp_files");
     131    }
    144132
    145133    $self = bless $self, $class;
Note: See TracChangeset for help on using the changeset viewer.