It is possible to change a few 'Row *' to 'Row &' without sematical changes. One could even add some 'const' in some places.
Patch attached. Andre' PS: Note that most of the '*cursor.row()' thingies could be changed back to 'cursor.row()' if we had MathCursor::row() return a Row &. But I did not want do change too much in one chunk... -- André Pönitz .............................................. [EMAIL PROTECTED]
Index: bufferview_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferview_funcs.C,v retrieving revision 1.43 diff -u -p -r1.43 bufferview_funcs.C --- bufferview_funcs.C 2001/11/26 10:19:47 1.43 +++ bufferview_funcs.C 2001/12/13 18:28:18 @@ -228,7 +228,7 @@ void toggleAndShow(BufferView * bv, LyXF if (font.language() != ignore_language || font.number() != LyXFont::IGNORE) { LyXCursor & cursor = text->cursor; - text->computeBidiTables(bv->buffer(), cursor.row()); + text->computeBidiTables(bv->buffer(), *cursor.row()); if (cursor.boundary() != text->isBoundary(bv->buffer(), cursor.par(), cursor.pos(), text->real_current_font) ) Index: lyxscreen.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxscreen.h,v retrieving revision 1.30 diff -u -p -r1.30 lyxscreen.h --- lyxscreen.h 2001/11/26 11:08:42 1.30 +++ lyxscreen.h 2001/12/13 18:28:18 @@ -101,7 +101,7 @@ private: int y_offset = 0, int x_offset = 0, bool internal=false); /// y is a coordinate of the text - void drawOneRow(LyXText *, BufferView *, Row * row, + void drawOneRow(LyXText *, BufferView *, Row const & row, int y_text, int y_offset = 0, int x_offset = 0); /// Index: lyxtext.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v retrieving revision 1.102 diff -u -p -r1.102 lyxtext.h --- lyxtext.h 2001/12/12 09:56:00 1.102 +++ lyxtext.h 2001/12/13 18:28:18 @@ -219,14 +219,13 @@ public: /** returns the column near the specified x-coordinate of the row x is set to the real beginning of this column */ - lyx::pos_type getColumnNearX(BufferView *, Row * row, + lyx::pos_type getColumnNearX(BufferView *, Row & row, int & x, bool & boundary) const; /** returns a pointer to a specified row. y is set to the beginning of the row */ - Row * getRow(Paragraph * par, - lyx::pos_type pos, int & y) const; + Row * getRow(Paragraph * par, lyx::pos_type pos, int & y) const; /** returns the firstrow, this could be done with the above too but IMO it's stupid to have to allocate a dummy y all the time I need the first row @@ -401,7 +400,7 @@ public: solution but faster. */ void getVisibleRow(BufferView *, int y_offset, int x_offset, - Row * row_ptr, int y, bool cleared=false); + Row const & row, int y, bool cleared = false); /// void toggleInset(BufferView *); @@ -473,7 +472,7 @@ public: /// int workWidth(BufferView *, Inset * inset) const; /// - void computeBidiTables(Buffer const *, Row * row) const; + void computeBidiTables(Buffer const *, Row const & row) const; /// Maps positions in the visual string to positions in logical string. inline @@ -540,11 +539,11 @@ private: /// void breakAgainOneRow(BufferView *, Row * row); /// Calculate and set the height of the row - void setHeightOfRow(BufferView *, Row * row_ptr) const; + void setHeightOfRow(BufferView *, Row & row_ptr) const; /** this calculates the specified parameters. needed when setting * the cursor and when creating a visible row */ - void prepareToPrint(BufferView *, Row * row, float & x, + void prepareToPrint(BufferView *, Row const * row, float & x, float & fill_separator, float & fill_hfill, float & fill_label_hfill, @@ -555,7 +554,7 @@ private: // the bufferview BufferView * bv; // the row - Row * row; + Row const * row; // the painter to use Painter * pain; // has the background been cleared @@ -678,21 +677,21 @@ private: /** returns the number of separators in the specified row. The separator on the very last column doesnt count */ - int numberOfSeparators(Buffer const *, Row const * row) const; + int numberOfSeparators(Buffer const *, Row const & row) const; /** returns the number of hfills in the specified row. The LyX-Hfill is a LaTeX \hfill so that the hfills at the beginning and at the end were ignored. This is {\em MUCH} more usefull than not to ignore! */ - int numberOfHfills(Buffer const *, Row const * row) const; + int numberOfHfills(Buffer const *, Row const & row) const; /// like NumberOfHfills, but only those in the manual label! - int numberOfLabelHfills(Buffer const *, Row const * row) const; + int numberOfLabelHfills(Buffer const *, Row const & row) const; /** returns true, if a expansion is needed. Rules are given by LaTeX */ - bool hfillExpansion(Buffer const *, Row const * row_ptr, + bool hfillExpansion(Buffer const *, Row const & row, lyx::pos_type pos) const; /// LColor::color backgroundColor(); @@ -723,9 +722,9 @@ private: /** returns the paragraph position of the last character in the specified row */ - lyx::pos_type rowLast(Row const * row) const; + lyx::pos_type rowLast(Row const & row) const; /// - lyx::pos_type rowLastPrintable(Row const * row) const; + lyx::pos_type rowLastPrintable(Row const & row) const; /// void charInserted(); Index: screen.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/screen.C,v retrieving revision 1.55 diff -u -p -r1.55 screen.C --- screen.C 2001/12/05 08:04:14 1.55 +++ screen.C 2001/12/13 18:28:18 @@ -127,7 +127,7 @@ void LyXScreen::drawFromTo(LyXText * tex while (row != 0 && y < y2) { LyXText::text_status st = text->status(); text->getVisibleRow(bv, y + y_offset, - x_offset, row, y + text->first); + x_offset, *row, y + text->first); internal = internal && (st != LyXText::CHANGED_IN_DRAW); while (internal && text->status() == LyXText::CHANGED_IN_DRAW) { if (text->fullRebreak(bv)) { @@ -136,7 +136,7 @@ void LyXScreen::drawFromTo(LyXText * tex } text->status(bv, st); text->getVisibleRow(bv, y + y_offset, - x_offset, row, y + text->first); + x_offset, *row, y + text->first); } y += row->height(); row = row->next(); @@ -153,13 +153,13 @@ void LyXScreen::drawFromTo(LyXText * tex } -void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row, +void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row const & row, int y_text, int y_offset, int x_offset) { int const y = y_text - text->first + y_offset; - if (((y + row->height()) > 0) && - ((y - row->height()) <= static_cast<int>(owner.height()))) { + if (((y + row.height()) > 0) && + ((y - row.height()) <= static_cast<int>(owner.height()))) { // ok there is something visible #if 0 LyXText::text_status st = bv->text->status(); @@ -454,7 +454,7 @@ void LyXScreen::update(LyXText * text, B case LyXText::NEED_VERY_LITTLE_REFRESH: { // ok I will update the current cursor row - drawOneRow(text, bv, text->refresh_row, text->refresh_y, + drawOneRow(text, bv, *text->refresh_row, text->refresh_y, y_offset, x_offset); // this because if we had a major update the refresh_row could // have been set to 0! Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.213 diff -u -p -r1.213 text.C --- text.C 2001/12/12 09:56:00 1.213 +++ text.C 2001/12/13 18:28:18 @@ -243,29 +243,29 @@ int LyXText::singleWidth(BufferView * bv // Returns the paragraph position of the last character in the specified row -pos_type LyXText::rowLast(Row const * row) const +pos_type LyXText::rowLast(Row const & row) const { - if (!row->next() || row->next()->par() != row->par()) - return row->par()->size() - 1; + if (!row.next() || row.next()->par() != row.par()) + return row.par()->size() - 1; else - return row->next()->pos() - 1; + return row.next()->pos() - 1; } -pos_type LyXText::rowLastPrintable(Row const * row) const +pos_type LyXText::rowLastPrintable(Row const & row) const { pos_type const last = rowLast(row); - if (last >= row->pos() - && row->next() - && row->next()->par() == row->par() - && row->par()->isSeparator(last)) + if (last >= row.pos() + && row.next() + && row.next()->par() == row.par() + && row.par()->isSeparator(last)) return last - 1; else return last; } -void LyXText::computeBidiTables(Buffer const * buf, Row * row) const +void LyXText::computeBidiTables(Buffer const * buf, Row const & row) const { bidi_same_direction = true; if (!lyxrc.rtl_support) { @@ -273,7 +273,7 @@ void LyXText::computeBidiTables(Buffer c return; } - bidi_start = row->pos(); + bidi_start = row.pos(); bidi_end = rowLastPrintable(row); if (bidi_start > bidi_end) { @@ -296,26 +296,26 @@ void LyXText::computeBidiTables(Buffer c pos_type stack[2]; bool const rtl_par = - row->par()->getParLanguage(buf->params)->RightToLeft(); + row.par()->getParLanguage(buf->params)->RightToLeft(); int level = 0; bool rtl = false; bool rtl0 = false; - pos_type const main_body = beginningOfMainBody(buf, row->par()); + pos_type const main_body = beginningOfMainBody(buf, row.par()); for (pos_type lpos = bidi_start; lpos <= bidi_end; ++lpos) { - bool is_space = row->par()->isLineSeparator(lpos); + bool is_space = row.par()->isLineSeparator(lpos); pos_type const pos = (is_space && lpos + 1 <= bidi_end && - !row->par()->isLineSeparator(lpos + 1) && - !row->par()->isNewline(lpos + 1)) + !row.par()->isLineSeparator(lpos + 1) && + !row.par()->isNewline(lpos + 1)) ? lpos + 1 : lpos; - LyXFont font = row->par()->getFontSettings(buf->params, pos); + LyXFont font = row.par()->getFontSettings(buf->params, pos); if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() && font.number() == LyXFont::ON && - row->par()->getFontSettings(buf->params, lpos - 1).number() + row.par()->getFontSettings(buf->params, lpos - 1).number() == LyXFont::ON) { - font = row->par()->getFontSettings(buf->params, lpos); + font = row.par()->getFontSettings(buf->params, lpos); is_space = false; } @@ -325,7 +325,7 @@ void LyXText::computeBidiTables(Buffer c int new_level; if (lpos == main_body - 1 - && row->pos() < main_body - 1 + && row.pos() < main_body - 1 && is_space) { new_level = (rtl_par) ? 1 : 0; new_rtl = new_rtl0 = rtl_par; @@ -486,7 +486,7 @@ void LyXText::drawInset(DrawRowParams & breakAgainOneRow(p.bv, prev); } setCursor(p.bv, cursor.par(), cursor.pos()); - need_break_row = p.row; + need_break_row = const_cast<Row *>(p.row); } } @@ -575,7 +575,7 @@ void LyXText::drawChars(DrawRowParams & bool hebrew, bool arabic) { pos_type pos = vis2log(vpos); - pos_type const last = rowLastPrintable(p.row); + pos_type const last = rowLastPrintable(*p.row); LyXFont const & orig_font = getFont(p.bv->buffer(), p.row->par(), pos); // first character @@ -1029,7 +1029,7 @@ int LyXText::fill(BufferView * bview, Ro int w; // get the pure distance - pos_type const last = rowLastPrintable(row); + pos_type const last = rowLastPrintable(*row); // special handling of the right address boxes if (textclasslist.Style(bview->buffer()->params.textclass, @@ -1113,13 +1113,13 @@ int LyXText::labelFill(BufferView * bvie // returns the number of separators in the specified row. The separator // on the very last column doesnt count -int LyXText::numberOfSeparators(Buffer const * buf, Row const * row) const +int LyXText::numberOfSeparators(Buffer const * buf, Row const & row) const { pos_type const last = rowLast(row); - pos_type p = max(row->pos(), beginningOfMainBody(buf, row->par())); + pos_type p = max(row.pos(), beginningOfMainBody(buf, row.par())); int n = 0; for (; p < last; ++p) { - if (row->par()->isSeparator(p)) { + if (row.par()->isSeparator(p)) { ++n; } } @@ -1130,21 +1130,21 @@ int LyXText::numberOfSeparators(Buffer c // returns the number of hfills in the specified row. The LyX-Hfill is // a LaTeX \hfill so that the hfills at the beginning and at the end were // ignored. This is *MUCH* more usefull than not to ignore! -int LyXText::numberOfHfills(Buffer const * buf, Row const * row) const +int LyXText::numberOfHfills(Buffer const * buf, Row const & row) const { pos_type const last = rowLast(row); - pos_type first = row->pos(); + pos_type first = row.pos(); if (first) { /* hfill *DO* count at the beginning * of paragraphs! */ - while (first <= last && row->par()->isHfill(first)) + while (first <= last && row.par()->isHfill(first)) ++first; } - first = max(first, beginningOfMainBody(buf, row->par())); + first = max(first, beginningOfMainBody(buf, row.par())); int n = 0; for (pos_type p = first; p <= last; ++p) { // last, because the end is ignored! - if (row->par()->isHfill(p)) { + if (row.par()->isHfill(p)) { ++n; } } @@ -1153,21 +1153,21 @@ int LyXText::numberOfHfills(Buffer const // like NumberOfHfills, but only those in the manual label! -int LyXText::numberOfLabelHfills(Buffer const * buf, Row const * row) const +int LyXText::numberOfLabelHfills(Buffer const * buf, Row const & row) const { pos_type last = rowLast(row); - pos_type first = row->pos(); + pos_type first = row.pos(); if (first) { /* hfill *DO* count at the beginning * of paragraphs! */ - while (first < last && row->par()->isHfill(first)) + while (first < last && row.par()->isHfill(first)) ++first; } - last = min(last, beginningOfMainBody(buf, row->par())); + last = min(last, beginningOfMainBody(buf, row.par())); int n = 0; for (pos_type p = first; p < last; ++p) { // last, because the end is ignored! - if (row->par()->isHfill(p)) { + if (row.par()->isHfill(p)) { ++n; } } @@ -1177,18 +1177,18 @@ int LyXText::numberOfLabelHfills(Buffer // returns true, if a expansion is needed. // Rules are given by LaTeX -bool LyXText::hfillExpansion(Buffer const * buf, Row const * row_ptr, +bool LyXText::hfillExpansion(Buffer const * buf, Row const & row, pos_type pos) const { // by the way, is it a hfill? - if (!row_ptr->par()->isHfill(pos)) + if (!row.par()->isHfill(pos)) return false; // at the end of a row it does not count // unless another hfill exists on the line - if (pos >= rowLast(row_ptr)) { - pos_type i = row_ptr->pos(); - while (i < pos && !row_ptr->par()->isHfill(i)) { + if (pos >= rowLast(row)) { + pos_type i = row.pos(); + while (i < pos && !row.par()->isHfill(i)) { ++i; } if (i == pos) { @@ -1198,22 +1198,22 @@ bool LyXText::hfillExpansion(Buffer cons // at the beginning of a row it does not count, if it is not // the first row of a paragaph - if (!row_ptr->pos()) + if (!row.pos()) return true; // in some labels it does not count if (textclasslist.Style(buf->params.textclass, - row_ptr->par()->getLayout()).margintype + row.par()->getLayout()).margintype != MARGIN_MANUAL - && pos < beginningOfMainBody(buf, row_ptr->par())) + && pos < beginningOfMainBody(buf, row.par())) return false; // if there is anything between the first char of the row and // the sepcified position that is not a newline and not a hfill, // the hfill will count, otherwise not - pos_type i = row_ptr->pos(); - while (i < pos && (row_ptr->par()->isNewline(i) - || row_ptr->par()->isHfill(i))) + pos_type i = row.pos(); + while (i < pos && (row.par()->isNewline(i) + || row.par()->isHfill(i))) ++i; return i != pos; @@ -1228,7 +1228,7 @@ LColor::color LyXText::backgroundColor() return LColor::background; } -void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const +void LyXText::setHeightOfRow(BufferView * bview, Row & row) const { /* get the maximum ascent and the maximum descent */ int asc = 0; @@ -1246,8 +1246,8 @@ void LyXText::setHeightOfRow(BufferView /* Correction: only the fontsize count. The other properties are taken from the layoutfont. Nicer on the screen :) */ - Paragraph * par = row_ptr->par(); - Paragraph * firstpar = row_ptr->par(); + Paragraph * par = row.par(); + Paragraph * firstpar = row.par(); LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass, firstpar->getLayout()); @@ -1255,7 +1255,7 @@ void LyXText::setHeightOfRow(BufferView // as max get the first character of this row then it can increes but not // decrees the height. Just some point to start with so we don't have to // do the assignment below too often. - LyXFont font = getFont(bview->buffer(), par, row_ptr->pos()); + LyXFont font = getFont(bview->buffer(), par, row.pos()); LyXFont::FONT_SIZE const tmpsize = font.size(); font = getLayoutFont(bview->buffer(), par); LyXFont::FONT_SIZE const size = font.size(); @@ -1264,8 +1264,8 @@ void LyXText::setHeightOfRow(BufferView LyXFont labelfont = getLabelFont(bview->buffer(), par); float spacing_val = 1.0; - if (!row_ptr->par()->params().spacing().isDefault()) { - spacing_val = row_ptr->par()->params().spacing().getValue(); + if (!row.par()->params().spacing().isDefault()) { + spacing_val = row.par()->params().spacing().getValue(); } else { spacing_val = bview->buffer()->params.spacing.getValue(); } @@ -1277,15 +1277,15 @@ void LyXText::setHeightOfRow(BufferView int maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * spacing_val); - pos_type const pos_end = rowLast(row_ptr); + pos_type const pos_end = rowLast(row); int labeladdon = 0; int maxwidth = 0; // Check if any insets are larger - for (pos_type pos = row_ptr->pos(); pos <= pos_end; ++pos) { - if (row_ptr->par()->isInset(pos)) { - tmpfont = getFont(bview->buffer(), row_ptr->par(), pos); - tmpinset = row_ptr->par()->getInset(pos); + for (pos_type pos = row.pos(); pos <= pos_end; ++pos) { + if (row.par()->isInset(pos)) { + tmpfont = getFont(bview->buffer(), row.par(), pos); + tmpinset = row.par()->getInset(pos); if (tmpinset) { #if 1 // this is needed for deep update on initialitation tmpinset->update(bview, tmpfont); @@ -1297,7 +1297,7 @@ void LyXText::setHeightOfRow(BufferView maxdesc = max(maxdesc, desc); } } else { - maxwidth += singleWidth(bview, row_ptr->par(), pos); + maxwidth += singleWidth(bview, row.par(), pos); } } @@ -1305,7 +1305,7 @@ void LyXText::setHeightOfRow(BufferView // This is not completely correct, but we can live with the small, // cosmetic error for now. LyXFont::FONT_SIZE maxsize = - row_ptr->par()->highestFontInRange(row_ptr->pos(), pos_end, size); + row.par()->highestFontInRange(row.pos(), pos_end, size); if (maxsize > font.size()) { font.setSize(maxsize); @@ -1321,10 +1321,10 @@ void LyXText::setHeightOfRow(BufferView ++maxasc; ++maxdesc; - row_ptr->ascent_of_text(maxasc); + row.ascent_of_text(maxasc); // is it a top line? - if (!row_ptr->pos() && (row_ptr->par() == firstpar)) { + if (!row.pos() && (row.par() == firstpar)) { // some parksips VERY EASY IMPLEMENTATION if (bview->buffer()->params.paragraph_separation == @@ -1347,7 +1347,7 @@ void LyXText::setHeightOfRow(BufferView } // the paper margins - if (!row_ptr->par()->previous() && bv_owner) + if (!row.par()->previous() && bv_owner) maxasc += LYX_PAPER_MARGIN; // add the vertical spaces, that the user added @@ -1369,8 +1369,8 @@ void LyXText::setHeightOfRow(BufferView && bview->buffer()->params.secnumdepth >= 0) { float spacing_val = 1.0; - if (!row_ptr->par()->params().spacing().isDefault()) { - spacing_val = row_ptr->par()->params().spacing().getValue(); + if (!row.par()->params().spacing().isDefault()) { + spacing_val = row.par()->params().spacing().getValue(); } else { spacing_val = bview->buffer()->params.spacing.getValue(); } @@ -1387,12 +1387,12 @@ void LyXText::setHeightOfRow(BufferView if ((layout.labeltype == LABEL_TOP_ENVIRONMENT || layout.labeltype == LABEL_BIBLIO || layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) - && row_ptr->par()->isFirstInSequence() - && !row_ptr->par()->getLabelstring().empty()) + && row.par()->isFirstInSequence() + && !row.par()->getLabelstring().empty()) { float spacing_val = 1.0; - if (!row_ptr->par()->params().spacing().isDefault()) { - spacing_val = row_ptr->par()->params().spacing().getValue(); + if (!row.par()->params().spacing().isDefault()) { + spacing_val = row.par()->params().spacing().getValue(); } else { spacing_val = bview->buffer()->params.spacing.getValue(); } @@ -1412,32 +1412,32 @@ void LyXText::setHeightOfRow(BufferView // or between the items of a itemize or enumerate environment if (!firstpar->params().pagebreakTop()) { - Paragraph * prev = row_ptr->par()->previous(); + Paragraph * prev = row.par()->previous(); if (prev) - prev = row_ptr->par()->depthHook(row_ptr->par()->getDepth()); + prev = row.par()->depthHook(row.par()->getDepth()); if (prev && prev->getLayout() == firstpar->getLayout() && prev->getDepth() == firstpar->getDepth() && prev->getLabelWidthString() == firstpar->getLabelWidthString()) { layoutasc = (layout.itemsep * defaultHeight()); - } else if (row_ptr->previous()) { + } else if (row.previous()) { tmptop = layout.topsep; - if (row_ptr->previous()->par()->getDepth() >= row_ptr->par()->getDepth()) + if (row.previous()->par()->getDepth() >= +row.par()->getDepth()) tmptop -= textclasslist.Style(bview->buffer()->params.textclass, - row_ptr->previous()->par()-> + +row.previous()->par()-> getLayout()).bottomsep; if (tmptop > 0) layoutasc = (tmptop * defaultHeight()); - } else if (row_ptr->par()->params().lineTop()) { + } else if (row.par()->params().lineTop()) { tmptop = layout.topsep; if (tmptop > 0) layoutasc = (tmptop * defaultHeight()); } - prev = row_ptr->par()->outerHook(); + prev = row.par()->outerHook(); if (prev) { maxasc += int(textclasslist.Style(bview->buffer()->params.textclass, prev->getLayout()).parsep * defaultHeight()); @@ -1456,8 +1456,8 @@ void LyXText::setHeightOfRow(BufferView } // is it a bottom line? - if (row_ptr->par() == par - && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par())) + if (row.par() == par + && (!row.next() || row.next()->par() != row.par())) { // the paper margins if (!par->next() && bv_owner) @@ -1482,9 +1482,9 @@ void LyXText::setHeightOfRow(BufferView // a section, or between the items of a itemize or enumerate // environment if (!firstpar->params().pagebreakBottom() - && row_ptr->par()->next()) { - Paragraph * nextpar = row_ptr->par()->next(); - Paragraph * comparepar = row_ptr->par(); + && row.par()->next()) { + Paragraph * nextpar = row.par()->next(); + Paragraph * comparepar = row.par(); float usual = 0; float unusual = 0; @@ -1519,18 +1519,18 @@ void LyXText::setHeightOfRow(BufferView maxdesc += int(layoutdesc * 2 / (2 + firstpar->getDepth())); // calculate the new height of the text - height -= row_ptr->height(); + height -= row.height(); - row_ptr->height(maxasc + maxdesc + labeladdon); - row_ptr->baseline(maxasc + labeladdon); + row.height(maxasc + maxdesc + labeladdon); + row.baseline(maxasc + labeladdon); - height += row_ptr->height(); + height += row.height(); float x = 0; if (layout.margintype != MARGIN_RIGHT_ADDRESS_BOX) { float dummy; - prepareToPrint(bview, row_ptr, x, dummy, dummy, dummy, false); + prepareToPrint(bview, &row, x, dummy, dummy, dummy, false); } - row_ptr->width(int(maxwidth + x)); + row.width(int(maxwidth + x)); if (inset_owner) { Row * r = firstrow; width = max(0,workWidth(bview)); @@ -1572,7 +1572,7 @@ void LyXText::appendParagraph(BufferView // fixed fill setting now by calling inset->update() in // SingleWidth when needed! tmprow->fill(fill(bview, tmprow, workWidth(bview))); - setHeightOfRow(bview, tmprow); + setHeightOfRow(bview, *tmprow); } while (not_ready); } @@ -1619,7 +1619,7 @@ void LyXText::breakAgain(BufferView * bv /* set the dimensions of the row */ tmprow->fill(fill(bview, tmprow, workWidth(bview))); - setHeightOfRow(bview, tmprow); + setHeightOfRow(bview, *tmprow); } while (not_ready); } @@ -1661,7 +1661,7 @@ void LyXText::breakAgainOneRow(BufferVie // set the dimensions of the row tmprow->fill(fill(bview, tmprow, workWidth(bview))); - setHeightOfRow(bview, tmprow); + setHeightOfRow(bview, *tmprow); } @@ -1730,7 +1730,7 @@ void LyXText::breakParagraph(BufferView // set the dimensions of the cursor row cursor.row()->fill(fill(bview, cursor.row(), workWidth(bview))); - setHeightOfRow(bview, cursor.row()); + setHeightOfRow(bview, *cursor.row()); while (cursor.par()->next()->size() && cursor.par()->next()->isNewline(0)) @@ -1929,7 +1929,7 @@ void LyXText::insertChar(BufferView * bv row->previous(), workWidth(bview))); - setHeightOfRow(bview, row->previous()); + setHeightOfRow(bview, *row->previous()); y -= row->previous()->height(); refresh_y = y; @@ -1972,7 +1972,7 @@ void LyXText::insertChar(BufferView * bv status(bview, LyXText::NEED_MORE_REFRESH); breakAgainOneRow(bview, row); // will the cursor be in another row now? - if (rowLast(row) <= cursor.pos() + 1 && row->next()) { + if (rowLast(*row) <= cursor.pos() + 1 && row->next()) { if (row->next() && row->next()->par() == row->par()) // this should always be true row = row->next(); @@ -1998,7 +1998,7 @@ void LyXText::insertChar(BufferView * bv refresh_pos = cursor.pos(); int const tmpheight = row->height(); - setHeightOfRow(bview, row); + setHeightOfRow(bview, *row); if (tmpheight == row->height()) status(bview, LyXText::NEED_VERY_LITTLE_REFRESH); else @@ -2042,7 +2042,7 @@ void LyXText::charInserted() void LyXText::prepareToPrint(BufferView * bview, - Row * row, float & x, + Row const * row, float & x, float & fill_separator, float & fill_hfill, float & fill_label_hfill, @@ -2071,15 +2071,15 @@ void LyXText::prepareToPrint(BufferView && textclasslist.Style(bview->buffer()->params.textclass, row->par()->getLayout()).labeltype == LABEL_MANUAL) { - /* one more since labels are left aligned */ - nlh = numberOfLabelHfills(bview->buffer(), row) + 1; + // one more since labels are left aligned + nlh = numberOfLabelHfills(bview->buffer(), *row) + 1; if (nlh && !row->par()->getLabelWidthString().empty()) { fill_label_hfill = labelFill(bview, row) / nlh; } } // are there any hfills in the row? - float const nh = numberOfHfills(bview->buffer(), row); + float const nh = numberOfHfills(bview->buffer(), *row); if (nh) { if (w > 0) @@ -2104,7 +2104,7 @@ void LyXText::prepareToPrint(BufferView switch (align) { case LYX_ALIGN_BLOCK: - ns = numberOfSeparators(bview->buffer(), row); + ns = numberOfSeparators(bview->buffer(), *row); if (ns && row->next() && row->next()->par() == row->par() && !(row->next()->par()->isNewline(row->next()->pos() - 1)) && !(row->next()->par()->isInset(row->next()->pos()) @@ -2128,11 +2128,11 @@ void LyXText::prepareToPrint(BufferView if (!bidi) return; - computeBidiTables(bview->buffer(), row); + computeBidiTables(bview->buffer(), *row); if (is_rtl) { pos_type main_body = beginningOfMainBody(bview->buffer(), row->par()); - pos_type last = rowLast(row); + pos_type last = rowLast(*row); if (main_body > 0 && (main_body-1 > last || @@ -2671,7 +2671,7 @@ void LyXText::backspace(BufferView * bvi // the layout things can change the height of a row ! int const tmpheight = cursor.row()->height(); - setHeightOfRow(bview, cursor.row()); + setHeightOfRow(bview, *cursor.row()); if (cursor.row()->height() != tmpheight) { refresh_y = cursor.y() - cursor.row()->baseline(); refresh_row = cursor.row(); @@ -2778,7 +2778,7 @@ void LyXText::backspace(BufferView * bvi pos_type z; /* remember that a space at the end of a row doesnt count * when calculating the fill */ - if (cursor.pos() < rowLast(row) || + if (cursor.pos() < rowLast(*row) || !cursor.par()->isLineSeparator(cursor.pos())) { row->fill(row->fill() + singleWidth(bview, cursor.par(), @@ -2863,7 +2863,7 @@ void LyXText::backspace(BufferView * bvi y -= tmprow->height(); tmprow->fill(fill(bview, tmprow, workWidth(bview))); - setHeightOfRow(bview, tmprow); + setHeightOfRow(bview, *tmprow); refresh_y = y; refresh_row = tmprow; @@ -2883,14 +2883,14 @@ void LyXText::backspace(BufferView * bvi // break the cursor row again if (row->next() && row->next()->par() == row->par() && - (rowLast(row) == row->par()->size() - 1 || - nextBreakPoint(bview, row, workWidth(bview)) != rowLast(row))) { + (rowLast(*row) == row->par()->size() - 1 || + nextBreakPoint(bview, row, workWidth(bview)) != rowLast(*row))) { /* it can happen that a paragraph loses one row * without a real breakup. This is when a word * is to long to be broken. Well, I don t care this * hack ;-) */ - if (rowLast(row) == row->par()->size() - 1) + if (rowLast(*row) == row->par()->size() - 1) removeRow(row->next()); refresh_y = y; @@ -2900,7 +2900,7 @@ void LyXText::backspace(BufferView * bvi breakAgainOneRow(bview, row); // will the cursor be in another row now? if (row->next() && row->next()->par() == row->par() && - rowLast(row) <= cursor.pos()) { + rowLast(*row) <= cursor.pos()) { row = row->next(); breakAgainOneRow(bview, row); } @@ -2915,7 +2915,7 @@ void LyXText::backspace(BufferView * bvi // set the dimensions of the row row->fill(fill(bview, row, workWidth(bview))); int const tmpheight = row->height(); - setHeightOfRow(bview, row); + setHeightOfRow(bview, *row); if (tmpheight == row->height()) status(bview, LyXText::NEED_VERY_LITTLE_REFRESH); else @@ -2958,7 +2958,7 @@ bool LyXText::paintRowBackground(DrawRow Inset * inset = 0; LyXFont font(LyXFont::ALL_SANE); - pos_type const last = rowLastPrintable(p.row); + pos_type const last = rowLastPrintable(*p.row); if (!p.bv->screen()->forceClear() && last == p.row->pos() && p.row->par()->isInset(p.row->pos())) { @@ -3022,7 +3022,7 @@ void LyXText::paintRowSelection(DrawRowP Row const * startrow = selection.start.row(); Row const * endrow = selection.end.row(); - Row * row = p.row; + Row const * row = p.row; if (bidi_same_direction) { int x; @@ -3072,7 +3072,7 @@ void LyXText::paintRowSelection(DrawRowP Buffer const * buffer = p.bv->buffer(); Paragraph * par = row->par(); pos_type main_body = beginningOfMainBody(buffer, par); - pos_type const last = rowLastPrintable(row); + pos_type const last = rowLastPrintable(*row); for (pos_type vpos = row->pos(); vpos <= last; ++vpos) { pos_type pos = vis2log(vpos); @@ -3089,7 +3089,7 @@ void LyXText::paintRowSelection(DrawRowP tmpx -= singleWidth(p.bv, par, main_body - 1); } - if (hfillExpansion(buffer, row, pos)) { + if (hfillExpansion(buffer, *row, pos)) { tmpx += singleWidth(p.bv, par, pos); if (pos >= main_body) tmpx += p.hfill; @@ -3501,7 +3501,7 @@ void LyXText::paintLastRow(DrawRowParams y_bottom -= asc; } - pos_type const last = rowLastPrintable(p.row); + pos_type const last = rowLastPrintable(*p.row); bool const is_rtl = p.row->par()->isRightToLeftPar(p.bv->buffer()->params); int const endlabel = par->getEndLabel(buffer->params); @@ -3551,7 +3551,7 @@ void LyXText::paintRowText(DrawRowParams Paragraph * par = p.row->par(); Buffer const * buffer = p.bv->buffer(); - pos_type const last = rowLastPrintable(p.row); + pos_type const last = rowLastPrintable(*p.row); pos_type main_body = beginningOfMainBody(buffer, par); if (main_body > 0 && @@ -3583,7 +3583,7 @@ void LyXText::paintRowText(DrawRowParams p.pain->line(int(p.x), y1, int(p.x), y0, LColor::added_space); - if (hfillExpansion(buffer, p.row, pos)) { + if (hfillExpansion(buffer, *p.row, pos)) { int const y2 = (y0 + y1) / 2; if (pos >= main_body) { @@ -3618,11 +3618,11 @@ void LyXText::paintRowText(DrawRowParams void LyXText::getVisibleRow(BufferView * bv, int y_offset, int x_offset, - Row * row, int y, bool cleared) + Row const & row, int y, bool cleared) { - if (row->height() <= 0) { + if (row.height() <= 0) { lyxerr << "LYX_ERROR: row.height: " - << row->height() << endl; + << row.height() << endl; return; } @@ -3631,10 +3631,10 @@ void LyXText::getVisibleRow(BufferView * // set up drawing parameters p.bv = bv; p.pain = &bv->painter(); - p.row = row; + p.row = &row; p.xo = x_offset; p.yo = y_offset; - prepareToPrint(bv, row, p.x, p.separator, p.hfill, p.label_hfill); + prepareToPrint(bv, &row, p.x, p.separator, p.hfill, p.label_hfill); if (inset_owner && (p.x < 0)) p.x = 0; p.x += p.xo; @@ -3659,12 +3659,12 @@ void LyXText::getVisibleRow(BufferView * paintRowDepthBar(p); // draw any stuff wanted for a first row of a paragraph - if (!row->pos()) { + if (!row.pos()) { paintFirstRow(p); } // draw any stuff wanted for the last row of a paragraph - if (!row->next() || (row->next()->par() != row->par())) { + if (!row.next() || (row.next()->par() != row.par())) { paintLastRow(p); } @@ -3683,7 +3683,7 @@ int LyXText::defaultHeight() const /* returns the column near the specified x-coordinate of the row * x is set to the real beginning of this column */ pos_type -LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, +LyXText::getColumnNearX(BufferView * bview, Row & row, int & x, bool & boundary) const { float tmpx = 0.0; @@ -3691,23 +3691,23 @@ LyXText::getColumnNearX(BufferView * bvi float fill_hfill; float fill_label_hfill; - prepareToPrint(bview, row, tmpx, fill_separator, + prepareToPrint(bview, &row, tmpx, fill_separator, fill_hfill, fill_label_hfill); - pos_type vc = row->pos(); + pos_type vc = row.pos(); pos_type last = rowLastPrintable(row); pos_type c = 0; LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass, - row->par()->getLayout()); + row.par()->getLayout()); bool left_side = false; - pos_type main_body = beginningOfMainBody(bview->buffer(), row->par()); + pos_type main_body = beginningOfMainBody(bview->buffer(), row.par()); float last_tmpx = tmpx; if (main_body > 0 && (main_body - 1 > last || - !row->par()->isLineSeparator(main_body - 1))) + !row.par()->isLineSeparator(main_body - 1))) main_body = 0; while (vc <= last && tmpx <= x) { @@ -3716,24 +3716,24 @@ LyXText::getColumnNearX(BufferView * bvi if (main_body > 0 && c == main_body-1) { tmpx += fill_label_hfill + lyxfont::width(layout.labelsep, - getLabelFont(bview->buffer(), row->par())); - if (row->par()->isLineSeparator(main_body - 1)) - tmpx -= singleWidth(bview, row->par(), main_body-1); + getLabelFont(bview->buffer(), +row.par())); + if (row.par()->isLineSeparator(main_body - 1)) + tmpx -= singleWidth(bview, row.par(), main_body-1); } if (hfillExpansion(bview->buffer(), row, c)) { - x += singleWidth(bview, row->par(), c); + x += singleWidth(bview, row.par(), c); if (c >= main_body) tmpx += fill_hfill; else tmpx += fill_label_hfill; } - else if (row->par()->isSeparator(c)) { - tmpx += singleWidth(bview, row->par(), c); + else if (row.par()->isSeparator(c)) { + tmpx += singleWidth(bview, row.par(), c); if (c >= main_body) tmpx+= fill_separator; } else - tmpx += singleWidth(bview, row->par(), c); + tmpx += singleWidth(bview, row.par(), c); ++vc; } @@ -3748,19 +3748,19 @@ LyXText::getColumnNearX(BufferView * bvi boundary = false; bool const lastrow = lyxrc.rtl_support // This is not needed, but gives // some speedup if rtl_support=false - && (!row->next() || row->next()->par() != row->par()); + && (!row.next() || row.next()->par() != row.par()); bool const rtl = (lastrow) - ? row->par()->isRightToLeftPar(bview->buffer()->params) + ? row.par()->isRightToLeftPar(bview->buffer()->params) : false; // If lastrow is false, we don't need to compute // the value of rtl. - if (row->pos() > last) // Row is empty? - c = row->pos(); + if (row.pos() > last) // Row is empty? + c = row.pos(); else if (lastrow && - ( ( rtl && left_side && vc == row->pos() && x < tmpx - 5) || + ( ( rtl && left_side && vc == row.pos() && x < tmpx - 5) || (!rtl && !left_side && vc == last + 1 && x > tmpx + 5) )) c = last + 1; - else if (vc == row->pos()) { + else if (vc == row.pos()) { c = vis2log(vc); if (bidi_level(c) % 2 == 1) ++c; @@ -3769,20 +3769,20 @@ LyXText::getColumnNearX(BufferView * bvi bool const rtl = (bidi_level(c) % 2 == 1); if (left_side == rtl) { ++c; - boundary = isBoundary(bview->buffer(), row->par(), c); + boundary = isBoundary(bview->buffer(), row.par(), c); } } - if (row->pos() <= last && c > last - && row->par()->isNewline(last)) { + if (row.pos() <= last && c > last + && row.par()->isNewline(last)) { if (bidi_level(last) % 2 == 0) - tmpx -= singleWidth(bview, row->par(), last); + tmpx -= singleWidth(bview, row.par(), last); else - tmpx += singleWidth(bview, row->par(), last); + tmpx += singleWidth(bview, row.par(), last); c = last; } - c -= row->pos(); + c -= row.pos(); x = int(tmpx); return c; } Index: text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.186 diff -u -p -r1.186 text2.C --- text2.C 2001/12/13 11:35:24 1.186 +++ text2.C 2001/12/13 18:28:18 @@ -81,7 +81,9 @@ void LyXText::init(BufferView * bview, b delete firstrow; firstrow = tmprow; } - lastrow = refresh_row = need_break_row = 0; + lastrow = 0; + refresh_row = 0; + need_break_row = 0; width = height = copylayouttype = 0; number_of_rows = first = refresh_y = 0; status_ = LyXText::UNCHANGED; @@ -806,13 +808,13 @@ void LyXText::redoHeightOfParagraph(Buff Row * tmprow = cur.row(); int y = cur.y() - tmprow->baseline(); - setHeightOfRow(bview, tmprow); + setHeightOfRow(bview, *tmprow); while (tmprow->previous() && tmprow->previous()->par() == tmprow->par()) { tmprow = tmprow->previous(); y -= tmprow->height(); - setHeightOfRow(bview, tmprow); + setHeightOfRow(bview, *tmprow); } // we can set the refreshing parameters now @@ -828,7 +830,7 @@ void LyXText::redoDrawingOfParagraph(Buf Row * tmprow = cur.row(); int y = cur.y() - tmprow->baseline(); - setHeightOfRow(bview, tmprow); + setHeightOfRow(bview, *tmprow); while (tmprow->previous() && tmprow->previous()->par() == tmprow->par()) { @@ -920,15 +922,15 @@ void LyXText::redoParagraphs(BufferView // this is because of layout changes if (refresh_row) { refresh_y -= refresh_row->height(); - setHeightOfRow(bview, refresh_row); + setHeightOfRow(bview, *refresh_row); } else { refresh_row = firstrow; refresh_y = 0; - setHeightOfRow(bview, refresh_row); + setHeightOfRow(bview, *refresh_row); } if (tmprow && tmprow->next()) - setHeightOfRow(bview, tmprow->next()); + setHeightOfRow(bview, *tmprow->next()); } @@ -1071,15 +1073,14 @@ void LyXText::cursorEnd(BufferView * bvi { if (!cursor.row()->next() || cursor.row()->next()->par() != cursor.row()->par()) { - setCursor(bview, cursor.par(), rowLast(cursor.row()) + 1); + setCursor(bview, cursor.par(), rowLast(*cursor.row()) + 1); } else { if (cursor.par()->size() && - (cursor.par()->getChar(rowLast(cursor.row())) == ' ' - || cursor.par()->isNewline(rowLast(cursor.row())))) { - setCursor(bview, cursor.par(), rowLast(cursor.row())); + (cursor.par()->getChar(rowLast(*cursor.row())) == ' ' + || cursor.par()->isNewline(rowLast(*cursor.row())))) { + setCursor(bview, cursor.par(), rowLast(*cursor.row())); } else { - setCursor(bview,cursor.par(), - rowLast(cursor.row()) + 1); + setCursor(bview, cursor.par(), rowLast(*cursor.row()) + 1); } } } @@ -2012,12 +2013,12 @@ void LyXText::checkParagraph(BufferView } int const tmpheight = row->height(); - pos_type const tmplast = rowLast(row); + pos_type const tmplast = rowLast(*row); refresh_y = y; refresh_row = row; breakAgain(bview, row); - if (row->height() == tmpheight && rowLast(row) == tmplast) + if (row->height() == tmpheight && rowLast(*row) == tmplast) status(bview, LyXText::NEED_VERY_LITTLE_REFRESH); else status(bview, LyXText::NEED_MORE_REFRESH); @@ -2122,7 +2123,7 @@ void LyXText::setCursor(BufferView *bvie prepareToPrint(bview, row, x, fill_separator, fill_hfill, fill_label_hfill); pos_type cursor_vpos = 0; - pos_type last = rowLastPrintable(row); + pos_type last = rowLastPrintable(*row); if (pos > last + 1) // This shouldn't happen. pos = last + 1; @@ -2164,7 +2165,7 @@ void LyXText::setCursor(BufferView *bvie if (row->par()->isLineSeparator(main_body-1)) x -= singleWidth(bview, row->par(),main_body-1); } - if (hfillExpansion(bview->buffer(), row, pos)) { + if (hfillExpansion(bview->buffer(), *row, pos)) { x += singleWidth(bview, row->par(), pos); if (pos >= main_body) x += fill_hfill; @@ -2271,7 +2272,7 @@ void LyXText::setCursorFromCoordinates(B Row * row = getRowNearY(y); bool bound = false; - pos_type const column = getColumnNearX(bview, row, x, bound); + pos_type const column = getColumnNearX(bview, *row, x, bound); cur.par(row->par()); cur.pos(row->pos() + column); cur.x(x); @@ -2493,7 +2494,7 @@ void LyXText::deleteEmptyParagraphMechan breakAgain(bview, refresh_row->next()); updateCounters(bview, refresh_row); } - setHeightOfRow(bview, refresh_row); + setHeightOfRow(bview, *refresh_row); } else { refresh_row = old_cursor.row()->next(); refresh_y = old_cursor.y() - old_cursor.row()->baseline(); Index: insets/insettext.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v retrieving revision 1.232 diff -u -p -r1.232 insettext.C --- insets/insettext.C 2001/12/10 13:30:27 1.232 +++ insets/insettext.C 2001/12/13 18:28:18 @@ -465,7 +465,7 @@ void InsetText::draw(BufferView * bv, Ly int yf = y_offset; y = 0; while ((row != 0) && (yf < ph)) { - lt->getVisibleRow(bv, y+y_offset, int(x), row, + lt->getVisibleRow(bv, y+y_offset, int(x), *row, y+first, cleared); y += row->height(); yf += row->height();