X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Foutput_latex.cpp;h=2f919f4fec998973bbf7375dd1d94d1aae2d6b5c;hb=1797f5218b8819874f9dbe97b44445b3b5d598a0;hp=5706a4456d5e0b8bc9b6d88b3c1584906cc6104b;hpb=958b6b7069dd05d3404a2dcfc0556f4cedd8b2ce;p=lyx.git diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 5706a4456d..2f919f4fec 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -30,6 +30,7 @@ #include "insets/InsetBibitem.h" #include "insets/InsetOptArg.h" +#include "support/lassert.h" #include "support/debug.h" #include "support/lstrings.h" @@ -38,11 +39,11 @@ using namespace std; using namespace lyx::support; + namespace lyx { namespace { - enum OpenEncoding { none, inputenc, @@ -308,11 +309,6 @@ TeXOnePar(Buffer const & buf, return nextpit; } - // FIXME This comment doesn't make sense. What's the - // length got to do with forceEmptyLayout()? I.e., what - // was forceDefaultParagraphs()? - // In an inset with unlimited length (all in one row), - // force layout to default Layout const style = pit->forceEmptyLayout() ? bparams.documentClass().emptyLayout() : pit->layout(); @@ -745,7 +741,7 @@ void latexParagraphs(Buffer const & buf, ParagraphList::const_iterator par = paragraphs.begin(); ParagraphList::const_iterator endpar = paragraphs.end(); - BOOST_ASSERT(runparams.par_begin <= runparams.par_end); + LASSERT(runparams.par_begin <= runparams.par_end, /**/); // if only part of the paragraphs will be outputed if (runparams.par_begin != runparams.par_end) { par = boost::next(paragraphs.begin(), runparams.par_begin); @@ -782,55 +778,45 @@ void latexParagraphs(Buffer const & buf, // if only_body while (par != endpar) { lastpar = par; - // well we have to check if we are in an inset with unlimited - // length (all in one row) if that is true then we don't allow - // any special options in the paragraph and also we don't allow - // any environment other than the default layout of the - // text class to be valid! - if (par->allowParagraphCustomization()) { - Layout const & layout = par->forceEmptyLayout() ? - tclass.emptyLayout() : - par->layout(); - - if (layout.intitle) { - if (already_title) { - lyxerr << "Error in latexParagraphs: You" - " should not mix title layouts" - " with normal ones." << endl; - } else if (!was_title) { - was_title = true; - if (tclass.titletype() == TITLE_ENVIRONMENT) { - os << "\\begin{" - << from_ascii(tclass.titlename()) - << "}\n"; - texrow.newline(); - } - } - } else if (was_title && !already_title) { + Layout const & layout = par->forceEmptyLayout() ? + tclass.emptyLayout() : + par->layout(); + + if (layout.intitle) { + if (already_title) { + lyxerr << "Error in latexParagraphs: You" + " should not mix title layouts" + " with normal ones." << endl; + } else if (!was_title) { + was_title = true; if (tclass.titletype() == TITLE_ENVIRONMENT) { - os << "\\end{" << from_ascii(tclass.titlename()) - << "}\n"; - } - else { - os << "\\" << from_ascii(tclass.titlename()) - << "\n"; + os << "\\begin{" + << from_ascii(tclass.titlename()) + << "}\n"; + texrow.newline(); } - texrow.newline(); - already_title = true; - was_title = false; } - - if (layout.is_environment) { - par = TeXOnePar(buf, text, par, os, texrow, - runparams, everypar); - } else if (layout.isEnvironment() || - !par->params().leftIndent().zero()) { - par = TeXEnvironment(buf, text, par, os, - texrow, runparams); - } else { - par = TeXOnePar(buf, text, par, os, texrow, - runparams, everypar); + } else if (was_title && !already_title) { + if (tclass.titletype() == TITLE_ENVIRONMENT) { + os << "\\end{" << from_ascii(tclass.titlename()) + << "}\n"; + } + else { + os << "\\" << from_ascii(tclass.titlename()) + << "\n"; } + texrow.newline(); + already_title = true; + was_title = false; + } + + if (layout.is_environment) { + par = TeXOnePar(buf, text, par, os, texrow, + runparams, everypar); + } else if (layout.isEnvironment() || + !par->params().leftIndent().zero()) { + par = TeXEnvironment(buf, text, par, os, + texrow, runparams); } else { par = TeXOnePar(buf, text, par, os, texrow, runparams, everypar); @@ -838,6 +824,7 @@ void latexParagraphs(Buffer const & buf, if (distance(lastpar, par) >= distance(lastpar, endpar)) break; } + // It might be that we only have a title in this document if (was_title && !already_title) { if (tclass.titletype() == TITLE_ENVIRONMENT) { @@ -850,6 +837,7 @@ void latexParagraphs(Buffer const & buf, } texrow.newline(); } + // if "auto end" is switched off, explicitely close the language at the end // but only if the last par is in a babel language if (maintext && !lyxrc.language_auto_end && !bparams.language->babel().empty() && @@ -860,6 +848,7 @@ void latexParagraphs(Buffer const & buf, << '\n'; texrow.newline(); } + // If the last paragraph is an environment, we'll have to close // CJK at the very end to do proper nesting. if (maintext && open_encoding_ == CJK) { @@ -867,6 +856,7 @@ void latexParagraphs(Buffer const & buf, texrow.newline(); open_encoding_ = none; } + // reset inherited encoding if (cjk_inherited_) { open_encoding_ = CJK;