* qt_helpers.cpp:
[lyx.git] / src / ParIterator.cpp
blob1ddf3479860dc8d27d96302b3bf4f28ce32f44eb
1 /* \file ParIterator.cpp
2 * This file is part of LyX, the document processor.
3 * Licence details can be found in the file COPYING.
5 * \author unknown
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
9 */
11 #include <config.h>
13 #include "ParIterator.h"
15 #include "Paragraph.h"
16 #include "Text.h"
18 #include "insets/Inset.h"
21 namespace lyx {
23 //////////////////////////////////////////////////////////////////////////
25 // ParIterator
27 //////////////////////////////////////////////////////////////////////////
29 ParIterator::ParIterator(DocIterator const & dit)
30 : DocIterator(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++()
53 forwardPar();
54 return *this;
58 ParIterator ParIterator::operator++(int)
60 ParIterator tmp(*this);
61 forwardPar();
62 return tmp;
66 #if 0
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--()
72 // FIXME: look here
73 // DocIterator::backwardPar();
74 return *this;
76 #endif
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 //////////////////////////////////////////////////////////////////////////
111 // ParConstIterator
113 //////////////////////////////////////////////////////////////////////////
116 ParConstIterator::ParConstIterator(Buffer const * buf)
117 : DocIterator(const_cast<Buffer *>(buf))
121 ParConstIterator::ParConstIterator(DocIterator const & dit)
122 : DocIterator(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();
140 return *this;
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();
161 #if 0
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);
173 #endif
176 } // namespace lyx