]> git.lyx.org Git - lyx.git/blob - src/TexRow.h
getting rid of more superfluous lyx::support:: statements.
[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 <vector>
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() : lastid(-1), lastpos(-1) {}
30
31         /// Clears structure
32         void reset();
33
34         /// Define what paragraph and position the next row will represent
35         void start(int id, int pos);
36
37         /// Insert node when line is completed
38         void newline();
39
40         /**
41          * getIdFromRow - find pid and position for a given row
42          * @param row row number to find
43          * @param id set to id if found
44          * @param pos set to paragraph position if found
45          * @return true if found, false otherwise
46          *
47          * If the row could not be found, pos is set to zero and
48          * id is set to -1
49          */
50         bool getIdFromRow(int row, int & id, int & pos) const;
51
52         /**
53          * getRowFromIdPos - find row containing a given id and pos
54          * @param id of the paragraph
55          * @param pos a given position in that paragraph
56          * @return the row number within the rowlist
57          */
58         int getRowFromIdPos(int id, int pos) const;
59         
60         /// Returns the number of rows contained
61         int rows() const { return rowlist.size(); }
62
63         /// an individual id/pos <=> row mapping
64         class RowItem {
65         public:
66                 RowItem(int id, int pos)
67                         : id_(id), pos_(pos)
68                 {}
69
70                 /// paragraph id
71                 int id() const { return id_; }
72                 /// set paragraph position
73                 void pos(int p) { pos_ = p; }
74                 /// paragraph position
75                 int pos() const { return pos_; }
76         private:
77                 RowItem();
78                 int id_;
79                 int pos_;
80         };
81         ///
82         typedef std::vector<RowItem> RowList;
83 private:
84         /// container of id/pos <=> row mapping
85         RowList rowlist;
86         /// Last paragraph
87         int lastid;
88         /// Last position
89         int lastpos;
90 };
91
92
93 } // namespace lyx
94
95 #endif // TEXROW_H