]> git.lyx.org Git - features.git/commitdiff
Backport r39970--39971 to branch.
authorRichard Heck <rgheck@comcast.net>
Tue, 25 Oct 2011 18:56:58 +0000 (18:56 +0000)
committerRichard Heck <rgheck@comcast.net>
Tue, 25 Oct 2011 18:56:58 +0000 (18:56 +0000)
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

src/mathed/InsetMathHull.cpp
status.20x

index 50fb014dc4acbb85da72f72d483a2d7dc17098d8..d78f29d0d8b32e7d3d311bb46ed9992e1df57e1b 100644 (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";
-                       }
+       }
+
+       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();
 }
 
index 07fd81b76e0f41adc9c5c40b9bdb4db2db300d8d..0c3bb49cbe43e3b736b5b3679b57dbd45e4bc0db 100644 (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