]> git.lyx.org Git - lyx.git/blob - src/FontIterator.cpp
cosmetics
[lyx.git] / src / FontIterator.cpp
1 /**
2  * \file src/FontIterator.cpp
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 #include <config.h>
13
14 #include "FontIterator.h"
15
16 #include "TextMetrics.h"
17 #include "Paragraph.h"
18
19
20 namespace lyx {
21
22
23 FontIterator::FontIterator(TextMetrics const & tm,
24                 Paragraph const & par, pit_type pit, pos_type pos)
25         : tm_(tm), par_(par), pit_(pit), pos_(pos),
26           font_(tm.displayFont(pit, pos)),
27           endspan_(par.fontSpan(pos).last),
28           bodypos_(par.beginOfBody())
29 {}
30
31
32 Font const & FontIterator::operator*() const
33 {
34         return font_;
35 }
36
37
38 Font * FontIterator::operator->()
39 {
40         return &font_;
41 }
42
43
44 FontIterator & FontIterator::operator++()
45 {
46         ++pos_;
47         if (pos_ > endspan_ || pos_ == bodypos_) {
48                 font_ = tm_.displayFont(pit_, pos_);
49                 endspan_ = par_.fontSpan(pos_).last;
50         }
51         return *this;
52 }
53
54
55 } // namespace lyx