2001-09-01 21:26:34 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "iterators.h"
|
|
|
|
|
2001-12-07 18:40:24 +00:00
|
|
|
ParIterator & ParIterator::operator++()
|
2001-09-01 21:26:34 +00:00
|
|
|
{
|
|
|
|
while (!positions.empty()) {
|
2002-02-16 15:59:55 +00:00
|
|
|
ParPosition & p = positions.top();
|
2001-09-01 21:26:34 +00:00
|
|
|
|
|
|
|
// Does the current inset contain more "cells" ?
|
|
|
|
if (p.index >= 0) {
|
|
|
|
++p.index;
|
|
|
|
Paragraph * par = (*p.it)->getFirstParagraph(p.index);
|
|
|
|
if (par) {
|
2002-02-16 15:59:55 +00:00
|
|
|
positions.push(ParPosition(par));
|
2001-09-01 21:26:34 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
++p.it;
|
2001-12-07 18:40:24 +00:00
|
|
|
} else
|
|
|
|
// The following line is needed because the value of
|
|
|
|
// p.it may be invalid if inset was added/removed to
|
|
|
|
// the paragraph pointed by the iterator
|
|
|
|
p.it = p.par->inset_iterator_begin();
|
2001-09-01 21:26:34 +00:00
|
|
|
|
|
|
|
// Try to find the next inset that contains paragraphs
|
2002-02-16 15:59:55 +00:00
|
|
|
Paragraph::inset_iterator end = p.par->inset_iterator_end();
|
|
|
|
for (; p.it != end; ++p.it) {
|
2001-09-01 21:26:34 +00:00
|
|
|
Paragraph * par = (*p.it)->getFirstParagraph(0);
|
|
|
|
if (par) {
|
|
|
|
p.index = 0;
|
2002-02-16 15:59:55 +00:00
|
|
|
positions.push(ParPosition(par));
|
2001-09-01 21:26:34 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Try to go to the next paragarph
|
|
|
|
if (p.par->next()) {
|
|
|
|
p = ParPosition(p.par->next());
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
positions.pop();
|
2001-09-01 21:26:34 +00:00
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|