1 /* \file ParIterator.cpp
2 * This file is part of LyX, the document processor.
3 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
13 #include "ParIterator.h"
15 #include "Paragraph.h"
18 #include "insets/Inset.h"
27 ParIterator::ParIterator(DocIterator const & cur)
32 ParIterator par_iterator_begin(Inset & inset)
34 return ParIterator(doc_iterator_begin(inset));
38 ParIterator par_iterator_end(Inset & inset)
40 return ParIterator(doc_iterator_end(inset));
44 ParIterator::ParIterator(ParIterator const & pi)
45 : DocIterator(DocIterator(pi))
49 ParIterator & ParIterator::operator++()
56 ParIterator ParIterator::operator++(int)
58 ParIterator tmp(*this);
65 // Unused member functions. Also having this makes ParIterator not be
66 // an forward iterator anymore. So unless we change that, this function
67 // should not be compiled/used. (Lgb)
68 ParIterator & ParIterator::operator--()
71 // DocIterator::backwardPar();
77 Paragraph & ParIterator::operator*() const
79 return const_cast<Paragraph&>(text()->getPar(pit()));
83 pit_type ParIterator::pit() const
85 return DocIterator::pit();
89 Paragraph * ParIterator::operator->() const
91 return const_cast<Paragraph*>(&text()->getPar(pit()));
95 pit_type ParIterator::outerPar() const
97 return bottom().pit();
101 ParagraphList & ParIterator::plist() const
103 return const_cast<ParagraphList&>(text()->paragraphs());
112 ParConstIterator::ParConstIterator(DocIterator const & dit)
117 ParConstIterator::ParConstIterator(ParConstIterator const & pi)
118 : DocIterator(DocIterator(pi))
122 void ParConstIterator::push_back(Inset const & inset)
124 DocIterator::push_back(CursorSlice(const_cast<Inset &>(inset)));
128 ParConstIterator & ParConstIterator::operator++()
130 DocIterator::forwardPar();
135 Paragraph const & ParConstIterator::operator*() const
137 return text()->getPar(pit());
141 Paragraph const * ParConstIterator::operator->() const
143 return &text()->getPar(pit());
147 ParagraphList const & ParConstIterator::plist() const
149 return text()->paragraphs();
153 bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
155 // FIXME: this makes two full copies!
156 return DocIterator(iter1) == DocIterator(iter2);
160 bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
162 return !(iter1 == iter2);
167 // FIXME: const correctness!
169 ParConstIterator par_const_iterator_begin(Inset const & inset)
171 return ParConstIterator(doc_iterator_begin(const_cast<Inset &>(inset)));
175 ParConstIterator par_const_iterator_end(Inset const & inset)
177 return ParConstIterator(doc_iterator_end(const_cast<Inset &>(inset)));