1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-05-30 03:37:24 +00:00
|
|
|
/**
|
|
|
|
* \file texrow.h
|
|
|
|
* Copyright 1995-2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2002-05-30 03:37:24 +00:00
|
|
|
* \author Matthias Ettrich
|
|
|
|
*/
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef TEXROW_H
|
|
|
|
#define TEXROW_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
#include <list>
|
2000-03-28 02:18:55 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
class Paragraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
/// Represents the correspondence between paragraphs and the generated LaTeX file
|
1999-09-27 18:44:28 +00:00
|
|
|
class TexRow {
|
|
|
|
public:
|
|
|
|
///
|
2000-06-08 23:16:16 +00:00
|
|
|
TexRow() : count(0), lastpar(0), lastpos(-1) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Clears structure
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
/// Define what paragraph and position the next row will represent
|
2001-06-25 00:06:33 +00:00
|
|
|
void start(Paragraph * par, int pos);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Insert node when line is completed
|
|
|
|
void newline();
|
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
/**
|
|
|
|
* getIdFromRow - find pid and position for a given row
|
|
|
|
* @param row row number to find
|
|
|
|
* @param id set to id if found
|
|
|
|
* @param pos set to paragraph position if found
|
|
|
|
* @return true if found, false otherwise
|
|
|
|
*
|
|
|
|
* If the row could not be found, pos is set to zero and
|
|
|
|
* id is set to -1
|
|
|
|
*/
|
2000-08-05 05:17:18 +00:00
|
|
|
bool getIdFromRow(int row, int & id, int & pos) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
TexRow & operator+= (TexRow const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
/// Returns the number of rows contained
|
2000-06-08 23:16:16 +00:00
|
|
|
int rows() const { return count; }
|
2000-05-04 08:14:34 +00:00
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
/// an individual id/pos <=> row mapping
|
2000-06-08 23:16:16 +00:00
|
|
|
class RowItem {
|
|
|
|
public:
|
2002-12-01 22:59:25 +00:00
|
|
|
RowItem(int id, int pos, int row)
|
2002-05-30 03:37:24 +00:00
|
|
|
: id_(id), pos_(pos), rownumber_(row)
|
|
|
|
{}
|
|
|
|
|
|
|
|
/// paragraph id
|
2000-06-08 23:16:16 +00:00
|
|
|
int id() const {
|
|
|
|
return id_;
|
|
|
|
}
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
/// set paragraph position
|
2000-06-08 23:16:16 +00:00
|
|
|
void pos(int p) {
|
|
|
|
pos_ = p;
|
|
|
|
}
|
2002-05-30 03:37:24 +00:00
|
|
|
|
|
|
|
/// paragraph position
|
2000-06-08 23:16:16 +00:00
|
|
|
int pos() const {
|
|
|
|
return pos_;
|
|
|
|
}
|
2002-05-30 03:37:24 +00:00
|
|
|
|
|
|
|
/// row number
|
2000-06-08 23:16:16 +00:00
|
|
|
int rownumber() const {
|
|
|
|
return rownumber_;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
int id_;
|
|
|
|
int pos_;
|
|
|
|
int rownumber_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
typedef std::list<RowItem> RowList;
|
2002-05-30 03:37:24 +00:00
|
|
|
/// increment position of all other RowItems
|
|
|
|
/// with same par id, to avoid placing error insets
|
|
|
|
/// at the same position
|
|
|
|
void increasePos(int id, int pos);
|
2000-08-05 05:17:18 +00:00
|
|
|
private:
|
2002-05-30 03:37:24 +00:00
|
|
|
/// number of lines
|
2000-08-05 05:17:18 +00:00
|
|
|
unsigned int count;
|
2002-05-30 03:37:24 +00:00
|
|
|
/// container of id/pos <=> row mapping
|
|
|
|
RowList rowlist;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Last paragraph
|
2001-06-25 00:06:33 +00:00
|
|
|
Paragraph * lastpar;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Last position
|
|
|
|
int lastpos;
|
|
|
|
};
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-05-30 03:37:24 +00:00
|
|
|
#endif // TEXROW_H
|