From: Lars Gullik Bjønnes Date: Wed, 2 Apr 2003 23:01:39 +0000 (+0000) Subject: parlist-3-a.diff X-Git-Tag: 1.6.10~17069 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c543071cb30fe6c179d72045062918fb46893181;p=lyx.git parlist-3-a.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6694 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 9260d72555..e227b809e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-04-03 Lars Gullik Bjønnes + + * lyxrow.h: store a ParagraphList::iterator instead of a + Paragraph* and adjust other class functions to suit. + + * lyxrow_funcs.C, text.C, text2.C, text3.C: adjust because of the + above. + 2003-04-01 Alfredo Braunstein * text2.C (setCursor): do not anchor to cursor row for the time being @@ -8,7 +16,7 @@ * lfuns.h: * lyx_main.C: * lyxtext.h: - * text.C: + * text.C: * text3.C: rename the "tab" lfuns. Remove tab support from normal text 2003-04-02 Lars Gullik Bjønnes diff --git a/src/lyxrow.C b/src/lyxrow.C index 99dcf70d82..33356ec0d7 100644 --- a/src/lyxrow.C +++ b/src/lyxrow.C @@ -23,26 +23,26 @@ using std::max; using std::min; Row::Row() - : par_(0), pos_(0), fill_(0), height_(0), width_(0), + : pos_(0), fill_(0), height_(0), width_(0), ascent_of_text_(0), baseline_(0) {} -Row::Row(Paragraph * pa, pos_type po) - : par_(pa), pos_(po), fill_(0), height_(0), width_(0), +Row::Row(ParagraphList::iterator pit, pos_type po) + : pit_(pit), pos_(po), fill_(0), height_(0), width_(0), ascent_of_text_(0), baseline_(0) {} -Paragraph * Row::par() +ParagraphList::iterator Row::par() { - return par_; + return pit_; } -Paragraph * Row::par() const +ParagraphList::iterator Row::par() const { - return par_; + return pit_; } @@ -52,9 +52,9 @@ unsigned short Row::height() const } -void Row::par(Paragraph * p) +void Row::par(ParagraphList::iterator pit) { - par_ = p; + pit_ = pit; } diff --git a/src/lyxrow.h b/src/lyxrow.h index d239416068..cbb72cec7c 100644 --- a/src/lyxrow.h +++ b/src/lyxrow.h @@ -15,23 +15,22 @@ #ifndef LYXROW_H #define LYXROW_H +#include "ParagraphList.h" #include "support/types.h" -class Paragraph; - /// class Row { public: /// Row(); /// - Row(Paragraph * pa, lyx::pos_type po); + Row(ParagraphList::iterator pit, lyx::pos_type po); /// - void par(Paragraph * p); + void par(ParagraphList::iterator pit); /// - Paragraph * par(); + ParagraphList::iterator par(); /// - Paragraph * par() const; + ParagraphList::iterator par() const; /// void pos(lyx::pos_type p); /// @@ -64,7 +63,7 @@ public: bool isParStart() const; private: /// - Paragraph * par_; + ParagraphList::iterator pit_; /// lyx::pos_type pos_; /** what is missing to a full row can be negative. diff --git a/src/lyxrow_funcs.C b/src/lyxrow_funcs.C index 897377de20..b2d5981835 100644 --- a/src/lyxrow_funcs.C +++ b/src/lyxrow_funcs.C @@ -39,15 +39,15 @@ namespace { bool nextRowIsAllInset(Row const & row, pos_type last) { - Paragraph const * par = row.par(); + ParagraphList::iterator pit = row.par(); - if (last + 1 >= par->size()) + if (last + 1 >= pit->size()) return false; - if (!par->isInset(last + 1)) + if (!pit->isInset(last + 1)) return false; - Inset const * i = par->getInset(last + 1); + Inset const * i = pit->getInset(last + 1); return i->needFullRow() || i->display(); } @@ -74,13 +74,13 @@ pos_type lastPrintablePos(LyXText const & lt, RowList::iterator rit) int numberOfSeparators(LyXText const & lt, RowList::iterator rit) { pos_type const last = lastPrintablePos(lt, rit); - Paragraph const * par = rit->par(); + ParagraphList::iterator pit = rit->par(); int n = 0; - pos_type p = max(rit->pos(), par->beginningOfBody()); + pos_type p = max(rit->pos(), pit->beginningOfBody()); for (; p < last; ++p) { - if (par->isSeparator(p)) { + if (pit->isSeparator(p)) { ++n; } } @@ -94,22 +94,22 @@ int numberOfHfills(LyXText const & lt, RowList::iterator rit) { pos_type const last = lastPos(lt, rit); pos_type first = rit->pos(); - Paragraph const * par = rit->par(); + ParagraphList::iterator pit = rit->par(); // hfill *DO* count at the beginning of paragraphs! if (first) { - while (first < last && par->isHfill(first)) { + while (first < last && pit->isHfill(first)) { ++first; } } - first = max(first, par->beginningOfBody()); + first = max(first, pit->beginningOfBody()); int n = 0; // last, because the end is ignored! for (pos_type p = first; p < last; ++p) { - if (par->isHfill(p)) + if (pit->isHfill(p)) ++n; } return n; @@ -122,20 +122,20 @@ int numberOfLabelHfills(LyXText const & lt, RowList::iterator rit) { pos_type last = lastPos(lt, rit); pos_type first = rit->pos(); - Paragraph const * par = rit->par(); + ParagraphList::iterator pit = rit->par(); // hfill *DO* count at the beginning of paragraphs! if (first) { - while (first < last && par->isHfill(first)) + while (first < last && pit->isHfill(first)) ++first; } - last = min(last, par->beginningOfBody()); + last = min(last, pit->beginningOfBody()); int n = 0; // last, because the end is ignored! for (pos_type p = first; p < last; ++p) { - if (par->isHfill(p)) + if (pit->isHfill(p)) ++n; } return n; @@ -144,16 +144,16 @@ int numberOfLabelHfills(LyXText const & lt, RowList::iterator rit) bool hfillExpansion(LyXText const & lt, RowList::iterator rit, pos_type pos) { - Paragraph const * par = rit->par(); + ParagraphList::iterator pit = rit->par(); - if (!par->isHfill(pos)) + if (!pit->isHfill(pos)) return false; // at the end of a row it does not count // unless another hfill exists on the line if (pos >= lastPos(lt, rit)) { pos_type i = rit->pos(); - while (i < pos && !par->isHfill(i)) { + while (i < pos && !pit->isHfill(i)) { ++i; } if (i == pos) { @@ -167,15 +167,15 @@ bool hfillExpansion(LyXText const & lt, RowList::iterator rit, pos_type pos) return true; // in some labels it does not count - if (par->layout()->margintype != MARGIN_MANUAL - && pos < par->beginningOfBody()) + if (pit->layout()->margintype != MARGIN_MANUAL + && pos < pit->beginningOfBody()) return false; // if there is anything between the first char of the row and // the specified position that is not a newline and not a hfill, // the hfill will count, otherwise not pos_type i = rit->pos(); - while (i < pos && (par->isNewline(i) || par->isHfill(i))) + while (i < pos && (pit->isNewline(i) || pit->isHfill(i))) ++i; return i != pos; diff --git a/src/text.C b/src/text.C index f4dc070067..2b2ea5a610 100644 --- a/src/text.C +++ b/src/text.C @@ -243,6 +243,7 @@ unsigned char LyXText::transformChar(unsigned char c, Paragraph * par, // // Lgb +#warning FIXME Convert this to ParagraphList::iterator int LyXText::singleWidth(Paragraph * par, pos_type pos) const { @@ -254,6 +255,7 @@ int LyXText::singleWidth(Paragraph * par, } +#warning FIXME Convert this to ParagraphList::iterator int LyXText::singleWidth(Paragraph * par, pos_type pos, char c) const { @@ -566,7 +568,7 @@ int LyXText::leftMargin(Row const & row) const } } - LyXFont const labelfont = getLabelFont(bv()->buffer(), row.par()); + LyXFont const labelfont = getLabelFont(bv()->buffer(), &*row.par()); switch (layout->margintype) { case MARGIN_DYNAMIC: if (!layout->leftmargin.empty()) { @@ -720,19 +722,20 @@ int LyXText::rightMargin(Buffer const & buf, Row const & row) const if (row.par()->getDepth()) { // find the next level paragraph - Paragraph const * newpar = row.par(); + ParagraphList::iterator newpit = row.par(); do { - newpar = newpar->previous(); - } while (newpar - && newpar->getDepth() >= row.par()->getDepth()); + --newpit; + } while (newpit != ownerParagraphs().begin() + && newpit->getDepth() >= row.par()->getDepth()); // make a corresponding row. Needed to call LeftMargin() // check wether it is a sufficent paragraph - if (newpar && newpar->layout()->isEnvironment()) { + if (newpit != ownerParagraphs().begin() && + newpit->layout()->isEnvironment()) { Row dummyrow; - dummyrow.par(const_cast(newpar)); + dummyrow.par(newpit); dummyrow.pos(0); x = rightMargin(buf, dummyrow); } else { @@ -786,7 +789,7 @@ pos_type addressBreakPoint(pos_type i, Paragraph * par) pos_type LyXText::rowBreakPoint(Row const & row) const { - Paragraph * par = row.par(); + ParagraphList::iterator pit = row.par(); // maximum pixel width of a row. int width = workWidth() - rightMargin(*bv()->buffer(), row); @@ -794,16 +797,16 @@ LyXText::rowBreakPoint(Row const & row) const // inset->textWidth() returns -1 via workWidth(), // but why ? if (width < 0) - return par->size(); + return pit->size(); - LyXLayout_ptr const & layout = par->layout(); + LyXLayout_ptr const & layout = pit->layout(); if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) - return addressBreakPoint(row.pos(), par); + return addressBreakPoint(row.pos(), &*pit); pos_type const pos = row.pos(); - pos_type const body_pos = par->beginningOfBody(); - pos_type const last = par->size(); + pos_type const body_pos = pit->beginningOfBody(); + pos_type const last = pit->size(); pos_type point = last; if (pos == last) @@ -822,21 +825,21 @@ LyXText::rowBreakPoint(Row const & row) const pos_type i = pos; for (; i < last; ++i) { - if (par->isNewline(i)) { + if (pit->isNewline(i)) { point = i; break; } - char const c = par->getChar(i); + char const c = pit->getChar(i); - int thiswidth = singleWidth(par, i, c); + int thiswidth = singleWidth(&*pit, i, c); // add the auto-hfill from label end to the body if (body_pos && i == body_pos) { thiswidth += font_metrics::width(layout->labelsep, - getLabelFont(bv()->buffer(), par)); - if (par->isLineSeparator(i - 1)) - thiswidth -= singleWidth(par, i - 1); + getLabelFont(bv()->buffer(), &*pit)); + if (pit->isLineSeparator(i - 1)) + thiswidth -= singleWidth(&*pit, i - 1); int left_margin = labelEnd(row); if (thiswidth < left_margin) thiswidth = left_margin; @@ -845,7 +848,7 @@ LyXText::rowBreakPoint(Row const & row) const x += thiswidth; chunkwidth += thiswidth; - Inset * in = par->isInset(i) ? par->getInset(i) : 0; + Inset * in = pit->isInset(i) ? pit->getInset(i) : 0; bool fullrow = (in && (in->display() || in->needFullRow())); // break before a character that will fall off @@ -864,7 +867,7 @@ LyXText::rowBreakPoint(Row const & row) const if (!in || in->isChar()) { // some insets are line separators too - if (par->isLineSeparator(i)) { + if (pit->isLineSeparator(i)) { point = i; chunkwidth = 0; } @@ -878,7 +881,7 @@ LyXText::rowBreakPoint(Row const & row) const if (i == pos) { if (pos < last - 1) { point = i; - if (par->isLineSeparator(i + 1)) + if (pit->isLineSeparator(i + 1)) ++point; } else { // to avoid extra rows @@ -926,28 +929,28 @@ int LyXText::fill(RowList::iterator row, int paper_width) const } else w = leftMargin(*row); - Paragraph * par = row->par(); - LyXLayout_ptr const & layout = par->layout(); + ParagraphList::iterator pit = row->par(); + LyXLayout_ptr const & layout = pit->layout(); - pos_type const body_pos = par->beginningOfBody(); + pos_type const body_pos = pit->beginningOfBody(); pos_type i = row->pos(); while (i <= last) { if (body_pos > 0 && i == body_pos) { - w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), par)); - if (par->isLineSeparator(i - 1)) - w -= singleWidth(par, i - 1); + w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), &*pit)); + if (pit->isLineSeparator(i - 1)) + w -= singleWidth(&*pit, i - 1); int left_margin = labelEnd(*row); if (w < left_margin) w = left_margin; } - w += singleWidth(par, i); + w += singleWidth(&*pit, i); ++i; } if (body_pos > 0 && body_pos > last) { - w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), par)); - if (last >= 0 && par->isLineSeparator(last)) - w -= singleWidth(par, last); + w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), &*pit)); + if (last >= 0 && pit->isLineSeparator(last)) + w -= singleWidth(&*pit, last); int const left_margin = labelEnd(*row); if (w < left_margin) w = left_margin; @@ -976,14 +979,14 @@ int LyXText::labelFill(Row const & row) const int w = 0; pos_type i = row.pos(); while (i <= last) { - w += singleWidth(row.par(), i); + w += singleWidth(&*row.par(), i); ++i; } int fill = 0; string const & labwidstr = row.par()->params().labelWidthString(); if (!labwidstr.empty()) { - LyXFont const labfont = getLabelFont(bv()->buffer(), row.par()); + LyXFont const labfont = getLabelFont(bv()->buffer(), &*row.par()); int const labwidth = font_metrics::width(labwidstr, labfont); fill = max(labwidth - w, 0); } @@ -1023,21 +1026,21 @@ void LyXText::setHeightOfRow(RowList::iterator rit) // Correction: only the fontsize count. The other properties // are taken from the layoutfont. Nicer on the screen :) - Paragraph * par = rit->par(); - Paragraph * firstpar = par; + ParagraphList::iterator pit = rit->par(); + ParagraphList::iterator firstpit = pit; - LyXLayout_ptr const & layout = firstpar->layout(); + LyXLayout_ptr const & layout = firstpit->layout(); // as max get the first character of this row then it can increase but not // decrease the height. Just some point to start with so we don't have to // do the assignment below too often. - LyXFont font = getFont(bv()->buffer(), par, rit->pos()); + LyXFont font = getFont(bv()->buffer(), &*pit, rit->pos()); LyXFont::FONT_SIZE const tmpsize = font.size(); - font = getLayoutFont(bv()->buffer(), par); + font = getLayoutFont(bv()->buffer(), &*pit); LyXFont::FONT_SIZE const size = font.size(); font.setSize(tmpsize); - LyXFont labelfont = getLabelFont(bv()->buffer(), par); + LyXFont labelfont = getLabelFont(bv()->buffer(), &*pit); float spacing_val = 1.0; if (!rit->par()->params().spacing().isDefault()) { @@ -1062,7 +1065,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit) // Check if any insets are larger for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) { if (rit->par()->isInset(pos)) { - tmpfont = getFont(bv()->buffer(), rit->par(), pos); + tmpfont = getFont(bv()->buffer(), &*rit->par(), pos); tmpinset = rit->par()->getInset(pos); if (tmpinset) { #if 1 // this is needed for deep update on initialitation @@ -1076,7 +1079,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit) maxdesc = max(maxdesc, desc); } } else { - maxwidth += singleWidth(rit->par(), pos); + maxwidth += singleWidth(&*rit->par(), pos); } } } @@ -1104,20 +1107,20 @@ void LyXText::setHeightOfRow(RowList::iterator rit) rit->ascent_of_text(maxasc); // is it a top line? - if (!rit->pos() && (rit->par() == firstpar)) { + if (!rit->pos() && (rit->par() == firstpit)) { // some parksips VERY EASY IMPLEMENTATION if (bv()->buffer()->params.paragraph_separation == BufferParams::PARSEP_SKIP) { if (layout->isParagraph() - && firstpar->getDepth() == 0 - && firstpar->previous()) + && firstpit->getDepth() == 0 + && firstpit->previous()) { maxasc += bv()->buffer()->params.getDefSkip().inPixels(*bv()); - } else if (firstpar->previous() && - firstpar->previous()->layout()->isParagraph() && - firstpar->previous()->getDepth() == 0) + } else if (firstpit->previous() && + firstpit->previous()->layout()->isParagraph() && + firstpit->previous()->getDepth() == 0) { // is it right to use defskip here too? (AS) maxasc += bv()->buffer()->params.getDefSkip().inPixels(*bv()); @@ -1129,19 +1132,19 @@ void LyXText::setHeightOfRow(RowList::iterator rit) maxasc += PAPER_MARGIN; // add the vertical spaces, that the user added - maxasc += getLengthMarkerHeight(*bv(), firstpar->params().spaceTop()); + maxasc += getLengthMarkerHeight(*bv(), firstpit->params().spaceTop()); // do not forget the DTP-lines! // there height depends on the font of the nearest character - if (firstpar->params().lineTop()) + if (firstpit->params().lineTop()) maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(), - firstpar, 0)); + &*firstpit, 0)); // and now the pagebreaks - if (firstpar->params().pagebreakTop()) + if (firstpit->params().pagebreakTop()) maxasc += 3 * defaultRowHeight(); - if (firstpar->params().startOfAppendix()) + if (firstpit->params().startOfAppendix()) maxasc += 3 * defaultRowHeight(); // This is special code for the chapter, since the label of this @@ -1192,13 +1195,13 @@ void LyXText::setHeightOfRow(RowList::iterator rit) // and now the layout spaces, for example before and after a section, // or between the items of a itemize or enumerate environment - if (!firstpar->params().pagebreakTop()) { + if (!firstpit->params().pagebreakTop()) { Paragraph * prev = rit->par()->previous(); if (prev) prev = rit->par()->depthHook(rit->par()->getDepth()); - if (prev && prev->layout() == firstpar->layout() && - prev->getDepth() == firstpar->getDepth() && - prev->getLabelWidthString() == firstpar->getLabelWidthString()) + if (prev && prev->layout() == firstpit->layout() && + prev->getDepth() == firstpit->getDepth() && + prev->getLabelWidthString() == firstpit->getLabelWidthString()) { layoutasc = (layout->itemsep * defaultRowHeight()); } else if (rit != rows().begin()) { @@ -1220,13 +1223,13 @@ void LyXText::setHeightOfRow(RowList::iterator rit) if (prev) { maxasc += int(prev->layout()->parsep * defaultRowHeight()); } else { - if (firstpar->previous() && - firstpar->previous()->getDepth() == 0 && - firstpar->previous()->layout() != - firstpar->layout()) + if (firstpit->previous() && + firstpit->previous()->getDepth() == 0 && + firstpit->previous()->layout() != + firstpit->layout()) { // avoid parsep - } else if (firstpar->previous()) { + } else if (firstpit->previous()) { maxasc += int(layout->parsep * defaultRowHeight()); } } @@ -1234,64 +1237,65 @@ void LyXText::setHeightOfRow(RowList::iterator rit) } // is it a bottom line? - if (rit->par() == par + if (rit->par() == pit && (boost::next(rit) == rows().end() || boost::next(rit)->par() != rit->par())) { // the bottom margin - if (!par->next() && !isInInset()) + if (boost::next(pit) == ownerParagraphs().end() && + !isInInset()) maxdesc += PAPER_MARGIN; // add the vertical spaces, that the user added - maxdesc += getLengthMarkerHeight(*bv(), firstpar->params().spaceBottom()); + maxdesc += getLengthMarkerHeight(*bv(), firstpit->params().spaceBottom()); // do not forget the DTP-lines! // there height depends on the font of the nearest character - if (firstpar->params().lineBottom()) + if (firstpit->params().lineBottom()) maxdesc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(), - par, - max(pos_type(0), par->size() - 1))); + &*pit, + max(pos_type(0), pit->size() - 1))); // and now the pagebreaks - if (firstpar->params().pagebreakBottom()) + if (firstpit->params().pagebreakBottom()) maxdesc += 3 * defaultRowHeight(); // and now the layout spaces, for example before and after // a section, or between the items of a itemize or enumerate // environment - if (!firstpar->params().pagebreakBottom() + if (!firstpit->params().pagebreakBottom() && rit->par()->next()) { - Paragraph * nextpar = rit->par()->next(); - Paragraph * comparepar = rit->par(); + ParagraphList::iterator nextpit = boost::next(rit->par()); + ParagraphList::iterator comparepit = rit->par(); float usual = 0; float unusual = 0; - if (comparepar->getDepth() > nextpar->getDepth()) { - usual = (comparepar->layout()->bottomsep * defaultRowHeight()); - comparepar = comparepar->depthHook(nextpar->getDepth()); - if (comparepar->layout()!= nextpar->layout() - || nextpar->getLabelWidthString() != - comparepar->getLabelWidthString()) + if (comparepit->getDepth() > nextpit->getDepth()) { + usual = (comparepit->layout()->bottomsep * defaultRowHeight()); + comparepit = comparepit->depthHook(nextpit->getDepth()); + if (comparepit->layout()!= nextpit->layout() + || nextpit->getLabelWidthString() != + comparepit->getLabelWidthString()) { - unusual = (comparepar->layout()->bottomsep * defaultRowHeight()); + unusual = (comparepit->layout()->bottomsep * defaultRowHeight()); } if (unusual > usual) layoutdesc = unusual; else layoutdesc = usual; - } else if (comparepar->getDepth() == nextpar->getDepth()) { + } else if (comparepit->getDepth() == nextpit->getDepth()) { - if (comparepar->layout() != nextpar->layout() - || nextpar->getLabelWidthString() != - comparepar->getLabelWidthString()) - layoutdesc = int(comparepar->layout()->bottomsep * defaultRowHeight()); + if (comparepit->layout() != nextpit->layout() + || nextpit->getLabelWidthString() != + comparepit->getLabelWidthString()) + layoutdesc = int(comparepit->layout()->bottomsep * defaultRowHeight()); } } } // incalculate the layout spaces - maxasc += int(layoutasc * 2 / (2 + firstpar->getDepth())); - maxdesc += int(layoutdesc * 2 / (2 + firstpar->getDepth())); + maxasc += int(layoutasc * 2 / (2 + firstpit->getDepth())); + maxdesc += int(layoutdesc * 2 / (2 + firstpit->getDepth())); // calculate the new height of the text height -= rit->height(); @@ -1890,7 +1894,7 @@ void LyXText::prepareToPrint(RowList::iterator rit, float & x, } // center displayed insets - Inset * inset; + Inset * inset = 0; if (rit->pos() < rit->par()->size() && rit->par()->isInset(rit->pos()) && (inset = rit->par()->getInset(rit->pos())) @@ -1944,7 +1948,8 @@ void LyXText::prepareToPrint(RowList::iterator rit, float & x, (body_pos - 1 > last || !rit->par()->isLineSeparator(body_pos - 1))) { x += font_metrics::width(layout->labelsep, - getLabelFont(bv()->buffer(), rit->par())); + getLabelFont(bv()->buffer(), + &*rit->par())); if (body_pos - 1 <= last) x += fill_label_hfill; } diff --git a/src/text2.C b/src/text2.C index 37f1bd7500..4d6d10b4ff 100644 --- a/src/text2.C +++ b/src/text2.C @@ -96,7 +96,7 @@ void LyXText::init(BufferView * bview, bool reinit) for (; par != end; ++par) { insertParagraph(&*par, rowlist_.end()); } - setCursorIntern(rowlist_.begin()->par(), 0); + setCursorIntern(&*rowlist_.begin()->par(), 0); selection.cursor = cursor; updateCounters(); @@ -298,10 +298,10 @@ void LyXText::removeRow(RowList::iterator rit) // remove all following rows of the paragraph of the specified row. void LyXText::removeParagraph(RowList::iterator rit) { - Paragraph * tmppar = rit->par(); + ParagraphList::iterator tmppit = rit->par(); ++rit; - while (rit != rows().end() && rit->par() == tmppar) { + while (rit != rows().end() && rit->par() == tmppit) { RowList::iterator tmprit = boost::next(rit); removeRow(rit); rit = tmprit; @@ -309,6 +309,7 @@ void LyXText::removeParagraph(RowList::iterator rit) } +#warning FIXME Convert this to ParagraphList::iterator void LyXText::insertParagraph(Paragraph * par, RowList::iterator rowit) { // insert a new row, starting at position 0 @@ -679,26 +680,26 @@ void LyXText::redoDrawingOfParagraph(LyXCursor const & cur) // and the specified par // This function is needed after SetLayout and SetFont etc. void LyXText::redoParagraphs(LyXCursor const & cur, - Paragraph const * endpar) + Paragraph const * ep) { RowList::iterator tmprit = cur.row(); - + ParagraphList::iterator endpit(const_cast(ep)); int y = cur.y() - tmprit->baseline(); - Paragraph * first_phys_par; + ParagraphList::iterator first_phys_pit; if (tmprit == rows().begin()) { // A trick/hack for UNDO. // This is needed because in an UNDO/REDO we could have // changed the ownerParagrah() so the paragraph inside // the row is NOT my really first par anymore. // Got it Lars ;) (Jug 20011206) - first_phys_par = &*ownerParagraphs().begin(); + first_phys_pit = ownerParagraphs().begin(); #warning FIXME // In here prevrit could be set to rows().end(). (Lgb) } else { - first_phys_par = tmprit->par(); + first_phys_pit = tmprit->par(); while (tmprit != rows().begin() - && boost::prior(tmprit)->par() == first_phys_par) + && boost::prior(tmprit)->par() == first_phys_pit) { --tmprit; y -= tmprit->height(); @@ -718,26 +719,26 @@ void LyXText::redoParagraphs(LyXCursor const & cur, } // remove it - while (tmprit != rows().end() && tmprit->par() != endpar) { + while (tmprit != rows().end() && tmprit->par() != endpit) { RowList::iterator tmprit2 = tmprit++; removeRow(tmprit2); } // Reinsert the paragraphs. - Paragraph * tmppar = first_phys_par; + ParagraphList::iterator tmppit = first_phys_pit; #warning FIXME // See if this loop can be rewritten as a while loop instead. // That should also make the code a bit easier to read. (Lgb) do { - if (tmppar) { - insertParagraph(tmppar, tmprit); + if (tmppit != ownerParagraphs().end()) { + insertParagraph(&*tmppit, tmprit); while (tmprit != rows().end() - && tmprit->par() == tmppar) { + && tmprit->par() == tmppit) { ++tmprit; } - tmppar = tmppar->next(); + ++tmppit; } - } while (tmppar && tmppar != endpar); + } while (tmppit != ownerParagraphs().end() && tmppit != endpit); #warning FIXME // If the above changes are done, then we can compare prevrit @@ -1270,28 +1271,28 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) void LyXText::updateCounters() { RowList::iterator rowit = rows().begin(); - Paragraph * par = rowit->par(); + ParagraphList::iterator pit = rowit->par(); // CHECK if this is really needed. (Lgb) bv()->buffer()->params.getLyXTextClass().counters().reset(); - while (par) { - while (rowit->par() != par) + while (pit != ownerParagraphs().end()) { + while (rowit->par() != pit) ++rowit; - string const oldLabel = par->params().labelString(); + string const oldLabel = pit->params().labelString(); // setCounter can potentially change the labelString. - setCounter(bv()->buffer(), par); + setCounter(bv()->buffer(), &*pit); - string const & newLabel = par->params().labelString(); + string const & newLabel = pit->params().labelString(); if (oldLabel.empty() && !newLabel.empty()) { removeParagraph(rowit); appendParagraph(rowit); } - par = par->next(); + ++pit; } } @@ -1788,23 +1789,23 @@ float LyXText::getCursorX(RowList::iterator rit, font_metrics::width( rit->par()->layout()->labelsep, getLabelFont(bv()->buffer(), - rit->par())); + &*rit->par())); if (rit->par()->isLineSeparator(body_pos - 1)) - x -= singleWidth(rit->par(), body_pos - 1); + x -= singleWidth(&*rit->par(), body_pos - 1); } if (hfillExpansion(*this, rit, pos)) { - x += singleWidth(rit->par(), pos); + x += singleWidth(&*rit->par(), pos); if (pos >= body_pos) x += fill_hfill; else x += fill_label_hfill; } else if (rit->par()->isSeparator(pos)) { - x += singleWidth(rit->par(), pos); + x += singleWidth(&*rit->par(), pos); if (pos >= body_pos) x += fill_separator; } else - x += singleWidth(rit->par(), pos); + x += singleWidth(&*rit->par(), pos); } return x; } @@ -1923,23 +1924,23 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const if (body_pos > 0 && c == body_pos - 1) { tmpx += fill_label_hfill + font_metrics::width(layout->labelsep, - getLabelFont(bv()->buffer(), rit->par())); + getLabelFont(bv()->buffer(), &*rit->par())); if (rit->par()->isLineSeparator(body_pos - 1)) - tmpx -= singleWidth(rit->par(), body_pos - 1); + tmpx -= singleWidth(&*rit->par(), body_pos - 1); } if (hfillExpansion(*this, rit, c)) { - tmpx += singleWidth(rit->par(), c); + tmpx += singleWidth(&*rit->par(), c); if (c >= body_pos) tmpx += fill_hfill; else tmpx += fill_label_hfill; } else if (rit->par()->isSeparator(c)) { - tmpx += singleWidth(rit->par(), c); + tmpx += singleWidth(&*rit->par(), c); if (c >= body_pos) tmpx+= fill_separator; } else { - tmpx += singleWidth(rit->par(), c); + tmpx += singleWidth(&*rit->par(), c); } ++vc; } @@ -1976,16 +1977,16 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const bool const rtl = (bidi_level(c) % 2 == 1); if (left_side == rtl) { ++c; - boundary = isBoundary(bv()->buffer(), rit->par(), c); + boundary = isBoundary(bv()->buffer(), &*rit->par(), c); } } if (rit->pos() <= last && c > last && rit->par()->isNewline(last)) { if (bidi_level(last) % 2 == 0) - tmpx -= singleWidth(rit->par(), last); + tmpx -= singleWidth(&*rit->par(), last); else - tmpx += singleWidth(rit->par(), last); + tmpx += singleWidth(&*rit->par(), last); c = last; } @@ -2037,7 +2038,7 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y) RowList::iterator row = getRowNearY(y); bool bound = false; pos_type const column = getColumnNearX(row, x, bound); - cur.par(row->par()); + cur.par(&*row->par()); cur.pos(row->pos() + column); cur.x(x); cur.y(y + row->baseline()); diff --git a/src/text3.C b/src/text3.C index b916f8d4b0..4351d6d252 100644 --- a/src/text3.C +++ b/src/text3.C @@ -282,7 +282,7 @@ void LyXText::cursorPrevious() bv()->screen().draw(bv()->text, bv(), new_y < 0 ? 0 : new_y); if (cursor.row() != rows().begin()) { LyXCursor cur; - setCursor(cur, boost::prior(cursor.row())->par(), + setCursor(cur, &*boost::prior(cursor.row())->par(), boost::prior(cursor.row())->pos(), false); if (cur.y() > top_y()) { cursorUp(true); @@ -343,7 +343,7 @@ void LyXText::cursorNext() bv()->screen().draw(bv()->text, bv(), new_y); if (boost::next(cursor.row()) != rows().end()) { LyXCursor cur; - setCursor(cur, boost::next(cursor.row())->par(), + setCursor(cur, &*boost::next(cursor.row())->par(), boost::next(cursor.row())->pos(), false); if (cur.y() < top_y() + bv()->workHeight()) { cursorDown(true);