]> git.lyx.org Git - lyx.git/blobdiff - src/BufferParams.cpp
fix compilation on F13 and binutils/gold by rewriting specialized X11 code
[lyx.git] / src / BufferParams.cpp
index a23bfd2d6d4c5653c3ff3dd1979bc24a0c842e5a..bfcae0e618777f40181b4f6a965ba9abd4ac897c 100644 (file)
@@ -404,8 +404,8 @@ BufferParams::BufferParams()
        html_be_strict = false;
        html_math_output = MathML;
        html_math_img_scale = 1.0;
-       html_latex_start = "<span class='latex'>";
-       html_latex_end = "</span>";
+
+       output_sync = false;
 }
 
 
@@ -831,9 +831,15 @@ string BufferParams::readToken(Lexer & lex, string const & token,
        } else if (token == "\\html_math_img_scale") {
                lex >> html_math_img_scale;
        } else if (token == "\\html_latex_start") {
-               lex >> html_latex_start;
+               lex.eatLine();
+               html_latex_start = lex.getString();
        } else if (token == "\\html_latex_end") {
-               lex >> html_latex_end;
+               lex.eatLine();
+               html_latex_end = lex.getString();
+       } else if (token == "\\output_sync") {
+               lex >> output_sync;
+       } else if (token == "\\output_sync_macro") {
+               lex >> output_sync_macro;
        } else {
                lyxerr << "BufferParams::readToken(): Unknown token: " << 
                        token << endl;
@@ -936,6 +942,9 @@ void BufferParams::writeFile(ostream & os) const
        }
        os << "\n\\graphics " << graphicsDriver << '\n';
        os << "\\default_output_format " << defaultOutputFormat << '\n';
+       os << "\\output_sync " << output_sync << '\n';
+       if (!output_sync_macro.empty())
+               os << "\\output_sync_macro \"" << output_sync_macro << "\"\n";
        os << "\\bibtex_command " << bibtex_command << '\n';
        os << "\\index_command " << index_command << '\n';
 
@@ -1054,10 +1063,14 @@ void BufferParams::writeFile(ostream & os) const
        os << "\\tracking_changes " << convert<string>(trackChanges) << '\n'
                 << "\\output_changes " << convert<string>(outputChanges) << '\n'
                 << "\\html_math_output " << html_math_output << '\n'
-                << "\\html_be_strict " << convert<string>(html_be_strict) << '\n'
-                << "\\html_math_img_scale " << convert<string>(html_math_img_scale) << '\n'
-                << "\\html_latex_start \"" << html_latex_start << "\"\n"
-                << "\\html_latex_end \"" << html_latex_end << "\"\n";
+                << "\\html_be_strict " << convert<string>(html_be_strict) << '\n';
+       
+       if (html_math_img_scale != 1.0)
+               os << "\\html_math_img_scale " << convert<string>(html_math_img_scale) << '\n';
+       if (!html_latex_start.empty())
+               os << "\\html_latex_start " << html_latex_start << '\n';
+       if (!html_latex_end.empty())
+                os << "\\html_latex_end " << html_latex_end << '\n';
 
        os << pimpl_->authorlist;
 }
@@ -1177,7 +1190,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
 
        // all paper sizes except of A4, A5, B5 and the US sizes need the
        // geometry package
-       bool nonstandard_papersize = papersize != PAPER_USLETTER
+       bool nonstandard_papersize = papersize != PAPER_DEFAULT
+               && papersize != PAPER_USLETTER
                && papersize != PAPER_USLEGAL
                && papersize != PAPER_USEXECUTIVE
                && papersize != PAPER_A4
@@ -1335,8 +1349,11 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        // XeTeX works without fontenc
        if (font_encoding() != "default" && language->lang() != "japanese"
            && !useXetex) {
+               size_t fars = language_options.str().find("farsi");
+               size_t arab = language_options.str().find("arabic");
                if (language->lang() == "arabic_arabi"
-                   || language->lang() == "farsi") {
+                       || language->lang() == "farsi" || fars != string::npos
+                       || arab != string::npos) {
                        os << "\\usepackage[" << from_ascii(font_encoding())
                           << ",LFE,LAE]{fontenc}\n";
                        texrow.newline();
@@ -1397,7 +1414,7 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                texrow.newline();
        }
        if (!tclass.provides("geometry")
-               && (use_geometry || nonstandard_papersize)) {
+           && (use_geometry || nonstandard_papersize)) {
                odocstringstream ods;
                if (!getGraphicsDriver("geometry").empty())
                        ods << getGraphicsDriver("geometry");
@@ -1558,7 +1575,8 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                        os << "}\n";
                        texrow.newline();
                }
-       } else if (orientation == ORIENTATION_LANDSCAPE) {
+       } else if (orientation == ORIENTATION_LANDSCAPE
+                  || papersize != PAPER_DEFAULT) {
                features.require("papersize");
        }
 
@@ -1644,6 +1662,15 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
        // Now insert the LyX specific LaTeX commands...
        docstring lyxpreamble;
 
+       if (output_sync) {
+               if (!output_sync_macro.empty())
+                       lyxpreamble += from_utf8(output_sync_macro) +"\n";
+               else if (features.runparams().flavor == OutputParams::LATEX)
+                       lyxpreamble += "\\usepackage[active]{srcltx}\n";
+               else if (features.runparams().flavor == OutputParams::PDFLATEX)
+                       lyxpreamble += "\\synctex=-1\n";
+       }
+
        // due to interferences with babel and hyperref, the color package has to
        // be loaded (when it is not already loaded) before babel when hyperref
        // is used with the colorlinks option, see