]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.C
This commit fixes a crash when accessing a math inset. This was due to an invalid...
[lyx.git] / src / mathed / InsetMathHull.C
index 1a3a85fe51e9f570c7cf3c3b4bec41e6ff729e36..095bf92dd6acffe60008e3876d96e55a2842f25f 100644 (file)
@@ -347,9 +347,8 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
                for (row_type row = 0; row < nrows(); ++row) {
                        int const yy = y + rowinfo_[row].offset_;
                        FontSetChanger dummy(pi.base, "mathrm");
-                       string const nl = nicelabel(row);
-                       docstring const dnl(nl.begin(), nl.end());
-                       pi.draw(xx, yy, dnl);
+                       docstring const nl = nicelabel(row);
+                       pi.draw(xx, yy, nl);
                }
        }
        setPosCache(pi, x, y);
@@ -463,11 +462,12 @@ bool InsetMathHull::display() const
 }
 
 
-void InsetMathHull::getLabelList(Buffer const &, vector<string> & labels) const
+void InsetMathHull::getLabelList(Buffer const &, vector<docstring> & labels) const
 {
        for (row_type row = 0; row < nrows(); ++row)
                if (!label_[row].empty() && nonum_[row] != 1)
-                       labels.push_back(label_[row]);
+                       // FIXME UNICODE
+                       labels.push_back(lyx::from_utf8(label_[row]));
 }
 
 
@@ -662,13 +662,14 @@ void InsetMathHull::delCol(col_type col)
 }
 
 
-string InsetMathHull::nicelabel(row_type row) const
+docstring InsetMathHull::nicelabel(row_type row) const
 {
        if (nonum_[row])
-               return string();
+               return docstring();
        if (label_[row].empty())
-               return string("(#)");
-       return '(' + label_[row] + ')';
+               return lyx::from_ascii("(#)");
+       // FIXME UNICODE
+       return lyx::from_utf8('(' + label_[row] + ')');
 }
 
 
@@ -979,7 +980,8 @@ void InsetMathHull::doExtern(LCursor & cur, FuncRequest & func)
                size_type pos = cur.cell().find_last(eq);
                MathArray ar;
                if (cur.inMathed() && cur.selection()) {
-                       asArray(grabAndEraseSelection(cur), ar);
+                       // FIXME UNICODE
+                       asArray(lyx::from_utf8(grabAndEraseSelection(cur)), ar);
                } else if (pos == cur.cell().size()) {
                        ar = cur.cell();
                        lyxerr << "use whole cell: " << ar << endl;
@@ -1121,7 +1123,8 @@ void InsetMathHull::doDispatch(LCursor & cur, FuncRequest & cmd)
                                numbered(r, true);
                        string old = label(r);
                        if (str != old) {
-                               cur.bv().buffer()->changeRefsIfUnique(old, str);
+                               cur.bv().buffer()->changeRefsIfUnique(old, str,
+                                                       InsetBase::REF_CODE);
                                label(r, str);
                        }
                        break;
@@ -1274,7 +1277,7 @@ void InsetMathHull::mutateToText()
                view_->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
 
        // remove ourselves
-       //theApp->lyxFunc().dispatch(LFUN_ESCAPE);
+       //lyx::dispatch(LFUN_ESCAPE);
 #endif
 }
 
@@ -1424,7 +1427,7 @@ void InsetMathHull::read(Buffer const &, LyXLex & lex)
 }
 
 
-int InsetMathHull::plaintext(Buffer const &, ostream & os,
+int InsetMathHull::plaintext(Buffer const &, lyx::odocstream & os,
                        OutputParams const &) const
 {
        if (0 && display()) {
@@ -1438,8 +1441,11 @@ int InsetMathHull::plaintext(Buffer const &, ostream & os,
                //metrics();
                return tpain.textheight();
        } else {
-               WriteStream wi(os, false, true);
+               std::ostringstream oss;
+               WriteStream wi(oss, false, true);
                wi << cell(0);
+               // FIXME UNICODE
+               os << lyx::from_utf8(oss.str());
                return wi.line();
        }
 }
@@ -1497,7 +1503,7 @@ int InsetMathHull::docbook(Buffer const & buf, ostream & os,
 }
 
 
-int InsetMathHull::textString(Buffer const & buf, ostream & os,
+int InsetMathHull::textString(Buffer const & buf, lyx::odocstream & os,
                       OutputParams const & op) const
 {
        return plaintext(buf, os, op);