#endif
#include "math_nestinset.h"
+#include "math_mathmlstream.h"
#include "debug.h"
-using std::max;
-using std::min;
MathNestInset::MathNestInset(idx_type nargs)
: MathDimInset(), cells_(nargs)
void MathNestInset::dump() const
{
- MathWriteInfo os(lyxerr);
+ WriteStream os(lyxerr);
os << "---------------------------------------------\n";
write(os);
os << "\n";
}
-void MathNestInset::push_back(MathAtom const & t)
+void MathNestInset::validate(LaTeXFeatures & features) const
{
- if (nargs())
- cells_.back().data_.push_back(t);
- else
- lyxerr << "can't push without a cell\n";
+ for (idx_type i = 0; i < nargs(); ++i)
+ cell(i).validate(features);
}
-void MathNestInset::validate(LaTeXFeatures & features) const
+bool MathNestInset::match(MathInset * p) const
{
+ if (nargs() != p->nargs())
+ return false;
for (idx_type i = 0; i < nargs(); ++i)
- cell(i).validate(features);
+ if (!cell(i).match(p->cell(i)))
+ return false;
+ return true;
}
-bool MathNestInset::covers(int x, int y) const
+void MathNestInset::replace(ReplaceData & rep)
{
- if (!nargs())
- return false;
- int x0 = xcell(0).xo();
- int y0 = xcell(0).yo() - xcell(0).ascent();
- int x1 = xcell(0).xo() + xcell(0).width();
- int y1 = xcell(0).yo() + xcell(0).descent();
- for (idx_type i = 1; i < nargs(); ++i) {
- x0 = min(x0, xcell(i).xo());
- y0 = min(y0, xcell(i).yo() - xcell(i).ascent());
- x1 = max(x1, xcell(i).xo() + xcell(i).width());
- y1 = max(y1, xcell(i).yo() + xcell(i).descent());
- }
- return x >= x0 && x <= x1 && y >= y0 && y <= y1;
+ for (idx_type i = 0; i < nargs(); ++i)
+ cell(i).replace(rep);
}