2002-05-30 03:37:24 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file TexRow.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2002-05-30 03:37:24 +00:00
|
|
|
|
* \author Matthias Ettrich
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-05-30 03:37:24 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "TexRow.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-09-05 22:17:02 +00:00
|
|
|
|
#include <algorithm>
|
2003-05-07 21:27:29 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2000-08-05 05:17:18 +00:00
|
|
|
|
using std::find_if;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
|
namespace {
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
|
/// function object returning true when row number is found
|
|
|
|
|
class same_rownumber {
|
|
|
|
|
public:
|
|
|
|
|
same_rownumber(int row) : row_(row) {}
|
|
|
|
|
bool operator()(TexRow::RowList::value_type const & vt) const {
|
|
|
|
|
return vt.rownumber() == row_;
|
|
|
|
|
}
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
|
private:
|
|
|
|
|
int row_;
|
|
|
|
|
};
|
|
|
|
|
|
2002-12-01 22:59:25 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void TexRow::reset()
|
|
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
|
rowlist.clear();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
count = 0;
|
2003-05-07 21:27:29 +00:00
|
|
|
|
lastid = -1;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
lastpos = -1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
2003-05-07 21:27:29 +00:00
|
|
|
|
void TexRow::start(int id, int pos)
|
1999-11-22 16:19:48 +00:00
|
|
|
|
{
|
2003-05-07 21:27:29 +00:00
|
|
|
|
lastid = id;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
lastpos = pos;
|
|
|
|
|
}
|
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void TexRow::newline()
|
|
|
|
|
{
|
2003-05-07 21:27:29 +00:00
|
|
|
|
int const id = lastid;
|
2002-05-30 03:37:24 +00:00
|
|
|
|
RowList::value_type tmp(id, lastpos, ++count);
|
1999-11-22 16:19:48 +00:00
|
|
|
|
rowlist.push_back(tmp);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-08-05 05:17:18 +00:00
|
|
|
|
bool TexRow::getIdFromRow(int row, int & id, int & pos) const
|
|
|
|
|
{
|
|
|
|
|
RowList::const_iterator cit =
|
2002-12-01 22:59:25 +00:00
|
|
|
|
find_if(rowlist.begin(), rowlist.end(),
|
2002-05-30 03:37:24 +00:00
|
|
|
|
same_rownumber(row));
|
2002-12-01 22:59:25 +00:00
|
|
|
|
|
2000-08-05 05:17:18 +00:00
|
|
|
|
if (cit != rowlist.end()) {
|
2001-07-12 11:11:10 +00:00
|
|
|
|
id = cit->id();
|
|
|
|
|
pos = cit->pos();
|
2000-08-05 05:17:18 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
id = -1;
|
|
|
|
|
pos = 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
|
TexRow & TexRow::operator+=(TexRow const & tr)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
|
rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
return *this;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|