namespace lyx {
-using support::rtrim;
using frontend::FontMetrics;
}
+void Row::Element::rtrim()
+{
+ if (type != STRING)
+ return;
+ /* This is intended for strings that have been created by splitAt.
+ * They may have trailing spaces, but they are not counted in the
+ * string length (QTextLayout feature, actually). We remove them,
+ * and decrease endpos, since spaces at row break are invisible.
+ */
+ str = support::rtrim(str);
+ endpos = pos + str.length();
+}
+
+
bool Row::isMarginSelected(bool left, DocIterator const & beg,
DocIterator const & end) const
{
break;
}
end_ = brk.endpos;
- /* after breakAt, there may be spaces at the end of the
- * string, but they are not counted in the string length
- * (QTextLayout feature, actually). We remove them, but do
- * not change the end of the row, since spaces at row
- * break are invisible.
- */
- brk.str = rtrim(brk.str);
- brk.endpos = brk.pos + brk.str.length();
*cit_brk = brk;
dim_.wid = wid_brk + brk.dim.wid;
// If there are other elements, they should be removed.
* boundary this time.
*/
Element remainder = cit->splitAt(w - wid, true);
- if (remainder.isValid()) {
+ if (cit->row_flags & BreakAfter) {
end_ = cit->endpos;
- // See comment above.
- cit->str = rtrim(cit->str);
- cit->endpos = cit->pos + cit->str.length();
dim_.wid = wid + cit->dim.wid;
// If there are other elements, they should be removed.
return splitFrom(elements_, next(cit, 1), remainder);
void cleanupRow(Row & row, pos_type pos, pos_type real_endpos, bool is_rtl)
{
row.endpos(pos);
+ // remove trailing spaces on row break
+ if (pos < real_endpos && !row.empty())
+ row.back().rtrim();
+ // boundary exists when there was no space at the end of row
row.right_boundary(!row.empty() && pos < real_endpos
&& row.back().endpos == pos);
// make sure that the RTL elements are in reverse ordering