X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ftexrow.h;h=2ee432f6af84aac3d18de945518016e00c4bf3d6;hb=5d3718cad2a2ef6a4d6a495054ab0705ba27b6b5;hp=11aa605740c374896276f56c3725ec6c8c1929ca;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/texrow.h b/src/texrow.h index 11aa605740..2ee432f6af 100644 --- a/src/texrow.h +++ b/src/texrow.h @@ -1,81 +1,98 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright (C) 1995 Matthias Ettrich - * Copyright (C) 1995-1998 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 +#ifndef TEXROW_H +#define TEXROW_H -class LyXParagraph; +#include -// Controls correspondance between paragraphs and the generated LaTeX file +class Paragraph; + +/// Represents the correspondence between paragraphs and the generated LaTeX file class TexRow { public: /// - TexRow() { - count = 0; - next = 0; - lastpar = 0; - lastpos = -1; - } - /// - ~TexRow() { - reset(); - } + TexRow() : count(0), lastpar(0), lastpos(-1) {} /// Clears structure 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+=(const TexRow &); + TexRow & operator+= (TexRow const &); -private: - /// Linked list of items - struct TexRow_Item { - /// - TexRow_Item() { - id = -1; - pos = -1; - next = 0; - rownumber = 0; + /// Returns the number of rows contained + int rows() const { return count; } + + /// an individual id/pos <=> row mapping + class RowItem { + public: + 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; } - /// - int id; - /// - int pos; - /// - int rownumber; - /// - TexRow_Item *next; + /// paragraph position + int pos() const { + return pos_; + } + + /// row number + int rownumber() const { + return rownumber_; + } + private: + int id_; + int pos_; + int rownumber_; }; /// + typedef std::list 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; - /// - TexRow_Item *next; + /// container of id/pos <=> row mapping + RowList rowlist; /// Last paragraph - LyXParagraph * lastpar; + Paragraph * lastpar; /// Last position int lastpos; - }; -#endif + +#endif // TEXROW_H