- if (par == paragraphs.end()) {
- // Make sure that the last paragraph is
- // correctly terminated (because TeXOnePar does
- // not add a \n in this case)
- os << '\n';
- texrow.newline();
- } else if (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();
+ // This is for debugging purpose at the end.
+ pit_type const par_begin = pit;
+ for (; pit < runparams.par_end; ++pit) {
+ ParagraphList::const_iterator par = paragraphs.constIterator(pit);
+
+ // check first if this is an higher depth paragraph.
+ bool go_out = (par->params().depth() < current_depth);
+ if (par->params().depth() == current_depth) {
+ // This environment is finished.
+ go_out |= (par->layout() != current_layout);
+ go_out |= (par->params().leftIndent() != current_left_indent);
+ }
+ if (go_out) {
+ // nothing to do here, restore pit and go out.
+ pit--;
+ break;
+ }
+
+ if (par->layout() == current_layout
+ && par->params().depth() == current_depth
+ && par->params().leftIndent() == current_left_indent) {
+ // We are still in the same environment so TeXOnePar and continue;
+ TeXOnePar(buf, text, pit, os, runparams);
+ continue;
+ }
+
+ // We are now in a deeper environment.
+ // Either par->layout() != current_layout
+ // Or par->params().depth() > current_depth
+ // Or par->params().leftIndent() != current_left_indent)
+
+ // FIXME This test should not be necessary.
+ // We should perhaps issue an error if it is.
+ bool const force_plain_layout = text.inset().forcePlainLayout();
+ Layout const & style = force_plain_layout
+ ? buf.params().documentClass().plainLayout()
+ : par->layout();
+
+ if (!style.isEnvironment()) {
+ // This is a standard paragraph, no need to call TeXEnvironment.
+ TeXOnePar(buf, text, pit, os, runparams);
+ continue;
+ }
+
+ // This is a new environment.
+ TeXEnvironmentData const data =
+ prepareEnvironment(buf, text, par, os, runparams);
+ // Recursive call to TeXEnvironment!
+ TeXEnvironment(buf, text, runparams, pit, os);
+ finishEnvironment(os, runparams, data);
+ }
+
+ if (pit != runparams.par_end)
+ LYXERR(Debug::LATEX, "TeXEnvironment for paragraph " << par_begin << " done.");
+}
+
+
+void getArgInsets(otexstream & os, OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs,
+ map<int, lyx::InsetArgument const *> ilist, vector<string> required, string const & prefix)
+{
+ unsigned int const argnr = latexargs.size();
+ if (argnr == 0)
+ return;
+
+ // Default and preset args are always output, so if they require
+ // other arguments, consider this.
+ Layout::LaTeXArgMap::const_iterator lit = latexargs.begin();
+ Layout::LaTeXArgMap::const_iterator const lend = latexargs.end();
+ for (; lit != lend; ++lit) {
+ Layout::latexarg arg = (*lit).second;
+ if ((!arg.presetarg.empty() || !arg.defaultarg.empty()) && !arg.requires.empty()) {
+ vector<string> req = getVectorFromString(arg.requires);
+ required.insert(required.end(), req.begin(), req.end());