-
- Language const * language = pit->getParLanguage(bparams);
- Language const * doc_language = bparams.language;
- Language const * previous_language =
- (pit != paragraphs.begin())
- ? boost::prior(pit)->getParLanguage(bparams)
- : doc_language;
-
- if (language->babel() != previous_language->babel()
- // check if we already put language command in TeXEnvironment()
- && !(style->isEnvironment()
- && (pit == paragraphs.begin() ||
- (boost::prior(pit)->layout() != pit->layout() &&
- boost::prior(pit)->getDepth() <= pit->getDepth())
- || boost::prior(pit)->getDepth() < pit->getDepth())))
- {
- if (!lyxrc.language_command_end.empty() &&
- previous_language->babel() != doc_language->babel())
- {
- os << subst(lyxrc.language_command_end, "$$lang",
- previous_language->babel())
- << endl;
- texrow.newline();
- }
-
- if (lyxrc.language_command_end.empty() ||
- language->babel() != doc_language->babel())
- {
- os << subst(lyxrc.language_command_begin, "$$lang",
- language->babel())
- << endl;
- texrow.newline();
- }
- }
-
- if (bparams.inputenc == "auto" &&
- language->encoding() != previous_language->encoding()) {
- os << "\\inputencoding{"
- << language->encoding()->LatexName()
- << "}\n";
- texrow.newline();
- }
-
- switch (style->latextype) {
- case LATEX_COMMAND:
- os << '\\' << style->latexname();
-
- // Separate handling of optional argument inset.
- if (style->optionalargs == 1) {
- InsetOptArg * it = optArgInset(*pit);
- if (it)
- it->latexOptional(buf, os, false, false);
- }
- else
- os << style->latexparam();
- break;
- case LATEX_ITEM_ENVIRONMENT:
- case LATEX_LIST_ENVIRONMENT:
- os << "\\item ";
- break;
- case LATEX_BIB_ENVIRONMENT:
- // ignore this, the inset will write itself
- break;
- default:
- break;
- }
-
- bool need_par = pit->simpleTeXOnePar(buf, bparams, os, texrow, moving_arg);
-
- // Make sure that \\par is done with the font of the last
- // character if this has another size as the default.
- // This is necessary because LaTeX (and LyX on the screen)
- // calculates the space between the baselines according
- // to this font. (Matthias)
- //
- // Is this really needed ? (Dekel)
- // We do not need to use to change the font for the last paragraph
- // or for a command.
- LyXFont const font =
- (pit->empty()
- ? pit->getLayoutFont(bparams) : pit->getFont(bparams, pit->size() - 1));
-
- bool is_command = style->isCommand();
-
- if (style->resfont.size() != font.size()
- && boost::next(pit) != paragraphs.end()
- && !is_command) {
- if (!need_par)
- os << '{';
- os << "\\" << font.latexSize() << " \\par}";
- } else if (need_par) {
- os << "\\par}";
- } else if (is_command)
- os << '}';
-
- switch (style->latextype) {
- case LATEX_ITEM_ENVIRONMENT:
- case LATEX_LIST_ENVIRONMENT:
- if (boost::next(pit) != paragraphs.end()
- && (pit->params().depth() < boost::next(pit)->params().depth())) {
- os << '\n';
- texrow.newline();
- }
- break;
- case LATEX_ENVIRONMENT:
- // if its the last paragraph of the current environment
- // skip it otherwise fall through
- if (boost::next(pit) != paragraphs.end()
- && (boost::next(pit)->layout() != pit->layout()
- || boost::next(pit)->params().depth() != pit->params().depth()))
- break;
- // fall through possible
- default:
- // we don't need it for the last paragraph!!!
- if (boost::next(pit) != paragraphs.end()) {
- os << '\n';
- texrow.newline();
- }
- }
-
- if ((in == 0) || !in->forceDefaultParagraphs(in)) {
- further_blank_line = false;
- if (pit->params().lineBottom()) {
- os << "\\lyxline{\\" << font.latexSize() << '}';
- further_blank_line = true;
- }
-
- if (pit->params().spaceBottom().kind() != VSpace::NONE) {
- os << pit->params().spaceBottom().asLatexCommand(bparams);
- further_blank_line = true;
- }
-
- if (pit->params().pagebreakBottom()) {
- os << "\\newpage";
- further_blank_line = true;
- }
-
- if (further_blank_line) {
- os << '\n';
- texrow.newline();
- }
-
- if (!pit->params().spacing().isDefault()
- && (boost::next(pit) == paragraphs.end()|| !boost::next(pit)->hasSameLayout(&*pit))) {
- os << pit->params().spacing().writeEnvirEnd() << '\n';
- texrow.newline();
- }
- }
-
- // we don't need it for the last paragraph!!!
- if (boost::next(pit) != paragraphs.end()) {
- os << '\n';
- texrow.newline();
- } else {
- // Since \selectlanguage write the language to the aux file,
- // we need to reset the language at the end of footnote or
- // float.
-
- if (language->babel() != doc_language->babel()) {
- if (lyxrc.language_command_end.empty())
- os << subst(lyxrc.language_command_begin,
- "$$lang",
- doc_language->babel())
- << endl;
- else
- os << subst(lyxrc.language_command_end,
- "$$lang",
- language->babel())
- << endl;
- texrow.newline();
- }
- }
-
- lyxerr[Debug::LATEX] << "TeXOnePar...done " << &*boost::next(pit) << endl;
- return ++pit;