]> git.lyx.org Git - lyx.git/blob - src/FontIterator.C
* Painter.h:
[lyx.git] / src / FontIterator.C
1 /**
2  * \file src/FontIterator.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alfredo Braunstein
7  *
8  * Full author contact details are available in file CREDITS.
9  *
10  */
11
12
13 #include <config.h>
14
15 #include "FontIterator.h"
16
17 #include "lyxtext.h"
18 #include "paragraph.h"
19
20
21 namespace lyx {
22
23
24 FontIterator::FontIterator(LyXText const & text, Paragraph const & par,
25                            pos_type pos)
26         : text_(text), par_(par), pos_(pos),
27           font_(text.getFont(par, pos)),
28           endspan_(par.fontSpan(pos).last),
29           bodypos_(par.beginOfBody())
30 {}
31
32
33 LyXFont const & FontIterator::operator*() const
34 {
35         return font_;
36 }
37
38
39 LyXFont * FontIterator::operator->()
40 {
41         return &font_;
42 }
43
44
45 FontIterator & FontIterator::operator++()
46 {
47         ++pos_;
48         if (pos_ > endspan_ || pos_ == bodypos_) {
49                 font_ = text_.getFont(par_, pos_);
50                 endspan_ = par_.fontSpan(pos_).last;
51         }
52         return *this;
53 }
54
55
56 } // namespace lyx