#include "insets/InsetBibitem.h"
#include "insets/InsetOptArg.h"
-#include "support/assert.h"
+#include "support/lassert.h"
#include "support/debug.h"
#include "support/lstrings.h"
};
static int open_encoding_ = none;
-static bool cjk_inherited_ = false;
+static int cjk_inherited_ = 0;
ParagraphList::const_iterator
if (par_language->encoding()->package() == Encoding::CJK &&
open_encoding_ != CJK && pit->isMultiLingual(bparams)) {
os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName())
- << "}{}%\n";
+ << "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
open_encoding_ = CJK;
cjk_nested = true;
texrow.newline();
runparams.moving_arg |= style.needprotect;
bool const maintext = text.isMainText(buf);
- // we are at the beginning of an inset and CJK is already open.
- if (pit == paragraphs.begin() && !maintext && open_encoding_ == CJK) {
- cjk_inherited_ = true;
+ // we are at the beginning of an inset and CJK is already open;
+ // we count inheritation levels to get the inset nesting right.
+ if (pit == paragraphs.begin() && !maintext
+ && (cjk_inherited_ > 0 || open_encoding_ == CJK)) {
+ cjk_inherited_ += 1;
open_encoding_ = none;
}
// the following is necessary after a CJK environment in a multilingual
// context (nesting issue).
if (par_language->encoding()->package() == Encoding::CJK &&
- open_encoding_ != CJK && !cjk_inherited_) {
+ open_encoding_ != CJK && cjk_inherited_ == 0) {
os << "\\begin{CJK}{" << from_ascii(par_language->encoding()->latexName())
- << "}{}%\n";
+ << "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
open_encoding_ = CJK;
texrow.newline();
}
// if the document's language is a CJK language
if (maintext && bparams.encoding().package() == Encoding::CJK) {
os << "\\begin{CJK}{" << from_ascii(bparams.encoding().latexName())
- << "}{}%\n";
+ << "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
texrow.newline();
open_encoding_ = CJK;
}
// if only_body
while (par != endpar) {
lastpar = par;
- 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);
}
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) {
}
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() &&
<< '\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) {
texrow.newline();
open_encoding_ = none;
}
+
// reset inherited encoding
- if (cjk_inherited_) {
- open_encoding_ = CJK;
- cjk_inherited_ = false;
+ if (cjk_inherited_ > 0) {
+ cjk_inherited_ -= 1;
+ if (cjk_inherited_ == 0)
+ open_encoding_ = CJK;
}
}
os << "\\egroup";
count += 7;
}
- os << "\\begin{CJK}{" << inputenc_arg << "}{}";
+ os << "\\begin{CJK}{" << inputenc_arg << "}{"
+ << from_ascii(bparams.fontsCJK) << "}";
open_encoding_ = CJK;
return make_pair(true, count + 15);
}