- Paragraph const & par = text_->getPar(pit);
- Bidi bidi;
- bidi.computeTables(par, buffer, row);
-
- pos_type vc = row.pos();
- pos_type end = row.endpos();
- pos_type c = 0;
- Layout const & layout = par.layout();
-
- bool left_side = false;
-
- pos_type body_pos = par.beginOfBody();
-
- double tmpx = row.x;
- double last_tmpx = tmpx;
-
- if (body_pos > 0 &&
- (body_pos > end || !par.isLineSeparator(body_pos - 1)))
- body_pos = 0;
-
- // check for empty row
- if (vc == end) {
- x = int(tmpx) + xo;
- return 0;
- }
-
- // This (rtl_support test) is not needed, but gives
- // some speedup if rtl_support == false
- bool const lastrow = lyxrc.rtl_support && row.endpos() == par.size();
-
- // If lastrow is false, we don't need to compute
- // the value of rtl.
- bool const rtl_on_lastrow = lastrow ? text_->isRTL(par) : false;
-
- // if the first character is a separator, and we are in RTL
- // text, this character will not be painted on screen
- // and thus we should not count it and skip to the next. Only
- // in freespacing paragraphs, this first character is painted.
- if (!par.isFreeSpacing() && par.isSeparator(bidi.vis2log(vc)))
- ++vc;
-
- while (vc < end && tmpx <= x) {
- c = bidi.vis2log(vc);
- last_tmpx = tmpx;
- if (body_pos > 0 && c == body_pos - 1) {
- FontMetrics const & fm = theFontMetrics(
- text_->labelFont(par));
- tmpx += row.label_hfill + fm.width(layout.labelsep);
- if (par.isLineSeparator(body_pos - 1))
- tmpx -= singleWidth(pit, body_pos - 1);
- }
-
- tmpx += singleWidth(pit, c);
- if (par.isSeparator(c) && c >= body_pos)
- tmpx += row.separator;
- ++vc;
- }
-
- if ((tmpx + last_tmpx) / 2 > x) {
- tmpx = last_tmpx;
- left_side = true;
- }
-
- // This shouldn't happen. But we can reset and try to continue.
- LASSERT(vc <= end, vc = end);