+ lyxerr[Debug::LATEX] << "TeXDeeper...done " << par << endl;
+
+ return par;
+}
+#endif
+
+
+#ifdef USE_OSTREAM_ONLY
+LyXParagraph * LyXParagraph::TeXEnvironment(ostream & os, TexRow & texrow,
+ ostream & foot,
+ TexRow & foot_texrow,
+ int & foot_count)
+{
+ bool eindent_open = false;
+ bool foot_this_level = false;
+ // flags when footnotetext should be appended to file.
+ static bool minipage_open = false;
+ static int minipage_open_depth = 0;
+ char par_sep = current_view->buffer()->params.paragraph_separation;
+
+ lyxerr[Debug::LATEX] << "TeXEnvironment... " << this << endl;
+ if (IsDummy())
+ lyxerr << "ERROR (LyXParagraph::TeXEnvironment)" << endl;
+
+ LyXLayout const & style =
+ textclasslist.Style(current_view->buffer()->params.textclass,
+ layout);
+
+ if (pextra_type == PEXTRA_INDENT) {
+ if (!pextra_width.empty()) {
+ os << "\\begin{LyXParagraphIndent}{"
+ << pextra_width << "}\n";
+ } else {
+ //float ib = atof(pextra_widthp.c_str())/100;
+ // string can't handle floats at present (971109)
+ // so I'll do a conversion by hand knowing that
+ // the limits are 0.0 to 1.0. ARRae.
+ os << "\\begin{LyXParagraphIndent}{";
+ switch (pextra_widthp.length()) {
+ case 3:
+ os << "1.00";
+ break;
+ case 2:
+ os << "0."
+ << pextra_widthp;
+ break;
+ case 1:
+ os << "0.0"
+ << pextra_widthp;
+ }
+ os << "\\columnwidth}\n";
+ }
+ texrow.newline();
+ eindent_open = true;
+ }
+ if ((pextra_type == PEXTRA_MINIPAGE) && !minipage_open) {
+ if (pextra_hfill && Previous() &&
+ (Previous()->pextra_type == PEXTRA_MINIPAGE)) {
+ os << "\\hfill{}\n";
+ texrow.newline();
+ }
+ if (par_sep == BufferParams::PARSEP_INDENT) {
+ os << "{\\setlength\\parindent{0pt}\n";
+ texrow.newline();
+ }
+ os << "\\begin{minipage}";
+ switch(pextra_alignment) {
+ case MINIPAGE_ALIGN_TOP:
+ os << "[t]";
+ break;
+ case MINIPAGE_ALIGN_MIDDLE:
+ os << "[m]";
+ break;
+ case MINIPAGE_ALIGN_BOTTOM:
+ os << "[b]";
+ break;
+ }
+ if (!pextra_width.empty()) {
+ os << '{' << pextra_width << "}\n";
+ } else {
+ //float ib = atof(par->pextra_width.c_str())/100;
+ // string can't handle floats at present
+ // so I'll do a conversion by hand knowing that
+ // the limits are 0.0 to 1.0. ARRae.
+ os << '{';
+ switch (pextra_widthp.length()) {
+ case 3:
+ os << "1.00";
+ break;
+ case 2:
+ os << "0."
+ << pextra_widthp;
+ break;
+ case 1:
+ os << "0.0"
+ << pextra_widthp;
+ }
+ os << "\\columnwidth}\n";
+ }
+ texrow.newline();
+ if (par_sep == BufferParams::PARSEP_INDENT) {
+ os << "\\setlength\\parindent{\\LyXMinipageIndent}\n";
+ texrow.newline();
+ }
+ minipage_open = true;
+ minipage_open_depth = depth;
+ }
+
+#ifdef WITH_WARNINGS
+#warning Define FANCY_FOOTNOTE_CODE to re-enable Allan footnote code
+ //I disabled it because it breaks when lists span on several
+ //pages (JMarc)
+#endif
+ if (style.isEnvironment()){
+ if (style.latextype == LATEX_LIST_ENVIRONMENT) {
+#ifdef FANCY_FOOTNOTE_CODE
+ if (foot_count < 0) {
+ // flag that footnote[mark][text] should be
+ // used for any footnotes from now on
+ foot_count = 0;
+ foot_this_level = true;
+ }
+#endif
+ os << "\\begin{" << style.latexname() << "}{"
+ << labelwidthstring << "}\n";
+ } else if (style.labeltype == LABEL_BIBLIO) {
+ // ale970405
+ os << "\\begin{" << style.latexname() << "}{"
+ << bibitemWidthest(current_view->painter())
+ << "}\n";
+ } else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
+#ifdef FANCY_FOOTNOTE_CODE
+ if (foot_count < 0) {
+ // flag that footnote[mark][text] should be
+ // used for any footnotes from now on
+ foot_count = 0;
+ foot_this_level = true;
+ }
+#endif
+ os << "\\begin{" << style.latexname() << '}'
+ << style.latexparam() << '\n';
+ } else
+ os << "\\begin{" << style.latexname() << '}'
+ << style.latexparam() << '\n';
+ texrow.newline();
+ }
+ LyXParagraph * par = this;
+ do {
+ par = par->TeXOnePar(os, texrow,
+ foot, foot_texrow, foot_count);
+
+ if (minipage_open && par && !style.isEnvironment() &&
+ (par->pextra_type == PEXTRA_MINIPAGE) &&
+ par->pextra_start_minipage) {
+ os << "\\end{minipage}\n";
+ texrow.newline();
+ if (par_sep == BufferParams::PARSEP_INDENT) {
+ os << "}\n";
+ texrow.newline();
+ }
+ minipage_open = false;
+ }
+ if (par && par->depth > depth) {
+ if (textclasslist.Style(current_view->buffer()->params.textclass,
+ par->layout).isParagraph()
+ && !par->table
+ // 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 = par->TeXDeeper(os, texrow,
+ foot, foot_texrow, foot_count);
+ }
+ if (par && par->layout == layout && par->depth == depth &&
+ (par->pextra_type == PEXTRA_MINIPAGE) && !minipage_open) {
+ if (par->pextra_hfill && par->Previous() &&
+ (par->Previous()->pextra_type == PEXTRA_MINIPAGE)){
+ os << "\\hfill{}\n";
+ texrow.newline();
+ }
+ if (par_sep == BufferParams::PARSEP_INDENT) {
+ os << "{\\setlength\\parindent{0pt}\n";
+ texrow.newline();
+ }
+ os << "\\begin{minipage}";
+ switch(par->pextra_alignment) {
+ case MINIPAGE_ALIGN_TOP:
+ os << "[t]";
+ break;
+ case MINIPAGE_ALIGN_MIDDLE:
+ os << "[m]";
+ break;
+ case MINIPAGE_ALIGN_BOTTOM:
+ os << "[b]";
+ break;
+ }
+ if (!par->pextra_width.empty()) {
+ os << '{' << par->pextra_width << "}\n";
+ } else {
+ //float ib = atof(par->pextra_widthp.c_str())/100;
+ // string can't handle floats at present
+ // so I'll do a conversion by hand knowing that
+ // the limits are 0.0 to 1.0. ARRae.
+ os << '{';
+ switch (par->pextra_widthp.length()) {
+ case 3:
+ os << "1.00";
+ break;
+ case 2:
+ os << "0." << par->pextra_widthp;
+ break;
+ case 1:
+ os << "0.0" << par->pextra_widthp;
+ }
+ os << "\\columnwidth}\n";
+ }
+ texrow.newline();
+ if (par_sep == BufferParams::PARSEP_INDENT) {
+ os << "\\setlength\\parindent{\\LyXMinipageIndent}\n";
+ texrow.newline();
+ }
+ minipage_open = true;
+ minipage_open_depth = par->depth;
+ }
+ } while (par
+ && par->layout == layout
+ && par->depth == depth
+ && par->pextra_type == pextra_type);
+
+ if (style.isEnvironment()) {
+ os << "\\end{" << style.latexname() << '}';
+ // maybe this should go after the minipage closes?
+ if (foot_this_level) {
+ if (foot_count >= 1) {
+ if (foot_count > 1) {
+ os << "\\addtocounter{footnote}{-"
+ << foot_count - 1
+ << '}';
+ }
+ os << foot;
+ texrow += foot_texrow;
+ foot.clear();
+ foot_texrow.reset();
+ foot_count = 0;
+ }
+ }
+ }
+ if (minipage_open && (minipage_open_depth == depth) &&
+ (!par || par->pextra_start_minipage ||
+ par->pextra_type != PEXTRA_MINIPAGE)) {
+ os << "\\end{minipage}\n";
+ texrow.newline();
+ if (par_sep == BufferParams::PARSEP_INDENT) {
+ os << "}\n";
+ texrow.newline();
+ }
+ if (par && par->pextra_type != PEXTRA_MINIPAGE) {
+ os << "\\medskip\n\n";
+ texrow.newline();
+ texrow.newline();
+ }
+ minipage_open = false;
+ }
+ if (eindent_open) {
+ os << "\\end{LyXParagraphIndent}\n";
+ texrow.newline();
+ }
+ if (!(par && (par->pextra_type == PEXTRA_MINIPAGE)
+ && par->pextra_hfill)) {
+ os << '\n';
+ texrow.newline();
+ }
+ lyxerr[Debug::LATEX] << "TeXEnvironment...done " << par << endl;
+ return par; // ale970302