mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
Get rid of need_new_row boolean in breakParagraph
Instead of having breakParagraph decide when breaking a row is necessary, let Row::shortenIfNeeded set the row_flag of the last element to request a row break. This was already done in splitAt. This is in preparation of splitAt splitting in more than two elements.
This commit is contained in:
parent
ef6dfe18c2
commit
4120635185
@ -473,6 +473,8 @@ Row::Elements splitFrom(Row::Elements & elts, Row::Elements::iterator const & it
|
|||||||
ret.push_back(init);
|
ret.push_back(init);
|
||||||
ret.insert(ret.end(), it, elts.end());
|
ret.insert(ret.end(), it, elts.end());
|
||||||
elts.erase(it, elts.end());
|
elts.erase(it, elts.end());
|
||||||
|
if (!elts.empty())
|
||||||
|
elts.back().row_flags = (elts.back().row_flags & ~AfterFlags) | BreakAfter;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,6 +1042,7 @@ bool operator==(flexible_const_iterator<T> const & t1,
|
|||||||
return t1.cit_ == t2.cit_ && t1.pile_.empty() && t2.pile_.empty();
|
return t1.cit_ == t2.cit_ && t1.pile_.empty() && t2.pile_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Row newRow(TextMetrics const & tm, pit_type pit, pos_type pos, bool is_rtl)
|
Row newRow(TextMetrics const & tm, pit_type pit, pos_type pos, bool is_rtl)
|
||||||
{
|
{
|
||||||
Row nrow;
|
Row nrow;
|
||||||
@ -1071,6 +1072,7 @@ void cleanupRow(Row & row, pos_type pos, pos_type real_endpos, bool is_rtl)
|
|||||||
row.reverseRTL(is_rtl);
|
row.reverseRTL(is_rtl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Implement the priorities described in RowFlags.h.
|
// Implement the priorities described in RowFlags.h.
|
||||||
bool needsRowBreak(int f1, int f2)
|
bool needsRowBreak(int f1, int f2)
|
||||||
{
|
{
|
||||||
@ -1093,14 +1095,12 @@ RowList TextMetrics::breakParagraph(Row const & bigrow) const
|
|||||||
bool const is_rtl = text_->isRTL(bigrow.pit());
|
bool const is_rtl = text_->isRTL(bigrow.pit());
|
||||||
bool const end_label = text_->getEndLabel(bigrow.pit()) != END_LABEL_NO_LABEL;
|
bool const end_label = text_->getEndLabel(bigrow.pit()) != END_LABEL_NO_LABEL;
|
||||||
|
|
||||||
bool need_new_row = true;
|
|
||||||
pos_type pos = 0;
|
pos_type pos = 0;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
flexible_const_iterator<Row> fcit = flexible_begin(bigrow);
|
flexible_const_iterator<Row> fcit = flexible_begin(bigrow);
|
||||||
flexible_const_iterator<Row> const end = flexible_end(bigrow);
|
flexible_const_iterator<Row> const end = flexible_end(bigrow);
|
||||||
while (true) {
|
while (true) {
|
||||||
bool const has_row = !rows.empty();
|
bool const row_empty = rows.empty() || rows.back().empty();
|
||||||
bool const row_empty = !has_row || rows.back().empty();
|
|
||||||
// The row flags of previous element, if there is one.
|
// The row flags of previous element, if there is one.
|
||||||
// Otherwise we use NoBreakAfter to avoid an empty row before
|
// Otherwise we use NoBreakAfter to avoid an empty row before
|
||||||
// e.g. a displayed equation.
|
// e.g. a displayed equation.
|
||||||
@ -1110,14 +1110,12 @@ RowList TextMetrics::breakParagraph(Row const & bigrow) const
|
|||||||
// paragraph has an end label (for which an empty row is OK).
|
// paragraph has an end label (for which an empty row is OK).
|
||||||
int const f2 = (fcit == end) ? (end_label ? Inline : NoBreakBefore)
|
int const f2 = (fcit == end) ? (end_label ? Inline : NoBreakBefore)
|
||||||
: fcit->row_flags;
|
: fcit->row_flags;
|
||||||
need_new_row |= needsRowBreak(f1, f2);
|
if (rows.empty() || needsRowBreak(f1, f2)) {
|
||||||
if (need_new_row) {
|
|
||||||
if (!rows.empty())
|
if (!rows.empty())
|
||||||
cleanupRow(rows.back(), pos, bigrow.endpos(), is_rtl);
|
cleanupRow(rows.back(), pos, bigrow.endpos(), is_rtl);
|
||||||
rows.push_back(newRow(*this, bigrow.pit(), pos, is_rtl));
|
rows.push_back(newRow(*this, bigrow.pit(), pos, is_rtl));
|
||||||
// the width available for the row.
|
// the width available for the row.
|
||||||
width = max_width_ - rows.back().right_margin;
|
width = max_width_ - rows.back().right_margin;
|
||||||
need_new_row = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The stopping condition is here because we may need a new
|
// The stopping condition is here because we may need a new
|
||||||
@ -1147,7 +1145,6 @@ RowList TextMetrics::breakParagraph(Row const & bigrow) const
|
|||||||
if (!next_elts.empty()) {
|
if (!next_elts.empty()) {
|
||||||
rb.flushed(false);
|
rb.flushed(false);
|
||||||
fcit.put(next_elts);
|
fcit.put(next_elts);
|
||||||
need_new_row = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// a new element in the row
|
// a new element in the row
|
||||||
@ -1163,7 +1160,6 @@ RowList TextMetrics::breakParagraph(Row const & bigrow) const
|
|||||||
// do as if we inserted this element in the original row
|
// do as if we inserted this element in the original row
|
||||||
if (!next_elt.str.empty())
|
if (!next_elt.str.empty())
|
||||||
fcit.put(next_elt);
|
fcit.put(next_elt);
|
||||||
need_new_row = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user