- } else {
- // Last position is an invariant
- pos_type const last = par->size();
- // this is the usual handling
- int x = leftMargin(&bview, &row);
- bool doitonetime = true;
- while (doitonetime || ((x < width) && (i < last))) {
- doitonetime = false;
- char const c = par->getChar(i);
- Inset * in = 0;
- if (c == Paragraph::META_INSET)
- in = par->getInset(i);
- if (IsNewlineChar(c)) {
- last_separator = i;
- x = width; // this means break
- } else if (in && !in->isChar()) {
- // check wether a Display() inset is
- // valid here. if not, change it to
- // non-display
- if (in->display() &&
- (layout->isCommand() ||
- (layout->labeltype == LABEL_MANUAL
- && i < par->beginningOfBody())))
- {
- // display istn't allowd
- in->display(false);
- x += singleWidth(&bview, par, i, c);
- } else if (in->display() || in->needFullRow()) {
- // So break the line here
- if (i == pos) {
- if (pos < last-1) {
- last_separator = i;
- if (par->isLineSeparator(i+1))
- ++last_separator;
- } else
- last_separator = last; // to avoid extra rows
- } else
- last_separator = i - 1;
- x = width; // this means break
- } else {
- x += singleWidth(&bview, par, i, c);
- // we have to check this separately as we could have a
- // lineseparator and then the algorithm below would prefer
- // that which IS wrong! We should always break on an inset
- // if it's too long and not on the last separator.
- // Maybe the only exeption is insets used as chars but
- // then we would have to have a special function inside
- // the inset to tell us this. Till then we leave it as
- // it is now. (Jug 20020106)
- if (pos < i && x >= width && last_separator >= 0)
- last_separator = i - 1;
- }
- } else {
- if (par->isLineSeparator(i))
- last_separator = i;
- x += singleWidth(&bview, par, i, c);