]> git.lyx.org Git - lyx.git/blobdiff - src/TexRow.h
compilation fix for Qt 4.5
[lyx.git] / src / TexRow.h
index 0dea3d158dcf2d6141ac5f6f09de822abca2395c..a4edc6c544113b8ab6a4cf3f1c5969d20eba2ae5 100644 (file)
@@ -5,7 +5,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Matthias Ettrich
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
  * \author John Levon
  *
  * Full author contact details are available in file CREDITS.
 #ifndef TEXROW_H
 #define TEXROW_H
 
-#include <list>
+#include <vector>
 
 
 namespace lyx {
 
 
 /// Represents the correspondence between paragraphs and the generated
-//LaTeX file
+//LaTeX file
 
 class TexRow {
 public:
        ///
-       TexRow() : count(0), lastid(-1), lastpos(-1) {}
-
-       TexRow & operator+= (TexRow const &);
+       TexRow() : lastid(-1), lastpos(-1), started(false) {}
 
        /// Clears structure
        void reset();
@@ -39,6 +37,9 @@ public:
        /// Insert node when line is completed
        void newline();
 
+       /// Insert multiple nodes when zero or more lines are completed
+       void newlines(int num_lines);
+
        /**
         * getIdFromRow - find pid and position for a given row
         * @param row row number to find
@@ -51,14 +52,22 @@ public:
         */
        bool getIdFromRow(int row, int & id, int & pos) const;
 
+       /**
+        * getRowFromIdPos - find row containing a given id and pos
+        * @param id of the paragraph
+        * @param pos a given position in that paragraph
+        * @return the row number within the rowlist
+        */
+       int getRowFromIdPos(int id, int pos) const;
+       
        /// Returns the number of rows contained
-       int rows() const { return count; }
+       int rows() const { return rowlist.size(); }
 
        /// an individual id/pos <=> row mapping
        class RowItem {
        public:
-               RowItem(int id, int pos, int row)
-                       : id_(id), pos_(pos), rownumber_(row)
+               RowItem(int id, int pos)
+                       : id_(id), pos_(pos)
                {}
 
                /// paragraph id
@@ -67,25 +76,22 @@ public:
                void pos(int p) { pos_ = p; }
                /// paragraph position
                int pos() const { return pos_; }
-               /// row number
-               int rownumber() const { return rownumber_; }
        private:
                RowItem();
                int id_;
                int pos_;
-               int rownumber_;
        };
        ///
-       typedef std::list<RowItem> RowList;
+       typedef std::vector<RowItem> RowList;
 private:
-       /// number of lines
-       unsigned int count;
        /// container of id/pos <=> row mapping
        RowList rowlist;
        /// Last paragraph
        int lastid;
        /// Last position
        int lastpos;
+       /// Is id/pos already registered for current row?
+       bool started;
 };