]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_symbolinset.C
infrastructure for requiring "amssymb".
[lyx.git] / src / mathed / math_symbolinset.C
index 4d731c6bfab2347dc7e0ae5f19befb6976cc414d..f2f0f5c6a2273a88990a9af1558fd148f7c4a4ff 100644 (file)
@@ -1,7 +1,10 @@
+#include <config.h>
+
 #include "math_symbolinset.h"
-#include "math_parser.h"
 #include "math_mathmlstream.h"
+#include "math_streamstr.h"
 #include "math_support.h"
+#include "math_parser.h"
 #include "debug.h"
 
 
@@ -15,6 +18,11 @@ MathSymbolInset::MathSymbolInset(const char * name)
 {}
 
 
+MathSymbolInset::MathSymbolInset(string const & name)
+       : sym_(in_word_set(name.c_str())), h_(0)
+{}
+
+
 
 MathInset * MathSymbolInset::clone() const
 {
@@ -96,7 +104,7 @@ void MathSymbolInset::draw(Painter & pain, int x, int y) const
 
 bool MathSymbolInset::isRelOp() const
 {      
-       return sym_->type == LMB_RELATION;
+       return sym_->type == "mathrel";
 }
 
 
@@ -114,7 +122,7 @@ bool MathSymbolInset::takesLimits() const
 
 void MathSymbolInset::normalize(NormalStream & os) const
 {
-       os << "[symbol " << name().c_str() << "]";
+       os << "[symbol " << name() << "]";
 }
 
 
@@ -123,13 +131,34 @@ void MathSymbolInset::maplize(MapleStream & os) const
        if (name() == "cdot")
                os << '*';
        else
-               os << name().c_str();
+               os << name();
+}
+
+
+char const * MathMLtype(string const & s)
+{
+       if (s == "mathop")
+               return "mo";
+       return "mi";
+}
+
+
+bool MathSymbolInset::match(MathInset * p) const
+{
+       MathSymbolInset const * q = p->asSymbolInset();
+       return q && name() == q->name();
 }
 
 
 void MathSymbolInset::mathmlize(MathMLStream & os) const
 {
-       os << name().c_str();
+       char const * type = MathMLtype(sym_->type);
+       os << '<' << type << "> ";
+       if (sym_->xmlname == "x") // unknown so far
+               os << name();
+       else
+               os << sym_->xmlname;
+       os << " </" << type << '>';
 }
 
 
@@ -138,13 +167,24 @@ void MathSymbolInset::octavize(OctaveStream & os) const
        if (name() == "cdot")
                os << '*';
        else
-               os << name().c_str();
+               os << name();
 }
 
 
 void MathSymbolInset::write(WriteStream & os) const
 {
-       os << '\\' << name().c_str() << ' ';
+       os << '\\' << name() << ' ';
+}
+
+
+void MathSymbolInset::infoize(std::ostream & os) const
+{
+       os << '\\' << name();
 }
 
 
+void MathSymbolInset::validate(LaTeXFeatures & features) const
+{
+       // if (...)
+       //      features.require("amssymb");
+}