Changeset 22494

Show
Ignore:
Timestamp:
26.07.2010 11:30:35 (9 years ago)
Author:
davidb
Message:

Restructuring of plugin to be both BaseMediaplugin? and ConvertBinaryFile?

Files:
1 modified

Legend:

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

    r22375 r22494  
    2727package OpenOfficeConverter; 
    2828 
     29use ConvertBinaryFile; 
    2930use BaseMediaConverter; 
    3031 
     
    3536 
    3637BEGIN { 
    37     @OpenOfficeConverter::ISA = ('BaseMediaConverter'); 
     38    @OpenOfficeConverter::ISA = ('ConvertBinaryFile', 'BaseMediaConverter'); 
    3839} 
    3940 
     
    4647      'reqd' => "no" }, 
    4748    { 'name' => "openoffice_port", 
    48       'desc' => "{OpenOfficeConverter.openoffice_scripting}", 
     49      'desc' => "{OpenOfficeConverter.openoffice_port}", 
    4950      'type' => "int", 
    5051      'deft' => "8100", 
     
    8687    else { 
    8788        # test to see if soffice in in path 
    88         my $cmd = "soffice -headless -help 2>&1"; 
    89  
    90         if (system($cmd)!=0) { 
     89        if ($ENV{'GSDLOS'} =~ m/^windows$/) { 
     90        my $ooffice_dir_guess = 
     91            &util::filename_cat($ENV{'ProgramFiles'},"OpenOffice.org 3", 
     92                    "program"); 
     93        if (-d  $ooffice_dir_guess) { 
     94            &util::envvar_append("PATH",$ooffice_dir_guess); 
     95        } 
     96        } 
     97 
     98        my $cmd = "soffice -headless"; 
     99 
     100        my $status = system($cmd); 
     101        if ($status != 0) { 
    91102        print STDERR "Failed to run: $cmd\n"; 
    92103        print STDERR "$!\n"; 
     
    98109 
    99110    if ($openoffice_conversion_available) { 
    100     push(@$arguments,$opt_arguments); 
    101  
    102     # have necessary components => launch OpenOffice in headless mode 
    103     # listing to localhost port 
     111    push(@$arguments,@$opt_arguments); 
    104112    } 
    105113 
     
    107115    push(@{$hashArgOptLists->{"OptList"}},$options); 
    108116 
    109     my $self  
    110     = new BaseMediaConverter($pluginlist, $inputargs, $hashArgOptLists, 1); 
     117    my $bmc_self = new BaseMediaConverter($pluginlist, $inputargs, $hashArgOptLists,1); 
     118    my $cbf_self = new ConvertBinaryFile($pluginlist, $inputargs, $hashArgOptLists); 
     119 
     120    my $self = BasePlugin::merge_inheritance($bmc_self,$cbf_self); 
    111121 
    112122    if ($openoffice_conversion_available) { 
    113  
    114     my $oo_port = $self->{'openoffice_port'}; 
    115     my $launch_cmd = "soffice"; 
    116     $launch_cmd .= " \"-accept=socket,host=localhost,port=$oo_port;urp;StarOffice.ServiceManager\""; 
    117     $launch_cmd .= " -headless"; 
    118      
    119     $self->{'openoffice_launch_cmd'} = $launch_cmd;  
     123    if ($self->{'openoffice_scripting'}) { 
     124        my $oo_port = $self->{'openoffice_port'}; 
     125        my $launch_cmd = "soffice"; 
     126        $launch_cmd .= " \"-accept=socket,host=localhost,port=$oo_port;urp;StarOffice.ServiceManager\""; 
     127        $launch_cmd .= " -headless"; 
     128         
     129        $self->{'openoffice_launch_cmd'} = $launch_cmd; 
     130    } 
    120131    } 
    121132    else {        
    122     $self->{'openoffice_conversion_available'} = $openoffice_conversion_available; 
    123133    $self->{'no_openoffice_conversion_reason'} = $no_openoffice_conversion_reason; 
    124134 
     
    126136    &gsprintf($outhandle, "OpenOfficeConverter: {OpenOfficeConverter.noconversionavailable} ({OpenOfficeConverter.$no_openoffice_conversion_reason})\n"); 
    127137    }   
     138 
     139    $self->{'openoffice_conversion_available'} = $openoffice_conversion_available; 
    128140     
    129141    return bless $self, $class; 
     
    133145sub init { 
    134146    my $self = shift(@_); 
    135  
     147    my ($verbosity, $outhandle, $failhandle) = @_; 
     148 
     149    $self->ConvertBinaryFile::init($verbosity,$outhandle,$failhandle); 
     150  
    136151    $self->{'ootmp_file_paths'} = (); 
    137152} 
     
    140155    my $self = shift(@_); 
    141156 
     157    $self->ConvertBinaryFile::deinit(@_); 
     158  
    142159    $self->clean_up_temporary_files(); 
    143160} 
     161 
     162 
    144163     
    145164 
     
    197216 
    198217 
     218sub tmp_area_convert_fileXX { 
     219    my $self = shift (@_); 
     220    my ($output_ext, $input_filename, $textref) = @_; 
     221     
     222    my $outhandle = $self->{'outhandle'}; 
     223    my $convert_to = $self->{'convert_to'}; 
     224    my $failhandle = $self->{'failhandle'}; 
     225    my $convert_to_ext = $self->{'convert_to_ext'}; 
     226     
     227    # derive tmp filename from input filename 
     228    my ($tailname, $dirname, $suffix) 
     229    = &File::Basename::fileparse($input_filename, "\\.[^\\.]+\$"); 
     230} 
     231 
    199232 
    200233sub clean_up_temporary_files {