3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
14 #include "lyxrow_funcs.h"
16 #include "lyxlayout.h"
18 #include "paragraph.h"
27 int numberOfSeparators(Paragraph const & par, Row const & row)
29 pos_type const first = max(row.pos(), par.beginOfBody());
30 pos_type const last = row.endpos() - 1;
32 for (pos_type p = first; p < last; ++p) {
33 if (par.isSeparator(p))
41 // This is called _once_ from LyXText and should at least be moved into
42 // an anonymous namespace there. (Lgb)
43 int numberOfHfills(Paragraph const & par, Row const & row)
45 pos_type const last = row.endpos() - 1;
46 pos_type first = row.pos();
48 // hfill *DO* count at the beginning of paragraphs!
50 while (first < last && par.isHfill(first))
54 first = max(first, par.beginOfBody());
58 // last, because the end is ignored!
59 for (pos_type p = first; p < last; ++p) {
68 // This is called _once_ from LyXText and should at least be moved into
69 // an anonymous namespace there. (Lgb)
70 int numberOfLabelHfills(Paragraph const & par, Row const & row)
72 pos_type last = row.endpos() - 1;
73 pos_type first = row.pos();
75 // hfill *DO* count at the beginning of paragraphs!
77 while (first < last && par.isHfill(first))
81 last = min(last, par.beginOfBody());
84 // last, because the end is ignored
85 for (pos_type p = first; p < last; ++p) {
94 bool hfillExpansion(Paragraph const & par, Row const & row, pos_type pos)
96 if (!par.isHfill(pos))
99 // at the end of a row it does not count
100 // unless another hfill exists on the line
101 if (pos >= row.endpos()) {
102 for (pos_type i = row.pos(); i < pos && !par.isHfill(i); ++i)
106 // at the beginning of a row it does not count, if it is not
107 // the first row of a paragaph
111 // in some labels it does not count
112 if (par.layout()->margintype != MARGIN_MANUAL
113 && pos < par.beginOfBody())
116 // if there is anything between the first char of the row and
117 // the specified position that is not a newline and not a hfill,
118 // the hfill will count, otherwise not
119 pos_type i = row.pos();
120 while (i < pos && (par.isNewline(i) || par.isHfill(i)))