Ignore:
Timestamp:
2011-06-16T19:16:15+12:00 (13 years ago)
Author:
ak19
Message:

2nd and tentatively final set of changes changes to get the new docx2html functionality to work on docx files. The changes have to do with error reporting when Word is not installed/can't be found/can't be instantiated, when the script is launched with the wrong number of args and if the input file does not exist. WordPlugin now has docx as part of the default process_expression (even when OO is not installed).

File:
1 edited

Legend:

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

    r24164 r24166  
    786786    my ($input_filename, $output_filestem) = @_;
    787787
    788     my $vbScript = &util::filename_cat($ENV{'GSDLHOME'}, "bin",
    789                        $ENV{'GSDLOS'}, "word2html");
     788    # build up the path to the doc-to-html conversion tool we're going to use
     789    my $vbScript = &util::filename_cat($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'});
    790790
    791791    if ($ENV{'GSDLOS'} =~ m/^windows$/i) {
    792     # if windows scripting with docx input, use new VBscript
    793     if($input_filename =~ m/docx$/i) {
    794         $vbScript = "docx2html.vbs";
    795     } else { # use the usual word2html conversion VB executable
    796         $vbScript = "word2html";
    797     }
    798     }
     792        # if windows scripting with docx input, use new VBscript to get the local Word install (if
     793        # any) to do the conversion, since docX can't be processed by word2html's windows_scripting
     794       
     795        if($input_filename =~ m/docx$/i) {  # need to use full path to docx2html script,
     796                                            # else script launch fails when there are error msgs
     797            $vbScript = &util::filename_cat($vbScript, "docx2html.vbs");
     798            $vbScript = "CScript //Nologo \"$vbScript\"";   # launche with CScript for error output in STDERR
     799                                                            # //Nologo flag avoids Microsoft's opening/logo msgs
     800        }
     801        else {  # old doc versions. use the usual VB executable word2html for the
     802                # conversion. Doesn't need full path, since bin\windows is on PATH         
     803            $vbScript = "word2html"; #$vbScript = "\"".&util::filename_cat($vbScript, "word2html")."\"";
     804        }
     805    }
     806    else { # not windows
     807        $vbScript = "\"".&util::filename_cat($vbScript, "word2html")."\"";
     808    }
    799809
    800810    if (-e "$output_filestem.html") {
     
    812822
    813823    # redirecting STDERR
    814     $cmd .= " 2> \"$output_filestem.err\""
    815     if ($ENV {'GSDLOS'} !~ m/^windows$/i || $is_winnt_2000);
    816    
     824   
     825    $cmd .= " 2> \"$output_filestem.err\""
     826        if ($ENV {'GSDLOS'} !~ m/^windows$/i || $is_winnt_2000);   
     827    #print STDERR "@@@@@@@@@ cmd=$cmd\n";
     828   
    817829    # execute the command
    818830    $!=0;
     
    822834    if (-s "$output_filestem.err") {
    823835        open (ERRFILE, "<$output_filestem.err");
    824        
     836       
    825837        my $write_to_fail_log=0;
    826838        if ($faillogfile ne "" && defined(open(FAILLOG,">>$faillogfile")))
Note: See TracChangeset for help on using the changeset viewer.