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))
68 first = max(first, par.beginningOfBody());
72 // last, because the end is ignored!
73 for (pos_type p = first; p < last; ++p) {
82 // This is called _once_ from LyXText and should at least be moved into
83 // an anonymous namespace there. (Lgb)
84 int numberOfLabelHfills(Paragraph const & par, Row const & row)
86 pos_type last = lastPos(par, row);
87 pos_type first = row.pos();
89 // hfill *DO* count at the beginning of paragraphs!
91 while (first < last && par.isHfill(first))
94 last = min(last, par.beginningOfBody());
97 // last, because the end is ignored
98 for (pos_type p = first; p < last; ++p) {
107 bool hfillExpansion(Paragraph const & par, Row const & row, pos_type pos)
109 if (!par.isHfill(pos))
112 // at the end of a row it does not count
113 // unless another hfill exists on the line
114 if (pos >= lastPos(par, row)) {
115 for (pos_type i = row.pos(); i < pos && !par.isHfill(i); ++i)
119 // at the beginning of a row it does not count, if it is not
120 // the first row of a paragaph
121 if (row.isParStart())
124 // in some labels it does not count
125 if (par.layout()->margintype != MARGIN_MANUAL
126 && pos < par.beginningOfBody())
129 // if there is anything between the first char of the row and
130 // the specified position that is not a newline and not a hfill,
131 // the hfill will count, otherwise not
132 pos_type i = row.pos();
133 while (i < pos && (par.isNewline(i) || par.isHfill(i)))