I think it would be beneficial to split the LyXText rowlist into per-paragraph rowlist because
- problems like "rows in rowlist with invalid pit_ member" would magically go away - better encapsulation - less "maintanance" code (i.e. instead of keeping a par list and a row list in parallel up-to-date and properly interlinked we can focus on the par list and I've already played around a bit with it and I think I found a fairly painless "small steps" transitions route to get there: 1. Add the following function to LyXText: // re-creates par iterator from row iterator by counting "jumps down" in // the sequence of pos values. ParagraphList::iterator LyXText::getPar(RowList::iterator row) const { ParagraphList::iterator pit = ownerParagraphs().begin(); RowList::iterator rit = rows().begin(); RowList::iterator rend = rows().end(); int lastpos = 0; for ( ; rit != rend; ++rit) { if (lastpos >= rit->pos()) { ++pit; if (pit == ownerParagraphs.end()) { lyxerr << "unexpected in LyXText::getPar()\n"; Assert(0); } } if (rit == row) break; lastpos = rit->pos(); } return pit; } This is obviously (a) a hack and (b) slow as hell. But works as advertised. 2. replace row.par() calls by getPar() calls 3. drop Row::pit_ member 4. split rowlist into per-par chunks, adjust getPar() 5. instead of using getPar(), pass needed par iterator to functions 6. remove getPar() It is safe to stop everywhere in between, estimated total effort less than a day. Ok to plan? Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)