5 #include "math_nestinset.h"
6 #include "math_cursor.h"
7 #include "math_mathmlstream.h"
11 MathNestInset::MathNestInset(idx_type nargs)
12 : MathDimInset(), cells_(nargs)
16 MathInset::idx_type MathNestInset::nargs() const
22 MathXArray & MathNestInset::xcell(idx_type i)
28 MathXArray const & MathNestInset::xcell(idx_type i) const
34 MathArray & MathNestInset::cell(idx_type i)
36 return cells_[i].data_;
40 MathArray const & MathNestInset::cell(idx_type i) const
42 return cells_[i].data_;
46 void MathNestInset::substitute(MathMacro const & m)
48 for (idx_type i = 0; i < nargs(); ++i)
49 cell(i).substitute(m);
53 void MathNestInset::metrics(MathMetricsInfo const & mi) const
55 MathMetricsInfo m = mi;
57 for (idx_type i = 0; i < nargs(); ++i) {
64 bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
66 if (idx + 1 >= nargs())
74 bool MathNestInset::idxRight(idx_type & idx, pos_type & pos) const
76 return idxNext(idx, pos);
80 bool MathNestInset::idxPrev(idx_type & idx, pos_type & pos) const
85 pos = cell(idx).size();
90 bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
92 return idxPrev(idx, pos);
96 bool MathNestInset::idxFirst(idx_type & i, pos_type & pos) const
106 bool MathNestInset::idxLast(idx_type & i, pos_type & pos) const
111 pos = cell(i).size();
116 bool MathNestInset::idxHome(idx_type & /* idx */, pos_type & pos) const
125 bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
127 pos_type n = cell(idx).size();
135 void MathNestInset::dump() const
137 WriteStream os(lyxerr);
138 os << "---------------------------------------------\n";
141 for (idx_type i = 0; i < nargs(); ++i)
142 os << cell(i) << "\n";
143 os << "---------------------------------------------\n";
147 void MathNestInset::validate(LaTeXFeatures & features) const
149 for (idx_type i = 0; i < nargs(); ++i)
150 cell(i).validate(features);
154 bool MathNestInset::match(MathInset * p) const
156 if (nargs() != p->nargs())
158 for (idx_type i = 0; i < nargs(); ++i)
159 if (!cell(i).match(p->cell(i)))
165 void MathNestInset::replace(ReplaceData & rep)
167 for (idx_type i = 0; i < nargs(); ++i)
168 cell(i).replace(rep);
172 bool MathNestInset::contains(MathArray const & ar)
174 for (idx_type i = 0; i < nargs(); ++i)
175 if (cell(i).contains(ar))
181 bool MathNestInset::editing() const
183 return mathcursor && mathcursor->isInside(this);