]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMath.C
BUG 686: delete empty math box with delete/backspace key
[lyx.git] / src / mathed / InsetMath.C
index 57fed3d60425a14a195ea698cc9e3b48f3203923..2a6d4462a43b9dc5432e719dd8af726445e56432 100644 (file)
 
 #include "InsetMath.h"
 #include "MathData.h"
-#include "MathMLStream.h"
+#include "MathStream.h"
 #include "debug.h"
 
 #include "support/lstrings.h"
 
 #include <boost/current_function.hpp>
 
-using std::string;
-using std::ostream;
+
+namespace lyx {
+
 using std::endl;
 
 
@@ -44,8 +45,10 @@ MathArray const & InsetMath::cell(idx_type) const
 void InsetMath::dump() const
 {
        lyxerr << "---------------------------------------------" << endl;
-       WriteStream wi(lyxerr, false, true);
+       odocstringstream os;
+       WriteStream wi(os, false, true);
        write(wi);
+       lyxerr << to_utf8(os.str());
        lyxerr << "\n---------------------------------------------" << endl;
 }
 
@@ -69,8 +72,8 @@ void InsetMath::drawT(TextPainter &, int, int) const
 
 void InsetMath::write(WriteStream & os) const
 {
-       string const s = name();
-       os << '\\' << s.c_str();
+       docstring const s = name();
+       os << "\\" << s;
        // We need an extra ' ' unless this is a single-char-non-ASCII name
        // or anything non-ASCII follows
        if (s.size() != 1 || isalpha(s[0]))
@@ -80,7 +83,7 @@ void InsetMath::write(WriteStream & os) const
 
 void InsetMath::normalize(NormalStream & os) const
 {
-       os << '[' << name().c_str() << "] ";
+       os << '[' << name() << "] ";
 }
 
 
@@ -112,10 +115,10 @@ void InsetMath::mathematica(MathematicaStream & os) const
 }
 
 
-void InsetMath::mathmlize(MathMLStream & os) const
+void InsetMath::mathmlize(MathStream & os) const
 {
-       NormalStream ns(os.os());
-       normalize(ns);
+        NormalStream ns(os.os());
+        normalize(ns);
 }
 
 
@@ -125,15 +128,27 @@ HullType InsetMath::getType() const
 }
 
 
-string InsetMath::name() const
+docstring InsetMath::name() const
 {
-       return "unknown";
+       return from_ascii("unknown");
 }
 
 
-ostream & operator<<(ostream & os, MathAtom const & at)
+std::ostream & operator<<(std::ostream & os, MathAtom const & at)
+{
+       odocstringstream oss;
+       WriteStream wi(oss, false, false);
+       at->write(wi);
+       return os << to_utf8(oss.str());
+}
+
+
+odocstream & operator<<(odocstream & os, MathAtom const & at)
 {
        WriteStream wi(os, false, false);
        at->write(wi);
        return os;
 }
+
+
+} // namespace lyx