- Row::Element next_elt = elt.splitAt(width - rows.back().width(),
- !elt.font.language()->wordWrap());
- if (elt.dim.wid > width - rows.back().width()) {
- Row & rb = rows.back();
- rb.push_back(*fcit);
- // if the row is too large, try to cut at last separator. In case
- // of success, reset indication that the row was broken abruptly.
- int const next_width = max_width_ - leftMargin(rb.pit(), rb.endpos())
- - rightMargin(rb.pit());
-
- Row::Elements next_elts = rb.shortenIfNeeded(width, next_width);
-
- // Go to next element
- ++fcit;
-
- // Handle later the elements returned by shortenIfNeeded.
- if (!next_elts.empty()) {
- rb.flushed(false);
- fcit.put(next_elts);
- need_new_row = true;
- }
- } else {
- // a new element in the row
- rows.back().push_back(elt);
- rows.back().finalizeLast();
- pos = elt.endpos;
-
- // Go to next element
- ++fcit;
-
- // Add a new next element on the pile
- if (next_elt.isValid()) {
- // do as if we inserted this element in the original row
- if (!next_elt.str.empty())
- fcit.put(next_elt);
- need_new_row = true;
- }
+ Row::Elements tail;
+ elt.splitAt(width - rows.back().width(), next_width, false, tail);
+ Row & rb = rows.back();
+ if (elt.type == Row::MARGINSPACE)
+ elt.dim.wid = max(elt.dim.wid, leftMargin(bigrow.pit()) - rb.width());
+ rb.push_back(elt);
+ rb.finalizeLast();
+ if (rb.width() > width) {
+ LATTEST(tail.empty());
+ // if the row is too large, try to cut at last separator.
+ tail = rb.shortenIfNeeded(width, next_width);