From: Lars Gullik Bjønnes Date: Thu, 8 Mar 2001 13:38:20 +0000 (+0000) Subject: mathed49.diff X-Git-Tag: 1.6.10~21499 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=120f07e51e6890cb8b9d03ed924810e111e8c78d;p=features.git mathed49.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1711 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index d791c11fe1..cd9d291a31 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -15,20 +15,21 @@ 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); + row_.data_ = 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); + row_.data_ = new MathedRowSt(nc_ + 1); nr_ = 1; } } @@ -50,7 +51,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt) //if (mrow->label) r->setLabel(mrow->getLabel()); if (!ro) - row_ = r; + row_.data_ = r; else ro->next_ = r; mrow = mrow->next_; @@ -58,7 +59,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt) ++nr_; } } else - row_ = 0; + row_.data_ = 0; flag = mt.flag; } @@ -136,7 +137,7 @@ void MathMatrixInset::Metrics() if (row_.empty()) { // lyxerr << " MIDA "; MathedXIter it(this); - row_ = it.adjustVerticalSt(); + row_.data_ = it.adjustVerticalSt(); } // Clean the arrays diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index 6ee2478ec0..8561d72a3b 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -46,8 +46,6 @@ public: /// Use this to manage the extra information independently of paragraph MathedRowContainer & getRowSt(); - /// - void setRowSt(MathedRowContainer & r); private: /// Number of columns & rows int nc_; @@ -91,11 +89,4 @@ MathedRowContainer & MathMatrixInset::getRowSt() { return row_; } - - -inline -void MathMatrixInset::setRowSt(MathedRowContainer & r) -{ - row_ = r; -} #endif diff --git a/src/mathed/math_parinset.h b/src/mathed/math_parinset.h index b3d8bc7d06..fc332c64e9 100644 --- a/src/mathed/math_parinset.h +++ b/src/mathed/math_parinset.h @@ -69,8 +69,6 @@ public: /// virtual MathedRowContainer & getRowSt(); /// - virtual void setRowSt(MathedRowContainer &); - /// virtual bool Permit(short f) const; /// int xo() const; @@ -149,11 +147,6 @@ int MathParInset::getMaxArgumentIdx() const } -inline -void MathParInset::setRowSt(MathedRowContainer &) -{} - - inline int MathParInset::xo() const { diff --git a/src/mathed/math_rowst.h b/src/mathed/math_rowst.h index 373aff6bca..488967e4fa 100644 --- a/src/mathed/math_rowst.h +++ b/src/mathed/math_rowst.h @@ -63,14 +63,20 @@ protected: bool numbered_; }; + +class MathedRowContainer; + class MathedRowSt : public MathedRowStruct { public: /// explicit MathedRowSt(int n) : MathedRowStruct(n), next_(0) {} +//private: /// MathedRowSt * next_; + /// + friend class MathedRowContainer; }; @@ -109,8 +115,6 @@ struct MathedRowContainer { /// MathedRowContainer() : data_(0) {} - /// - MathedRowContainer(MathedRowSt * data) : data_(data) {} /// iterator begin() { return iterator(this); } @@ -118,12 +122,8 @@ struct MathedRowContainer { bool empty() const { return data_ == 0; } /// insert 'item' before 'iterator' - void insert(iterator const & pos, MathedRowSt const & item) { - MathedRowSt * st = new MathedRowSt(item); - link_before(pos, st); - } - - void link_before(iterator const & it, MathedRowSt * r) { + void insert(iterator const & it, MathedRowSt const & item) { + MathedRowSt * r = new MathedRowSt(item); if (data_ == it.st_) data_ = r; else { @@ -134,9 +134,25 @@ struct MathedRowContainer { r->next_ = it.st_; } + /// insert 'item' after 'iterator' + void insert_after(iterator & it, MathedRowSt const & item) { + MathedRowSt * r = new MathedRowSt(item); + if (it) { + r->next_ = it.st_->next_; + it.st_->next_ = r; + } else { + it.st_ = r; + r->next_ = 0; + } + } /// MathedRowSt * data_; + +private: + // currently unimplemented just to make sure it's not used + MathedRowContainer(MathedRowContainer const &); // unimplemented + void operator=(MathedRowContainer const &); // unimplemented }; diff --git a/src/mathed/math_xiter.C b/src/mathed/math_xiter.C index 9e54961bf7..d2204c1113 100644 --- a/src/mathed/math_xiter.C +++ b/src/mathed/math_xiter.C @@ -164,14 +164,8 @@ void MathedXIter::Merge(MathedArray const & a) while (pos < pos2 && OK()) { if (IsCR()) { if (p_ && p_->Permit(LMPF_ALLOW_CR)) { - MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) ); - if (crow_) { - r.st_->next_ = crow_.st_->next_; - crow_.st_->next_ = r.st_; - } else { - r.st_->next_ = 0; - } - crow_ = r; + container().insert_after(crow_, MathedRowSt(ncols + 1)); + ++crow_; } else { Delete(); --pos2; @@ -378,15 +372,9 @@ void MathedXIter::addRow() return; } + // Create new item for the structure - MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) ); - if (crow_) { - r.st_->next_ = crow_.st_->next_; - crow_.st_->next_ = r.st_; - } else { - crow_ = r; - r.st_->next_ = 0; - } + container().insert_after(crow_, MathedRowSt(ncols + 1)); // Fill missed tabs in current row while (col < ncols - 1) insert('T', LM_TC_TAB); @@ -595,19 +583,16 @@ MathedRowSt * MathedXIter::adjustVerticalSt() { GoBegin(); if (!crow_) { -// lyxerr << " CRW" << ncols << " "; crow_.st_ = new MathedRowSt(ncols + 1); // this leaks } -// lyxerr<< " CRW[" << crow_ << "] "; MathedRowSt * mrow = crow_.st_; while (OK()) { if (IsCR()) { - if (col >= ncols) ncols = col + 1; + if (col >= ncols) + ncols = col + 1; MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks -// r->next = crow_->next; crow_.st_->next_ = r; crow_.st_ = r; -// lyxerr << " CX[" << crow_ << "]"; } Next(); }