* Returns whether the iterator is positioned at the last element in a * given level. (e.g. the last word in a line, the last line in a block) */
| 206 | * given level. (e.g. the last word in a line, the last line in a block) |
| 207 | */ |
| 208 | bool PageIterator::IsAtFinalElement(PageIteratorLevel level, |
| 209 | PageIteratorLevel element) const { |
| 210 | if (Empty(element)) return true; // Already at the end! |
| 211 | // The result is true if we step forward by element and find we are |
| 212 | // at the the end of the page or at beginning of *all* levels in: |
| 213 | // [level, element). |
| 214 | // When there is more than one level difference between element and level, |
| 215 | // we could for instance move forward one symbol and still be at the first |
| 216 | // word on a line, so we also have to be at the first symbol in a word. |
| 217 | PageIterator next(*this); |
| 218 | next.Next(element); |
| 219 | if (next.Empty(element)) return true; // Reached the end of the page. |
| 220 | while (element > level) { |
| 221 | element = static_cast<PageIteratorLevel>(element - 1); |
| 222 | if (!next.IsAtBeginningOf(element)) |
| 223 | return false; |
| 224 | } |
| 225 | return true; |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Returns whether this iterator is positioned |
no test coverage detected