]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macro.C
fix typo that put too many include paths for most people
[lyx.git] / src / mathed / math_macro.C
index 69e14928f1f32bbebca7c3be94b168b3b1211b91..3cf76db27b4908c164e563e8cd0d792c05b77fd0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  File:        math_macro.C
- *  Purpose:     Implementation of macro class for mathed 
- *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
+ *  Purpose:     Implementation of macro class for mathed
+ *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
  *  Created:     November 1996
  *  Description: WYSIWYG math macros
  *
@@ -66,6 +66,12 @@ bool MathMacro::defining() const
 }
 
 
+void MathMacro::expand() const
+{
+       expanded_ = tmplate_->xcell(tmplate_->cell(1).empty() ? 0 : 1);
+}
+
+
 void MathMacro::metrics(MathMetricsInfo const & mi) const
 {
        whichFont(font_, LM_TC_TEX, mi);
@@ -77,7 +83,7 @@ void MathMacro::metrics(MathMetricsInfo const & mi) const
        }
 
        if (editing()) {
-               expanded_ = tmplate_->xcell(0);
+               expand();
                expanded_.metrics(mi_);
                width_   = expanded_.width()   + 4;
                ascent_  = expanded_.ascent()  + 2;
@@ -98,9 +104,9 @@ void MathMacro::metrics(MathMetricsInfo const & mi) const
                        descent_ += max(c.descent(), ldes) + 5;
                }
                return;
-       } 
+       }
 
-       expanded_ = tmplate_->xcell(0);
+       expand();
        expanded_.data_.substitute(*this);
        expanded_.metrics(mi_);
        width_   = expanded_.width();
@@ -214,7 +220,7 @@ void MathMacro::octavize(OctaveStream & os) const
 void MathMacro::normalize(NormalStream & os) const
 {
        os << "[macro " << name() << " ";
-       for (idx_type i = 0; i < nargs(); ++i) 
+       for (idx_type i = 0; i < nargs(); ++i)
                os << cell(i) << ' ';
        os << ']';
 }
@@ -225,13 +231,13 @@ void MathMacro::write(WriteStream & os) const
        os << '\\' << name();
        for (idx_type i = 0; i < nargs(); ++i)
                os << '{' << cell(i) << '}';
-       if (nargs() == 0) 
+       if (nargs() == 0)
                os << ' ';
 }
 
 
 void MathMacro::updateExpansion() const
 {
-       expanded_ = tmplate_->xcell(0);
+       expand();
        expanded_.data_.substitute(*this);
 }