Andre Poenitz <[EMAIL PROTECTED]> writes: | Index: lyxtext.h | =================================================================== | RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtext.h,v | retrieving revision 1.208 | diff -u -p -r1.208 lyxtext.h | --- lyxtext.h 11 Aug 2003 09:08:53 -0000 1.208 | +++ lyxtext.h 12 Aug 2003 12:22:15 -0000 | @@ -512,6 +512,9 @@ public: | /// return true if this is owned by an inset. | bool isInInset() const; | | + /// recreate paragraphlist iterator from rowlist iterator | + ParagraphList::iterator getPar(RowList::iterator rit) const;
Are you creating something? Or is this really just a find... so you are just returning a paragraphlist iterator. | @@ -2281,3 +2281,39 @@ int LyXText::getDepth() const | { | return cursor.par()->getDepth(); | } | + | + | +// re-creates par iterator from row iterator by counting zeros in | +// the sequence of pos values. | + | +ParagraphList::iterator LyXText::getPar(RowList::iterator row) const | +{ Drop this check. At most add an assert: (Assert(row != rows().end())) passing rows().end() should not be allowed. | + if (row == rows().end()) { | + lyxerr << "LyXText::getPar: pit at end " << endl; | + return ownerParagraphs().begin(); | + } | + | + if (row == rows().begin()) { | + return ownerParagraphs().begin(); | + } | + | + ParagraphList::iterator pit = ownerParagraphs().begin(); | + RowList::iterator rit = rows().begin(); | + RowList::iterator rend = rows().end(); | + for (++rit ; rit != rend; ++rit) { | + if (rit == row) | + return pit; | + if (rit->pos() == 0) { | + ++pit; | + if (pit == ownerParagraphs().end()) { | + lyxerr << "unexpected in | + LyXText::getPar()" << endl; is it only unexpected or completely bogus. ( Assert(pit != ownerParagraphs().end()) ) | + Assert(0); false | + return ownerParagraphs().begin(); drop this and leave the above Assert permanent. -- Lgb