2004-03-30 12:14:01 +00:00
|
|
|
|
/* \file pariterator.C
|
2004-03-28 22:00:22 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author unknown
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "pariterator.h"
|
|
|
|
|
|
|
|
|
|
#include "ParagraphList_fwd.h"
|
|
|
|
|
#include "paragraph.h"
|
|
|
|
|
#include "lyxtext.h"
|
|
|
|
|
|
|
|
|
|
#include "insets/inset.h"
|
|
|
|
|
|
|
|
|
|
using lyx::par_type;
|
|
|
|
|
|
2004-04-01 10:21:29 +00:00
|
|
|
|
|
2004-03-28 22:00:22 +00:00
|
|
|
|
///
|
|
|
|
|
/// ParIterator
|
|
|
|
|
///
|
|
|
|
|
|
2004-03-31 19:11:56 +00:00
|
|
|
|
ParIterator::ParIterator(DocIterator const & cur) : DocIterator(cur)
|
2004-03-28 22:00:22 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2004-03-30 08:18:09 +00:00
|
|
|
|
ParIterator par_iterator_begin(InsetBase & inset)
|
2004-03-28 22:00:22 +00:00
|
|
|
|
{
|
2004-03-30 08:18:09 +00:00
|
|
|
|
return ParIterator(doc_iterator_begin(inset));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParIterator par_iterator_end(InsetBase & inset)
|
|
|
|
|
{
|
|
|
|
|
return ParIterator(doc_iterator_end(inset));
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParIterator::ParIterator(ParIterator const & pi)
|
2004-03-31 19:11:56 +00:00
|
|
|
|
: DocIterator(DocIterator(pi))
|
2004-03-28 22:00:22 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParIterator & ParIterator::operator++()
|
|
|
|
|
{
|
|
|
|
|
forwardPar();
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParIterator & ParIterator::operator--()
|
|
|
|
|
{
|
2004-04-01 10:21:29 +00:00
|
|
|
|
#warning look here
|
2004-03-31 19:11:56 +00:00
|
|
|
|
// DocIterator::backwardPar();
|
2004-03-28 22:00:22 +00:00
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph & ParIterator::operator*() const
|
|
|
|
|
{
|
|
|
|
|
return text()->getPar(par());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
par_type ParIterator::pit() const
|
|
|
|
|
{
|
|
|
|
|
return par();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph * ParIterator::operator->() const
|
|
|
|
|
{
|
|
|
|
|
return &text()->getPar(par());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
par_type ParIterator::outerPar() const
|
|
|
|
|
{
|
|
|
|
|
return bottom().par();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParagraphList & ParIterator::plist() const
|
|
|
|
|
{
|
|
|
|
|
return text()->paragraphs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool operator==(ParIterator const & iter1, ParIterator const & iter2)
|
|
|
|
|
{
|
2004-03-31 19:11:56 +00:00
|
|
|
|
return DocIterator(iter1) == DocIterator(iter2);
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool operator!=(ParIterator const & iter1, ParIterator const & iter2)
|
|
|
|
|
{
|
|
|
|
|
return !(iter1 == iter2);
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-01 10:21:29 +00:00
|
|
|
|
|
|
|
|
|
DocIterator makeDocIterator(ParIterator const & par, lyx::pos_type pos)
|
2004-03-28 22:00:22 +00:00
|
|
|
|
{
|
2004-03-31 19:11:56 +00:00
|
|
|
|
DocIterator dit(par);
|
2004-03-28 22:00:22 +00:00
|
|
|
|
dit.pos() = pos;
|
|
|
|
|
return dit;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-01 10:21:29 +00:00
|
|
|
|
|
|
|
|
|
|
2004-03-28 22:00:22 +00:00
|
|
|
|
///
|
|
|
|
|
/// ParConstIterator
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
|
2004-03-31 19:11:56 +00:00
|
|
|
|
ParConstIterator::ParConstIterator(DocIterator const & dit)
|
|
|
|
|
: DocIterator(dit)
|
2004-03-28 22:00:22 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParConstIterator::ParConstIterator(ParConstIterator const & pi)
|
2004-03-31 19:11:56 +00:00
|
|
|
|
: DocIterator(DocIterator(pi))
|
2004-03-28 22:00:22 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParConstIterator & ParConstIterator::operator++()
|
|
|
|
|
{
|
2004-03-31 19:11:56 +00:00
|
|
|
|
DocIterator::forwardPar();
|
2004-03-28 22:00:22 +00:00
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph const & ParConstIterator::operator*() const
|
|
|
|
|
{
|
|
|
|
|
return text()->getPar(par());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph const * ParConstIterator::operator->() const
|
|
|
|
|
{
|
|
|
|
|
return &text()->getPar(par());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParagraphList const & ParConstIterator::plist() const
|
|
|
|
|
{
|
|
|
|
|
return text()->paragraphs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
|
|
|
|
|
{
|
2004-03-31 19:11:56 +00:00
|
|
|
|
return DocIterator(iter1) == DocIterator(iter2);
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
|
|
|
|
|
{
|
|
|
|
|
return !(iter1 == iter2);
|
|
|
|
|
}
|
2004-03-30 08:18:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#warning const correctness!
|
|
|
|
|
|
|
|
|
|
ParConstIterator par_const_iterator_begin(InsetBase const & inset)
|
|
|
|
|
{
|
|
|
|
|
return ParConstIterator(doc_iterator_begin(const_cast<InsetBase &>(inset)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParConstIterator par_const_iterator_end(InsetBase const & inset)
|
|
|
|
|
{
|
|
|
|
|
return ParConstIterator(doc_iterator_end(const_cast<InsetBase &>(inset)));
|
|
|
|
|
}
|