]> git.lyx.org Git - features.git/blobdiff - src/mathed/InsetMathHull.cpp
Add a member to TocItem that tells us whether the item in question
[features.git] / src / mathed / InsetMathHull.cpp
index 2d2025cca3a03c8b8e9c79eb7b7ec40515d0d718..2a47f2035683a563576f458fdf72cc60b1a21892 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 *);
@@ -282,7 +284,7 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype)
 }
 
 
-void InsetMathHull::addToToc(DocIterator const & pit) const
+void InsetMathHull::addToToc(DocIterator const & pit, bool output_active) const
 {
        if (!buffer_) {
                //FIXME: buffer_ should be set at creation for this inset! Problem is
@@ -297,8 +299,8 @@ void InsetMathHull::addToToc(DocIterator const & pit) const
                if (!numbered_[row])
                        continue;
                if (label_[row])
-                       label_[row]->addToToc(pit);
-               toc.push_back(TocItem(pit, 0, nicelabel(row)));
+                       label_[row]->addToToc(pit, output_active);
+               toc.push_back(TocItem(pit, 0, nicelabel(row), output_active));
        }
 }
 
@@ -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);
 }
@@ -1038,7 +1039,7 @@ void InsetMathHull::splitTo3Cols()
        InsetMathGrid::addCol(2);
        for (row_type row = 0; row < nrows(); ++row) {
                idx_type const i = 3 * row + 1;
-               if (cell(i).size()) {
+               if (!cell(i).empty()) {
                        cell(i + 1) = MathData(buffer_, cell(i).begin() + 1, cell(i).end());
                        cell(i).erase(1, cell(i).size());
                }
@@ -1308,7 +1309,7 @@ void InsetMathHull::doExtern(Cursor & cur, FuncRequest & func)
                MathData ar;
                if (cur.inMathed() && cur.selection()) {
                        asArray(grabAndEraseSelection(cur), ar);
-               } else if (pos == cur.cell().size()) {
+               } else if (!pos == cur.cell().empty()) {
                        ar = cur.cell();
                        lyxerr << "use whole cell: " << ar << endl;
                } else {
@@ -1367,7 +1368,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
                cur.undispatched();
                break;
 
-       case LFUN_BREAK_PARAGRAPH:
+       case LFUN_PARAGRAPH_BREAK:
                // just swallow this
                break;
 
@@ -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();
@@ -1569,7 +1570,7 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
 
        // we never allow this in math, and we want to bind enter
        // to another actions in command-alternatives
-       case LFUN_BREAK_PARAGRAPH:
+       case LFUN_PARAGRAPH_BREAK:
                status.setEnabled(false);
                return true;
        case LFUN_MATH_MUTATE: {
@@ -1894,7 +1895,8 @@ bool InsetMathHull::readQuiet(Lexer & lex)
 }
 
 
-int InsetMathHull::plaintext(odocstream & os, OutputParams const & op) const
+int InsetMathHull::plaintext(odocstringstream & os,
+        OutputParams const & op, size_t max_length) const
 {
        // disables ASCII-art for export of equations. See #2275.
        if (0 && display()) {
@@ -1922,7 +1924,7 @@ int InsetMathHull::plaintext(odocstream & os, OutputParams const & op) const
                                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)
+                       if (op.for_toc || op.for_tooltip || oss.str().size() >= max_length)
                                break;
                        wi << "\n";
                }
@@ -2238,7 +2240,9 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
 
 void InsetMathHull::toString(odocstream & os) const
 {
-       plaintext(os, OutputParams(0));
+       odocstringstream ods;
+       plaintext(ods, OutputParams(0));
+       os << ods.str();
 }