]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMath.cpp
Move <algorithm> from DocIterator.h
[lyx.git] / src / mathed / InsetMath.cpp
index aec53d0518a961da755350b0d127a270b79e9ba2..1adeec10a834f80df8728227cb92c4bacb79feae 100644 (file)
 
 #include "InsetMath.h"
 #include "MathData.h"
+#include "MathRow.h"
 #include "MathStream.h"
 
+#include "MetricsInfo.h"
+
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
-#include "support/lassert.h"
 
 using namespace std;
 
@@ -49,9 +52,32 @@ MathData const & InsetMath::cell(idx_type) const
 }
 
 
-MathClass InsetMath::mathClass() const
+InsetMath::marker_type InsetMath::marker(BufferView const *) const
+{
+       return nargs() > 0 ? MARKER : NO_MARKER;
+}
+
+
+bool InsetMath::addToMathRow(MathRow & mrow, MetricsInfo & mi) const
 {
-       return MC_ORD;
+       MathRow::Element e(mi, MathRow::INSET, mathClass());
+       e.inset = this;
+       e.marker = mi.base.macro_nesting ? NO_MARKER : marker(mi.base.bv);
+       mrow.push_back(e);
+       return true;
+}
+
+
+/// write LaTeX and LyX code
+void InsetMath::writeLimits(WriteStream & os) const
+{
+       if (limits() == LIMITS) {
+               os << "\\limits";
+               os.pendingSpace(true);
+       } else if (limits() == NO_LIMITS) {
+               os << "\\nolimits";
+               os.pendingSpace(true);
+       }
 }
 
 
@@ -91,7 +117,7 @@ void InsetMath::write(WriteStream & os) const
 }
 
 
-int InsetMath::plaintext(odocstringstream &, 
+int InsetMath::plaintext(odocstringstream &,
         OutputParams const &, size_t) const
 {
        // all math plain text output shall take place in InsetMathHull
@@ -134,13 +160,13 @@ void InsetMath::mathematica(MathematicaStream & os) const
 }
 
 
-void InsetMath::mathmlize(MathStream & os) const
+void InsetMath::mathmlize(MathStream & ms) const
 {
-       os << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
-       os << MTag("mi");
-       NormalStream ns(os.os());
+       ms << "<!-- " << from_utf8(insetName(lyxCode())) << " -->";
+       ms << MTag("mi");
+       NormalStream ns(ms.os());
        normalize(ns);
-       os << ETag("mi");
+       ms << ETag("mi");
 }