+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
if (!ro)
row_ = r;
else
- ro->setNext(r);
+ ro->next_ = r;
mrow = mrow->next_;
ro = r;
++nr_;
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
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_;
};
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_; }
///
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
{
return p_;
}
+MathedRowContainer & MathedXIter::container()
+{
+ Assert(p_);
+ return p_->getRowSt();
+}
+
void MathedXIter::GetPos(int & xx, int & yy) const
{
MathedRowContainer::iterator r = crow_;
++r;
if (r) {
- crow_.st_->setNext(r.st_->getNext());
+ crow_.st_->next_ = r.st_->next_;
delete r.st_;
}
}
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 {
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))
} 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);
x_ = y_ = 0;
sw_ = sx_ = 0;
if (p_) {
- crow_ = p_->getRowSt().begin();
+ crow_ = container().begin();
if (crow_) {
x_ = crow_->getTab(0);
y_ = crow_->getBaseline();
// 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)
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);
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_;
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_ << "]";
}
#include "math_iter.h"
#include "math_rowst.h"
+#include "math_rowst.h"
class MathParInset;
}
private:
+ ///
+ MathedRowContainer & container();
/// This function is not recursive, as MathPar::Metrics is
void IMetrics(int, int &, int &, int &);
/// Font size (display, text, script, script2)
bool limits_;
///
MathedRowContainer::iterator crow_;
-
///
//friend class MathedCursor;
};