]> git.lyx.org Git - lyx.git/blob - src/ParIterator.cpp
Update status
[lyx.git] / src / ParIterator.cpp
1 /* \file ParIterator.cpp
2  * This file is part of LyX, the document processor.
3  * Licence details can be found in the file COPYING.
4  *
5  * \author unknown
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "ParIterator.h"
14
15 #include "Paragraph.h"
16 #include "Text.h"
17
18 #include "insets/Inset.h"
19
20
21 namespace lyx {
22
23 //////////////////////////////////////////////////////////////////////////
24 //
25 // ParIterator
26 //
27 //////////////////////////////////////////////////////////////////////////
28
29 ParIterator::ParIterator(DocIterator const & dit)
30         : DocIterator(dit)
31 {}
32
33
34 ParIterator::ParIterator(ParIterator const & pi)
35         : DocIterator(DocIterator(pi))
36 {}
37
38
39 ParIterator par_iterator_begin(Inset & inset)
40 {
41         return ParIterator(doc_iterator_begin(&inset.buffer(), &inset));
42 }
43
44
45 ParIterator par_iterator_end(Inset & inset)
46 {
47         return ParIterator(doc_iterator_end(&inset.buffer(), &inset));
48 }
49
50
51 ParIterator & ParIterator::operator++()
52 {
53         forwardPar();
54         return *this;
55 }
56
57
58 ParIterator ParIterator::operator++(int)
59 {
60         ParIterator tmp(*this);
61         forwardPar();
62         return tmp;
63 }
64
65
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--()
71 {
72         // FIXME: look here
73 //      DocIterator::backwardPar();
74         return *this;
75 }
76 #endif
77
78
79 Paragraph & ParIterator::operator*() const
80 {
81         return const_cast<Paragraph&>(text()->getPar(pit()));
82 }
83
84
85 pit_type ParIterator::pit() const
86 {
87         return DocIterator::pit();
88 }
89
90
91 Paragraph * ParIterator::operator->() const
92 {
93         return const_cast<Paragraph*>(&text()->getPar(pit()));
94 }
95
96
97 pit_type ParIterator::outerPar() const
98 {
99         return bottom().pit();
100 }
101
102
103 ParagraphList & ParIterator::plist() const
104 {
105         return const_cast<ParagraphList&>(text()->paragraphs());
106 }
107
108
109 //////////////////////////////////////////////////////////////////////////
110 //
111 // ParConstIterator
112 //
113 //////////////////////////////////////////////////////////////////////////
114
115
116 ParConstIterator::ParConstIterator(Buffer const * buf)
117         : DocIterator(const_cast<Buffer *>(buf))
118 {}
119
120
121 ParConstIterator::ParConstIterator(DocIterator const & dit)
122         : DocIterator(dit)
123 {}
124
125
126 ParConstIterator::ParConstIterator(ParConstIterator const & pi)
127         : DocIterator(DocIterator(pi))
128 {}
129
130
131 void ParConstIterator::push_back(Inset const & inset)
132 {
133         DocIterator::push_back(CursorSlice(const_cast<Inset &>(inset)));
134 }
135
136
137 ParConstIterator & ParConstIterator::operator++()
138 {
139         DocIterator::forwardPar();
140         return *this;
141 }
142
143
144 Paragraph const & ParConstIterator::operator*() const
145 {
146         return text()->getPar(pit());
147 }
148
149
150 Paragraph const * ParConstIterator::operator->() const
151 {
152         return &text()->getPar(pit());
153 }
154
155
156 ParagraphList const & ParConstIterator::plist() const
157 {
158         return text()->paragraphs();
159 }
160
161 #if 0
162 bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
163 {
164         // FIXME: this makes two full copies!
165         return DocIterator(iter1) == DocIterator(iter2);
166 }
167
168
169 bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
170 {
171         return !(iter1 == iter2);
172 }
173 #endif
174
175
176 } // namespace lyx