Show
Ignore:
Timestamp:
28.09.2011 19:56:37 (8 years ago)
Author:
ak19
Message:

If soffice is not installed, then the OpenOfficeConverter?'s attempt to start soffice in the BEGIN statement fails with a popup generated by Windows that it couldn't find soffice. Before trying to run start soffice on Windows, the code now runs a which soffice command to determine that it is installed.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/open-office/trunk/src/perllib/plugins/OpenOfficeConverter.pm

    r24569 r24687  
    6464        # test to see if soffice is in path      
    6565        my $cmd = "soffice -headless 2>&1"; # for linux and mac 
     66        my $status = 0; 
    6667 
    6768        # The port that jodconverter uses to connect to soffice. 
     
    9697        # tends to hang, waiting for the prompt to return after OO has been started up 
    9798        # (which doesn't happen, so need to Ctrl-C GLI and run it again for it to work). 
    98         $cmd = "start \"soffice process\" soffice \"-accept=socket,host=$ENV{'SOFFICE_HOST'},port=$ENV{'SOFFICE_PORT'};urp;StarOffice.ServiceManager\" -headless 2>&1"; 
    99         $cmd .= " >nul"; 
    100         #print STDERR "***** Tried to start-up OpenOffice with:\n$cmd\n"; 
     99         
     100        # first need to silently check soffice exists else windows will display a popup 
     101        $status = system("which soffice >nul 2>&1"); # which.exe should be in bin/windows 
     102        if ($status == 0) { 
     103            $cmd = "start \"soffice process\" soffice \"-accept=socket,host=$ENV{'SOFFICE_HOST'},port=$ENV{'SOFFICE_PORT'};urp;StarOffice.ServiceManager\" -headless 2>&1"; 
     104            $cmd .= " >nul"; 
     105            #print STDERR "***** Tried to start-up OpenOffice with:\n$cmd\n";            
     106        } 
     107        # else cmd is still undefined 
    101108        } 
    102109        else { 
     
    109116        } 
    110117         
    111         my $status = system($cmd); 
     118        $status = system($cmd) if ($status == 0); 
    112119        if ($status != 0) { 
    113120        #print STDERR "Failed to run: $cmd\n";