]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
tex2lyx/text.cpp: fix typos
[lyx.git] / src / mathed / InsetMathHull.cpp
index e06a40ec5a9c9bc56c6f79d97d50f327d571273c..2055fb2c4ba0a9aa5f523e0cabf6cb1c2525863d 100644 (file)
@@ -225,6 +225,8 @@ void InsetMathHull::setBuffer(Buffer & buffer)
 }
 
 
+// FIXME This should really be controlled by the TOC level, or
+// something of the sort.
 namespace {
        const char * counters_to_save[] = {"section", "chapter"};
        unsigned int const numcnts = sizeof(counters_to_save)/sizeof(char *);
@@ -771,12 +773,11 @@ void InsetMathHull::validate(LaTeXFeatures & features) const
                // it would be better to do this elsewhere, but we can't validate in
                // InsetMathMatrix and we have no way, outside MathExtern, to know if
                // we even have any matrices.
-                               features.addPreambleSnippet("<style type=\"text/css\">\n"
+                               features.addCSSSnippet(
                                        "table.matrix{display: inline-block; vertical-align: middle; text-align:center;}\n"
                                        "table.matrix td{padding: 0.25px;}\n"
                                        "td.ldelim{width: 0.5ex; border: thin solid black; border-right: none;}\n"
-                                       "td.rdelim{width: 0.5ex; border: thin solid black; border-left: none;}\n"
-                                       "</style>");
+                                       "td.rdelim{width: 0.5ex; border: thin solid black; border-left: none;}");
        }
        InsetMathGrid::validate(features);
 }
@@ -1376,7 +1377,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
                if (type_ == hullSimple || type_ == hullEquation) {
                        cur.recordUndoInset();
                        bool const align =
-                               cur.bv().buffer().params().use_amsmath == BufferParams::package_on;
+                               cur.bv().buffer().params().use_package("amsmath") == BufferParams::package_on;
                        mutate(align ? hullAlign : hullEqnArray);
                        // mutate() may change labels and such.
                        cur.forceBufferUpdate();
@@ -1894,7 +1895,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()) {
@@ -1907,24 +1908,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();
 }
 
 
@@ -2240,14 +2246,16 @@ 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();
 }
 
 
-docstring InsetMathHull::contextMenuName() const
+string InsetMathHull::contextMenuName() const
 {
-       return from_ascii("context-math");
+       return "context-math";
 }