6 #include "insets/updatableinset.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
31 InsetList::iterator::iterator(InsetList::List::iterator const & iter)
36 InsetList::iterator & InsetList::iterator::operator++()
43 InsetList::iterator InsetList::iterator::operator++(int)
51 pos_type InsetList::iterator::getPos() const
57 Inset * InsetList::iterator::getInset() const
63 void InsetList::iterator::setInset(Inset * inset)
69 InsetList::~InsetList()
71 // If we begin storing a shared_ptr in the List
72 // this code can be removed. (Lgb)
73 List::iterator it = list.begin();
74 List::iterator end = list.end();
75 for (; it != end; ++it) {
81 InsetList::iterator InsetList::begin()
83 return iterator(list.begin());
87 InsetList::iterator InsetList::end()
89 return iterator(list.end());
93 InsetList::iterator InsetList::begin() const
95 return iterator(const_cast<InsetList*>(this)->list.begin());
99 InsetList::iterator InsetList::end() const
101 return iterator(const_cast<InsetList*>(this)->list.end());
106 InsetList::insetIterator(pos_type pos)
108 InsetTable search_elem(pos, 0);
109 List::iterator it = lower_bound(list.begin(),
111 search_elem, MatchIt());
116 void InsetList::insert(Inset * inset, lyx::pos_type pos)
118 InsetTable search_elem(pos, 0);
119 List::iterator it = lower_bound(list.begin(),
121 search_elem, MatchIt());
122 if (it != list.end() && it->pos == pos) {
123 lyxerr << "ERROR (InsetList::insert): "
124 << "There is an inset in position: " << pos << endl;
126 list.insert(it, InsetTable(pos, inset));
131 void InsetList::erase(pos_type pos)
133 InsetTable search_elem(pos, 0);
135 lower_bound(list.begin(),
137 search_elem, MatchIt());
138 if (it != list.end() && it->pos == pos) {
145 Inset * InsetList::release(pos_type pos)
147 InsetTable search_elem(pos, 0);
149 lower_bound(list.begin(),
151 search_elem, MatchIt());
152 if (it != list.end() && it->pos == pos) {
153 Inset * tmp = it->inset;
161 Inset * InsetList::get(pos_type pos) const
163 InsetTable search_elem(pos, 0);
165 lower_bound(const_cast<InsetList*>(this)->list.begin(),
166 const_cast<InsetList*>(this)->list.end(),
167 search_elem, MatchIt());
168 if (it != const_cast<InsetList*>(this)->list.end() && it->pos == pos)
174 void InsetList::increasePosAfterPos(pos_type pos)
176 InsetTable search_elem(pos, 0);
177 List::iterator it = lower_bound(list.begin(),
179 search_elem, MatchIt());
180 List::iterator end = list.end();
181 for (; it != end; ++it) {
187 void InsetList::decreasePosAfterPos(pos_type pos)
189 InsetTable search_elem(pos, 0);
190 List::iterator end = list.end();
191 List::iterator it = upper_bound(list.begin(),
193 search_elem, MatchIt());
194 for (; it != end; ++it) {
200 void InsetList::deleteInsetsLyXText(BufferView * bv)
202 List::iterator it = list.begin();
203 List::iterator end = list.end();
204 for (; it != end; ++it) {
206 if (it->inset->isTextInset()) {
207 static_cast<UpdatableInset*>
208 (it->inset)->deleteLyXText(bv, true);
215 void InsetList::resizeInsetsLyXText(BufferView * bv)
217 List::iterator it = list.begin();
218 List::iterator end = list.end();
219 for (; it != end; ++it) {
221 if (it->inset->isTextInset()) {
222 static_cast<UpdatableInset*>
223 (it->inset)->resizeLyXText(bv, true);
231 bool operator==(InsetList::iterator const & i1,
232 InsetList::iterator const & i2)
234 return i1.it == i2.it;
239 bool operator!=(InsetList::iterator const & i1,
240 InsetList::iterator const & i2)