6 #include "insets/inset.h"
12 using std::lower_bound;
13 using std::upper_bound;
19 /// used by lower_bound and upper_bound
21 int operator()(InsetList::InsetTable const & a,
22 InsetList::InsetTable const & b) const {
30 InsetList::iterator::iterator(InsetList::List::iterator const & iter)
35 InsetList::iterator & InsetList::iterator::operator++()
42 InsetList::iterator InsetList::iterator::operator++(int)
50 pos_type InsetList::iterator::getPos() const
56 Inset * InsetList::iterator::getInset() const
62 void InsetList::iterator::setInset(Inset * inset)
68 InsetList::~InsetList()
70 // If we begin storing a shared_ptr in the List
71 // this code can be removed. (Lgb)
72 List::iterator it = list.begin();
73 List::iterator end = list.end();
74 for (; it != end; ++it) {
80 InsetList::iterator InsetList::begin()
82 return iterator(list.begin());
86 InsetList::iterator InsetList::end()
88 return iterator(list.end());
92 InsetList::iterator InsetList::begin() const
94 return iterator(const_cast<InsetList*>(this)->list.begin());
98 InsetList::iterator InsetList::end() const
100 return iterator(const_cast<InsetList*>(this)->list.end());
105 InsetList::insetIterator(pos_type pos)
107 InsetTable search_elem(pos, 0);
108 List::iterator it = lower_bound(list.begin(),
110 search_elem, MatchIt());
115 void InsetList::insert(Inset * inset, lyx::pos_type pos)
117 InsetTable search_elem(pos, 0);
118 List::iterator it = lower_bound(list.begin(),
120 search_elem, MatchIt());
121 if (it != list.end() && it->pos == pos) {
122 lyxerr << "ERROR (InsetList::insert): "
123 << "There is an inset in position: " << pos << endl;
125 list.insert(it, InsetTable(pos, inset));
130 void InsetList::erase(pos_type pos)
132 InsetTable search_elem(pos, 0);
134 lower_bound(list.begin(),
136 search_elem, MatchIt());
137 if (it != list.end() && it->pos == pos) {
144 Inset * InsetList::release(pos_type pos)
146 InsetTable search_elem(pos, 0);
148 lower_bound(list.begin(),
150 search_elem, MatchIt());
151 if (it != list.end() && it->pos == pos) {
152 Inset * tmp = it->inset;
160 Inset * InsetList::get(pos_type pos) const
162 InsetTable search_elem(pos, 0);
164 lower_bound(const_cast<InsetList*>(this)->list.begin(),
165 const_cast<InsetList*>(this)->list.end(),
166 search_elem, MatchIt());
167 if (it != const_cast<InsetList*>(this)->list.end() && it->pos == pos)
173 void InsetList::increasePosAfterPos(pos_type pos)
175 InsetTable search_elem(pos, 0);
176 List::iterator it = lower_bound(list.begin(),
178 search_elem, MatchIt());
179 List::iterator end = list.end();
180 for (; it != end; ++it) {
186 void InsetList::decreasePosAfterPos(pos_type pos)
188 InsetTable search_elem(pos, 0);
189 List::iterator end = list.end();
190 List::iterator it = upper_bound(list.begin(),
192 search_elem, MatchIt());
193 for (; it != end; ++it) {
199 void InsetList::deleteInsetsLyXText(BufferView * bv)
201 List::iterator it = list.begin();
202 List::iterator end = list.end();
203 for (; it != end; ++it) {
205 if (it->inset->isTextInset()) {
206 static_cast<UpdatableInset*>
207 (it->inset)->deleteLyXText(bv, true);
214 void InsetList::resizeInsetsLyXText(BufferView * bv)
216 List::iterator it = list.begin();
217 List::iterator end = list.end();
218 for (; it != end; ++it) {
220 if (it->inset->isTextInset()) {
221 static_cast<UpdatableInset*>
222 (it->inset)->resizeLyXText(bv, true);
230 bool operator==(InsetList::iterator const & i1,
231 InsetList::iterator const & i2)
233 return i1.it == i2.it;
238 bool operator!=(InsetList::iterator const & i1,
239 InsetList::iterator const & i2)