3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
6 * \author Matthias Ettrich
14 #pragma implementation
18 #include "paragraph.h"
27 /// function object returning true when row number is found
28 class same_rownumber {
30 same_rownumber(int row) : row_(row) {}
31 bool operator()(TexRow::RowList::value_type const & vt) const {
32 return vt.rownumber() == row_;
40 /// increment the pos value of the argument if the par id
41 /// is the same, and the pos parameter is larger
44 increase_pos(int id, int pos)
45 : id_(id), pos_(pos) {}
47 void operator()(TexRow::RowList::value_type & vt) const {
48 if (vt.id() != id_ || vt.pos() >= pos_)
53 << "TeXRow::increasePos: ideally this "
54 "should never happen..." << endl;
56 // FIXME: When verified to work this clause should be deleted.
57 if (id_ == vt.id() && pos_ == vt.pos()) {
59 << "TexRow::increasePos: this should happen "
60 "maximum one time for each run of "
61 "increasePos!" << endl;
82 void TexRow::start(Paragraph * par, int pos)
89 void TexRow::newline()
91 int const id = lastpar ? lastpar->id() : -1;
92 RowList::value_type tmp(id, lastpos, ++count);
93 rowlist.push_back(tmp);
97 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
99 RowList::const_iterator cit =
100 find_if(rowlist.begin(), rowlist.end(),
101 same_rownumber(row));
103 if (cit != rowlist.end()) {
114 void TexRow::increasePos(int id, int pos)
116 RowList::iterator it = rowlist.begin();
117 RowList::iterator end = rowlist.end();
118 for_each(it, end, increase_pos(id, pos));
122 TexRow & TexRow::operator+=(TexRow const & tr)
124 rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());