-#ifndef NEW_INSETS
-LyXParagraph * LyXParagraph::TeXFootnote(Buffer const * buf,
- BufferParams const & bparams,
- ostream & os, TexRow & texrow,
- ostream & foot, TexRow & foot_texrow,
- int & foot_count,
- bool parent_is_rtl)
-{
- lyxerr[Debug::LATEX] << "TeXFootnote... " << this << endl;
- if (footnoteflag == LyXParagraph::NO_FOOTNOTE)
- lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
- "No footnote!" << endl;
-
- LyXParagraph * par = this;
- LyXLayout const & style =
- textclasslist.Style(bparams.textclass,
- previous->GetLayout());
-
- if (style.needprotect && footnotekind != LyXParagraph::FOOTNOTE){
- lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
- "Float other than footnote in command"
- " with moving argument is illegal" << endl;
- }
-
- if (footnotekind != LyXParagraph::FOOTNOTE
- && footnotekind != LyXParagraph::MARGIN
- && os.tellp()
- // Thinko
- // How to solve this?
- //&& !suffixIs(file, '\n')
- ) {
- // we need to ensure that real floats like tables and figures
- // have their \begin{} on a new line otherwise we can get
- // incorrect results when using the endfloat.sty package
- // especially if two floats follow one another. ARRae 981022
- // NOTE: if the file is length 0 it must have just been
- // written out so we assume it ended with a '\n'
- // Thinkee:
- // As far as I can see there is never any harm in writing
- // a '\n' too much. Please tell me if I am wrong. (Lgb)
- os << '\n';
- texrow.newline();
- }
-
- bool moving_arg = false;
- bool need_closing = false;
- bool is_rtl = isRightToLeftPar(bparams);
-
- if (is_rtl != parent_is_rtl) {
- if (is_rtl)
- os << "\\R{";
- else
- os << "\\L{";
- need_closing = true;
- }
-
- //BufferParams * params = ¤t_view->buffer()->params;
- bool footer_in_body = true;
- switch (footnotekind) {
- case LyXParagraph::FOOTNOTE:
- if (style.intitle) {
- os << "\\thanks{\n";
- footer_in_body = false;
- moving_arg = true;
- } else {
- if (foot_count == -1) {
- // we're at depth 0 so we can use:
- os << "\\footnote{%\n";
- footer_in_body = false;
- } else {
- os << "\\footnotemark{}%\n";
- if (foot_count) {
- // we only need this when there are
- // multiple footnotes
- os << "\\stepcounter{footnote}";
- }
- os << "\\footnotetext{%\n";
- foot_texrow.start(this, 0);
- foot_texrow.newline();
- ++foot_count;
- }
- }
- break;
- case LyXParagraph::MARGIN:
- os << "\\marginpar{\n";
- break;
- case LyXParagraph::FIG:
- if (pextra_type == PEXTRA_FLOATFLT
- && (!pextra_width.empty()
- || !pextra_widthp.empty())) {
- if (!pextra_width.empty())
- os << "\\begin{floatingfigure}{"
- << pextra_width << "}\n";
- else
- os << "\\begin{floatingfigure}{"
- << atoi(pextra_widthp.c_str())/100.0
- << "\\textwidth}\n";
- } else {
- os << "\\begin{figure}";
- if (!bparams.float_placement.empty()) {
- os << '[' << bparams.float_placement << "]\n";
- } else {
- os << '\n';
- }
- }
- break;
- case LyXParagraph::TAB:
- os << "\\begin{table}";
- if (!bparams.float_placement.empty()) {
- os << '[' << bparams.float_placement << "]\n";
- } else {
- os << '\n';
- }
- break;
- case LyXParagraph::WIDE_FIG:
- os << "\\begin{figure*}";
- if (!bparams.float_placement.empty()) {
- os << '[' << bparams.float_placement << "]\n";
- } else {
- os << '\n';
- }
- break;
- case LyXParagraph::WIDE_TAB:
- os << "\\begin{table*}";
- if (!bparams.float_placement.empty()) {
- os << '[' << bparams.float_placement << "]\n";
- } else {
- os << '\n';
- }
- break;
- case LyXParagraph::ALGORITHM:
- os << "\\begin{algorithm}\n";
- break;
- }
- texrow.newline();
-
- if (footnotekind != LyXParagraph::FOOTNOTE
- || !footer_in_body) {
- // Process text for all floats except footnotes in body
- do {
- LyXLayout const & style =
- textclasslist
- .Style(bparams.textclass, par->layout);
- if (par->IsDummy())
- lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
- << endl;
- if (style.isEnvironment()
- || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
- // Allows the use of minipages within float
- // environments. Shouldn't be circular because
- // we don't support footnotes inside
- // floats (yet). ARRae
- par = par->TeXEnvironment(buf, bparams, os,
- texrow,
- foot, foot_texrow,
- foot_count);
- } else {
- par = par->TeXOnePar(buf, bparams,
- os, texrow, moving_arg,
- foot, foot_texrow,
- foot_count);
- }
-
- if (par && !par->IsDummy() && par->depth > depth) {
- par = par->TeXDeeper(buf, bparams, os, texrow,
- foot, foot_texrow,
- foot_count);
- }
- } while (par && par->footnoteflag != LyXParagraph::NO_FOOTNOTE);
- } else {
- // process footnotes > depth 0 or in environments separately
- // NOTE: Currently don't support footnotes within footnotes
- // even though that is possible using the \footnotemark
-#ifdef HAVE_SSTREAM
- std::ostringstream dummy;
-#else
- ostrstream dummy;
-#endif
- TexRow dummy_texrow;
- int dummy_count = 0;
- do {
- LyXLayout const & style =
- textclasslist
- .Style(bparams.textclass, par->layout);
- if (par->IsDummy())
- lyxerr << "ERROR (LyXParagraph::TeXFootnote)"
- << endl;
- if (style.isEnvironment()
- || par->pextra_type == PEXTRA_MINIPAGE) { /* && !minipage_open ?? */
- // Allows the use of minipages within float
- // environments. Shouldn't be circular because
- // we don't support footnotes inside
- // floats (yet). ARRae
- par = par->TeXEnvironment(buf, bparams,
- foot, foot_texrow,
- dummy, dummy_texrow,
- dummy_count);
- } else {
- par = par->TeXOnePar(buf, bparams,
- foot, foot_texrow,
- moving_arg,
- dummy, dummy_texrow,
- dummy_count);
- }
-
- if (par && !par->IsDummy() && par->depth > depth) {
- par = par->TeXDeeper(buf, bparams,
- foot, foot_texrow,
- dummy, dummy_texrow,
- dummy_count);
- }
- } while (par
- && par->footnoteflag != LyXParagraph::NO_FOOTNOTE);
- if (dummy_count) {
- lyxerr << "ERROR (LyXParagraph::TeXFootnote): "
- "Footnote in a Footnote -- not supported"
- << endl;
- }
-#ifndef HAVE_OSTREAM
- delete [] dummy.str();
-#endif
- }
-
- switch (footnotekind) {
- case LyXParagraph::FOOTNOTE:
- if (footer_in_body) {
- // This helps tell which of the multiple
- // footnotetexts an error was in.
- foot << "}%\n";
- foot_texrow.newline();
- } else {
- os << '}';
- }
- break;
- case LyXParagraph::MARGIN:
- os << '}';
- break;
- case LyXParagraph::FIG:
- if (pextra_type == PEXTRA_FLOATFLT
- && (!pextra_width.empty()
- || !pextra_widthp.empty()))
- os << "\\end{floatingfigure}";
- else
- os << "\\end{figure}";
- break;
- case LyXParagraph::TAB:
- os << "\\end{table}";
- break;
- case LyXParagraph::WIDE_FIG:
- os << "\\end{figure*}";
- break;
- case LyXParagraph::WIDE_TAB:
- os << "\\end{table*}";
- break;
- case LyXParagraph::ALGORITHM:
- os << "\\end{algorithm}";
- break;
- }
-
- if (need_closing)
- os << "}";
-
- if (footnotekind != LyXParagraph::FOOTNOTE
- && footnotekind != LyXParagraph::MARGIN) {
- // we need to ensure that real floats like tables and figures
- // have their \end{} on a line of their own otherwise we can
- // get incorrect results when using the endfloat.sty package.
- os << "\n";
- texrow.newline();
- }
-
- lyxerr[Debug::LATEX] << "TeXFootnote...done " << par->next << endl;
- return par;
-}
-
-
-bool LyXParagraph::IsDummy() const
-{
- return (footnoteflag == LyXParagraph::NO_FOOTNOTE && previous
- && previous->footnoteflag != LyXParagraph::NO_FOOTNOTE);
-}
-#endif
-
-void LyXParagraph::SetPExtraType(BufferParams const & bparams,
- int type, char const * width,
- char const * widthp)
-{
- pextra_type = type;
- pextra_width = width;
- pextra_widthp = widthp;
-
- if (textclasslist.Style(bparams.textclass,
- layout).isEnvironment()) {
- LyXParagraph
- * par = this,
- * ppar = par;
-
- while (par && (par->layout == layout)
- && (par->depth == depth)) {
- ppar = par;
- par = par->Previous();
-#ifndef NEW_INSETS
- if (par)
- par = par->FirstPhysicalPar();
-#endif
- while (par && par->depth > depth) {
- par = par->Previous();
-#ifndef NEW_INSETS
- if (par)
- par = par->FirstPhysicalPar();
-#endif
- }
- }
- par = ppar;
- while (par && (par->layout == layout)
- && (par->depth == depth)) {
- par->pextra_type = type;
- par->pextra_width = width;
- par->pextra_widthp = widthp;
-#ifndef NEW_INSETS
- par = par->NextAfterFootnote();
-#else
- par = par->Next();
-#endif
- if (par && (par->depth > depth))
- par->SetPExtraType(bparams,
- type, width, widthp);
-#ifndef NEW_INSETS
- while (par && ((par->depth > depth) || par->IsDummy()))
- par = par->NextAfterFootnote();
-#else
- while (par && ((par->depth > depth)))
- par = par->Next();
-#endif
- }
- }
-}
-
-
-void LyXParagraph::UnsetPExtraType(BufferParams const & bparams)