1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
16 #pragma implementation
20 #include "lyxparagraph.h"
35 // Defines paragraph and position for the beginning of this row
36 void TexRow::start(LyXParagraph * par, int pos)
43 // Insert node when line is completed
44 void TexRow::newline()
49 tmp.id(lastpar->id());
52 tmp.rownumber(++count);
53 rowlist.push_back(tmp);
57 class same_rownumber {
59 same_rownumber(TexRow::RowList::value_type const & v):vt(v){}
60 bool operator()(TexRow::RowList::value_type const & vt1) const {
61 return vt.rownumber() == vt1.rownumber();
64 TexRow::RowList::value_type const & vt;
69 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
71 RowList::value_type vt;
73 RowList::const_iterator cit =
74 find_if(rowlist.begin(), rowlist.end(), same_rownumber(vt));
76 if (cit != rowlist.end()) {
78 RowList::iterator kit = rowlist.begin();
79 RowList::iterator end = rowlist.end();
80 // Increase the pos of all rows with the
81 // same id (and where the pos is larger)
82 // to avoid putting errorinsets at the
84 for(; kit != end; ++kit) {
85 if (&(*kit) != &(*cit)
86 && (*kit).id() == (*cit).id()
87 && (*kit).pos() >= (*cit).pos())
88 (*kit).pos((*kit).pos() + 1);
101 // should perhaps have a better name...
102 // Increase the pos of all rows with the
103 // same id (and where the pos is larger)
104 // to avoid putting errorinsets at the
106 void TexRow::increasePos(int id, int pos) const
108 RowList::iterator kit = rowlist.begin();
109 RowList::iterator end = rowlist.end();
110 for(; kit != end; ++kit) {
111 if (id == (*kit).id()
112 && pos < (*kit).pos()) {
113 (*kit).pos((*kit).pos() + 1);
114 lyxerr << "TeXRow::increasePos: ideally this "
115 "should never happen..." << endl;
117 // When verified to work this clause should be deleted.
118 if (id == (*kit).id()
119 && pos == (*kit).pos()) {
120 lyxerr << "TexRow::increasePos: this should happen "
121 "maximum one time for each run of "
122 "increasePos!" << endl;
128 TexRow & TexRow::operator+= (TexRow const & tr)
130 rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());