]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
Load hyperref with a suitable driver
[lyx.git] / src / BufferParams.cpp
index 24aaf02c510a175e2d35731b1adb0b6ae25d5e0b..60c7bb0c129952e7596367e3ce2f026a3be3acab 100644 (file)
@@ -323,7 +323,7 @@ bool inSystemDir(FileName const & document_dir, string & system_dir)
        return false;
 }
 
-} // anon namespace
+} // namespace
 
 
 class BufferParams::Impl
@@ -394,7 +394,7 @@ BufferParams::BufferParams()
        papersize = PAPER_DEFAULT;
        orientation = ORIENTATION_PORTRAIT;
        use_geometry = false;
-       biblio_style = "plain";
+       biblio_style = string();
        use_bibtopic = false;
        multibib = string();
        use_indices = false;
@@ -459,6 +459,7 @@ BufferParams::BufferParams()
        html_css_as_file = false;
        display_pixel_ratio = 1.0;
 
+       shell_escape = false;
        output_sync = false;
        use_refstyle = true;
        use_minted = false;
@@ -866,7 +867,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                lex >> is_math_indent;
        } else if (token == "\\math_indentation") {
                lex.next();
-               pimpl_->mathindent = Length(lex.getString());
+               string mathindent = lex.getString();
+               if (mathindent == "default")
+                       pimpl_->mathindent = Length();
+               else
+                       pimpl_->mathindent = Length(mathindent);
        } else if (token == "\\math_numbering_side") {
                string tmp;
                lex >> tmp;
@@ -1115,7 +1120,7 @@ namespace {
                        return "\"" + str + "\"";
                return str;
        }
-}
+} // namespace
 
 
 void BufferParams::writeFile(ostream & os, Buffer const * buf) const
@@ -1377,8 +1382,9 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
        else
                os << "\n\\defskip " << getDefSkip().asLyXCommand();
        os << "\n\\is_math_indent " << is_math_indent;
