]> git.lyx.org Git - lyx.git/blob - src/texrow.h
fix compilation bug
[lyx.git] / src / texrow.h
1 // -*- C++ -*-
2 /**
3  * \file texrow.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author Matthias Ettrich
8  */
9
10
11 #ifndef TEXROW_H
12 #define TEXROW_H
13
14 #include <list>
15
16 class Paragraph;
17
18 /// Represents the correspondence between paragraphs and the generated LaTeX file
19 class TexRow {
20 public:
21         ///
22         TexRow() : count(0), lastpar(0), lastpos(-1) {}
23
24         /// Clears structure
25         void reset();
26
27         /// Define what paragraph and position the next row will represent
28         void start(Paragraph * par, int pos);
29
30         /// Insert node when line is completed
31         void newline();
32
33         /**
34          * getIdFromRow - find pid and position for a given row
35          * @param row row number to find
36          * @param id set to id if found
37          * @param pos set to paragraph position if found
38          * @return true if found, false otherwise
39          *
40          * If the row could not be found, pos is set to zero and
41          * id is set to -1
42          */
43         bool getIdFromRow(int row, int & id, int & pos) const;
44
45         TexRow & operator+= (TexRow const &);
46
47         /// Returns the number of rows contained
48         int rows() const { return count; }
49
50         /// an individual id/pos <=> row mapping
51         class RowItem {
52         public:
53                 RowItem(int id, int pos, int row)
54                         : id_(id), pos_(pos), rownumber_(row)
55                 {}
56
57                 /// paragraph id
58                 int id() const {
59                         return id_;
60                 }
61
62                 /// set paragraph position
63                 void pos(int p) {
64                         pos_ = p;
65                 }
66
67                 /// paragraph position
68                 int pos() const {
69                         return pos_;
70                 }
71
72                 /// row number
73                 int rownumber() const {
74                         return rownumber_;
75                 }
76         private:
77                 int id_;
78                 int pos_;
79                 int rownumber_;
80         };
81         ///
82         typedef std::list<RowItem> RowList;
83         /// increment position of all other RowItems
84         /// with same par id, to avoid placing error insets
85         /// at the same position
86         void increasePos(int id, int pos);
87 private:
88         /// number of lines
89         unsigned int count;
90         /// container of id/pos <=> row mapping
91         RowList rowlist;
92         /// Last paragraph
93         Paragraph * lastpar;
94         /// Last position
95         int lastpos;
96 };
97
98 #endif // TEXROW_H