bool SpecialisedMover::do_copy(FileName const & from, FileName const & to, string const & latex) const { if (command_.empty()) return Mover::do_copy(from, to, latex); string command = command_; command = subst(command, "$$i", quoteName(from.toFilesystemEncoding())); command = subst(command, "$$o", quoteName(to.toFilesystemEncoding())); command = subst(command, "$$l", quoteName(latex)); Systemcall one; return one.startscript(Systemcall::Wait, command) == 0; }
bool tex2tex(string const & infilename, FileName const & outfilename, string const & encoding) { if (!tex2lyx(infilename, outfilename, encoding)) return false; string command = quoteName(package().lyx_binary().toFilesystemEncoding()); if (overwrite_files) command += " -f main"; else command += " -f none"; if (pdflatex) command += " -e pdflatex "; else command += " -e latex "; command += quoteName(outfilename.toFilesystemEncoding()); Systemcall one; if (one.startscript(Systemcall::Wait, command) == 0) return true; cerr << "Error: Running '" << command << "' failed." << endl; return false; }
void rescanTexStyles(string const & arg) { // Run rescan in user lyx directory PathChanger p(package().user_support()); FileName const prog = support::libFileSearch("scripts", "TeXFiles.py"); Systemcall one; string const command = os::python() + ' ' + quoteName(prog.toFilesystemEncoding()) + ' ' + arg; int const status = one.startscript(Systemcall::Wait, command); if (status == 0) return; // FIXME UNICODE frontend::Alert::error(_("Could not update TeX information"), bformat(_("The script `%1$s' failed."), from_utf8(prog.absFileName()))); }
void PreviewLoader::Impl::startLoading(bool wait) { if (pending_.empty() || !pconverter_) return; // Only start the process off after the buffer is loaded from file. if (!buffer_.isFullyLoaded()) return; LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()"); // As used by the LaTeX file and by the resulting image files string const directory = buffer_.temppath(); string const filename_base = unique_filename(directory); // Create an InProgress instance to place in the map of all // such processes if it starts correctly. InProgress inprogress(filename_base, pending_, pconverter_->to); // clear pending_, so we're ready to start afresh. pending_.clear(); // Output the LaTeX file. FileName const latexfile(filename_base + ".tex"); // we use the encoding of the buffer Encoding const & enc = buffer_.params().encoding(); ofdocstream of; try { of.reset(enc.iconvName()); } catch (iconv_codecvt_facet_exception const & e) { LYXERR0("Caught iconv exception: " << e.what() << "\nUnable to create LaTeX file: " << latexfile); return; } TexRow texrow; otexstream os(of, texrow); OutputParams runparams(&enc); LaTeXFeatures features(buffer_, buffer_.params(), runparams); if (!openFileWrite(of, latexfile)) return; if (!of) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "Unable to create LaTeX file\n" << latexfile); return; } of << "\\batchmode\n"; dumpPreamble(os); // handle inputenc etc. buffer_.params().writeEncodingPreamble(os, features); of << "\n\\begin{document}\n"; dumpData(of, inprogress.snippets); of << "\n\\end{document}\n"; of.close(); if (of.fail()) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "File was not closed properly."); return; } double const font_scaling_factor = buffer_.isExporting() ? 75.0 * buffer_.params().html_math_img_scale : 0.01 * lyxrc.dpi * lyxrc.zoom * lyxrc.preview_scale_factor; // FIXME XHTML // The colors should be customizable. ColorCode const bg = buffer_.isExporting() ? Color_white : PreviewLoader::backgroundColor(); ColorCode const fg = buffer_.isExporting() ? Color_black : PreviewLoader::foregroundColor(); // The conversion command. ostringstream cs; cs << pconverter_->command << " " << quoteName(latexfile.toFilesystemEncoding()) << " --dpi " << int(font_scaling_factor) << " --fg " << theApp()->hexName(fg) << " --bg " << theApp()->hexName(bg); // FIXME what about LuaTeX? if (buffer_.params().useNonTeXFonts) cs << " --latex=xelatex"; if (buffer_.params().encoding().package() == Encoding::japanese) cs << " --latex=platex"; if (buffer_.params().bibtex_command != "default") cs << " --bibtex=" << quoteName(buffer_.params().bibtex_command); else if (buffer_.params().encoding().package() == Encoding::japanese) cs << " --bibtex=" << quoteName(lyxrc.jbibtex_command); else cs << " --bibtex=" << quoteName(lyxrc.bibtex_command); if (buffer_.params().bufferFormat() == "lilypond-book") cs << " --lilypond"; string const command = libScriptSearch(cs.str()); if (wait) { ForkedCall call(buffer_.filePath()); int ret = call.startScript(ForkedProcess::Wait, command); static int fake = (2^20) + 1; int pid = fake++; inprogress.pid = pid; inprogress.command = command; in_progress_[pid] = inprogress; finishedGenerating(pid, ret); return; } // Initiate the conversion from LaTeX to bitmap images files. ForkedCall::SignalTypePtr convert_ptr(new ForkedCall::SignalType); convert_ptr->connect(bind(&Impl::finishedGenerating, this, _1, _2)); ForkedCall call(buffer_.filePath()); int ret = call.startScript(command, convert_ptr); if (ret != 0) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "Unable to start process\n" << command); return; } // Store the generation process in a list of all such processes inprogress.pid = call.pid(); inprogress.command = command; in_progress_[inprogress.pid] = inprogress; }