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