]> git.lyx.org Git - lyx.git/blob - src/ParIterator.cpp
Avoid full metrics computation with Update:FitCursor
[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 "CursorSlice.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
30 ParIterator par_iterator_begin(Inset & inset)
31 {
32         return ParIterator(doc_iterator_begin(&inset.buffer(), &inset));
33 }
34
35
36 ParIterator par_iterator_end(Inset & inset)
37 {
38         return ParIterator(doc_iterator_end(&inset.buffer(), &inset));
39 }
40
41
42 ParIterator & ParIterator::operator++()
43 {
44         forwardPar();
45         return *this;
46 }
47
48
49 ParIterator ParIterator::operator++(int)
50 {
51         ParIterator tmp(*this);
52         forwardPar();
53         return tmp;
54 }
55
56
57 #if 0
58 // Unused member functions. Also having this makes ParIterator not be
59 // an forward iterator anymore. So unless we change that, this function
60 // should not be compiled/used. (Lgb)
61 ParIterator & ParIterator::operator--()
62 {
63         // FIXME: look here
64 //      DocIterator::backwardPar();
65         return *this;
66 }
67 #endif
68
69
70 Paragraph & ParIterator::operator*() const
71 {
72         return text()->getPar(pit());
73 }
74
75
76 pit_type ParIterator::pit() const
77 {
78         return DocIterator::pit();
79 }
80
81
82 Paragraph * ParIterator::operator->() const
83 {
84         return &text()->getPar(pit());
85 }
86
87
88 pit_type ParIterator::outerPar() const
89 {
90         return bottom().pit();
91 }
92
93
94 ParagraphList & ParIterator::plist() const
95 {
96         return text()->paragraphs();
97 }
98
99
100 //////////////////////////////////////////////////////////////////////////
101 //
102 // ParConstIterator
103 //
104 //////////////////////////////////////////////////////////////////////////
105
106
107 void ParConstIterator::push_back(Inset const & inset)
108 {
109         DocIterator::push_back(CursorSlice(const_cast<Inset &>(inset)));
110 }
111
112
113 ParConstIterator & ParConstIterator::operator++()
114 {
115         DocIterator::forwardPar();
116         return *this;
117 }
118
119
120 Paragraph const & ParConstIterator::operator*() const
121 {
122         return text()->getPar(pit());
123 }
124
125
126 Paragraph const * ParConstIterator::operator->() const
127 {
128         return &text()->getPar(pit());
129 }
130
131
132 ParagraphList const & ParConstIterator::plist() const
133 {
134         return text()->paragraphs();
135 }
136
137 #if 0
138 bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
139 {
140         return static_cast<DocIterator const &>(iter1) == static_cast<DocIterator const &>(iter2);
141 }
142
143
144 bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
145 {
146         return !(iter1 == iter2);
147 }
148 #endif
149
150
151 } // namespace lyx