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 : asc_(0), desc_(0), y_(0), numbered_(true)
24 string const & getLabel() const;
26 bool isNumbered() const;
28 int getBaseline() const;
30 void setBaseline(int b);
40 int getTab(unsigned int i) const;
42 void setLabel(string const & l);
44 void setNumbered(bool nf);
46 void setTab(unsigned int i, int t);
64 class MathedRowContainer {
69 iterator() : st_(0), pos_(0) {}
71 explicit iterator(MathedRowContainer * m) : st_(m), pos_(0) {}
72 /// "better" conversion to bool, static_cast doens't help?
73 operator void *() const
74 { return (void *)(st_ && pos_ < st_->data_.size()); }
76 MathedRowStruct & operator*() { Assert(st_); return st_->data_[pos_]; }
78 MathedRowStruct * operator->() { Assert(st_); return &st_->data_[pos_]; }
80 MathedRowStruct const * operator->() const { Assert(st_); return &st_->data_[pos_]; }
82 void operator++() { Assert(st_); ++pos_; }
84 bool is_last() const { Assert(st_); return pos_ == st_->data_.size() - 1; }
86 bool operator==(const iterator & it) const
87 { return st_ == it.st_ && pos_ == it.pos_; }
91 friend class MathedRowContainer;
93 /// pointer to the container to which we belong
94 MathedRowContainer * st_;
95 /// position in this container, e.g. row number
101 iterator begin() { return iterator(this); }
103 bool empty() const { return data_.size() == 0; }
105 /// insert item before 'it'
106 void insert(iterator const & it) {
107 Assert(it.st_ == this);
108 data_.insert(data_.begin() + it.pos_, MathedRowStruct());
111 /// erase item pointed to by 'it'
112 void erase(iterator & it) {
113 Assert(it.st_ == this);
114 data_.erase(data_.begin() + it.pos_);
117 /// access to last item
118 MathedRowStruct & back() {
119 Assert(data_.size());
123 /// append empty element
125 data_.push_back(MathedRowStruct());
130 std::vector<MathedRowStruct> data_;
133 // currently unimplemented just to make sure it's not used
134 void operator=(MathedRowContainer const &); // unimplemented
140 string const & MathedRowStruct::getLabel() const
147 bool MathedRowStruct::isNumbered() const
154 int MathedRowStruct::getBaseline() const
161 void MathedRowStruct::setBaseline(int b)
168 int MathedRowStruct::ascent() const
175 int MathedRowStruct::descent() const
182 void MathedRowStruct::ascent(int a)
189 void MathedRowStruct::descent(int d)
196 int MathedRowStruct::getTab(unsigned int i) const
198 return i < widths_.size() ? widths_[i] : 0;
203 void MathedRowStruct::setLabel(string const & l)
210 void MathedRowStruct::setNumbered(bool nf)
217 void MathedRowStruct::setTab(unsigned int i, int t)
219 if (i >= widths_.size())
220 widths_.resize(i + 2);