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"
36 // Defines paragraph and position for the beginning of this row
37 void TexRow::start(LyXParagraph * 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()) {
79 RowList::iterator kit = rowlist.begin();
80 RowList::iterator end = rowlist.end();
81 // Increase the pos of all rows with the
82 // same id (and where the pos is larger)
83 // to avoid putting errorinsets at the
85 for (; kit != end; ++kit) {
86 if (&(*kit) != &(*cit)
87 && (*kit).id() == (*cit).id()
88 && (*kit).pos() >= (*cit).pos())
89 (*kit).pos((*kit).pos() + 1);
102 // should perhaps have a better name...
103 // Increase the pos of all rows with the
104 // same id (and where the pos is larger)
105 // to avoid putting errorinsets at the
107 void TexRow::increasePos(int id, int pos) const
109 RowList::iterator kit = rowlist.begin();
110 RowList::iterator end = rowlist.end();
111 for (; kit != end; ++kit) {
112 if (id == (*kit).id()
113 && pos < (*kit).pos()) {
114 (*kit).pos((*kit).pos() + 1);
116 << "TeXRow::increasePos: ideally this "
117 "should never happen..." << endl;
119 // When verified to work this clause should be deleted.
120 if (id == (*kit).id()
121 && pos == (*kit).pos()) {
123 << "TexRow::increasePos: this should happen "
124 "maximum one time for each run of "
125 "increasePos!" << endl;
131 TexRow & TexRow::operator+= (TexRow const & tr)
133 rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());