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"
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
using lyx::pit_type;
|
2004-03-28 22:00:22 +00:00
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-16 20:41:38 +00:00
|
|
|
|
ParIterator ParIterator::operator++(int)
|
|
|
|
|
{
|
|
|
|
|
ParIterator tmp(*this);
|
|
|
|
|
forwardPar();
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
// Unused member functions. Also having this makes ParIterator not be
|
|
|
|
|
// an forward iterator anymore. So unless we change that, this function
|
|
|
|
|
// should not be compiled/used. (Lgb)
|
2004-03-28 22:00:22 +00:00
|
|
|
|
ParIterator & ParIterator::operator--()
|
|
|
|
|
{
|
2004-04-05 09:36:28 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2004-04-01 10:21:29 +00:00
|
|
|
|
#warning look here
|
2004-04-05 09:36:28 +00:00
|
|
|
|
#endif
|
2004-03-31 19:11:56 +00:00
|
|
|
|
// DocIterator::backwardPar();
|
2004-03-28 22:00:22 +00:00
|
|
|
|
return *this;
|
|
|
|
|
}
|
2004-11-16 20:41:38 +00:00
|
|
|
|
#endif
|
2004-03-28 22:00:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph & ParIterator::operator*() const
|
|
|
|
|
{
|
2005-07-18 11:00:15 +00:00
|
|
|
|
return const_cast<Paragraph&>(text()->getPar(pit()));
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type ParIterator::pit() const
|
2004-03-28 22:00:22 +00:00
|
|
|
|
{
|
2004-11-30 01:59:49 +00:00
|
|
|
|
return DocIterator::pit();
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph * ParIterator::operator->() const
|
|
|
|
|
{
|
2005-07-18 11:00:15 +00:00
|
|
|
|
return const_cast<Paragraph*>(&text()->getPar(pit()));
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type ParIterator::outerPar() const
|
2004-03-28 22:00:22 +00:00
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
return bottom().pit();
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParagraphList & ParIterator::plist() const
|
|
|
|
|
{
|
2005-07-18 11:00:15 +00:00
|
|
|
|
return const_cast<ParagraphList&>(text()->paragraphs());
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
return text()->getPar(pit());
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Paragraph const * ParConstIterator::operator->() const
|
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
return &text()->getPar(pit());
|
2004-03-28 22:00:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
2004-04-29 14:49:02 +00:00
|
|
|
|
#ifdef WITH_WARNINGS
|
2004-03-30 08:18:09 +00:00
|
|
|
|
#warning const correctness!
|
2004-04-29 14:49:02 +00:00
|
|
|
|
#endif
|
2004-03-30 08:18:09 +00:00
|
|
|
|
|
|
|
|
|
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)));
|
|
|
|
|
}
|