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;
67 class MathedRowContainer;
69 class MathedRowSt : public MathedRowStruct {
72 explicit MathedRowSt(int n)
73 : MathedRowStruct(n), next_(0)
79 friend class MathedRowContainer;
83 // The idea is to change this MathedRowContainer to mimic the behaviour
84 // of std::list<MathedRowStruct> in several small steps. In the end it
85 // could be replaced by such a list and MathedRowSt can go as well.
87 struct MathedRowContainer {
91 iterator() : st_(0) {}
93 explicit iterator(MathedRowSt * st) : st_(st) {}
95 explicit iterator(MathedRowContainer * m) : st_(m->data_) {}
96 /// "better" conversion to bool
97 operator void *() const { return st_; }
99 MathedRowStruct & operator*() { Assert(st_); return *st_; }
101 MathedRowStruct * operator->() { return st_; }
103 MathedRowStruct const * operator->() const { return st_; }
105 void operator++() { Assert(st_); st_ = st_->next_; }
107 bool is_last() const { Assert(st_); return st_->next_ == 0; }
109 bool operator==(const iterator & it) const { return st_ == it.st_; }
117 MathedRowContainer() : data_(0) {}
120 iterator begin() { return iterator(this); }
122 bool empty() const { return data_ == 0; }
124 /// insert 'item' before 'iterator'
125 void insert(iterator const & it, MathedRowSt const & item) {
126 MathedRowSt * r = new MathedRowSt(item);
130 MathedRowSt * pos = data_;
131 if (pos->next_ == it.st_)
137 /// insert 'item' after 'iterator'
138 void insert_after(iterator & it, MathedRowSt const & item) {
139 MathedRowSt * r = new MathedRowSt(item);
141 r->next_ = it.st_->next_;
153 // currently unimplemented just to make sure it's not used
154 MathedRowContainer(MathedRowContainer const &); // unimplemented
155 void operator=(MathedRowContainer const &); // unimplemented
161 string const & MathedRowStruct::getLabel() const
168 bool MathedRowStruct::isNumbered() const
175 int MathedRowStruct::getBaseline() const
182 void MathedRowStruct::setBaseline(int b)
189 int MathedRowStruct::ascent() const
196 int MathedRowStruct::descent() const
203 void MathedRowStruct::ascent(int a)
210 void MathedRowStruct::descent(int d)
217 int MathedRowStruct::getTab(int i) const
224 void MathedRowStruct::setLabel(string const & l)
231 void MathedRowStruct::setNumbered(bool nf)
238 void MathedRowStruct::setTab(int i, int t)