-namespace {
-
-ParagraphList::iterator
-TeXEnvironment(Buffer const * buf,
- ParagraphList const & paragraphs,
- ParagraphList::iterator pit,
- ostream & os, TexRow & texrow,
- LatexRunParams const & runparams);
-
-ParagraphList::iterator
-TeXOnePar(Buffer const * buf,
- ParagraphList const & paragraphs,
- ParagraphList::iterator pit,
- ostream & os, TexRow & texrow,
- LatexRunParams const & runparams,
- string const & everypar = string());
-
-
-ParagraphList::iterator
-TeXDeeper(Buffer const * buf,
- ParagraphList const & paragraphs,
- ParagraphList::iterator pit,
- ostream & os, TexRow & texrow,
- LatexRunParams const & runparams)
-{
- lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl;
- ParagraphList::iterator par = pit;
-
- while (par != const_cast<ParagraphList&>(paragraphs).end() &&
- par->params().depth() == pit->params().depth()) {
- if (par->layout()->isEnvironment()) {
- par = TeXEnvironment(buf, paragraphs, par,
- os, texrow, runparams);
- } else {
- par = TeXOnePar(buf, paragraphs, par,
- os, texrow, runparams);
- }
- }
- lyxerr[Debug::LATEX] << "TeXDeeper...done " << &*par << endl;
-
- return par;
-}
-
-
-ParagraphList::iterator
-TeXEnvironment(Buffer const * buf,
- ParagraphList const & paragraphs,
- ParagraphList::iterator pit,
- ostream & os, TexRow & texrow,
- LatexRunParams const & runparams)
-{
- lyxerr[Debug::LATEX] << "TeXEnvironment... " << &*pit << endl;
-
- BufferParams const & bparams = buf->params;
-
- LyXLayout_ptr const & style = pit->layout();
-
- Language const * language = pit->getParLanguage(bparams);
- Language const * doc_language = bparams.language;
- Language const * previous_language =
- (pit != const_cast<ParagraphList&>(paragraphs).begin())
- ? boost::prior(pit)->getParLanguage(bparams)
- : doc_language;
- if (language->babel() != previous_language->babel()) {
-
- 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();
- }
- }
-
- bool leftindent_open = false;
- if (!pit->params().leftIndent().zero()) {
- os << "\\begin{LyXParagraphLeftIndent}{" <<
- pit->params().leftIndent().asLatexString() << "}\n";
- texrow.newline();
- leftindent_open = true;
- }
-
- if (style->isEnvironment()) {
- if (style->latextype == LATEX_LIST_ENVIRONMENT) {
- os << "\\begin{" << style->latexname() << "}{"
- << pit->params().labelWidthString() << "}\n";
- } else if (style->labeltype == LABEL_BIBLIO) {
- // ale970405
- os << "\\begin{" << style->latexname() << "}{"
- << bibitemWidest(buf)
- << "}\n";
- } else if (style->latextype == LATEX_ITEM_ENVIRONMENT) {
- os << "\\begin{" << style->latexname() << '}'
- << style->latexparam() << '\n';
- } else
- os << "\\begin{" << style->latexname() << '}'
- << style->latexparam() << '\n';
- texrow.newline();
- }
- ParagraphList::iterator par = pit;
- do {
- par = TeXOnePar(buf, paragraphs, par, os, texrow, runparams);
-
- if (par != const_cast<ParagraphList&>(paragraphs).end() && par->params().depth() > pit->params().depth()) {
- if (par->layout()->isParagraph()) {
-
- // Thinko!
- // How to handle this? (Lgb)
- //&& !suffixIs(os, "\n\n")
- //) {
- // There should be at least one '\n' already
- // but we need there to be two for Standard
- // paragraphs that are depth-increment'ed to be
- // output correctly. However, tables can
- // also be paragraphs so don't adjust them.
- // ARRae
- // Thinkee:
- // Will it ever harm to have one '\n' too
- // many? i.e. that we sometimes will have
- // three in a row. (Lgb)
- os << '\n';
- texrow.newline();
- }
- par = TeXDeeper(buf, paragraphs, par, os, texrow,
- runparams);
- }
- } while (par != const_cast<ParagraphList&>(paragraphs).end()
- && par->layout() == pit->layout()
- && par->params().depth() == pit->params().depth()
- && par->params().leftIndent() == pit->params().leftIndent());
-
- if (style->isEnvironment()) {
- os << "\\end{" << style->latexname() << "}\n";
- texrow.newline();
- }
-
- if (leftindent_open) {
- os << "\\end{LyXParagraphLeftIndent}\n";
- texrow.newline();
- }
-
- lyxerr[Debug::LATEX] << "TeXEnvironment...done " << &*par << endl;
- return par; // ale970302
-}
-
-
-InsetOptArg * optArgInset(Paragraph const & par)
-{
- // Find the entry.
- InsetList::const_iterator it = par.insetlist.begin();
- InsetList::const_iterator end = par.insetlist.end();
- for (; it != end; ++it) {
- InsetOld * ins = it->inset;
- if (ins->lyxCode() == InsetOld::OPTARG_CODE) {
- return static_cast<InsetOptArg *>(ins);
- }
- }
- return 0;
-}
-
-
-ParagraphList::iterator
-TeXOnePar(Buffer const * buf,
- ParagraphList const & paragraphs,
- ParagraphList::iterator pit,
- ostream & os, TexRow & texrow,
- LatexRunParams const & runparams,
- string const & everypar)