2007-04-26 04:41:58 +00:00
|
|
|
/* \file ParIterator.cpp
|
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
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2004-03-28 22:00:22 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "ParIterator.h"
|
2004-03-28 22:00:22 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Paragraph.h"
|
2007-04-29 23:33:02 +00:00
|
|
|
#include "Text.h"
|
2004-03-28 22:00:22 +00:00
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
#include "insets/Inset.h"
|
2004-03-28 22:00:22 +00:00
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
2004-04-01 10:21:29 +00:00
|
|
|
|
2008-11-17 11:46:07 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ParIterator
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2004-03-28 22:00:22 +00:00
|
|
|
|
2008-11-17 11:46:07 +00:00
|
|
|
ParIterator::ParIterator(DocIterator const & dit)
|
|
|
|
: DocIterator(dit)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
ParIterator::ParIterator(ParIterator const & pi)
|
|
|
|
: DocIterator(DocIterator(pi))
|
2004-03-28 22:00:22 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
ParIterator par_iterator_begin(Inset & inset)
|
2004-03-28 22:00:22 +00:00
|
|
|
{
|
2008-11-17 11:46:07 +00:00
|
|
|
return ParIterator(doc_iterator_begin(&inset.buffer(), &inset));
|
2004-03-30 08:18:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
ParIterator par_iterator_end(Inset & inset)
|
2004-03-30 08:18:09 +00:00
|
|
|
{
|
2008-11-17 11:46:07 +00:00
|
|
|
return ParIterator(doc_iterator_end(&inset.buffer(), &inset));
|
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--()
|
|
|
|
{
|
2007-08-10 11:47:12 +00:00
|
|
|
// FIXME: look here
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-17 11:46:07 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// ParConstIterator
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
ParConstIterator::ParConstIterator(Buffer const * buf)
|
|
|
|
: DocIterator(const_cast<Buffer *>(buf))
|
|
|
|
{}
|
2004-03-28 22:00:22 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
{}
|
|
|
|
|
|
|
|
|
2008-02-15 08:32:27 +00:00
|
|
|
void ParConstIterator::push_back(Inset const & inset)
|
|
|
|
{
|
|
|
|
DocIterator::push_back(CursorSlice(const_cast<Inset &>(inset)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2008-01-12 21:38:51 +00:00
|
|
|
#if 0
|
2004-03-28 22:00:22 +00:00
|
|
|
bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
|
|
|
|
{
|
2008-01-12 21:38:51 +00:00
|
|
|
// FIXME: this makes two full copies!
|
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);
|
|
|
|
}
|
2008-01-12 21:38:51 +00:00
|
|
|
#endif
|
2004-03-30 08:18:09 +00:00
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|