Changeset 22494 for gs2-extensions/open-office/trunk/perllib
- Timestamp:
- 2010-07-26T11:30:35+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/open-office/trunk/perllib/plugins/OpenOfficeConverter.pm
r22375 r22494 27 27 package OpenOfficeConverter; 28 28 29 use ConvertBinaryFile; 29 30 use BaseMediaConverter; 30 31 … … 35 36 36 37 BEGIN { 37 @OpenOfficeConverter::ISA = (' BaseMediaConverter');38 @OpenOfficeConverter::ISA = ('ConvertBinaryFile', 'BaseMediaConverter'); 38 39 } 39 40 … … 46 47 'reqd' => "no" }, 47 48 { 'name' => "openoffice_port", 48 'desc' => "{OpenOfficeConverter.openoffice_ scripting}",49 'desc' => "{OpenOfficeConverter.openoffice_port}", 49 50 'type' => "int", 50 51 'deft' => "8100", … … 86 87 else { 87 88 # 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) { 91 102 print STDERR "Failed to run: $cmd\n"; 92 103 print STDERR "$!\n"; … … 98 109 99 110 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); 104 112 } 105 113 … … 107 115 push(@{$hashArgOptLists->{"OptList"}},$options); 108 116 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); 111 121 112 122 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 } 120 131 } 121 132 else { 122 $self->{'openoffice_conversion_available'} = $openoffice_conversion_available;123 133 $self->{'no_openoffice_conversion_reason'} = $no_openoffice_conversion_reason; 124 134 … … 126 136 &gsprintf($outhandle, "OpenOfficeConverter: {OpenOfficeConverter.noconversionavailable} ({OpenOfficeConverter.$no_openoffice_conversion_reason})\n"); 127 137 } 138 139 $self->{'openoffice_conversion_available'} = $openoffice_conversion_available; 128 140 129 141 return bless $self, $class; … … 133 145 sub init { 134 146 my $self = shift(@_); 135 147 my ($verbosity, $outhandle, $failhandle) = @_; 148 149 $self->ConvertBinaryFile::init($verbosity,$outhandle,$failhandle); 150 136 151 $self->{'ootmp_file_paths'} = (); 137 152 } … … 140 155 my $self = shift(@_); 141 156 157 $self->ConvertBinaryFile::deinit(@_); 158 142 159 $self->clean_up_temporary_files(); 143 160 } 161 162 144 163 145 164 … … 197 216 198 217 218 sub 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 199 232 200 233 sub clean_up_temporary_files {
Note:
See TracChangeset
for help on using the changeset viewer.