Changeset 22708

Show
Ignore:
Timestamp:
22.08.2010 00:00:08 (9 years ago)
Author:
davidb
Message:

Switch to running java -jar command directly (rather than going through oo2html). Has the advantage of better quoting around filenames (compared to oo2html.bat which was known to be deficient).

Files:
1 modified

Legend:

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

    r22704 r22708  
    153153sub convert { 
    154154    my $self = shift(@_); 
    155     my ($source_file_full_path, $target_file_type) = @_; 
    156  
    157     return 0 unless $openoffice_conversion_available; 
     155    my $source_file_full_path = shift(@_); 
     156    my $target_file_type      = shift(@_); 
     157    my $convert_options       = shift(@_) || ""; 
     158    my $convert_id            = shift(@_) || ""; 
     159    my $cache_mode            = shift(@_) || ""; 
     160 
     161    return (0,undef,undef) unless $openoffice_conversion_available; 
    158162    # check the filename 
    159     return 0 if ( !-f $source_file_full_path); 
     163    return (0,undef,undef) if ( !-f $source_file_full_path); 
    160164 
    161165    my $outhandle = $self->{'outhandle'}; 
     
    169173    my $cache_dir = $self->{'cached_dir'}; 
    170174    my $file_root = $self->{'cached_file_root'}; 
    171     #$file_root .= "_$convert_id" if ($convert_id ne ""); 
     175    $file_root .= "_$convert_id" if ($convert_id ne ""); 
    172176    my $target_file = "$file_root.$target_file_type"; 
    173177    $target_file_path = &util::filename_cat($cache_dir,$target_file); 
     
    180184 
    181185    # Generate and run the convert command 
    182     my $convert_command = "oo2html \"$source_file_full_path\" \"$target_file_path\""; 
     186    my $jodjar; 
     187 
     188    my $gextoo_home = $ENV{'GEXT_OPENOFFICE'}; 
     189    my $jodjar = &util::filename_cat($gextoo_home,"lib","java","jodconverter.jar"); 
     190 
     191    my $convert_cmd = "java -jar \"$jodjar\""; 
     192    $convert_cmd .= " \"$source_file_full_path\" \"$target_file_path\""; 
     193 
    183194    if ($verbosity>2) { 
    184     print $outhandle "Convert command: $convert_command\n"; 
     195    print $outhandle "Convert command: $convert_cmd\n"; 
    185196    } 
    186197 
    187198    my $print_info = { 'message_prefix' => "OpenOffice Conversion", 
    188199               'message' => "Converting $source_file_no_path to: $target_file_type" }; 
    189     #$print_info->{'cache_mode'} = $cache_mode if ($cache_mode ne ""); 
     200    $print_info->{'cache_mode'} = $cache_mode if ($cache_mode ne ""); 
    190201 
    191202    my ($regenerated,$result,$had_error)  
    192     = $self->autorun_general_cmd($convert_command,$source_file_full_path, $target_file_path,$print_info); 
     203    = $self->autorun_general_cmd($convert_cmd,$source_file_full_path, $target_file_path,$print_info); 
    193204    if ($had_error) { 
    194205    return (0, $result,$target_file_path); 
     
    198209 
    199210 
    200  
    201 sub convert_orig { 
    202     my $self = shift(@_); 
     211sub convert_without_result { 
     212    my $self = shift(@_); 
     213 
    203214    my $source_file_path = shift(@_); 
    204215    my $target_file_type = shift(@_); 
    205216    my $convert_options  = shift(@_) || ""; 
    206217    my $convert_id       = shift(@_) || ""; 
    207     my $cache_mode       = shift(@_) || ""; 
    208  
    209     my $outhandle = $self->{'outhandle'}; 
    210     my $verbosity = $self->{'verbosity'}; 
    211  
    212     my $source_file_no_path = &File::Basename::basename($source_file_path); 
    213  
    214     # Determine the full name and path of the output file 
    215     my $target_file_path; 
    216     if ($self->{'enable_cache'}) { 
    217     my $cached_image_dir = $self->{'cached_dir'}; 
    218     my $image_root = $self->{'cached_file_root'}; 
    219     $image_root .= "_$convert_id" if ($convert_id ne ""); 
    220     my $image_file = "$image_root.$target_file_type"; 
    221     $target_file_path = &util::filename_cat($cached_image_dir,$image_file); 
    222     } 
    223     else { 
    224     $target_file_path = &util::get_tmp_filename($target_file_type); 
    225     push(@{$self->{'ootmp_file_paths'}}, $target_file_path); 
    226     } 
    227  
    228     # Generate and run the convert command 
    229     my $convert_command = "oo2html $convert_options \"$source_file_path\" \"$target_file_path\""; 
    230  
    231     my $print_info = { 'message_prefix' => $convert_id, 
    232                'message' => "Converting $source_file_no_path to: $convert_id $target_file_type" }; 
    233     $print_info->{'cache_mode'} = $cache_mode if ($cache_mode ne ""); 
    234  
    235     my ($regenerated,$result,$had_error)  
    236     = $self->autorun_general_cmd($convert_command,$target_file_path,$print_info); 
    237  
    238     return ($result,$target_file_path); 
    239 } 
    240  
    241 sub convert_without_result { 
    242     my $self = shift(@_); 
    243  
    244     my $source_file_path = shift(@_); 
    245     my $target_file_type = shift(@_); 
    246     my $convert_options  = shift(@_) || ""; 
    247     my $convert_id       = shift(@_) || ""; 
    248218 
    249219    return $self->convert($source_file_path,$target_file_type,