This changes Row to store a ParagraphList::iterator instead of a Paragraph *, this is a major step forwar and paves the way for other changes.
Please look it over.
Index: po/POTFILES.in =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/po/POTFILES.in,v retrieving revision 1.324 diff -u -p -r1.324 POTFILES.in --- po/POTFILES.in 26 Mar 2003 15:55:51 -0000 1.324 +++ po/POTFILES.in 2 Apr 2003 22:12:04 -0000 @@ -29,9 +29,10 @@ src/frontends/controllers/helper_funcs.C src/frontends/gnome/GLog.C src/frontends/LyXView.C src/frontends/qt2/Alert_pimpl.C +src/frontends/qt2/BulletsModule.C src/frontends/qt2/Dialogs.C src/frontends/qt2/FileDialog.C -src/frontends/qt2/lengthcombo.C +src/frontends/qt2/floatplacement.C src/frontends/qt2/QAbout.C src/frontends/qt2/QBibitem.C src/frontends/qt2/QBibtex.C @@ -78,7 +79,6 @@ src/frontends/qt2/QVCLog.C src/frontends/qt2/QWrap.C src/frontends/xforms/Alert_pimpl.C src/frontends/xforms/ColorHandler.C -src/frontends/xforms/combox.C src/frontends/xforms/Dialogs.C src/frontends/xforms/FileDialog.C src/frontends/xforms/FormAboutlyx.C @@ -123,7 +123,6 @@ src/frontends/xforms/FormToc.C src/frontends/xforms/FormUrl.C src/frontends/xforms/FormVCLog.C src/frontends/xforms/FormWrap.C -src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C src/frontends/xforms/xformsBC.h src/frontends/xforms/xforms_helpers.C @@ -169,7 +168,6 @@ src/lyxfont.C src/lyxfunc.C src/lyx_main.C src/lyxrc.C -src/lyxtextclasslist.C src/lyxvc.C src/mathed/formulabase.C src/mathed/formulamacro.C @@ -181,8 +179,6 @@ src/paragraph.C src/paragraph_funcs.C src/ParagraphParameters.C src/rowpainter.C -src/support/filetools.C -src/tabular.C src/text2.C src/text3.C src/text.C Index: src/lyxrow.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrow.C,v retrieving revision 1.23 diff -u -p -r1.23 lyxrow.C --- src/lyxrow.C 1 Apr 2003 16:55:44 -0000 1.23 +++ src/lyxrow.C 2 Apr 2003 22:12:04 -0000 @@ -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; } Index: src/lyxrow.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrow.h,v retrieving revision 1.26 diff -u -p -r1.26 lyxrow.h --- src/lyxrow.h 1 Apr 2003 16:55:44 -0000 1.26 +++ src/lyxrow.h 2 Apr 2003 22:12:04 -0000 @@ -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. Index: src/lyxrow_funcs.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrow_funcs.C,v retrieving revision 1.2 diff -u -p -r1.2 lyxrow_funcs.C --- src/lyxrow_funcs.C 2 Apr 2003 00:51:45 -0000 1.2 +++ src/lyxrow_funcs.C 2 Apr 2003 22:12:04 -0000 @@ -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 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, R { 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 & { 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 & 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, 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; Index: src/text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.338 diff -u -p -r1.338 text.C --- src/text.C 2 Apr 2003 00:51:45 -0000 1.338 +++ src/text.C 2 Apr 2003 22:12:06 -0000 @@ -243,6 +243,7 @@ unsigned char LyXText::transformChar(uns // // 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) } } - 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 & 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<Paragraph *>(newpar)); + dummyrow.par(newpit); dummyrow.pos(0); x = rightMargin(buf, dummyrow); } else { @@ -786,7 +789,7 @@ pos_type addressBreakPoint(pos_type i, P 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) // 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) 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) 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) 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) 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, } 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) 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::it // 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::it // 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::it maxdesc = max(maxdesc, desc); } } else { - maxwidth += singleWidth(rit->par(), pos); + maxwidth += singleWidth(&*rit->par(), pos); } } } @@ -1104,20 +1107,20 @@ void LyXText::setHeightOfRow(RowList::it 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::it 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::it // 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::it 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::it } // 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::it } // 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::it (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; } Index: src/text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.321 diff -u -p -r1.321 text2.C --- src/text2.C 2 Apr 2003 21:19:33 -0000 1.321 +++ src/text2.C 2 Apr 2003 22:12:07 -0000 @@ -96,7 +96,7 @@ void LyXText::init(BufferView * bview, b 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::iterato // 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::i } +#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(LyX // 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<Paragraph*>(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 c } // 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 * 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; } } @@ -1781,23 +1782,23 @@ float LyXText::getCursorX(RowList::itera 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; } @@ -1916,23 +1917,23 @@ LyXText::getColumnNearX(RowList::iterato 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; } @@ -1969,16 +1970,16 @@ LyXText::getColumnNearX(RowList::iterato 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; } @@ -2030,7 +2031,7 @@ void LyXText::setCursorFromCoordinates(L 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()); Index: src/text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.59 diff -u -p -r1.59 text3.C --- src/text3.C 2 Apr 2003 17:11:36 -0000 1.59 +++ src/text3.C 2 Apr 2003 22:12:08 -0000 @@ -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);
-- Lgb