Changeset 22708
- Timestamp:
- 2010-08-22T00:00:08+12:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/open-office-src/trunk/perllib/plugins/OpenOfficeConverter.pm
r22704 r22708 153 153 sub convert { 154 154 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; 158 162 # check the filename 159 return 0if ( !-f $source_file_full_path);163 return (0,undef,undef) if ( !-f $source_file_full_path); 160 164 161 165 my $outhandle = $self->{'outhandle'}; … … 169 173 my $cache_dir = $self->{'cached_dir'}; 170 174 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 ""); 172 176 my $target_file = "$file_root.$target_file_type"; 173 177 $target_file_path = &util::filename_cat($cache_dir,$target_file); … … 180 184 181 185 # 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 183 194 if ($verbosity>2) { 184 print $outhandle "Convert command: $convert_c ommand\n";195 print $outhandle "Convert command: $convert_cmd\n"; 185 196 } 186 197 187 198 my $print_info = { 'message_prefix' => "OpenOffice Conversion", 188 199 '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 ""); 190 201 191 202 my ($regenerated,$result,$had_error) 192 = $self->autorun_general_cmd($convert_c ommand,$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); 193 204 if ($had_error) { 194 205 return (0, $result,$target_file_path); … … 198 209 199 210 200 201 sub convert_orig { 202 my $self = shift(@_); 211 sub convert_without_result { 212 my $self = shift(@_); 213 203 214 my $source_file_path = shift(@_); 204 215 my $target_file_type = shift(@_); 205 216 my $convert_options = shift(@_) || ""; 206 217 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 file215 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 command229 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(@_) || "";248 218 249 219 return $self->convert($source_file_path,$target_file_type,
Note:
See TracChangeset
for help on using the changeset viewer.