]> git.lyx.org Git - lyx.git/blob - src/pariterator.C
the pariterator stuff
[lyx.git] / src / pariterator.C
1 /* \file iterators.C
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
12 #include <config.h>
13
14
15 #include "pariterator.h"
16
17 #include "ParagraphList_fwd.h"
18 #include "paragraph.h"
19 #include "lyxtext.h"
20
21 #include "insets/inset.h"
22
23 using lyx::par_type;
24
25 ///
26 /// ParIterator
27 ///
28
29 ParIterator::ParIterator(DocumentIterator const & cur) : DocumentIterator(cur)
30 {}
31
32
33 ParIterator::ParIterator(InsetBase & in, par_type pit) : DocumentIterator(in)
34 {
35         par() = pit;
36 }
37
38
39 ParIterator::ParIterator(ParIterator const & pi)
40         : DocumentIterator(DocumentIterator(pi))
41 {}
42
43
44 ParIterator & ParIterator::operator++()
45 {
46         forwardPar();
47         return *this;
48 }
49
50
51 ParIterator & ParIterator::operator--()
52 {
53 //      DocumentIterator::backwardPar();
54         return *this;
55 }
56
57
58 Paragraph & ParIterator::operator*() const
59 {
60         return text()->getPar(par());
61 }
62
63
64 par_type ParIterator::pit() const
65 {
66         return par();
67 }
68
69
70 Paragraph * ParIterator::operator->() const
71 {
72         return &text()->getPar(par());
73 }
74
75
76 par_type ParIterator::outerPar() const
77 {
78         return bottom().par();
79 }
80
81
82 ParagraphList & ParIterator::plist() const
83 {
84         return text()->paragraphs();
85 }
86
87
88 bool operator==(ParIterator const & iter1, ParIterator const & iter2)
89 {
90         return DocumentIterator(iter1) == DocumentIterator(iter2);
91 }
92
93
94 bool operator!=(ParIterator const & iter1, ParIterator const & iter2)
95 {
96         return !(iter1 == iter2);
97 }
98
99 DocumentIterator
100 makeDocumentIterator(ParIterator const & par, lyx::pos_type pos)
101 {
102         DocumentIterator dit(par);
103         dit.pos() = pos;
104         return dit;
105 }
106
107 ///
108 /// ParConstIterator
109 ///
110
111
112 ParConstIterator::ParConstIterator(InsetBase const & in, par_type pit)
113         : DocumentIterator(const_cast<InsetBase &>(in))
114 {
115         par() = pit;
116 }
117
118
119 ParConstIterator::ParConstIterator(DocumentIterator const & dit)
120         : DocumentIterator(dit)
121 {}
122
123
124 ParConstIterator::ParConstIterator(ParConstIterator const & pi)
125         : DocumentIterator(DocumentIterator(pi))
126 {}
127
128
129 ParConstIterator & ParConstIterator::operator++()
130 {
131         DocumentIterator::forwardPar();
132         return *this;
133 }
134
135
136 Paragraph const & ParConstIterator::operator*() const
137 {
138         return text()->getPar(par());
139 }
140
141
142 Paragraph const * ParConstIterator::operator->() const
143 {
144         return &text()->getPar(par());
145 }
146
147
148 ParagraphList const & ParConstIterator::plist() const
149 {
150         return text()->paragraphs();
151 }
152
153
154 bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
155 {
156         return DocumentIterator(iter1) == DocumentIterator(iter2);
157 }
158
159
160 bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
161 {
162         return !(iter1 == iter2);
163 }