From: Richard Heck Date: Tue, 25 Oct 2011 18:56:58 +0000 (+0000) Subject: Backport r39970--39971 to branch. X-Git-Tag: 2.0.2~130 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=be2b9eb9ebc2aa3f6c1803c799d62a829e6fd901;p=features.git Backport r39970--39971 to branch. Fix display of section headings, etc, that include math in the TOC and menus. The newline we were writing previously caused all kinds of problems. Writing a whole array in some cases would also cause problems. So we do less. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@39972 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 50fb014dc4..d78f29d0d8 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -1880,7 +1880,7 @@ bool InsetMathHull::readQuiet(Lexer & lex) } -int InsetMathHull::plaintext(odocstream & os, OutputParams const &) const +int InsetMathHull::plaintext(odocstream & os, OutputParams const & op) const { // disables ASCII-art for export of equations. See #2275. if (0 && display()) { @@ -1893,24 +1893,29 @@ int InsetMathHull::plaintext(odocstream & os, OutputParams const &) const // reset metrics cache to "real" values //metrics(); return tpain.textheight(); - } else { - odocstringstream oss; - Encoding const * const enc = encodings.fromLyXName("utf8"); - WriteStream wi(oss, false, true, WriteStream::wsDefault, enc); - // Fix Bug #6139 - if (type_ == hullRegexp) - write(wi); - else { - for (row_type r = 0; r < nrows(); ++r) { - for (col_type c = 0; c < ncols(); ++c) - wi << (c == 0 ? "" : "\t") << cell(index(r, c)); - wi << "\n"; - } + } + + odocstringstream oss; + Encoding const * const enc = encodings.fromLyXName("utf8"); + WriteStream wi(oss, false, true, WriteStream::wsDefault, enc); + + // Fix Bug #6139 + if (type_ == hullRegexp) + write(wi); + else { + for (row_type r = 0; r < nrows(); ++r) { + for (col_type c = 0; c < ncols(); ++c) + wi << (c == 0 ? "" : "\t") << cell(index(r, c)); + // if it's for the TOC, we write just the first line + // and do not include the newline. + if (op.for_toc) + break; + wi << "\n"; } - docstring const str = oss.str(); - os << str; - return str.size(); } + docstring const str = oss.str(); + os << str; + return str.size(); } @@ -2226,7 +2231,9 @@ void InsetMathHull::toString(odocstream & os) const void InsetMathHull::forToc(docstring & os, size_t) const { odocstringstream ods; - plaintext(ods, OutputParams(0)); + OutputParams op(0); + op.for_toc = true; + plaintext(ods, op); os += ods.str(); } diff --git a/status.20x b/status.20x index 07fd81b76e..0c3bb49cbe 100644 --- a/status.20x +++ b/status.20x @@ -165,6 +165,9 @@ What's new - Fix import of required arguments of standard environments (part of bug 7468) +- Fix display of section (etc) headings, in both TOC and menu, when there is + math in the title. + * ADVANCED FIND AND REPLACE