+2005-10-04 Georg Baum <Georg.Baum@post.rwth-aachen.de>
+
+ * math_macro.C (editXY): new, fix crash (bug 2060)
+ * math_macro.C (cursorPos): new, fix potential crash
+ * math_macro.C (drawSelection): new, fix potential crash
+ * math_nestinset.C (doDispatch): fix crash when inserting math macros
+ with 0 arguments
+
2005-09-30 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* math_nestinset.C (doDispatch): do not leave the inset after
}
+void MathMacro::cursorPos(CursorSlice const & sl, bool boundary, int & x,
+ int & y) const
+{
+ // We may have 0 arguments, but MathNestInset requires at least one.
+ if (nargs() > 0)
+ MathNestInset::cursorPos(sl, boundary, x, y);
+}
+
+
void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (!MacroTable::globalMacros().has(name())) {
}
+void MathMacro::drawSelection(PainterInfo & pi, int x, int y) const
+{
+ // We may have 0 arguments, but MathNestInset requires at least one.
+ if (nargs() > 0)
+ MathNestInset::drawSelection(pi, x, y);
+}
+
+
void MathMacro::validate(LaTeXFeatures & features) const
{
if (name() == "binom" || name() == "mathcircumflex")
}
+InsetBase * MathMacro::editXY(LCursor & cur, int x, int y)
+{
+ // We may have 0 arguments, but MathNestInset requires at least one.
+ if (nargs() > 0)
+ return MathNestInset::editXY(cur, x, y);
+ return this;
+}
+
+
void MathMacro::maple(MapleStream & os) const
{
updateExpansion();
void draw(PainterInfo & pi, int x, int y) const;
///
void drawExpanded(PainterInfo & pi, int x, int y) const;
+ /// draw selection background
+ void drawSelection(PainterInfo & pi, int x, int y) const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
+ /// get cursor position
+ void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
+ ///
+ InsetBase * editXY(LCursor & cur, int x, int y);
///
std::string name() const;
///
std::string name_;
/// the unexpanded macro defintition
mutable MathArray tmpl_;
- /// the matcro substituted with our args
+ /// the macro substituted with our args
mutable MathArray expanded_;
};
int cell(0);
if (cmd.argument == "\\root")
cell = 1;
- if (ar.size() == 1 && (ar[0].nucleus()->asNestInset())) {
+ // math macros are nest insets and may have 0 cells.
+ // handleNest would crash in this case.
+ if (ar.size() == 1 && (ar[0].nucleus()->asNestInset()) &&
+ ar[0].nucleus()->nargs() > cell) {
cur.handleNest(ar[0], cell);
} else
cur.niceInsert(cmd.argument);