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;
|
2002-08-11 15:03:52 +00:00
|
|
|
Paragraph * par = p.it.getInset()->getFirstParagraph(p.index);
|
2001-09-01 21:26:34 +00:00
|
|
|
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
|
2002-08-11 15:03:52 +00:00
|
|
|
p.it = p.par->insetlist.begin();
|
2001-09-01 21:26:34 +00:00
|
|
|
|
|
|
|
// Try to find the next inset that contains paragraphs
|
2002-08-11 15:03:52 +00:00
|
|
|
InsetList::iterator end = p.par->insetlist.end();
|
2002-02-16 15:59:55 +00:00
|
|
|
for (; p.it != end; ++p.it) {
|
2002-08-11 15:03:52 +00:00
|
|
|
Paragraph * par = p.it.getInset()->getFirstParagraph(0);
|
2001-09-01 21:26:34 +00:00
|
|
|
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;
|
|
|
|
}
|
2002-11-08 01:08:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
ParConstIterator & ParConstIterator::operator++()
|
|
|
|
{
|
|
|
|
while (!positions.empty()) {
|
|
|
|
ParPosition & p = positions.top();
|
|
|
|
|
|
|
|
// Does the current inset contain more "cells" ?
|
|
|
|
if (p.index >= 0) {
|
|
|
|
++p.index;
|
|
|
|
Paragraph * par = p.it.getInset()->getFirstParagraph(p.index);
|
|
|
|
if (par) {
|
|
|
|
positions.push(ParPosition(par));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
++p.it;
|
|
|
|
} 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->insetlist.begin();
|
|
|
|
|
|
|
|
// Try to find the next inset that contains paragraphs
|
|
|
|
InsetList::iterator end = p.par->insetlist.end();
|
|
|
|
for (; p.it != end; ++p.it) {
|
|
|
|
Paragraph * par = p.it.getInset()->getFirstParagraph(0);
|
|
|
|
if (par) {
|
|
|
|
p.index = 0;
|
|
|
|
positions.push(ParPosition(par));
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Try to go to the next paragarph
|
|
|
|
if (p.par->next()) {
|
|
|
|
p = ParPosition(p.par->next());
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
positions.pop();
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|