]> git.lyx.org Git - lyx.git/blobdiff - src/texrow.h
move definition of variables to the main cmake file
[lyx.git] / src / texrow.h
index 8db0533603f5f5e8d13a6841eb937ea5ea86d9e0..ba80acb58a47135ad8aa04dabbd25536028ad5f7 100644 (file)
@@ -1,80 +1,96 @@
 // -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- * 
- *           LyX, The Document Processor
- *      
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team
+/**
+ * \file texrow.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * ====================================================== */
+ * \author Matthias Ettrich
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
+ */
 
 #ifndef TEXROW_H
 #define TEXROW_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
-
 #include <list>
 
-class LyXParagraph;
 
-// Controls correspondance between paragraphs and the generated LaTeX file
+/// Represents the correspondence between paragraphs and the generated LaTeX file
 class TexRow {
 public:
        ///
-       TexRow() {
-               count = 0;
-               lastpar = 0;
-               lastpos = -1;
-       }
+       TexRow() : count(0), lastid(-1), lastpos(-1) {}
+
+       TexRow & operator+= (TexRow const &);
 
        /// Clears structure
        void reset();
 
        /// Define what paragraph and position the next row will represent
-       void start(LyXParagraph * par, int pos);
+       void start(int id, int pos);
 
        /// Insert node when line is completed
        void newline();
 
-       /// Returns paragraph id and position from a row number
-       void getIdFromRow(int row, int & id, int & pos);
+       /**
+        * 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
+        */
+       bool getIdFromRow(int row, int & id, int & pos) const;
 
-       /// Appends another TexRow
-       TexRow & operator+= (TexRow const &);
+       /// Returns the number of rows contained
+       int rows() const { return count; }
 
-       /// Returns the number of rows in this texrow
-       int rows() { return count; }
+       /// an individual id/pos <=> row mapping
+       class RowItem {
+       public:
+               RowItem(int id, int pos, int row)
+                       : id_(id), pos_(pos), rownumber_(row)
+               {}
 
-private:
-       /// Linked list of items
-       struct RowItem {
-               ///
-               RowItem() {
-                       id = -1;
-                       pos = -1;
-                       rownumber = 0;
+               /// paragraph id
+               int id() const {
+                       return id_;
+               }
+
+               /// set paragraph position
+               void pos(int p) {
+                       pos_ = p;
                }
 
-               ///
-               int id;
-               ///
-               int pos;
-               ///
-               int rownumber;
+               /// paragraph position
+               int pos() const {
+                       return pos_;
+               }
+
+               /// row number
+               int rownumber() const {
+                       return rownumber_;
+               }
+       private:
+               int id_;
+               int pos_;
+               int rownumber_;
        };
        ///
-       unsigned int count;
-       ///
        typedef std::list<RowItem> RowList;
-       ///
+private:
+       /// number of lines
+       unsigned int count;
+       /// container of id/pos <=> row mapping
        RowList rowlist;
        /// Last paragraph
-       LyXParagraph * lastpar;
+       int lastid;
        /// Last position
        int lastpos;
-       
 };
-#endif
+
+#endif // TEXROW_H