X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_matrixinset.C;h=7495df99a8d10010f36283e348cc738610987d20;hb=4590c8cfab02a3bc56813cfb1f2e80bd1119af9e;hp=d791c11fe1d4b80eb425e75f374d3acf3a8f1f66;hpb=ac8cbdbddb7cf17fc717203b3fd9b93b31a3ee32;p=lyx.git diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index d791c11fe1..7495df99a8 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -15,66 +15,26 @@ extern int number_of_newlines; MathMatrixInset::MathMatrixInset(int m, int n, short st) : MathParInset(st, "array", LM_OT_MATRIX), nc_(m), nr_(0), ws_(m), - v_align_(0), h_align_(nc_, 'c'), row_(0) + v_align_(0), h_align_(nc_, 'c') { flag = 15; if (n > 0) { - row_ = new MathedRowSt(nc_ + 1); MathedXIter it(this); - for (int j = 1; j < n; ++j) it.addRow(); + for (int j = 1; j < n; ++j) + it.addRow(); nr_ = n; if (nr_ == 1 && nc_ > 1) { for (int j = 0; j < nc_ - 1; ++j) it.insert('T', LM_TC_TAB); } } else if (n < 0) { - row_ = new MathedRowSt(nc_ + 1); + MathedXIter it(this); + it.addRow(); nr_ = 1; } } -MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt) - : MathParInset(mt.GetStyle(), mt.GetName(), mt.GetType()), - nc_(mt.nc_), nr_(0), ws_(mt.nc_), - v_align_(mt.v_align_), h_align_(mt.h_align_) -{ - array = mt.GetData(); - if (!mt.row_.empty()) { - MathedRowSt * ro = 0; - MathedRowSt * mrow = mt.row_.data_; - - while (mrow) { - MathedRowSt * r = new MathedRowSt(nc_ + 1); - r->setNumbered(mrow->isNumbered()); - //if (mrow->label) - r->setLabel(mrow->getLabel()); - if (!ro) - row_ = r; - else - ro->next_ = r; - mrow = mrow->next_; - ro = r; - ++nr_; - } - } else - row_ = 0; - flag = mt.flag; -} - - -MathMatrixInset::~MathMatrixInset() -{ - MathedRowSt * r = row_.data_; - while (r) { - MathedRowSt * q = r->next_; - delete r; - r = q; - } -} - - - MathedInset * MathMatrixInset::Clone() { return new MathMatrixInset(*this); @@ -133,11 +93,19 @@ void MathMatrixInset::draw(Painter & pain, int x, int baseline) void MathMatrixInset::Metrics() { - if (row_.empty()) { - // lyxerr << " MIDA "; - MathedXIter it(this); - row_ = it.adjustVerticalSt(); - } + // Adjust row structure + MathedXIter it(this); + it.GoBegin(); + int nrows = 1; + while (it.OK()) { + if (it.IsCR()) { + ++nrows; + if (it.col >= it.ncols) + it.ncols = it.col + 1; + } + it.Next(); + } + row_.data_.resize(nrows); // Clean the arrays for (MathedRowContainer::iterator it = row_.begin(); it; ++it)