Changeset 10275

Show
Ignore:
Timestamp:
25.07.2005 13:52:52 (15 years ago)
Author:
chi
Message:

A modification to allow a secondary plugin setting through ConvertToPlug?

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/PPTPlug.pm

    r10254 r10275  
    4141    'type' => "regexp", 
    4242    'reqd' => "no", 
    43     'deft' => &get_default_process_exp() }, 
     43    'deft' => &get_default_process_exp()} 
    4444      ]; 
    4545 
     
    5555    push(@$pluginlist, $class); 
    5656 
     57    if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 
     58    my $ws_arg = { 'name' => "windows_scripting", 
     59               'desc' => "PPTPlug.windows_scripting}", 
     60               'type' => "flag", 
     61               'reqd' => "no" }; 
     62    push(@$arguments,$ws_arg); 
     63    } 
     64     
    5765    if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});} 
    5866    if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)}; 
    5967 
    6068    my $self = (defined $hashArgOptLists)? new ConvertToPlug($pluginlist,$inputargs,$hashArgOptLists): new ConvertToPlug($pluginlist,$inputargs); 
     69  
     70    # ppthtml outputs utf-8 already. 
     71    #these are passed through to gsConvert.pl by ConvertToPlug.pm 
     72    $self->{'convert_options'} = "-windows_scripting" if $self->{'window_scripting'}; 
     73    my $secondary_plugin_options = $self->{'secondary_plugin_options'}; 
    6174 
    62     # ppthtml outputs utf-8 already. 
     75    if ($self->{'windows_scripting'} && ($self->{'convert_to'} eq "PagedImg")) { 
     76        $secondary_plugin_options->{'PagedImgPlug'} = []; 
     77    } else { 
     78    $secondary_plugin_options->{'HTMLPlug'} = []; 
     79    } 
     80    my $html_options = $secondary_plugin_options->{'HTMLPlug'}; 
     81    my $pageimg_options = $secondary_plugin_options->{'PagedImgPlug'}; 
     82 
    6383    if ($self->{'input_encoding'} eq "auto") { 
    6484    $self->{'input_encoding'} = "utf8"; 
     85    $self->{'extract_language'} = 1; 
     86    if (defined $secondary_plugin_options->{'HTMLPlug'}){ 
     87        push(@$html_options,"-input_encoding", "utf8"); 
     88        push(@$html_options,"-extract_language"); 
     89 
     90        # Instruct HTMLPlug (when eventually accessed through read_into_doc_obj)  
     91        # to extract these metadata fields from the HEAD META fields 
     92        push(@$html_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>"); 
     93        #push(@$html_options , "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?'); 
     94    }  
     95    if (defined $secondary_plugin_options->{'PagedImgPlug'}){ 
     96        push(@$pageimg_options,"-input_encoding", "utf8"); 
     97        push(@$pageimg_options,"-extract_language"); 
     98    } 
    6599    } 
    66100 
    67     return bless $self, $class; 
     101    $self = bless $self, $class; 
     102 
     103    $self->load_secondary_plugins($class,$secondary_plugin_options); 
     104    return $self; 
    68105} 
    69106 
     
    72109    return q^(?i)\.ppt$^; 
    73110} 
    74      
     111 
     112sub get_file_type { 
     113    my $self = shift (@_); 
     114    my $file_type = "PPT"; 
     115    return $file_type; 
     116} 
     117 
     118sub convert_post_process 
     119{ 
     120    my $self = shift (@_); 
     121    my ($conv_filename) = @_; 
     122 
     123    my $outhandle=$self->{'outhandle'}; 
     124    my ($language, $encoding) = $self->textcat_get_language_encoding ($conv_filename); 
     125    # read in file ($text will be in utf8) 
     126    my $text = ""; 
     127    $self->read_file ($conv_filename, $encoding, $language, \$text); 
     128  
     129    # turn any high bytes that aren't valid utf-8 into utf-8. 
     130    unicode::ensure_utf8(\$text); 
     131    # Write it out again! 
     132    $self->utf8_write_file (\$text, $conv_filename); 
     133} 
     134 
    75135sub process { 
    76136    my $self = shift (@_); 
     137    my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_; 
    77138 
    78     my $outhandle = $self->{'outhandle'}; 
    79     print $outhandle "PPTPlug: passing $_[3] on to $self->{'converted_to'}Plug\n" 
    80     if $self->{'verbosity'} > 1; 
    81     print STDERR "<Processing n='$_[3]' p='PPTPlug'>\n" if ($_[6]); 
    82  
    83     return ConvertToPlug::process_type($self,"ppt",@_); 
     139    return $self->process_type("ppt",$base_dir,$file,$doc_obj); 
    84140} 
    85141 
    861421; 
     143