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"
23 //////////////////////////////////////////////////////////////////////////
27 //////////////////////////////////////////////////////////////////////////
29 ParIterator::ParIterator(DocIterator const & dit)
34 ParIterator::ParIterator(ParIterator const & pi)
35 : DocIterator(DocIterator(pi))
39 ParIterator par_iterator_begin(Inset & inset)
41 return ParIterator(doc_iterator_begin(&inset.buffer(), &inset));
45 ParIterator par_iterator_end(Inset & inset)
47 return ParIterator(doc_iterator_end(&inset.buffer(), &inset));
51 ParIterator & ParIterator::operator++()
58 ParIterator ParIterator::operator++(int)
60 ParIterator tmp(*this);
67 // Unused member functions. Also having this makes ParIterator not be
68 // an forward iterator anymore. So unless we change that, this function
69 // should not be compiled/used. (Lgb)
70 ParIterator & ParIterator::operator--()
73 // DocIterator::backwardPar();
79 Paragraph & ParIterator::operator*() const
81 return const_cast<Paragraph&>(text()->getPar(pit()));
85 pit_type ParIterator::pit() const
87 return DocIterator::pit();
91 Paragraph * ParIterator::operator->() const
93 return const_cast<Paragraph*>(&text()->getPar(pit()));
97 pit_type ParIterator::outerPar() const
99 return bottom().pit();
103 ParagraphList & ParIterator::plist() const
105 return const_cast<ParagraphList&>(text()->paragraphs());
109 //////////////////////////////////////////////////////////////////////////
113 //////////////////////////////////////////////////////////////////////////
116 ParConstIterator::ParConstIterator(Buffer const * buf)
117 : DocIterator(const_cast<Buffer *>(buf))
121 ParConstIterator::ParConstIterator(DocIterator const & dit)
126 ParConstIterator::ParConstIterator(ParConstIterator const & pi)
127 : DocIterator(DocIterator(pi))
131 void ParConstIterator::push_back(Inset const & inset)
133 DocIterator::push_back(CursorSlice(const_cast<Inset &>(inset)));
137 ParConstIterator & ParConstIterator::operator++()
139 DocIterator::forwardPar();
144 Paragraph const & ParConstIterator::operator*() const
146 return text()->getPar(pit());
150 Paragraph const * ParConstIterator::operator->() const
152 return &text()->getPar(pit());
156 ParagraphList const & ParConstIterator::plist() const
158 return text()->paragraphs();
162 bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
164 // FIXME: this makes two full copies!
165 return DocIterator(iter1) == DocIterator(iter2);
169 bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
171 return !(iter1 == iter2);