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::~InsetList()
33 // If we begin storing a shared_ptr in the List
34 // this code can be removed. (Lgb)
35 List::iterator it = list.begin();
36 List::iterator end = list.end();
37 for (; it != end; ++it) {
43 InsetList::iterator InsetList::begin()
49 InsetList::iterator InsetList::end()
55 InsetList::const_iterator InsetList::begin() const
61 InsetList::const_iterator InsetList::end() const
68 InsetList::insetIterator(pos_type pos)
70 InsetTable search_elem(pos, 0);
71 List::iterator it = lower_bound(list.begin(),
73 search_elem, MatchIt());
78 void InsetList::insert(Inset * inset, lyx::pos_type pos)
80 InsetTable search_elem(pos, 0);
81 List::iterator end = list.end();
82 List::iterator it = lower_bound(list.begin(),
84 search_elem, MatchIt());
85 if (it != end && it->pos == pos) {
86 lyxerr << "ERROR (InsetList::insert): "
87 << "There is an inset in position: " << pos << endl;
89 list.insert(it, InsetTable(pos, inset));
94 void InsetList::erase(pos_type pos)
96 InsetTable search_elem(pos, 0);
97 List::iterator end = list.end();
99 lower_bound(list.begin(),
101 search_elem, MatchIt());
102 if (it != end && it->pos == pos) {
109 Inset * InsetList::release(pos_type pos)
111 InsetTable search_elem(pos, 0);
112 List::iterator end = list.end();
114 lower_bound(list.begin(),
116 search_elem, MatchIt());
117 if (it != end && it->pos == pos) {
118 Inset * tmp = it->inset;
126 Inset * InsetList::get(pos_type pos) const
128 InsetTable search_elem(pos, 0);
129 List::const_iterator end = list.end();
130 List::const_iterator it =
131 lower_bound(list.begin(),
133 search_elem, MatchIt());
134 if (it != end && it->pos == pos)
140 void InsetList::increasePosAfterPos(pos_type pos)
142 InsetTable search_elem(pos, 0);
143 List::iterator end = list.end();
144 List::iterator it = lower_bound(list.begin(),
146 search_elem, MatchIt());
147 for (; it != end; ++it) {
153 void InsetList::decreasePosAfterPos(pos_type pos)
155 InsetTable search_elem(pos, 0);
156 List::iterator end = list.end();
157 List::iterator it = upper_bound(list.begin(),
159 search_elem, MatchIt());
160 for (; it != end; ++it) {
166 void InsetList::deleteInsetsLyXText(BufferView * bv)
168 List::iterator it = list.begin();
169 List::iterator end = list.end();
170 for (; it != end; ++it) {
172 if (it->inset->isTextInset()) {
173 static_cast<UpdatableInset*>
174 (it->inset)->deleteLyXText(bv, true);
181 void InsetList::resizeInsetsLyXText(BufferView * bv)
183 List::iterator it = list.begin();
184 List::iterator end = list.end();
185 for (; it != end; ++it) {
187 if (it->inset->isTextInset()) {
188 static_cast<UpdatableInset*>
189 (it->inset)->resizeLyXText(bv, true);