2003-04-01 Alfredo Braunstein <[EMAIL PROTECTED]> * lyxrow_funcs.[Ch]: introduce endPos, endPrintablePos.
One of the first next things will be to make rtl to work with the asserts. Regards, Alfredo
Index: lyxrow_funcs.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxrow_funcs.C,v retrieving revision 1.1 diff -u -p -u -r1.1 lyxrow_funcs.C --- lyxrow_funcs.C 2003/04/01 16:55:44 1.1 +++ lyxrow_funcs.C 2003/04/01 20:34:57 @@ -37,19 +37,29 @@ pos_type lastPos(LyXText const & lt, Row } +pos_type endPos(LyXText const & lt, RowList::iterator rit) +{ + if (isParEnd(lt, rit)) { + return rit->par()->size(); + } else { + return boost::next(rit)->pos(); + } +} + + namespace { -bool nextRowIsAllInset(Row const & row, pos_type last) +bool nextRowIsAllInset(Row const & row, pos_type end) { Paragraph const * par = row.par(); - if (last + 1 >= par->size()) + if (end == par->size()) return false; - if (!par->isInset(last + 1)) + if (!par->isInset(end)) return false; - Inset const * i = par->getInset(last + 1); + Inset const * i = par->getInset(end); return i->needFullRow() || i->display(); } @@ -64,12 +74,29 @@ pos_type lastPrintablePos(LyXText const if (isParEnd(lt, rit)) return last; - bool const nextrownotinset = !nextRowIsAllInset(*rit, last); + bool const nextrownotinset = !nextRowIsAllInset(*rit, last + 1); if (nextrownotinset && rit->par()->isSeparator(last)) return last - 1; return last; +} + + +pos_type endPrintablePos(LyXText const & lt, RowList::iterator rit) +{ + pos_type const end = endPos(lt, rit); + + // if this row is an end of par, just act like endPos() + if (isParEnd(lt, rit)) + return end; + + bool const nextrownotinset = !nextRowIsAllInset(*rit, end); + + if (nextrownotinset && rit->par()->isSeparator(end - 1)) + return end - 1; + + return end; } Index: lyxrow_funcs.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxrow_funcs.h,v retrieving revision 1.1 diff -u -p -u -r1.1 lyxrow_funcs.h --- lyxrow_funcs.h 2003/04/01 16:55:44 1.1 +++ lyxrow_funcs.h 2003/04/01 20:34:57 @@ -14,6 +14,10 @@ lyx::pos_type lastPos(LyXText const & lt lyx::pos_type lastPrintablePos(LyXText const & lt, RowList::iterator rit); +lyx::pos_type endPos(LyXText const & lt, RowList::iterator rit); + +lyx::pos_type endPrintablePos(LyXText const & lt, RowList::iterator rit); + int numberOfSeparators(LyXText const & lt, RowList::iterator rit); int numberOfHfills(LyXText const & lt, RowList::iterator rit);