]> git.lyx.org Git - lyx.git/blob - src/iterators.C
Fix for bug: #260 special rules if partially linking
[lyx.git] / src / iterators.C
1 #include <config.h>
2
3 #include "iterators.h"
4
5 ParIterator & ParIterator::operator++()
6 {
7         while (!positions.empty()) {
8                 ParPosition & p = positions.top();
9
10                 // Does the current inset contain more "cells" ?
11                 if (p.index >= 0) {
12                         ++p.index;
13                         Paragraph * par = (*p.it)->getFirstParagraph(p.index);
14                         if (par) {
15                                 positions.push(ParPosition(par));
16                                 return *this;
17                         }
18                         ++p.it;
19                 } else
20                         // The following line is needed because the value of
21                         // p.it may be invalid if inset was added/removed to
22                         // the paragraph pointed by the iterator
23                         p.it = p.par->inset_iterator_begin();
24
25                 // Try to find the next inset that contains paragraphs
26                 Paragraph::inset_iterator end = p.par->inset_iterator_end();
27                 for (; p.it != end; ++p.it) {
28                         Paragraph * par = (*p.it)->getFirstParagraph(0);
29                         if (par) {
30                                 p.index = 0;
31                                 positions.push(ParPosition(par));
32                                 return *this;
33                         }
34                 }
35                 // Try to go to the next paragarph
36                 if (p.par->next()) {
37                         p = ParPosition(p.par->next());
38                         return *this;
39                 }
40
41                 positions.pop();
42         }
43         return *this;
44 }