]> git.lyx.org Git - lyx.git/blobdiff - src/converter.C
"Inter-word Space"
[lyx.git] / src / converter.C
index 04d296b45012ce24ae11f4f2ea61fce55a63ea99..cd8a7ae10e673916274bdde8cc0433cb67c18da6 100644 (file)
@@ -16,6 +16,7 @@
 #include "lyxrc.h"
 #include "buffer.h"
 #include "bufferview_funcs.h"
+#include "errorlist.h"
 #include "LaTeX.h"
 #include "lyx_cb.h" // ShowMessage()
 #include "gettext.h"
@@ -28,6 +29,7 @@
 #include "support/filetools.h"
 #include "support/lyxfunctional.h"
 #include "support/path.h"
+#include "support/tostr.h"
 #include "support/systemcall.h"
 
 #include <cctype>
@@ -254,6 +256,9 @@ bool Converters::convert(Buffer const * buffer,
        if (edgepath.empty()) {
                return false;
        }
+       LatexRunParams runparams;
+       runparams.flavor = usePdflatex(edgepath) ?
+               LatexRunParams::PDFLATEX : LatexRunParams::LATEX;
 
        string path = OnlyPath(from_file);
        Path p(path);
@@ -290,7 +295,7 @@ bool Converters::convert(Buffer const * buffer,
                        run_latex = true;
                        string command = subst(conv.command, token_from, "");
                        lyxerr[Debug::FILES] << "Running " << command << endl;
-                       if (!runLaTeX(buffer, command))
+                       if (!runLaTeX(buffer, command, runparams))
                                return false;
                } else {
                        if (conv.need_aux && !run_latex
@@ -298,7 +303,7 @@ bool Converters::convert(Buffer const * buffer,
                                lyxerr[Debug::FILES]
                                        << "Running " << latex_command_
                                        << " to update aux file"<<  endl;
-                               runLaTeX(buffer, latex_command_);
+                               runLaTeX(buffer, latex_command_, runparams);
                        }
 
                        string infile2 = (conv.original_dir)
@@ -458,63 +463,31 @@ bool Converters::formatIsUsed(string const & format)
 }
 
 
-namespace {
-
-void alertErrors(string const & prog, int nr_errors)
-{
-       string s;
-       if (nr_errors == 1)
-               s = bformat(_("One error detected when running %1$s.\n"), prog);
-       else
-               s = bformat(_("%1$s errors detected when running %2$s.\n"),
-                       prog, tostr(nr_errors));
-       Alert::error(_("Errors found"), s);
-}
-
-}
-
-
-bool Converters::scanLog(Buffer const * buffer, string const & command,
-                       string const & filename)
+bool Converters::scanLog(Buffer const * buffer, string const & /*command*/,
+                        string const & filename)
 {
        if (!buffer)
                return false;
 
        BufferView * bv = buffer->getUser();
-       if (bv) {
-               bv->owner()->busy(true);
-               // all error insets should have been removed by now
-       }
-
-       LaTeX latex("", filename, "");
+       LatexRunParams runparams;
+       runparams.flavor = LatexRunParams::LATEX;
+       LaTeX latex("", runparams, filename, "");
        TeXErrors terr;
        int result = latex.scanLogFile(terr);
-       if (bv) {
-               if ((result & LaTeX::ERRORS)) {
-                       // Insert all errors as errors boxes
-                       bv->insertErrors(terr);
-#warning repaint() or update() or nothing ?
-                       bv->repaint();
-                       bv->fitCursor();
-               }
-               bv->owner()->busy(false);
-       }
 
-       if ((result & LaTeX::ERRORS)) {
-               string head;
-               split(command, head, ' ');
-               alertErrors(head, latex.getNumErrors());
-               return false;
-       } else if (result & LaTeX::NO_OUTPUT) {
-               Alert::warning(_("Output is empty"),
-                       _("An empty output file was generated."));
-               return false;
+       if (bv && (result & LaTeX::ERRORS)) {
+               ErrorList el(*buffer, terr);
+               bv->setErrorList(el);
+               bv->showErrorList(_("LaTeX"));
        }
+
        return true;
 }
 
 
-bool Converters::runLaTeX(Buffer const * buffer, string const & command)
+bool Converters::runLaTeX(Buffer const * buffer, string const & command,
+                         LatexRunParams const & runparams)
 {
        if (!buffer)
                return false;
@@ -529,19 +502,16 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
 
        // do the LaTeX run(s)
        string name = buffer->getLatexName();
-       LaTeX latex(command, name, buffer->filePath());
+       LaTeX latex(command, runparams, name, buffer->filePath());
        TeXErrors terr;
        int result = latex.run(terr,
                               bv ? &bv->owner()->getLyXFunc() : 0);
 
-       if (bv) {
-               if ((result & LaTeX::ERRORS)) {
-                       // Insert all errors as errors boxes
-                       bv->insertErrors(terr);
-#warning repaint() or update() or nothing ?
-                       bv->repaint();
-                       bv->fitCursor();
-               }
+       if (bv && (result & LaTeX::ERRORS)) {
+               //show errors
+               ErrorList el(*buffer, terr);
+               bv->setErrorList(el);
+               bv->showErrorList(_("LaTeX"));
        }
 
        // check return value from latex.run().
@@ -549,9 +519,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
                string str = bformat(_("LaTeX did not run successfully. Additionally, LyX "
                        "could not locate the LaTeX log %1$s."), name);
                Alert::error(_("LaTeX failed"), str);
-       } else if ((result & LaTeX::ERRORS)) {
-               alertErrors("LaTeX", latex.getNumErrors());
-       }  else if (result & LaTeX::NO_OUTPUT) {
+       } else if (result & LaTeX::NO_OUTPUT) {
                Alert::warning(_("Output is empty"),
                        _("An empty output file was generated."));
        }