]> git.lyx.org Git - lyx.git/blobdiff - src/texrow.h
more code in the menu backend == less code in the menu frontends; add support for...
[lyx.git] / src / texrow.h
index 2013ff1a2ca44a7b09dffa5c7e48ef5a80bacfce..2ee432f6af84aac3d18de945518016e00c4bf3d6 100644 (file)
@@ -1,26 +1,21 @@
 // -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- * 
- *           LyX, The Document Processor
- *      
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team
+/**
+ * \file texrow.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
  *
- * ====================================================== */
+ * \author Matthias Ettrich
+ */
+
 
 #ifndef TEXROW_H
 #define TEXROW_H
 
-#ifdef __GNUG__
-#pragma interface
-#endif
-
 #include <list>
 
-class LyXParagraph;
+class Paragraph;
 
-// Controls correspondance between paragraphs and the generated LaTeX file
+/// Represents the correspondence between paragraphs and the generated LaTeX file
 class TexRow {
 public:
        ///
@@ -30,68 +25,74 @@ public:
        void reset();
 
        /// Define what paragraph and position the next row will represent
-       void start(LyXParagraph * par, int pos);
+       void start(Paragraph * par, 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 in this texrow
+       /// Returns the number of rows contained
        int rows() const { return count; }
 
-private:
-       /// Linked list of items
+       /// an individual id/pos <=> row mapping
        class RowItem {
        public:
-               ///
-               RowItem() : id_(-1), pos_(-1), rownumber_(0) {}
-               ///
-               void id(int i) {
-                       id_ = i;
-               }
-               ///
+               RowItem(int id, int pos, int row)
+                       : id_(id), pos_(pos), rownumber_(row)
+               {}
+
+               /// paragraph id
                int id() const {
                        return id_;
                }
-               ///
+
+               /// set paragraph position
                void pos(int p) {
                        pos_ = p;
                }
-               ///
+
+               /// paragraph position
                int pos() const {
                        return pos_;
                }
-               ///
-               void rownumber(int r) {
-                       rownumber_ = r;
-               }
-               ///
+
+               /// row number
                int rownumber() const {
                        return rownumber_;
                }
        private:
-               ///
                int id_;
-               ///
                int pos_;
-               ///
                int rownumber_;
        };
        ///
-       unsigned int count;
-       ///
        typedef std::list<RowItem> RowList;
-       ///
+       /// increment position of all other RowItems
+       /// with same par id, to avoid placing error insets
+       /// at the same position
+       void increasePos(int id, int pos);
+private:
+       /// number of lines
+       unsigned int count;
+       /// container of id/pos <=> row mapping
        RowList rowlist;
        /// Last paragraph
-       LyXParagraph * lastpar;
+       Paragraph * lastpar;
        /// Last position
        int lastpos;
-       
 };
-#endif
+
+#endif // TEXROW_H