1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
16 #pragma implementation
20 #include "paragraph.h"
36 // Defines paragraph and position for the beginning of this row
37 void TexRow::start(Paragraph * par, int pos)
44 // Insert node when line is completed
45 void TexRow::newline()
50 tmp.id(lastpar->id());
53 tmp.rownumber(++count);
54 rowlist.push_back(tmp);
58 class same_rownumber {
60 same_rownumber(TexRow::RowList::value_type const & v):vt(v){}
61 bool operator()(TexRow::RowList::value_type const & vt1) const {
62 return vt.rownumber() == vt1.rownumber();
65 TexRow::RowList::value_type const & vt;
70 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
72 RowList::value_type vt;
74 RowList::const_iterator cit =
75 find_if(rowlist.begin(), rowlist.end(), same_rownumber(vt));
77 if (cit != rowlist.end()) {
88 // should perhaps have a better name...
89 // Increase the pos of all rows with the
90 // same id (and where the pos is larger)
91 // to avoid putting errorinsets at the
93 void TexRow::increasePos(int id, int pos) const
95 RowList::iterator kit = rowlist.begin();
96 RowList::iterator end = rowlist.end();
97 for (; kit != end; ++kit) {
99 && pos < kit->pos()) {
100 kit->pos(kit->pos() + 1);
102 << "TeXRow::increasePos: ideally this "
103 "should never happen..." << endl;
105 // When verified to work this clause should be deleted.
107 && pos == kit->pos()) {
109 << "TexRow::increasePos: this should happen "
110 "maximum one time for each run of "
111 "increasePos!" << endl;
117 TexRow & TexRow::operator+= (TexRow const & tr)
119 rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());