X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathFrac.cpp;h=6a175fad31ac26e0568c24684ef557917ee5a5c9;hb=f67cf6f4bb3e3d22ac9aebfa22027c3537cbdf61;hp=752dd54bea51d3583dce802437256697012bec37;hpb=f27853ad41e62f15793902e163754c4b3db1400a;p=lyx.git
diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp
index 752dd54bea..6a175fad31 100644
--- a/src/mathed/InsetMathFrac.cpp
+++ b/src/mathed/InsetMathFrac.cpp
@@ -22,6 +22,7 @@
#include "MetricsInfo.h"
#include "TextPainter.h"
+#include "support/lassert.h"
#include "frontends/Painter.h"
using namespace std;
@@ -368,37 +369,137 @@ bool InsetMathFrac::extraBraces() const
void InsetMathFrac::maple(MapleStream & os) const
{
+ if (nargs() != 2) {
+ // Someone who knows about maple should fix this.
+ LASSERT(false, return);
+ }
os << '(' << cell(0) << ")/(" << cell(1) << ')';
}
void InsetMathFrac::mathematica(MathematicaStream & os) const
{
+ if (nargs() != 2) {
+ // Someone who knows about mathematica should fix this.
+ LASSERT(false, return);
+ }
os << '(' << cell(0) << ")/(" << cell(1) << ')';
}
void InsetMathFrac::octave(OctaveStream & os) const
{
+ if (nargs() != 2) {
+ // Someone who knows about octave should fix this.
+ LASSERT(false, return);
+ }
os << '(' << cell(0) << ")/(" << cell(1) << ')';
}
void InsetMathFrac::mathmlize(MathStream & os) const
{
- os << MTag("mfrac")
- << MTag("mrow") << cell(0) << ETag("mrow")
- << MTag("mrow") << cell(1) << ETag("mrow")
- << ETag("mfrac");
+ switch (kind_) {
+ case ATOP:
+ os << MTag("mfrac", "linethickeness='0'")
+ << MTag("mrow") << cell(0) << ETag("mrow")
+ << MTag("mrow") << cell(1) << ETag("mrow")
+ << ETag("mfrac");
+ break;
+
+ // we do not presently distinguish these
+ case OVER:
+ case FRAC:
+ case DFRAC:
+ case TFRAC:
+ case CFRAC:
+ case CFRACLEFT:
+ case CFRACRIGHT:
+ os << MTag("mfrac")
+ << MTag("mrow") << cell(0) << ETag("mrow")
+ << MTag("mrow") << cell(1) << ETag("mrow")
+ << ETag("mfrac");
+ break;
+
+ case NICEFRAC:
+ os << MTag("mfrac", "bevelled='true'")
+ << MTag("mrow") << cell(0) << ETag("mrow")
+ << MTag("mrow") << cell(1) << ETag("mrow")
+ << ETag("mfrac");
+ break;
+
+ case UNITFRAC:
+ if (nargs() == 3)
+ os << cell(2);
+ os << MTag("mfrac", "bevelled='true'")
+ << MTag("mrow") << cell(0) << ETag("mrow")
+ << MTag("mrow") << cell(1) << ETag("mrow")
+ << ETag("mfrac");
+ break;
+
+ case UNIT:
+ // FIXME This is not right, because we still output mi, etc,
+ // when we output the cell. So we need to prevent that somehow.
+ if (nargs() == 2)
+ os << cell(0)
+ << MTag("mstyle mathvariant='normal'")
+ << cell(1)
+ << ETag("mstyle");
+ else
+ os << MTag("mstyle mathvariant='normal'")
+ << cell(0)
+ << ETag("mstyle");
+ }
}
void InsetMathFrac::htmlize(HtmlStream & os) const
{
- os << MTag("span", "class='frac'")
- << MTag("span", "class='numer'") << cell(0) << ETag("span")
- << MTag("span", "class='denom'") << cell(1) << ETag("span")
- << ETag("span");
+ switch (kind_) {
+ case ATOP:
+ os << MTag("span", "class='frac'")
+ << MTag("span", "class='numer'") << cell(0) << ETag("span")
+ << MTag("span", "class='numer'") << cell(1) << ETag("span")
+ << ETag("span");
+ break;
+
+ // we do not presently distinguish these
+ case OVER:
+ case FRAC:
+ case DFRAC:
+ case TFRAC:
+ case CFRAC:
+ case CFRACLEFT:
+ case CFRACRIGHT:
+ os << MTag("span", "class='frac'")
+ << MTag("span", "class='numer'") << cell(0) << ETag("span")
+ << MTag("span", "class='denom'") << cell(1) << ETag("span")
+ << ETag("span");
+ break;
+
+ case NICEFRAC:
+ os << cell(0) << '/' << cell(1);
+ break;
+
+ case UNITFRAC:
+ if (nargs() == 3)
+ os << cell(2) << ' ';
+ os << cell(0) << '/' << cell(1);
+ break;
+
+ case UNIT:
+ // FIXME This is not right, because we still output i, etc,
+ // when we output the cell. So we need to prevent that somehow.
+ if (nargs() == 2)
+ os << cell(0)
+ << MTag("span")
+ << cell(1)
+ << ETag("span");
+ else
+ os << MTag("span")
+ << cell(0)
+ << ETag("span");
+ }
}
@@ -411,11 +512,10 @@ void InsetMathFrac::validate(LaTeXFeatures & features) const
features.require("amsmath");
if (features.runparams().math_flavor == OutputParams::MathAsHTML)
// CSS adapted from eLyXer
- features.addPreambleSnippet("");
+ "span.denom{display: block; border-top: thin solid #000040;}");
InsetMathNest::validate(features);
}
@@ -616,11 +716,10 @@ void InsetMathBinom::validate(LaTeXFeatures & features) const
if (kind_ == DBINOM || kind_ == TBINOM)
features.require("amsmath");
} else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
- features.addPreambleSnippet("");
+ "span.binomdelim{font-size: 2em;}");
InsetMathNest::validate(features);
}