+ } else {
+ runparams.nice = false;
+ if (!buffer->makeLaTeXFile(filename, buffer->filePath(), runparams))
+ return false;
+ }
+
+ string const error_type = (format == "program")? "Build" : bufferFormat(*buffer);
+ string const ext = formats.extension(format);
+ string const tmp_result_file = changeExtension(filename, ext);
+ bool const success = converters.convert(buffer, filename,
+ tmp_result_file, buffer->fileName(), backend_format, format,
+ buffer->errorList(error_type));
+ // Emit the signal to show the error list.
+ buffer->errors(error_type);
+ if (!success)
+ return false;
+
+ if (put_in_tempdir)
+ result_file = tmp_result_file;
+ else {
+ result_file = changeExtension(buffer->fileName(), ext);
+ // We need to copy referenced files (e. g. included graphics
+ // if format == "dvi") to the result dir.
+ vector<ExportedFile> const files =
+ runparams.exportdata->externalFiles(format);
+ string const dest = onlyPath(result_file);
+ CopyStatus status = SUCCESS;
+ for (vector<ExportedFile>::const_iterator it = files.begin();
+ it != files.end() && status != CANCEL; ++it) {
+ string const fmt =
+ formats.getFormatFromFile(it->sourceName);
+ status = copyFile(fmt, it->sourceName,
+ makeAbsPath(it->exportName, dest),
+ it->exportName, status == FORCE);
+ }
+ if (status == CANCEL) {
+ buffer->message(_("Document export cancelled."));
+ } else if (fs::exists(tmp_result_file)) {
+ // Finally copy the main file
+ status = copyFile(format, tmp_result_file,
+ result_file, result_file,
+ status == FORCE);
+ buffer->message(bformat(_("Document exported as %1$s "
+ "to file `%2$s'"),
+ formats.prettyName(format),
+ makeDisplayPath(result_file)));
+ } else {
+ // This must be a dummy converter like fax (bug 1888)
+ buffer->message(bformat(_("Document exported as %1$s"),
+ formats.prettyName(format)));
+ }
+ }