]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
Rename some LFUN names to match their text name
[lyx.git] / src / mathed / InsetMathHull.cpp
index 1f135f54c2e6eafc7fe50160a35faec138901b83..956b6b9bca220271066bf090aff0e89a32191827 100644 (file)
@@ -284,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
@@ -299,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));
        }
 }
 
@@ -412,7 +412,9 @@ ColorCode InsetMathHull::standardColor() const
 
 bool InsetMathHull::previewState(BufferView * bv) const
 {
-       if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) {
+       if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON
+               && type_ != hullRegexp)
+       {
                graphics::PreviewImage const * pimage =
                        preview_->getPreviewImage(bv->buffer());
                return pimage && pimage->image();
@@ -663,7 +665,7 @@ bool InsetMathHull::notifyCursorLeaves(Cursor const & old, Cursor & cur)
 
 docstring InsetMathHull::label(row_type row) const
 {
-       LASSERT(row < nrows(), /**/);
+       LASSERT(row < nrows(), return docstring());
        if (InsetLabel * il = label_[row])
                return il->screenLabel();
        return docstring();
@@ -1020,7 +1022,7 @@ void InsetMathHull::glueall(HullType type)
 
 void InsetMathHull::splitTo2Cols()
 {
-       LASSERT(ncols() == 1, /**/);
+       LASSERT(ncols() == 1, return);
        InsetMathGrid::addCol(1);
        for (row_type row = 0; row < nrows(); ++row) {
                idx_type const i = 2 * row;
@@ -1033,13 +1035,13 @@ void InsetMathHull::splitTo2Cols()
 
 void InsetMathHull::splitTo3Cols()
 {
-       LASSERT(ncols() < 3, /**/);
+       LASSERT(ncols() < 3, return);
        if (ncols() < 2)
                splitTo2Cols();
        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());
                }
@@ -1263,9 +1265,9 @@ void InsetMathHull::infoize(odocstream & os) const
 
 void InsetMathHull::check() const
 {
-       LASSERT(numbered_.size() == nrows(), /**/);
-       LASSERT(numbers_.size() == nrows(), /**/);
-       LASSERT(label_.size() == nrows(), /**/);
+       LATTEST(numbered_.size() == nrows());
+       LATTEST(numbers_.size() == nrows());
+       LATTEST(label_.size() == nrows());
 }
 
 
@@ -1309,7 +1311,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 {
@@ -1432,7 +1434,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_LABEL_COPY_AS_REF: {
+       case LFUN_LABEL_COPY_AS_REFERENCE: {
                row_type row;
                if (cmd.argument().empty() && &cur.inset() == this)
                        // if there is no argument and we're inside math, we retrieve
@@ -1628,7 +1630,7 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
                status.setEnabled(type_ != hullSimple);
                return true;
 
-       case LFUN_LABEL_COPY_AS_REF: {
+       case LFUN_LABEL_COPY_AS_REFERENCE: {
                bool enabled = false;
                row_type row;
                if (cmd.argument().empty() && &cur.inset() == this) {
@@ -1895,7 +1897,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()) {
@@ -1923,7 +1926,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";
                }
@@ -2120,7 +2123,7 @@ void InsetMathHull::mathAsLatex(WriteStream & os) const
 docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
 {
        BufferParams::MathOutput const mathtype = 
-               buffer().params().html_math_output;
+               buffer().masterBuffer()->params().html_math_output;
 
        bool success = false;
 
@@ -2204,7 +2207,7 @@ docstring InsetMathHull::xhtml(XHTMLStream & xs, OutputParams const & op) const
                        string const tag = (getType() == hullSimple) ? "span" : "div";
                        xs << html::CR()
                           << html::StartTag(tag)
-                                << html::CompTag("img", "src=\"" + filename + "\"")
+                                << html::CompTag("img", "src=\"" + filename + "\" alt=\"Mathematical Equation\"")
                                 << html::EndTag(tag)
                                 << html::CR();
                        success = true;
@@ -2239,7 +2242,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();
 }