- if (i == 0) {
- /* If we are here, it means that we have not found a
- * separator to shorten the row. There is one case
- * where we can do something: when we have one big
- * string, maybe with a paragraph marker after it.
- */
- Element & front = elements_.front();
- if (!(front.type == STRING
- && (elements_.size() == 1
- || (elements_.size() == 2
- && back().type == VIRTUAL))))
- return;
-
- // If this is a string element, we can try to split it.
- if (front.type != STRING)
- return;
- double xstr = w - x;
- // If there is a paragraph marker, it should be taken in account
- if (elements_.size() == 2)
- xstr -= back().width();
- pos_type new_pos = front.x2pos(xstr, true);
- front.str = front.str.substr(0, new_pos - pos_);
- front.dim.wid = xstr;
- front.endpos = new_pos;
- end_ = new_pos;
- dim_.wid = x + xstr;
- // If there is a paragraph marker, it should be removed.
- if (elements_.size() == 2)
- elements_.pop_back();
+
+ if (cit != beg) {
+ // There is no separator, but several elements (probably
+ // insets) have been added. We can cut at this place.
+ end_ = cit->pos;
+ dim_.wid = wid;
+ elements_.erase(cit, end);