]> git.lyx.org Git - lyx.git/blob - src/FloatList.cpp
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / FloatList.cpp
1 /**
2  * \file FloatList.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
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 "FloatList.h"
14 #include "Floating.h"
15
16 using namespace std;
17
18 namespace lyx {
19
20 FloatList::FloatList()
21 {}
22
23
24 FloatList::const_iterator FloatList::begin() const
25 {
26         return list.begin();
27 }
28
29
30 FloatList::const_iterator FloatList::end() const
31 {
32         return list.end();
33 }
34
35
36 void FloatList::newFloat(Floating const & fl)
37 {
38         list[fl.floattype()] = fl;
39 }
40
41
42 string const FloatList::defaultPlacement(string const & t) const
43 {
44         List::const_iterator cit = list.find(t);
45         if (cit != list.end())
46                 return cit->second.placement();
47         return string();
48 }
49
50
51 string const FloatList::allowedPlacement(string const & t) const
52 {
53         List::const_iterator cit = list.find(t);
54         if (cit != list.end())
55                 return cit->second.allowedPlacement();
56         return string();
57 }
58
59
60 bool FloatList::typeExist(string const & t) const
61 {
62         List::const_iterator cit = list.find(t);
63         return cit != list.end();
64 }
65
66
67 bool FloatList::allowsWide(string const & t) const
68 {
69         List::const_iterator cit = list.find(t);
70         if (cit != list.end())
71                 return cit->second.allowsWide();
72         return false;
73 }
74
75
76 bool FloatList::allowsSideways(string const & t) const
77 {
78         List::const_iterator cit = list.find(t);
79         if (cit != list.end())
80                 return cit->second.allowsSideways();
81         return false;
82 }
83
84
85 Floating const & FloatList::getType(string const & t) const
86 {
87         // I wish we could use exceptions
88         List::const_iterator cit = list.find(t);
89         if (cit != list.end())
90                 return cit->second;
91 #ifdef HAVE_EXCEPTIONS
92         throw UnknownFloatType(t);
93 #else
94         static Floating const empty_float;
95         return empty_float;
96 #endif
97 }
98
99
100 void FloatList::erase(string const & t)
101 {
102         list.erase(t);
103 }
104
105
106 FloatList::const_iterator FloatList::operator[](string const & t) const
107 {
108         return list.find(t);
109 }
110
111
112 } // namespace lyx