mathed48.diff

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1709 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-03-08 11:51:35 +00:00
parent b8acafded6
commit ac8cbdbddb
6 changed files with 51 additions and 38 deletions

View File

@ -1,3 +1,9 @@
2001-03-08 André Pönitz <poenitz@htwm.de>
* math_rowst.h: give MathedRowContainer an 'insert' method.
* math_xiter.C: new 'container()' method to encapsulated access to
the MathParInset's MathedRowContainer
2001-03-06 André Pönitz <poenitz@htwm.de>
* array.[Ch]: factor out deep_copy,
remove third argument from raw_pointer_insert

View File

@ -52,7 +52,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset const & mt)
if (!ro)
row_ = r;
else
ro->setNext(r);
ro->next_ = r;
mrow = mrow->next_;
ro = r;
++nr_;

View File

@ -603,8 +603,8 @@ void mathed_parse(MathedArray & array, unsigned flags = 0,
if (mt && (flags & FLAG_END)) {
if (mt->Permit(LMPF_ALLOW_CR)) {
if (crow) {
crow->setNext(new MathedRowSt(mt->GetColumns() + 1)); // this leaks
crow = crow->getNext();
crow->next_ = new MathedRowSt(mt->GetColumns() + 1);
crow = crow->next_;
}
data.insert('K', LM_TC_CR);
} else

View File

@ -69,11 +69,6 @@ public:
explicit MathedRowSt(int n)
: MathedRowStruct(n), next_(0)
{}
/// Should be const but...
MathedRowSt * getNext() const;
/// ...we couldn't use this.
void setNext(MathedRowSt * n);
//private:
///
MathedRowSt * next_;
};
@ -90,7 +85,7 @@ struct MathedRowContainer {
iterator() : st_(0) {}
///
explicit iterator(MathedRowSt * st) : st_(st) {}
/// "better" conversion to bool
///
explicit iterator(MathedRowContainer * m) : st_(m->data_) {}
/// "better" conversion to bool
operator void *() const { return st_; }
@ -122,26 +117,30 @@ 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) {
if (data_ == it.st_)
data_ = r;
else {
MathedRowSt * pos = data_;
if (pos->next_ == it.st_)
pos->next_ = r;
}
r->next_ = it.st_;
}
///
MathedRowSt * data_;
};
inline
MathedRowSt * MathedRowSt::getNext() const
{
return next_;
}
inline
void MathedRowSt::setNext(MathedRowSt * n)
{
next_ = n;
}
inline
string const & MathedRowStruct::getLabel() const
{

View File

@ -36,6 +36,12 @@ MathParInset * MathedXIter::getPar() const
return p_;
}
MathedRowContainer & MathedXIter::container()
{
Assert(p_);
return p_->getRowSt();
}
void MathedXIter::GetPos(int & xx, int & yy) const
{
@ -122,7 +128,7 @@ void MathedXIter::Clean(int pos2)
MathedRowContainer::iterator r = crow_;
++r;
if (r) {
crow_.st_->setNext(r.st_->getNext());
crow_.st_->next_ = r.st_->next_;
delete r.st_;
}
}
@ -160,10 +166,10 @@ void MathedXIter::Merge(MathedArray const & a)
if (p_ && p_->Permit(LMPF_ALLOW_CR)) {
MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
if (crow_) {
r.st_->setNext(crow_.st_->getNext());
crow_.st_->setNext(r.st_);
r.st_->next_ = crow_.st_->next_;
crow_.st_->next_ = r.st_;
} else {
r.st_->setNext(0);
r.st_->next_ = 0;
}
crow_ = r;
} else {
@ -186,7 +192,7 @@ void MathedXIter::SetData(MathParInset * pp)
x_ = y_ = 0;
array = &p_->GetData();
ncols = p_->GetColumns();
crow_ = p_->getRowSt().begin();
crow_ = container().begin();
if (p_->Permit(LMPF_ALLOW_CR))
flags |= MthIF_CR;
if (p_->Permit(LMPF_ALLOW_TAB))
@ -240,7 +246,7 @@ bool MathedXIter::Next()
} else
if (c == LM_TC_CR && p_) {
x_ = 0;
if (crow_ && crow_.st_->getNext()) {
if (crow_ && crow_.st_->next_) {
++crow_;
y_ = crow_->getBaseline();
w = crow_->getTab(0);
@ -272,7 +278,7 @@ void MathedXIter::GoBegin()
x_ = y_ = 0;
sw_ = sx_ = 0;
if (p_) {
crow_ = p_->getRowSt().begin();
crow_ = container().begin();
if (crow_) {
x_ = crow_->getTab(0);
y_ = crow_->getBaseline();
@ -375,11 +381,11 @@ void MathedXIter::addRow()
// Create new item for the structure
MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
if (crow_) {
r.st_->setNext(crow_.st_->getNext());
crow_.st_->setNext(r.st_);
r.st_->next_ = crow_.st_->next_;
crow_.st_->next_ = r.st_;
} else {
crow_ = r;
r.st_->setNext(0);
r.st_->next_ = 0;
}
// Fill missed tabs in current row
while (col < ncols - 1)
@ -419,9 +425,9 @@ void MathedXIter::delRow()
if (line_empty) {
MathedRowContainer::iterator r( crow_.st_->getNext() );
MathedRowContainer::iterator r( crow_.st_->next_ );
if (r) {
crow_.st_->setNext(r.st_->getNext());
crow_.st_->next_ = r.st_->next_;
delete r.st_;
}
join(p1);
@ -447,7 +453,7 @@ void MathedXIter::ipop()
x_ = stck.x;
y_ = stck.y;
if (p_) {
crow_ = p_->getRowSt().begin();
crow_ = container().begin();
if (crow_)
for (int i = 0; i < row; ++i)
++crow_;
@ -599,7 +605,7 @@ MathedRowSt * MathedXIter::adjustVerticalSt()
if (col >= ncols) ncols = col + 1;
MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks
// r->next = crow_->next;
crow_.st_->setNext(r);
crow_.st_->next_ = r;
crow_.st_ = r;
// lyxerr << " CX[" << crow_ << "]";
}

View File

@ -4,6 +4,7 @@
#include "math_iter.h"
#include "math_rowst.h"
#include "math_rowst.h"
class MathParInset;
@ -86,6 +87,8 @@ public:
}
private:
///
MathedRowContainer & container();
/// This function is not recursive, as MathPar::Metrics is
void IMetrics(int, int &, int &, int &);
/// Font size (display, text, script, script2)
@ -106,7 +109,6 @@ private:
bool limits_;
///
MathedRowContainer::iterator crow_;
///
//friend class MathedCursor;
};