]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.cpp
Add \makeat switches to babel settings if necessary.
[lyx.git] / src / mathed / MathMacro.cpp
index 3e4f4409901b3e9a490cd0f7a2ae06af37d411d5..cd9b757a51742385a883a283ccd1d68913d59e8b 100644 (file)
@@ -138,6 +138,15 @@ Inset * MathMacro::clone() const
 }
 
 
+void MathMacro::normalize(NormalStream & os) const
+{
+       os << "[macro " << name();
+       for (size_t i = 0; i < nargs(); ++i)
+               os << ' ' << cell(i);
+       os << ']';
+}
+
+
 docstring MathMacro::name() const
 {
        if (displayMode_ == DISPLAY_UNFOLDED)
@@ -252,7 +261,7 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
                // otherwise do a manual metrics call
                CoordCache & coords = mi.base.bv->coordCache();
                for (idx_type i = 0; i < nargs(); ++i) {
-                       if (!coords.getArrays().has(&cell(i))) {
+                       if (!coords.getArrays().hasDim(&cell(i))) {
                                Dimension tdim;
                                cell(i).metrics(mi, tdim);
                        }
@@ -302,7 +311,8 @@ void MathMacro::updateMacro(MacroContext const & mc)
 }
 
 
-void MathMacro::updateRepresentation()
+void MathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
+               UpdateType utype)
 {
        // known macro?
        if (macro_ == 0)
@@ -333,6 +343,8 @@ void MathMacro::updateRepresentation()
        }
        // expanding macro with the values
        macro_->expand(values, expanded_.cell(0));
+       if (utype == OutputUpdate && !expanded_.cell(0).empty())
+               expanded_.cell(0).updateMacros(cur, mc, utype);
        // get definition for list edit mode
        docstring const & display = macro_->display();
        asArray(display.empty() ? macro_->definition() : display, definition_);
@@ -643,6 +655,7 @@ bool MathMacro::notifyCursorLeaves(Cursor const & old, Cursor & cur)
                        inset_cursor.cell().erase(inset_cursor.pos());
                        inset_cursor.cell().insert(inset_cursor.pos(),
                                createInsetMath(unfolded_name, cur.buffer()));
+                       cur.resetAnchor();
                        cur.screenUpdateFlags(cur.result().screenUpdate() | Update::SinglePar);
                        return true;
                }
@@ -743,13 +756,23 @@ void MathMacro::maple(MapleStream & os) const
 
 void MathMacro::mathmlize(MathStream & os) const
 {
-       os << expanded_.cell(0);
+       MathData const & data = expanded_.cell(0);
+       if (data.empty()) {
+               // this means that we do not recognize the macro
+               throw MathExportException();
+       }
+       os << data;
 }
 
 
 void MathMacro::htmlize(HtmlStream & os) const
 {
-       os << expanded_.cell(0);
+       MathData const & data = expanded_.cell(0);
+       if (data.empty()) {
+               // this means that we do not recognize the macro
+               throw MathExportException();
+       }
+       os << data;
 }