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 pos_type lastPos(Paragraph const & par, Row const & row)
31 pos_type pos = row.endpos() - 1;
32 if (pos == par.size())
38 int numberOfSeparators(Paragraph const & par, Row const & row)
40 pos_type const last = lastPos(par, row);
42 pos_type p = max(row.pos(), par.beginningOfBody());
43 for ( ; p < last; ++p)
44 if (par.isSeparator(p))
50 // This is called _once_ from LyXText and should at least be moved into
51 // an anonymous namespace there. (Lgb)
52 int numberOfHfills(Paragraph const & par, Row const & row)
54 pos_type const last = lastPos(par, row);
55 pos_type first = row.pos();
57 // hfill *DO* count at the beginning of paragraphs!
59 while (first < last && par.isHfill(first))
63 first = max(first, par.beginningOfBody());
67 // last, because the end is ignored!
68 for (pos_type p = first; p < last; ++p) {
77 // This is called _once_ from LyXText and should at least be moved into
78 // an anonymous namespace there. (Lgb)
79 int numberOfLabelHfills(Paragraph const & par, Row const & row)
81 pos_type last = lastPos(par, row);
82 pos_type first = row.pos();
84 // hfill *DO* count at the beginning of paragraphs!
86 while (first < last && par.isHfill(first))
90 last = min(last, par.beginningOfBody());
93 // last, because the end is ignored
94 for (pos_type p = first; p < last; ++p) {
103 bool hfillExpansion(Paragraph const & par, Row const & row, pos_type pos)
105 if (!par.isHfill(pos))
108 // at the end of a row it does not count
109 // unless another hfill exists on the line
110 if (pos >= row.endpos()) {
111 for (pos_type i = row.pos(); i < pos && !par.isHfill(i); ++i)
115 // at the beginning of a row it does not count, if it is not
116 // the first row of a paragaph
120 // in some labels it does not count
121 if (par.layout()->margintype != MARGIN_MANUAL
122 && pos < par.beginningOfBody())
125 // if there is anything between the first char of the row and
126 // the specified position that is not a newline and not a hfill,
127 // the hfill will count, otherwise not
128 pos_type i = row.pos();
129 while (i < pos && (par.isNewline(i) || par.isHfill(i)))