mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
mathed49.diff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1711 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b66c83b542
commit
120f07e51e
@ -15,20 +15,21 @@ extern int number_of_newlines;
|
|||||||
|
|
||||||
MathMatrixInset::MathMatrixInset(int m, int n, short st)
|
MathMatrixInset::MathMatrixInset(int m, int n, short st)
|
||||||
: MathParInset(st, "array", LM_OT_MATRIX), nc_(m), nr_(0), ws_(m),
|
: 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;
|
flag = 15;
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
row_ = new MathedRowSt(nc_ + 1);
|
row_.data_ = new MathedRowSt(nc_ + 1);
|
||||||
MathedXIter it(this);
|
MathedXIter it(this);
|
||||||
for (int j = 1; j < n; ++j) it.addRow();
|
for (int j = 1; j < n; ++j)
|
||||||
|
it.addRow();
|
||||||
nr_ = n;
|
nr_ = n;
|
||||||
if (nr_ == 1 && nc_ > 1) {
|
if (nr_ == 1 && nc_ > 1) {
|
||||||
for (int j = 0; j < nc_ - 1; ++j)
|
for (int j = 0; j < nc_ - 1; ++j)
|
||||||
it.insert('T', LM_TC_TAB);
|
it.insert('T', LM_TC_TAB);
|
||||||
}
|
}
|
||||||
} else if (n < 0) {
|
} else if (n < 0) {
|
||||||
row_ = new MathedRowSt(nc_ + 1);
|
row_.data_ = new MathedRowSt(nc_ + 1);
|
||||||
nr_ = 1;
|
nr_ = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +51,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt)
|
|||||||
//if (mrow->label)
|
//if (mrow->label)
|
||||||
r->setLabel(mrow->getLabel());
|
r->setLabel(mrow->getLabel());
|
||||||
if (!ro)
|
if (!ro)
|
||||||
row_ = r;
|
row_.data_ = r;
|
||||||
else
|
else
|
||||||
ro->next_ = r;
|
ro->next_ = r;
|
||||||
mrow = mrow->next_;
|
mrow = mrow->next_;
|
||||||
@ -58,7 +59,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt)
|
|||||||
++nr_;
|
++nr_;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
row_ = 0;
|
row_.data_ = 0;
|
||||||
flag = mt.flag;
|
flag = mt.flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ void MathMatrixInset::Metrics()
|
|||||||
if (row_.empty()) {
|
if (row_.empty()) {
|
||||||
// lyxerr << " MIDA ";
|
// lyxerr << " MIDA ";
|
||||||
MathedXIter it(this);
|
MathedXIter it(this);
|
||||||
row_ = it.adjustVerticalSt();
|
row_.data_ = it.adjustVerticalSt();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean the arrays
|
// Clean the arrays
|
||||||
|
@ -46,8 +46,6 @@ public:
|
|||||||
|
|
||||||
/// Use this to manage the extra information independently of paragraph
|
/// Use this to manage the extra information independently of paragraph
|
||||||
MathedRowContainer & getRowSt();
|
MathedRowContainer & getRowSt();
|
||||||
///
|
|
||||||
void setRowSt(MathedRowContainer & r);
|
|
||||||
private:
|
private:
|
||||||
/// Number of columns & rows
|
/// Number of columns & rows
|
||||||
int nc_;
|
int nc_;
|
||||||
@ -91,11 +89,4 @@ MathedRowContainer & MathMatrixInset::getRowSt()
|
|||||||
{
|
{
|
||||||
return row_;
|
return row_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
void MathMatrixInset::setRowSt(MathedRowContainer & r)
|
|
||||||
{
|
|
||||||
row_ = r;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,8 +69,6 @@ public:
|
|||||||
///
|
///
|
||||||
virtual MathedRowContainer & getRowSt();
|
virtual MathedRowContainer & getRowSt();
|
||||||
///
|
///
|
||||||
virtual void setRowSt(MathedRowContainer &);
|
|
||||||
///
|
|
||||||
virtual bool Permit(short f) const;
|
virtual bool Permit(short f) const;
|
||||||
///
|
///
|
||||||
int xo() const;
|
int xo() const;
|
||||||
@ -149,11 +147,6 @@ int MathParInset::getMaxArgumentIdx() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
|
||||||
void MathParInset::setRowSt(MathedRowContainer &)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
int MathParInset::xo() const
|
int MathParInset::xo() const
|
||||||
{
|
{
|
||||||
|
@ -63,14 +63,20 @@ protected:
|
|||||||
bool numbered_;
|
bool numbered_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MathedRowContainer;
|
||||||
|
|
||||||
class MathedRowSt : public MathedRowStruct {
|
class MathedRowSt : public MathedRowStruct {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
explicit MathedRowSt(int n)
|
explicit MathedRowSt(int n)
|
||||||
: MathedRowStruct(n), next_(0)
|
: MathedRowStruct(n), next_(0)
|
||||||
{}
|
{}
|
||||||
|
//private:
|
||||||
///
|
///
|
||||||
MathedRowSt * next_;
|
MathedRowSt * next_;
|
||||||
|
///
|
||||||
|
friend class MathedRowContainer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -109,8 +115,6 @@ struct MathedRowContainer {
|
|||||||
|
|
||||||
///
|
///
|
||||||
MathedRowContainer() : data_(0) {}
|
MathedRowContainer() : data_(0) {}
|
||||||
///
|
|
||||||
MathedRowContainer(MathedRowSt * data) : data_(data) {}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
iterator begin() { return iterator(this); }
|
iterator begin() { return iterator(this); }
|
||||||
@ -118,12 +122,8 @@ struct MathedRowContainer {
|
|||||||
bool empty() const { return data_ == 0; }
|
bool empty() const { return data_ == 0; }
|
||||||
|
|
||||||
/// insert 'item' before 'iterator'
|
/// insert 'item' before 'iterator'
|
||||||
void insert(iterator const & pos, MathedRowSt const & item) {
|
void insert(iterator const & it, MathedRowSt const & item) {
|
||||||
MathedRowSt * st = new MathedRowSt(item);
|
MathedRowSt * r = new MathedRowSt(item);
|
||||||
link_before(pos, st);
|
|
||||||
}
|
|
||||||
|
|
||||||
void link_before(iterator const & it, MathedRowSt * r) {
|
|
||||||
if (data_ == it.st_)
|
if (data_ == it.st_)
|
||||||
data_ = r;
|
data_ = r;
|
||||||
else {
|
else {
|
||||||
@ -134,9 +134,25 @@ struct MathedRowContainer {
|
|||||||
r->next_ = it.st_;
|
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_;
|
MathedRowSt * data_;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// currently unimplemented just to make sure it's not used
|
||||||
|
MathedRowContainer(MathedRowContainer const &); // unimplemented
|
||||||
|
void operator=(MathedRowContainer const &); // unimplemented
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,14 +164,8 @@ void MathedXIter::Merge(MathedArray const & a)
|
|||||||
while (pos < pos2 && OK()) {
|
while (pos < pos2 && OK()) {
|
||||||
if (IsCR()) {
|
if (IsCR()) {
|
||||||
if (p_ && p_->Permit(LMPF_ALLOW_CR)) {
|
if (p_ && p_->Permit(LMPF_ALLOW_CR)) {
|
||||||
MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
|
container().insert_after(crow_, MathedRowSt(ncols + 1));
|
||||||
if (crow_) {
|
++crow_;
|
||||||
r.st_->next_ = crow_.st_->next_;
|
|
||||||
crow_.st_->next_ = r.st_;
|
|
||||||
} else {
|
|
||||||
r.st_->next_ = 0;
|
|
||||||
}
|
|
||||||
crow_ = r;
|
|
||||||
} else {
|
} else {
|
||||||
Delete();
|
Delete();
|
||||||
--pos2;
|
--pos2;
|
||||||
@ -378,15 +372,9 @@ void MathedXIter::addRow()
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new item for the structure
|
// Create new item for the structure
|
||||||
MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
|
container().insert_after(crow_, MathedRowSt(ncols + 1));
|
||||||
if (crow_) {
|
|
||||||
r.st_->next_ = crow_.st_->next_;
|
|
||||||
crow_.st_->next_ = r.st_;
|
|
||||||
} else {
|
|
||||||
crow_ = r;
|
|
||||||
r.st_->next_ = 0;
|
|
||||||
}
|
|
||||||
// Fill missed tabs in current row
|
// Fill missed tabs in current row
|
||||||
while (col < ncols - 1)
|
while (col < ncols - 1)
|
||||||
insert('T', LM_TC_TAB);
|
insert('T', LM_TC_TAB);
|
||||||
@ -595,19 +583,16 @@ MathedRowSt * MathedXIter::adjustVerticalSt()
|
|||||||
{
|
{
|
||||||
GoBegin();
|
GoBegin();
|
||||||
if (!crow_) {
|
if (!crow_) {
|
||||||
// lyxerr << " CRW" << ncols << " ";
|
|
||||||
crow_.st_ = new MathedRowSt(ncols + 1); // this leaks
|
crow_.st_ = new MathedRowSt(ncols + 1); // this leaks
|
||||||
}
|
}
|
||||||
// lyxerr<< " CRW[" << crow_ << "] ";
|
|
||||||
MathedRowSt * mrow = crow_.st_;
|
MathedRowSt * mrow = crow_.st_;
|
||||||
while (OK()) {
|
while (OK()) {
|
||||||
if (IsCR()) {
|
if (IsCR()) {
|
||||||
if (col >= ncols) ncols = col + 1;
|
if (col >= ncols)
|
||||||
|
ncols = col + 1;
|
||||||
MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks
|
MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks
|
||||||
// r->next = crow_->next;
|
|
||||||
crow_.st_->next_ = r;
|
crow_.st_->next_ = r;
|
||||||
crow_.st_ = r;
|
crow_.st_ = r;
|
||||||
// lyxerr << " CX[" << crow_ << "]";
|
|
||||||
}
|
}
|
||||||
Next();
|
Next();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user