4 #include "BufferView.h"
8 #include "insets/updatableinset.h"
9 #include "insets/insetbranch.h"
15 using std::lower_bound;
16 using std::upper_bound;
22 /// used by lower_bound and upper_bound
24 int operator()(InsetList::InsetTable const & a,
25 InsetList::InsetTable const & b) const
34 InsetList::~InsetList()
36 // If we begin storing a shared_ptr in the List
37 // this code can be removed. (Lgb)
38 List::iterator it = list.begin();
39 List::iterator end = list.end();
40 for (; it != end; ++it) {
46 InsetList::iterator InsetList::begin()
52 InsetList::iterator InsetList::end()
58 InsetList::const_iterator InsetList::begin() const
64 InsetList::const_iterator InsetList::end() const
71 InsetList::insetIterator(pos_type pos)
73 InsetTable search_elem(pos, 0);
74 List::iterator it = lower_bound(list.begin(),
76 search_elem, MatchIt());
81 void InsetList::insert(InsetOld * inset, lyx::pos_type pos)
83 InsetTable search_elem(pos, 0);
84 List::iterator end = list.end();
85 List::iterator it = lower_bound(list.begin(),
87 search_elem, MatchIt());
88 if (it != end && it->pos == pos) {
89 lyxerr << "ERROR (InsetList::insert): "
90 << "There is an inset in position: " << pos << endl;
92 list.insert(it, InsetTable(pos, inset));
97 void InsetList::erase(pos_type pos)
99 InsetTable search_elem(pos, 0);
100 List::iterator end = list.end();
102 lower_bound(list.begin(),
104 search_elem, MatchIt());
105 if (it != end && it->pos == pos) {
112 InsetOld * InsetList::release(pos_type pos)
114 InsetTable search_elem(pos, 0);
115 List::iterator end = list.end();
117 lower_bound(list.begin(),
119 search_elem, MatchIt());
120 if (it != end && it->pos == pos) {
121 InsetOld * tmp = it->inset;
129 InsetOld * InsetList::get(pos_type pos) const
131 InsetTable search_elem(pos, 0);
132 List::const_iterator end = list.end();
133 List::const_iterator it =
134 lower_bound(list.begin(),
136 search_elem, MatchIt());
137 if (it != end && it->pos == pos)
143 void InsetList::increasePosAfterPos(pos_type pos)
145 InsetTable search_elem(pos, 0);
146 List::iterator end = list.end();
147 List::iterator it = lower_bound(list.begin(),
149 search_elem, MatchIt());
150 for (; it != end; ++it) {
156 void InsetList::decreasePosAfterPos(pos_type pos)
158 InsetTable search_elem(pos, 0);
159 List::iterator end = list.end();
160 List::iterator it = upper_bound(list.begin(),
162 search_elem, MatchIt());
163 for (; it != end; ++it) {
169 void InsetList::deleteInsetsLyXText(BufferView * bv)
171 List::iterator it = list.begin();
172 List::iterator end = list.end();
173 for (; it != end; ++it) {
175 if (it->inset->isTextInset()) {
176 static_cast<UpdatableInset*>
177 (it->inset)->deleteLyXText(bv, true);
184 void InsetList::insetsOpenCloseBranch(BufferView * bv)
186 BufferParams bp = bv->buffer()->params;
187 List::iterator it = list.begin();
188 List::iterator end = list.end();
189 for (; it != end; ++it) {
190 if (it->inset && it->inset->lyxCode() == InsetOld::BRANCH_CODE) {
191 InsetBranch * inset = static_cast<InsetBranch *>(it->inset);
192 if (bp.branchlist.selected(inset->params().branch)) {