]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathFrac.cpp
Do some caching of window title and related UI
[lyx.git] / src / mathed / InsetMathFrac.cpp
index 90937619bf2a8d46f93710a20db708bc9f84ea17..467735558cd2d087e35e25e5e8463a8a8dd9e931 100644 (file)
@@ -22,6 +22,7 @@
 #include "MetricsInfo.h"
 #include "TextPainter.h"
 
+#include "support/lassert.h"
 #include "frontends/Painter.h"
 
 using namespace std;
@@ -366,23 +367,32 @@ bool InsetMathFrac::extraBraces() const
 }
 
 
-// FIXME This will crash on unitone and is wrong in other cases.
 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) << ')';
 }
 
 
-// FIXME This will crash on unitone and is wrong in other cases.
 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) << ')';
 }
 
 
-// FIXME This will crash on unitone and is wrong in other cases.
 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) << ')';
 }
 
@@ -502,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("<style type=\"text/css\">\n"
+               features.addCSSSnippet(
                        "span.frac{display: inline-block; vertical-align: middle; text-align:center;}\n"
                        "span.numer{display: block;}\n"
-                       "span.denom{display: block; border-top: thin solid #000040;}\n"
-                       "</style>");
+                       "span.denom{display: block; border-top: thin solid #000040;}");
        InsetMathNest::validate(features);
 }
 
@@ -544,8 +553,8 @@ void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        Dimension dim0, dim1;
 
-       // FIXME: for an unknown reason the cells must be set directly
-       // after the StyleChanger and cannot be set after the if case
+       // The cells must be set while the RAII objects (StyleChanger,
+       // FracChanger) do still exist and cannot be set after the if case.
        if (kind_ == DBINOM) {
                StyleChanger dummy(mi.base, LM_ST_DISPLAY);
                cell(0).metrics(mi, dim0);
@@ -578,8 +587,8 @@ void InsetMathBinom::draw(PainterInfo & pi, int x, int y) const
                kind_ == BRACK ? from_ascii("]") : from_ascii(")");
 
        int m = x + dim.width() / 2;
-       // FIXME: for an unknown reason the cells must be drawn directly
-       // after the StyleChanger and cannot be drawn after the if case
+       // The cells must be drawn while the RAII objects (StyleChanger,
+       // FracChanger) do still exist and cannot be drawn after the if case.
        if (kind_ == DBINOM) {
                StyleChanger dummy(pi.base, LM_ST_DISPLAY);
                cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 3 - 5);
@@ -707,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("<style type=\"text/css\">\n"
+               features.addCSSSnippet(
                        "span.binom{display: inline-block; vertical-align: bottom; text-align:center;}\n"
                        "span.binom span{display: block;}\n"
-                       "span.binomdelim{font-size: 2em;}\n"
-                       "</style>");
+                       "span.binomdelim{font-size: 2em;}");
        InsetMathNest::validate(features);
 }