]> git.lyx.org Git - lyx.git/blobdiff - src/Converter.cpp
Fix biber execution om MikTeX.
[lyx.git] / src / Converter.cpp
index 2b83b3d479f46e9537bef98d8797f7b41b488f42..a589b60b1f2add5a0e8fa334828edab56ce457a0 100644 (file)
@@ -131,21 +131,6 @@ void Converter::readFlags()
 }
 
 
-bool operator<(Converter const & a, Converter const & b)
-{
-       // use the compare_ascii_no_case instead of compare_no_case,
-       // because in turkish, 'i' is not the lowercase version of 'I',
-       // and thus turkish locale breaks parsing of tags.
-       int const i = compare_ascii_no_case(a.From->prettyname(),
-                                           b.From->prettyname());
-       if (i == 0)
-               return compare_ascii_no_case(a.To->prettyname(),
-                                            b.To->prettyname()) < 0;
-       else
-               return i < 0;
-}
-
-
 Converter const * Converters::getConverter(string const & from,
                                            string const & to) const
 {
@@ -194,6 +179,10 @@ void Converters::add(string const & from, string const & to,
        if (converter.latex
            && (latex_command_.empty() || converter.latex_flavor == "latex"))
                latex_command_ = subst(command, token_from, "");
+       // Similarly, set xelatex_command to xelatex.
+       if (converter.latex
+           && (xelatex_command_.empty() || converter.latex_flavor == "xelatex"))
+               xelatex_command_ = subst(command, token_from, "");
 
        if (it == converterlist_.end()) {
                converterlist_.push_back(converter);
@@ -246,12 +235,6 @@ void Converters::updateLast(Formats const & formats)
 }
 
 
-void Converters::sort()
-{
-       std::sort(converterlist_.begin(), converterlist_.end());
-}
-
-
 OutputParams::FLAVOR Converters::getFlavor(Graph::EdgePath const & path)
 {
        for (Graph::EdgePath::const_iterator cit = path.begin();
@@ -262,6 +245,8 @@ OutputParams::FLAVOR Converters::getFlavor(Graph::EdgePath const & path)
                                return OutputParams::XETEX;
                        if (conv.latex_flavor == "lualatex")
                                return OutputParams::LUATEX;
+                       if (conv.latex_flavor == "dvilualatex")
+                               return OutputParams::DVILUATEX;
                        if (conv.latex_flavor == "pdflatex")
                                return OutputParams::PDFLATEX;
                if (conv.xml)
@@ -303,7 +288,8 @@ bool Converters::convert(Buffer const * buffer,
                        LYXERR(Debug::FILES, "No converter defined! "
                                   "I use convertDefault.py:\n\t" << command);
                        Systemcall one;
-                       one.startscript(Systemcall::Wait, command);
+                       one.startscript(Systemcall::Wait, command, buffer ?
+                                       buffer->filePath() : string());
                        if (to_file.isReadableFile()) {
                                if (conversionflags & try_cache)
                                        ConverterCache::get().add(orig_from,
@@ -333,7 +319,7 @@ bool Converters::convert(Buffer const * buffer,
        runparams.flavor = getFlavor(edgepath);
 
        if (buffer) {
-               runparams.use_japanese = buffer->bufferFormat() == "platex";
+               runparams.use_japanese = buffer->params().bufferFormat() == "platex";
                runparams.use_indices = buffer->params().use_indices;
                runparams.bibtex_command = (buffer->params().bibtex_command == "default") ?
                        string() : buffer->params().bibtex_command;
@@ -397,9 +383,12 @@ bool Converters::convert(Buffer const * buffer,
                } else {
                        if (conv.need_aux && !run_latex
                            && !latex_command_.empty()) {
-                               LYXERR(Debug::FILES, "Running " << latex_command_
+                               string const command = (buffer && buffer->params().useNonTeXFonts) ?
+                                       xelatex_command_ : latex_command_;
+                               LYXERR(Debug::FILES, "Running " << command
                                        << " to update aux file");
-                               runLaTeX(*buffer, latex_command_, runparams, errorList);
+                               if (!runLaTeX(*buffer, command, runparams, errorList))
+                                       return false;
                        }
 
                        // FIXME UNICODE
@@ -436,12 +425,15 @@ bool Converters::convert(Buffer const * buffer,
                        int res;
                        if (dummy) {
                                res = one.startscript(Systemcall::DontWait,
-                                       to_filesystem8bit(from_utf8(command)));
+                                       to_filesystem8bit(from_utf8(command)),
+                                       buffer ? buffer->filePath() : string());
                                // We're not waiting for the result, so we can't do anything
                                // else here.
                        } else {
                                res = one.startscript(Systemcall::Wait,
-                                               to_filesystem8bit(from_utf8(command)));
+                                               to_filesystem8bit(from_utf8(command)),
+                                               buffer ? buffer->filePath()
+                                                      : string());
                                if (!real_outfile.empty()) {
                                        Mover const & mover = getMover(conv.to);
                                        if (!mover.rename(outfile, real_outfile))
@@ -461,7 +453,8 @@ bool Converters::convert(Buffer const * buffer,
                                                " < " + quoteName(infile2 + ".out") +
                                                " > " + quoteName(logfile);
                                        one.startscript(Systemcall::Wait,
-                                               to_filesystem8bit(from_utf8(command2)));
+                                               to_filesystem8bit(from_utf8(command2)),
+                                               buffer->filePath());
                                        if (!scanLog(*buffer, command, makeAbsPath(logfile, path), errorList))
                                                return false;
                                }
@@ -605,7 +598,8 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command,
 
        // do the LaTeX run(s)
        string const name = buffer.latexName();
-       LaTeX latex(command, runparams, FileName(makeAbsPath(name)));
+       LaTeX latex(command, runparams, FileName(makeAbsPath(name)),
+                   buffer.filePath());
        TeXErrors terr;
        ShowMessage show(buffer);
        latex.message.connect(show);
@@ -684,43 +678,14 @@ Converters::getReachableTo(string const & target, bool const clear_visited)
 
 vector<Format const *> const
 Converters::getReachable(string const & from, bool const only_viewable,
-                        bool const clear_visited)
-{
-       vector<int> const & reachables =
-               G_.getReachable(formats.getNumber(from),
-                               only_viewable,
-                               clear_visited);
-
-       return intToFormat(reachables);
-}
-
-
-vector<Format const *> const
-Converters::getReachable(string const & from, bool const only_viewable,
-                        bool const clear_visited, string const & exclude)
+                        bool const clear_visited, set<string> const & excludes)
 {
-       vector<int> const & reachables =
-               G_.getReachable(formats.getNumber(from),
-                               only_viewable,
-                               clear_visited,
-                               formats.getNumber(exclude));
+       set<int> excluded_numbers;;
 
-       return intToFormat(reachables);
-}
-
-
-vector<Format const *> const
-Converters::getReachable(string const & from, bool const only_viewable,
-                        bool const clear_visited, vector<string> const & excludes)
-{
-       vector<int> excluded_numbers(excludes.size());
-
-       vector<string>::const_iterator sit = excludes.begin();
-       vector<string>::const_iterator const end = excludes.end();
-       vector<int>::iterator it = excluded_numbers.begin();
-       for ( ; sit != end; ++sit, ++it) {
-               *it = formats.getNumber(*sit);
-       }
+       set<string>::const_iterator sit = excludes.begin();
+       set<string>::const_iterator const end = excludes.end();
+       for (; sit != end; ++sit)
+               excluded_numbers.insert(formats.getNumber(*sit));
 
        vector<int> const & reachables =
                G_.getReachable(formats.getNumber(from),
@@ -792,6 +757,7 @@ vector<string> Converters::savers() const
        v.push_back("latex");
        v.push_back("literate");
        v.push_back("luatex");
+       v.push_back("dviluatex");
        v.push_back("lyx");
        v.push_back("xhtml");
        v.push_back("pdflatex");