3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Martin Vermeer
9 * Full author contact details are available in file CREDITS.
14 #include "InsetList.h"
17 #include "BufferParams.h"
18 #include "BranchList.h"
19 #include "support/debug.h"
21 #include "insets/InsetBranch.h"
30 typedef InsetList::InsetTable Table;
32 struct InsetTablePosLess
34 bool operator()(Table const & t1, Table const & t2) const
36 return t1.pos < t2.pos;
44 InsetList::~InsetList()
46 // If we begin storing a shared_ptr in the List
47 // this code can be removed. (Lgb)
48 List::iterator it = list_.begin();
49 List::iterator end = list_.end();
50 for (; it != end; ++it) {
56 InsetList::iterator InsetList::insetIterator(pos_type pos)
58 InsetTable search_elem(pos, 0);
59 return lower_bound(list_.begin(), list_.end(), search_elem,
64 InsetList::const_iterator InsetList::insetIterator(pos_type pos) const
66 InsetTable search_elem(pos, 0);
67 return lower_bound(list_.begin(), list_.end(), search_elem,
72 void InsetList::insert(Inset * inset, pos_type pos)
74 List::iterator end = list_.end();
75 List::iterator it = insetIterator(pos);
76 if (it != end && it->pos == pos) {
77 LYXERR0("ERROR (InsetList::insert): "
78 << "There is an inset in position: " << pos);
80 list_.insert(it, InsetTable(pos, inset));
85 void InsetList::erase(pos_type pos)
87 List::iterator end = list_.end();
88 List::iterator it = insetIterator(pos);
89 if (it != end && it->pos == pos) {
96 Inset * InsetList::release(pos_type pos)
98 List::iterator end = list_.end();
99 List::iterator it = insetIterator(pos);
100 if (it != end && it->pos == pos) {
101 Inset * tmp = it->inset;
109 Inset * InsetList::get(pos_type pos) const
111 List::const_iterator end = list_.end();
112 List::const_iterator it = insetIterator(pos);
113 if (it != end && it->pos == pos)
119 void InsetList::increasePosAfterPos(pos_type pos)
121 List::iterator end = list_.end();
122 List::iterator it = insetIterator(pos);
123 for (; it != end; ++it) {
129 void InsetList::decreasePosAfterPos(pos_type pos)
131 List::iterator end = list_.end();
132 List::iterator it = insetIterator(pos);
133 for (; it != end; ++it) {
139 InsetList::InsetList(InsetList const & il)
142 List::iterator it = list_.begin();
143 List::iterator end = list_.end();
144 for (; it != end; ++it)
145 it->inset = it->inset->clone();
149 pos_type InsetList::find(InsetCode code, pos_type startpos) const
151 List::const_iterator it = insetIterator(startpos);
152 List::const_iterator end = list_.end();
153 for (; it != end ; ++it) {
154 if (it->inset->lyxCode() == code)
161 int InsetList::count(InsetCode code, pos_type startpos) const
164 List::const_iterator it = insetIterator(startpos);
165 List::const_iterator end = list_.end();
166 for (; it != end ; ++it) {
167 if (it->inset->lyxCode() == code)