]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.C
Fix command-line export
[lyx.git] / src / mathed / InsetMathHull.C
index cdcaa57a23c89db9cb4ea96820d51197501e1420..ac27c50a4802190f922fbafca1df87f16d29d000 100644 (file)
@@ -463,11 +463,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]));
 }
 
 
@@ -508,37 +509,46 @@ void InsetMathHull::header_write(WriteStream & os) const
 {
        bool n = numberedType();
 
-       if (type_ == hullNone)
-               ;
+       switch(type_) {
+       case hullNone:
+               break;
 
-       else if (type_ == hullSimple) {
+       case hullSimple:
                os << '$';
                if (cell(0).empty())
                        os << ' ';
-       }
+               break;
 
-       else if (type_ == hullEquation) {
+       case hullEquation:
                if (n)
                        os << "\\begin{equation" << star(n) << "}\n";
                else
                        os << "\\[\n";
-       }
+               break;
 
-       else if (type_ == hullEqnArray || type_ == hullAlign || type_ ==
-hullFlAlign
-                || type_ == hullGather || type_ == hullMultline)
-                       os << "\\begin{" << type_ << star(n) << "}\n";
+       case hullEqnArray:
+       case hullAlign:
+       case hullFlAlign:
+       case hullGather:
+       case hullMultline:
+               os << "\\begin{" << hullName(type_) << star(n) << "}\n";
+               break;
 
-       else if (type_ == hullAlignAt || type_ == hullXAlignAt)
-               os << "\\begin{" << type_ << star(n) << '}'
+       case hullAlignAt:
+       case hullXAlignAt:
+               os << "\\begin{" << hullName(type_) << star(n) << '}'
                  << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
+               break;
 
-       else if (type_ == hullXXAlignAt)
-               os << "\\begin{" << type_ << '}'
+       case hullXXAlignAt:
+               os << "\\begin{" << hullName(type_) << '}'
                  << '{' << static_cast<unsigned int>((ncols() + 1)/2) << "}\n";
+               break;
 
-       else
+       default:
                os << "\\begin{unknown" << star(n) << '}';
+               break;
+       }
 }
 
 
@@ -546,29 +556,40 @@ void InsetMathHull::footer_write(WriteStream & os) const
 {
        bool n = numberedType();
 
-       if (type_ == hullNone)
+       switch(type_) {
+       case hullNone:
                os << "\n";
+               break;
 
-       else if (type_ == hullSimple)
+       case hullSimple:
                os << '$';
+               break;
 
-       else if (type_ == hullEquation)
+       case hullEquation:
                if (n)
                        os << "\\end{equation" << star(n) << "}\n";
                else
                        os << "\\]\n";
+               break;
 
-       else if (type_ == hullEqnArray || type_ == hullAlign || type_ ==
-hullFlAlign
-                || type_ == hullAlignAt || type_ == hullXAlignAt
-                || type_ == hullGather || type_ == hullMultline)
-               os << "\\end{" << type_ << star(n) << "}\n";
+       case hullEqnArray:
+       case hullAlign:
+       case hullFlAlign:
+       case hullAlignAt:
+       case hullXAlignAt:
+       case hullGather:
+       case hullMultline:
+               os << "\\end{" << hullName(type_) << star(n) << "}\n";
+               break;
 
-       else if (type_ == hullXXAlignAt)
-               os << "\\end{" << type_ << "}\n";
+       case hullXXAlignAt:
+               os << "\\end{" << hullName(type_) << "}\n";
+               break;
 
-       else
+       default:
                os << "\\end{unknown" << star(n) << '}';
+               break;
+       }
 }
 
 
@@ -873,8 +894,9 @@ void InsetMathHull::mutate(HullType newtype)
        }
 
        else {
-               lyxerr << "mutation from '" << type_
-                      << "' to '" << newtype << "' not implemented" << endl;
+               lyxerr << "mutation from '" << hullName(type_)
+                      << "' to '" << hullName(newtype)
+                      << "' not implemented" << endl;
        }
 }
 
@@ -902,7 +924,7 @@ void InsetMathHull::write(WriteStream & os) const
 
 void InsetMathHull::normalize(NormalStream & os) const
 {
-       os << "[formula " << type_ << ' ';
+       os << "[formula " << hullName(type_) << ' ';
        InsetMathGrid::normalize(os);
        os << "] ";
 }
@@ -916,7 +938,7 @@ void InsetMathHull::mathmlize(MathMLStream & os) const
 
 void InsetMathHull::infoize(ostream & os) const
 {
-       os << "Type: " << type_;
+       os << "Type: " << hullName(type_);
 }
 
 
@@ -1100,7 +1122,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;
@@ -1253,7 +1276,7 @@ void InsetMathHull::mutateToText()
                view_->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
 
        // remove ourselves
-       //theApp->lyxFunc().dispatch(LFUN_ESCAPE);
+       //lyx::dispatch(LFUN_ESCAPE);
 #endif
 }
 
@@ -1403,7 +1426,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()) {
@@ -1417,8 +1440,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();
        }
 }
@@ -1476,7 +1502,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);