6 #include "support/LAssert.h"
8 /** The physical structure of a row and aditional information is stored here.
9 It allows to manage the extra info independently of the paragraph data.
10 Only used for multiline paragraphs.
17 typedef std::vector<int> Widths;
21 MathedRowStruct(int n)
22 : asc_(0), desc_(0), y_(0), widths_(n + 1, 0),
26 string const & getLabel() const;
28 bool isNumbered() const;
30 int getBaseline() const;
32 void setBaseline(int b);
42 int getTab(int i) const;
44 void setLabel(string const & l);
46 void setNumbered(bool nf);
48 void setTab(int i, int t);
50 friend class MathedRowSt;
66 class MathedRowSt : public MathedRowStruct {
69 explicit MathedRowSt(int n)
70 : MathedRowStruct(n), next_(0)
77 // The idea is to change this MathedRowContainer to mimic the behaviour
78 // of std::list<MathedRowStruct> in several small steps. In the end it
79 // could be replaced by such a list and MathedRowSt can go as well.
81 struct MathedRowContainer {
85 iterator() : st_(0) {}
87 explicit iterator(MathedRowSt * st) : st_(st) {}
89 explicit iterator(MathedRowContainer * m) : st_(m->data_) {}
90 /// "better" conversion to bool
91 operator void *() const { return st_; }
93 MathedRowStruct & operator*() { Assert(st_); return *st_; }
95 MathedRowStruct * operator->() { return st_; }
97 MathedRowStruct const * operator->() const { return st_; }
99 void operator++() { Assert(st_); st_ = st_->next_; }
101 bool is_last() const { Assert(st_); return st_->next_ == 0; }
103 bool operator==(const iterator & it) const { return st_ == it.st_; }
111 MathedRowContainer() : data_(0) {}
113 MathedRowContainer(MathedRowSt * data) : data_(data) {}
116 iterator begin() { return iterator(this); }
118 bool empty() const { return data_ == 0; }
120 /// insert 'item' before 'iterator'
121 void insert(iterator const & pos, MathedRowSt const & item) {
122 MathedRowSt * st = new MathedRowSt(item);
123 link_before(pos, st);
126 void link_before(iterator const & it, MathedRowSt * r) {
130 MathedRowSt * pos = data_;
131 if (pos->next_ == it.st_)
145 string const & MathedRowStruct::getLabel() const
152 bool MathedRowStruct::isNumbered() const
159 int MathedRowStruct::getBaseline() const
166 void MathedRowStruct::setBaseline(int b)
173 int MathedRowStruct::ascent() const
180 int MathedRowStruct::descent() const
187 void MathedRowStruct::ascent(int a)
194 void MathedRowStruct::descent(int d)
201 int MathedRowStruct::getTab(int i) const
208 void MathedRowStruct::setLabel(string const & l)
215 void MathedRowStruct::setNumbered(bool nf)
222 void MathedRowStruct::setTab(int i, int t)