1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Matthias Ettrich
|
1999-10-07 18:44:17 +00:00
|
|
|
* Copyright (C) 1995-1999 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "texrow.h"
|
|
|
|
#include "lyxparagraph.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Delete linked list
|
|
|
|
void TexRow::reset()
|
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
rowlist.clear();
|
1999-09-27 18:44:28 +00:00
|
|
|
count = 0;
|
|
|
|
lastpar = 0;
|
|
|
|
lastpos = -1;
|
|
|
|
}
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Defines paragraph and position for the beginning of this row
|
1999-11-22 16:19:48 +00:00
|
|
|
void TexRow::start(LyXParagraph * par, int pos)
|
|
|
|
{
|
1999-09-27 18:44:28 +00:00
|
|
|
lastpar = par;
|
|
|
|
lastpos = pos;
|
|
|
|
}
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Insert node when line is completed
|
|
|
|
void TexRow::newline()
|
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
RowItem tmp;
|
|
|
|
tmp.pos = lastpos;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lastpar)
|
1999-11-22 16:19:48 +00:00
|
|
|
tmp.id = lastpar->id();
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
1999-11-22 16:19:48 +00:00
|
|
|
tmp.id = -1;
|
|
|
|
tmp.rownumber = ++count;
|
|
|
|
rowlist.push_back(tmp);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
void TexRow::getIdFromRow(int row, int & id, int & pos)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
RowList::const_iterator cit = rowlist.begin();
|
|
|
|
for (; cit != rowlist.end(); ++cit) {
|
|
|
|
if ((*cit).rownumber == row) break;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-22 16:19:48 +00:00
|
|
|
if (cit != rowlist.end()) {
|
|
|
|
RowList::iterator kit = rowlist.begin();
|
1999-09-27 18:44:28 +00:00
|
|
|
// Increase the pos of all rows with the
|
|
|
|
// same id (and where the pos is larger)
|
|
|
|
// to avoid putting errorinsets at the
|
|
|
|
// same pos.
|
1999-11-22 16:19:48 +00:00
|
|
|
for(; kit != rowlist.end(); ++kit) {
|
|
|
|
if (&(*kit) != &(*cit)
|
|
|
|
&& (*kit).id == (*cit).id
|
|
|
|
&& (*kit).pos >= (*cit).pos)
|
|
|
|
(*kit).pos++;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
id = -1;
|
|
|
|
pos = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-22 16:19:48 +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;
|
|
|
|
}
|