- if (int const nh = numberOfHfills(row, par.beginOfBody())) {
- if (w > 0)
- hfill = w / double(nh);
- // we don't have to look at the alignment if it is ALIGN_LEFT and
- // if the row is already larger then the permitted width as then
- // we force the LEFT_ALIGN'edness!
- } else if (int(row.width()) < max_width_) {
- // is it block, flushleft or flushright?
- // set x how you need it
- switch (getAlign(par, row.pos())) {
- case LYX_ALIGN_BLOCK: {
- int const ns = numberOfSeparators(row);
- /** If we have separators, and this row has
- * not be broken abruptly by a display inset
- * or newline, then stretch it */
- if (ns && !row.right_boundary()
- && row.endpos() != par.size()) {
- setSeparatorWidth(row, w / ns);
- row.dimension().wid = width;
- } else if (is_rtl) {
- row.dimension().wid = width;
- row.x += w;
+ ParagraphMetrics & pm = par_metrics_[row.pit()];
+ int nh = numberOfHfills(row, pm, par.beginOfBody());
+ int hfill = 0;
+ int hfill_rem = 0;
+
+ // We don't have to look at the alignment if the row is already
+ // larger then the permitted width as then we force the
+ // LEFT_ALIGN'edness!
+ if (int(row.width()) >= max_width_)
+ return;
+
+ if (nh == 0) {
+ // Common case : there is no hfill, and the alignment will be
+ // meaningful
+ switch (getAlign(par, row)) {
+ case LYX_ALIGN_BLOCK:
+ // Expand expanding characters by a total of w
+ if (!row.setExtraWidth(w) && text_->isRTL(par)) {
+ // Justification failed and the text is RTL: align to the right
+ row.left_margin += w;
+ row.dimension().wid += w;