-       if (is_math_indent && !getMathIndent().empty())
-               os << "\n\\math_indentation " << getMathIndent().asString();
+       if (is_math_indent)
+               os << "\n\\math_indentation "
+                  << (getMathIndent().empty() ? "default" : getMathIndent().asString());
        os << "\n\\math_numbering_side ";
        switch(math_numbering_side) {
        case LEFT:
@@ -1548,7 +1554,7 @@ void BufferParams::validate(LaTeXFeatures & features) const
 
        if (useNonTeXFonts && fontsMath() != "auto")
                features.require("unicode-math");
-       
+
        if (use_microtype)
                features.require("microtype");
 
@@ -2044,13 +2050,12 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg144349.html
        os << from_ascii(features.getColorOptions());
 
-       // If we use hyperref, jurabib, japanese, varioref or vietnamese,
+       // If we use hyperref, jurabib, japanese or varioref,
        // we have to call babel before
        if (use_babel
            && (features.isRequired("jurabib")
                || features.isRequired("hyperref")
                || features.isRequired("varioref")
-               || features.isRequired("vietnamese")
                || features.isRequired("japanese"))) {
                        os << features.getBabelPresettings();
                        // FIXME UNICODE
@@ -2089,8 +2094,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
                OutputParams tmp_params = features.runparams();
                pdfoptions().writeLaTeX(tmp_params, os,
                                        features.isProvided("hyperref"));
-               // correctly break URLs with hyperref and dvi output
-               if (features.runparams().flavor == OutputParams::LATEX
+               // correctly break URLs with hyperref and dvi/ps output
+               if (features.runparams().hyperref_driver == "dvips"
                    && features.isAvailable("breakurl"))
                        os << "\\usepackage{breakurl}\n";
        } else if (features.isRequired("nameref"))
@@ -2246,8 +2251,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // called after babel, though.
        if (use_babel && !features.isRequired("jurabib")
            && !features.isRequired("hyperref")
-               && !features.isRequired("varioref")
-           && !features.isRequired("vietnamese")
+           && !features.isRequired("varioref")
            && !features.isRequired("japanese")) {
                os << features.getBabelPresettings();
                // FIXME UNICODE
@@ -2282,7 +2286,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // (the rest is obsoleted by the new TU encoding).
        // It needs to be loaded at least after amsmath, amssymb,
        // esint and the other packages that provide special glyphs
-       if (features.mustProvide("tipa") && useNonTeXFonts) {
+       if (features.mustProvide("tipa") && useNonTeXFonts
+           && !features.isProvided("xunicode")) {
                // The package officially only supports XeTeX, but also works
                // with LuaTeX. Thus we work around its XeTeX test.
                if (features.runparams().flavor != OutputParams::XETEX) {
@@ -2317,7 +2322,11 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        }
 
        // ... but before biblatex (see #7065)
-       if (features.mustProvide("biblatex")) {
+       if (features.mustProvide("biblatex")
+           && !features.isProvided("biblatex-natbib")
+           && !features.isProvided("natbib-internal")
+           && !features.isProvided("natbib")
+           && !features.isProvided("jurabib")) {
                string delim = "";
                string opts;
                os << "\\usepackage";
@@ -2573,7 +2582,7 @@ FormatList const & BufferParams::exportableFormats(bool only_viewable) const
 {
        FormatList & cached = only_viewable ?
                        pimpl_->viewableFormatList : pimpl_->exportableFormatList;
-       bool & valid = only_viewable ? 
+       bool & valid = only_viewable ?
                        pimpl_->isViewCacheValid : pimpl_->isExportCacheValid;
        if (valid)
                return cached;
@@ -2588,7 +2597,7 @@ FormatList const & BufferParams::exportableFormats(bool only_viewable) const
                theConverters().getReachable(backs[0], only_viewable, true, excludes);
        for (vector<string>::const_iterator it = backs.begin() + 1;
             it != backs.end(); ++it) {
-               FormatList r = theConverters().getReachable(*it, only_viewable, 
+               FormatList r = theConverters().getReachable(*it, only_viewable,
                                false, excludes);
                result.insert(result.end(), r.begin(), r.end());
        }
@@ -2617,8 +2626,16 @@ vector<string> BufferParams::backends() const
                        v.push_back("luatex");
                        v.push_back("dviluatex");
                }
-       } else
-               v.push_back(buffmt);
+       } else {
+               string rbuffmt = buffmt;
+               // If we use an OutputFormat in Japanese docs,
+               // we need special format in order to get the path
+               // via pLaTeX (#8823)
+               if (documentClass().hasOutputFormat()
+                   && encoding().package() == Encoding::japanese)
+                       rbuffmt += "-ja";
+               v.push_back(rbuffmt);
+       }
 
        v.push_back("xhtml");
        v.push_back("text");
@@ -2683,14 +2700,15 @@ string BufferParams::getDefaultOutputFormat() const
        if (!default_output_format.empty()
            && default_output_format != "default")
                return default_output_format;
-       if (isDocBook()
-           || encoding().package() == Encoding::japanese) {
+       if (isDocBook()) {
                FormatList const & formats = exportableFormats(true);
                if (formats.empty())
                        return string();
                // return the first we find
                return formats.front()->name();
        }
+       if (encoding().package() == Encoding::japanese)
+               return lyxrc.default_platex_view_format;
        if (useNonTeXFonts)
                return lyxrc.default_otf_view_format;
        return lyxrc.default_view_format;
@@ -3363,7 +3381,7 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
 Encoding const & BufferParams::encoding() const
 {
        // Main encoding for LaTeX output.
-       // 
+       //
        // Exception: XeTeX with 8-bit TeX fonts requires ASCII (see #9740).
        // As the "flavor" is only known once export started, this
        // cannot be handled here. Instead, runparams.encoding is set
@@ -3408,6 +3426,9 @@ bool BufferParams::addCiteEngine(vector<string> const & engine)
 
 string const & BufferParams::defaultBiblioStyle() const
 {
+       if (!biblio_style.empty())
+               return biblio_style;
+
        map<string, string> const & bs = documentClass().defaultBiblioStyle();
        auto cit = bs.find(theCiteEnginesList.getTypeAsString(citeEngineType()));
        if (cit != bs.end())