]> git.lyx.org Git - lyx.git/blob - src/FloatList.C
Dekels tabular/textinset patches
[lyx.git] / src / FloatList.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "FloatList.h"
8
9 FloatList::FloatList()
10 {
11         // Insert the latex builtin float-types
12
13         // table
14         Floating table("table", "htbp", "lot", "", "plain", "Table", true);
15         list[table.type()] = table;
16
17         // figure
18         Floating figure("figure", "htbp", "lof", "", "plain", "Figure", true);
19         list[figure.type()] = figure;
20         
21         // And we add algorithm too since LyX has
22         // supported that for a long time,
23         // but support for this should probably be moved to a layout file.
24         Floating algorithm("algorithm", "htbp", "loa",
25                            "", "ruled", "Algorithm");
26         list[algorithm.type()] = algorithm;
27 }
28
29
30 FloatList::const_iterator FloatList::begin() const 
31 {
32         return list.begin();
33 }
34
35
36 FloatList::const_iterator FloatList::end() const 
37 {
38         return list.end();
39 }
40
41
42 void FloatList::newFloat(Floating const & fl)
43 {
44         list[fl.type()] = fl;
45 }
46
47
48 string const FloatList::defaultPlacement(string const & t) const
49 {
50         List::const_iterator cit = list.find(t);
51         if (cit != list.end())
52                 return (*cit).second.placement();
53         return string();
54 }
55
56
57 bool FloatList::typeExist(string const & t) const
58 {
59         List::const_iterator cit = list.find(t);
60         return cit != list.end();
61 }
62
63
64 Floating const & FloatList::getType(string const & t) const
65 {
66         // I wish we could use exceptions
67         List::const_iterator cit = list.find(t);
68         if (cit != list.end())
69                 return (*cit).second;
70 #ifdef HAVE_EXCEPTIONS
71         throw UnknownFloatType(t);
72 #else
73         static Floating empty_float;
74         return empty_float;
75 #endif
76 }
77
78
79 FloatList::const_iterator FloatList::operator[](string const & t) const
80 {
81         return list.find(t);
82 }
83
84
85 // The global floatlist
86 FloatList floatList;