Changeset 23473


Ignore:
Timestamp:
2010-12-14T11:35:25+13:00 (13 years ago)
Author:
ak19
Message:

Provision for supporting .docx and .pptx files when Windows scripting is on.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/gsConvert.pl

    r22642 r23473  
    9898    my ($input_type,$output_type,$verbose);
    9999
    100    
     100    # Dynamically figure out what the --type option can support, based on whether -windows_scripting
     101    # is in use or not
     102    my $default_type_re = "(doc|dot|pdf|ps|ppt|rtf|xls)";
     103    #my $enhanced_type_re = "(docx?|dot|pdf|ps|pptx?|rtf|xlsx?)";
     104    #my $enhanced_type_re = "(docx?|dot|pdf|ps|pptx?|rtf|xlsx?)";
     105    # Currently only have VBA for Word and PPT(but no XLS)
     106    my $enhanced_type_re = "(docx?|dot|pdf|ps|pptx?|rtf|xls)";
     107
     108    my $type_re = $default_type_re;
     109   
     110    foreach my $a (@ARGV) {
     111        if ($a =~ m/^windows_scripting$/i) {
     112            $type_re = $enhanced_type_re;
     113        }
     114    }
     115   
    101116    # read command-line arguments
    102117    if (!parsargv::parse(\@ARGV,
    103              'type/(doc|dot|pdf|ps|ppt|rtf|xls)/', \$input_type,
     118             "type/$type_re/", \$input_type,
    104119             '/errlog/.*/', \$faillogfile,
    105120             'output/(auto|html|text|pagedimg).*/', \$output_type,
     
    148163    exit(1);
    149164    }
    150     elsif ($input_type eq "doc" || $input_type eq "dot") {
     165    elsif ($input_type =~ m/^docx?$/ || $input_type eq "dot") {
    151166    print &convertDOC($input_filename, $output_filestem, $output_type);
    152167    print "\n";
     
    164179    print "\n";
    165180    }
    166     elsif ($input_type eq "ppt") {
     181    elsif ($input_type =~ m/pptx?$/) {
    167182    print &convertPPT($input_filename, $output_filestem, $output_type);
    168183    print "\n";
    169184    }
    170     elsif ($input_type eq "xls") {
     185    elsif ($input_type =~ m/xlsx?$/) {
    171186    print &convertXLS($input_filename, $output_filestem, $output_type);
    172187    print "\n";
     
    203218    my $realtype = &find_docfile_type($input_filename);
    204219
    205     if ($realtype eq "word6" || $realtype eq "word7" || $realtype eq "word8") {
     220    if ($realtype eq "word6" || $realtype eq "word7"
     221        || $realtype eq "word8" || $realtype eq "docx") {
    206222    return &convertWord678($input_filename, $output_filestem, $output_type);
    207223    } elsif ($realtype eq "rtf") {
     
    455471sub find_docfile_type {
    456472    my ($input_filename) = @_;
    457    
     473   
     474    if (($windows_scripting) && ($input_filename =~ m/\.docx$/)) {
     475        return "docx";
     476    }
     477   
    458478    open(CHK, "<$input_filename");
    459479    binmode(CHK);
     
    477497    if ($line =~ m/Word\.Document\.([678])/) {
    478498        close(CHK);
     499
    479500        return "word$1";
    480501    }
Note: See TracChangeset for help on using the changeset viewer.