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 bool isParEnd(Paragraph const & par, Row const & row)
29 return row.end() == par.size();
33 pos_type lastPos(Paragraph const & par, Row const & row)
37 pos_type pos = row.end() - 1;
38 if (pos == par.size())
44 int numberOfSeparators(Paragraph const & par, Row const & row)
46 pos_type const last = lastPos(par, row);
48 pos_type p = max(row.pos(), par.beginningOfBody());
49 for ( ; p < last; ++p)
50 if (par.isSeparator(p))
56 // This is called _once_ from LyXText and should at least be moved into
57 // an anonymous namespace there. (Lgb)
58 int numberOfHfills(Paragraph const & par, Row const & row)
60 pos_type const last = lastPos(par, row);
61 pos_type first = row.pos();
63 // hfill *DO* count at the beginning of paragraphs!
65 while (first < last && par.isHfill(first))
69 first = max(first, par.beginningOfBody());
73 // last, because the end is ignored!
74 for (pos_type p = first; p < last; ++p) {
83 // This is called _once_ from LyXText and should at least be moved into
84 // an anonymous namespace there. (Lgb)
85 int numberOfLabelHfills(Paragraph const & par, Row const & row)
87 pos_type last = lastPos(par, row);
88 pos_type first = row.pos();
90 // hfill *DO* count at the beginning of paragraphs!
92 while (first < last && par.isHfill(first))
96 last = min(last, par.beginningOfBody());
99 // last, because the end is ignored
100 for (pos_type p = first; p < last; ++p) {
109 bool hfillExpansion(Paragraph const & par, Row const & row, pos_type pos)
111 if (!par.isHfill(pos))
114 // at the end of a row it does not count
115 // unless another hfill exists on the line
116 if (pos >= lastPos(par, row)) {
117 for (pos_type i = row.pos(); i < pos && !par.isHfill(i); ++i)
121 // at the beginning of a row it does not count, if it is not
122 // the first row of a paragaph
123 if (row.isParStart())
126 // in some labels it does not count
127 if (par.layout()->margintype != MARGIN_MANUAL
128 && pos < par.beginningOfBody())
131 // if there is anything between the first char of the row and
132 // the specified position that is not a newline and not a hfill,
133 // the hfill will count, otherwise not
134 pos_type i = row.pos();
135 while (i < pos && (par.isNewline(i) || par.isHfill(i)))