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;
}
}
//if (mrow->label)
r->setLabel(mrow->getLabel());
if (!ro)
- row_ = r;
+ row_.data_ = r;
else
ro->next_ = r;
mrow = mrow->next_;
++nr_;
}
} else
- row_ = 0;
+ row_.data_ = 0;
flag = mt.flag;
}
if (row_.empty()) {
// lyxerr << " MIDA ";
MathedXIter it(this);
- row_ = it.adjustVerticalSt();
+ row_.data_ = it.adjustVerticalSt();
}
// Clean the arrays
/// Use this to manage the extra information independently of paragraph
MathedRowContainer & getRowSt();
- ///
- void setRowSt(MathedRowContainer & r);
private:
/// Number of columns & rows
int nc_;
{
return row_;
}
-
-
-inline
-void MathMatrixInset::setRowSt(MathedRowContainer & r)
-{
- row_ = r;
-}
#endif
///
virtual MathedRowContainer & getRowSt();
///
- virtual void setRowSt(MathedRowContainer &);
- ///
virtual bool Permit(short f) const;
///
int xo() const;
}
-inline
-void MathParInset::setRowSt(MathedRowContainer &)
-{}
-
-
inline
int MathParInset::xo() const
{
bool numbered_;
};
+
+class MathedRowContainer;
+
class MathedRowSt : public MathedRowStruct {
public:
///
explicit MathedRowSt(int n)
: MathedRowStruct(n), next_(0)
{}
+//private:
///
MathedRowSt * next_;
+ ///
+ friend class MathedRowContainer;
};
///
MathedRowContainer() : data_(0) {}
- ///
- MathedRowContainer(MathedRowSt * data) : data_(data) {}
///
iterator begin() { return iterator(this); }
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 {
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
};
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;
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);
{
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();
}