Changeset 22609 for gs2-extensions


Ignore:
Timestamp:
2010-08-12T15:55:23+12:00 (14 years ago)
Author:
kjdon
Message:

now just inherits from BaseMediaConverter not ConvertBinaryFile. A new convert method, which is used by OpenOfficePlugin and other plugins that use this.

File:
1 edited

Legend:

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

    r22508 r22609  
    4141
    4242BEGIN {
    43     @OpenOfficeConverter::ISA = ('ConvertBinaryFile', 'BaseMediaConverter');
     43    @OpenOfficeConverter::ISA = ('BaseMediaConverter');
    4444
    4545    # Check that OpenOffice and jodconverter are installed and available on
    4646    # the path
    47 
    4847    $openoffice_conversion_available = 1;
    4948    $no_openoffice_conversion_reason = "";
     
    5554    else {
    5655    my $gextoo_home = $ENV{'GEXT_OPENOFFICE'};
    57     my $jodjar = &util::filename_cat($gextoo_home,"lib","java","jodconverter.jar");
     56    my $jodjar = &util::filename_cat($gextoo_home,"lib","java","jodconverterx.jar");
    5857
    5958    if (!-e $jodjar) {
     
    109108    push(@{$hashArgOptLists->{"OptList"}},$options);
    110109
    111     my $bmc_self = new BaseMediaConverter($pluginlist, $inputargs, $hashArgOptLists,1);
    112     my $cbf_self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists);
    113     my $self = BasePlugin::merge_inheritance($bmc_self,$cbf_self);
     110    my $self = new BaseMediaConverter($pluginlist, $inputargs, $hashArgOptLists);
    114111
    115112    if ($self->{'info_only'}) {
     
    130127    my $outhandle = $self->{'outhandle'};
    131128    &gsprintf($outhandle, "OpenOfficeConverter: {OpenOfficeConverter.noconversionavailable} ({OpenOfficeConverter.$no_openoffice_conversion_reason})\n");
    132     &gsprintf($outhandle, "OpenOfficeConverter {OpenOfficeConverter.ConvertBinaryFileDefault}\n");
    133129    } 
    134130
     
    143139    my ($verbosity, $outhandle, $failhandle) = @_;
    144140
    145     $self->ConvertBinaryFile::init($verbosity,$outhandle,$failhandle);
    146  
    147141    $self->{'ootmp_file_paths'} = ();
    148142}
     
    151145    my $self = shift(@_);
    152146
    153     $self->ConvertBinaryFile::deinit(@_);
    154  
    155147    $self->clean_up_temporary_files();
    156148}
    157149
    158150
    159    
    160 
    161151sub convert {
     152    my $self = shift(@_);
     153    my ($source_file_full_path, $target_file_type) = @_;
     154
     155    return 0 unless $openoffice_conversion_available;
     156    # check the filename
     157    return 0 if ( !-f $source_file_full_path);
     158
     159    my $source_file_no_path = &File::Basename::basename($source_file_full_path);
     160    # Determine the full name and path of the output file
     161    my $target_file_path;
     162    if ($self->{'enable_cache'}) {
     163    $self->init_cache_for_file($source_file_full_path);
     164    my $cache_dir = $self->{'cached_dir'};
     165    my $file_root = $self->{'cached_file_root'};
     166    #$file_root .= "_$convert_id" if ($convert_id ne "");
     167    my $target_file = "$file_root.$target_file_type";
     168    $target_file_path = &util::filename_cat($cache_dir,$target_file);
     169    }
     170    else {
     171    # this is in gsdl/tmp. get a tmp filename in collection instead???
     172    $target_file_path = &util::get_tmp_filename($target_file_type);
     173    push(@{$self->{'ootmp_file_paths'}}, $target_file_path);
     174    }
     175
     176    # Generate and run the convert command
     177    my $convert_command = "oo2html \"$source_file_full_path\" \"$target_file_path\"";
     178    print STDERR "convert_command = $convert_command\n";
     179    my $print_info = { 'message_prefix' => "OpenOffice Conversion",
     180               'message' => "Converting $source_file_no_path to: $target_file_type" };
     181    #$print_info->{'cache_mode'} = $cache_mode if ($cache_mode ne "");
     182
     183    my ($regenerated,$result,$had_error)
     184    = $self->autorun_general_cmd($convert_command,$source_file_full_path, $target_file_path,$print_info);
     185    if ($had_error) {
     186    return (0, $result,$target_file_path);
     187    }
     188    return (1, $result,$target_file_path);
     189}
     190
     191
     192
     193sub convert_orig {
    162194    my $self = shift(@_);
    163195    my $source_file_path = shift(@_);
Note: See TracChangeset for help on using the changeset viewer.