]> git.lyx.org Git - features.git/commitdiff
Fix read in of \over (related to bug 2481)
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Wed, 19 Jul 2006 10:50:18 +0000 (10:50 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Wed, 19 Jul 2006 10:50:18 +0000 (10:50 +0000)
        * src/mathed/math_factory.C
        (createMathInset): Create a MathFracInset of kind OVER for \over

        * src/mathed/math_fracinset.C
        (MathFracInset::draw): handle kind OVER
        (MathFracInset::drawT): ditto
        (MathFracInset::write): ditto
        (MathFracInset::name): ditto
        (MathFracInset::extraBraces): ditto

        * src/mathed/math_fracinset.h
        (Kind): New kind OVER

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14487 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_factory.C
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h

index d55fc094db0997fe82e6664a67a7bf4295e75fc9..97da7b6b152a360effaa43e918f1c0d9bddfb71f 100644 (file)
@@ -320,8 +320,10 @@ MathAtom createMathInset(string const & s)
                return MathAtom(new MathStackrelInset);
        if (s == "binom" || s == "choose")
                return MathAtom(new MathBinomInset(s == "choose"));
-       if (s == "over" || s == "frac")
+       if (s == "frac")
                return MathAtom(new MathFracInset);
+       if (s == "over")
+               return MathAtom(new MathFracInset(MathFracInset::OVER));
        if (s == "nicefrac")
                return MathAtom(new MathFracInset(MathFracInset::NICEFRAC));
        //if (s == "infer")
index 2ba15ab46282200371bb2206f7519db53eb01e91..34e979af52fe944c74099c1099966b9d0d7cfc60 100644 (file)
@@ -77,18 +77,17 @@ void MathFracInset::draw(PainterInfo & pi, int x, int y) const
                                y - cell(0).descent() - 5);
                cell(1).draw(pi, x + cell(0).width() + 5,
                                y + cell(1).ascent() / 2);
+               pi.pain.line(x + cell(0).width(), 
+                               y + dim_.des - 2, 
+                               x + cell(0).width() + 5, 
+                               y - dim_.asc + 2, LColor::math);
        } else {
                cell(0).draw(pi, m - cell(0).width() / 2, 
                                y - cell(0).descent() - 2 - 5);
                cell(1).draw(pi, m - cell(1).width() / 2,
                                y + cell(1).ascent()  + 2 - 5);
        }
-       if (kind_ == NICEFRAC)
-               pi.pain.line(x + cell(0).width(), 
-                               y + dim_.des - 2, 
-                               x + cell(0).width() + 5, 
-                               y - dim_.asc + 2, LColor::math);
-       if (kind_ == FRAC)
+       if (kind_ == FRAC || kind_ == OVER)
                pi.pain.line(x + 1, y - 5, 
                                x + dim_.wid - 2, y - 5, LColor::math);
        drawMarkers(pi, x, y);
@@ -112,17 +111,26 @@ void MathFracInset::drawT(TextPainter & pain, int x, int y) const
        cell(0).drawT(pain, m - cell(0).width() / 2, y - cell(0).descent() - 1);
        cell(1).drawT(pain, m - cell(1).width() / 2, y + cell(1).ascent());
        // ASCII art: ignore niceties
-       if (kind_ == FRAC || kind_ == NICEFRAC)
+       if (kind_ == FRAC || kind_ == OVER || kind_ == NICEFRAC)
                pain.horizontalLine(x, y, dim_.width());
 }
 
 
 void MathFracInset::write(WriteStream & os) const
 {
-       if (kind_ == ATOP)
+       switch (kind_) {
+       case ATOP:
                os << '{' << cell(0) << "\\atop " << cell(1) << '}';
-       else // it's \\frac
+               break;
+       case OVER:
+               // \\over is only for compatibility, normalize this to \\frac
+               os << "\\frac{" << cell(0) << "}{" << cell(1) << '}';
+               break;
+       case FRAC:
+       case NICEFRAC:
                MathNestInset::write(os);
+               break;
+       }
 }
 
 
@@ -131,19 +139,19 @@ string MathFracInset::name() const
        switch (kind_) {
        case FRAC:
                return "frac";
+       case OVER:
+               return "over";
        case NICEFRAC:
                return "nicefrac";
        case ATOP:
                return "atop";
-       default:
-               return string();
        }
 }
 
 
 bool MathFracInset::extraBraces() const
 {
-       return kind_ == ATOP;
+       return kind_ == ATOP || kind_ == OVER;
 }
 
 
index 1abb102f8f950d129c4b9912081a8d99b64a53d7..53abf281849b4b8597fad3f03d30bf1aa6f7cece 100644 (file)
@@ -22,6 +22,7 @@ public:
        ///
        enum Kind {
                FRAC,
+               OVER,
                ATOP,
                NICEFRAC
        };