]> git.lyx.org Git - lyx.git/blobdiff - src/lyxrow.C
fix some C++ parsing bugs
[lyx.git] / src / lyxrow.C
index 7351b7f2481c8896ac4b72b0db4c1a91d59acf0f..ca328bc33f5abdaa5eedb4647548b95af8acc384 100644 (file)
@@ -28,6 +28,30 @@ Row::Row()
 {}
 
 
+Paragraph * Row::par()
+{
+       return par_;
+}
+
+
+Paragraph * Row::par() const
+{
+       return par_;
+}
+
+
+unsigned short Row::height() const
+{
+       return height_;
+}
+
+
+Row * Row::next() const
+{
+       return next_;
+}
+
+
 void Row::par(Paragraph * p)
 {
        par_ = p;
@@ -144,7 +168,7 @@ bool Row::isParEnd() const
 
 pos_type Row::lastPos() const
 {
-       if (!par()->size())
+       if (par()->empty())
                return 0;
 
        if (isParEnd()) {
@@ -159,6 +183,9 @@ namespace {
 
 bool nextRowIsAllInset(Row const & row, pos_type last)
 {
+       if (last + 1 >= row.par()->size())
+               return false;
+
        if (!row.par()->isInset(last + 1))
                return false;
 
@@ -189,10 +216,10 @@ pos_type Row::lastPrintablePos() const
 int Row::numberOfSeparators() const
 {
        pos_type const last = lastPrintablePos();
-       pos_type p = max(pos(), par()->beginningOfMainBody());
+       pos_type p = max(pos(), par()->beginningOfBody());
 
        int n = 0;
-       for (; p <= last; ++p) {
+       for (; p < last; ++p) {
                if (par()->isSeparator(p)) {
                        ++n;
                }
@@ -208,17 +235,17 @@ int Row::numberOfHfills() const
 
        // hfill *DO* count at the beginning of paragraphs!
        if (first) {
-               while (first <= last && par()->isHfill(first)) {
+               while (first < last && par()->isHfill(first)) {
                        ++first;
                }
        }
 
-       first = max(first, par()->beginningOfMainBody());
+       first = max(first, par()->beginningOfBody());
 
        int n = 0;
 
        // last, because the end is ignored!
-       for (pos_type p = first; p <= last; ++p) {
+       for (pos_type p = first; p < last; ++p) {
                if (par()->isHfill(p))
                        ++n;
        }
@@ -237,7 +264,7 @@ int Row::numberOfLabelHfills() const
                        ++first;
        }
 
-       last = min(last, par()->beginningOfMainBody());
+       last = min(last, par()->beginningOfBody());
        int n = 0;
 
        // last, because the end is ignored!
@@ -271,17 +298,16 @@ bool Row::hfillExpansion(pos_type pos) const
        if (isParStart())
                return true;
 
-       // in some labels  it does not count
+       // in some labels it does not count
        if (par()->layout()->margintype != MARGIN_MANUAL
-           && pos < par()->beginningOfMainBody())
+           && pos < par()->beginningOfBody())
                return false;
 
        // if there is anything between the first char of the row and
-       // the sepcified position that is not a newline and not a hfill,
+       // the specified position that is not a newline and not a hfill,
        // the hfill will count, otherwise not
        pos_type i = this->pos();
-       while (i < pos && (par()->isNewline(i)
-                          || par()->isHfill(i)))
+       while (i < pos && (par()->isNewline(i) || par()->isHfill(i)))
                ++i;
 
        return i != pos;