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
This commit is contained in:
Richard Heck 2011-10-25 18:56:58 +00:00
parent d98eb6e4f1
commit be2b9eb9eb
2 changed files with 29 additions and 19 deletions

View File

@ -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";
}
}
docstring const str = oss.str();
os << str;
return str.size();
}
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();
}
@ -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();
}

View File

@ -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