]> git.lyx.org Git - lyx.git/blob - src/FloatList.C
try pre2 again
[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         Floating table;
13         table.type = "table";
14         table.placement = "htbp";
15         table.ext = "lot";
16         table.within = "";
17         table.style = "plain";
18         table.name = "Table";
19         table.builtin = true;
20         list[table.type] = table;
21         Floating figure;
22         figure.type = "figure";
23         figure.placement = "htbp";
24         figure.ext = "lof";
25         figure.within = "";
26         figure.style = "plain";
27         figure.name = "Figure";
28         figure.builtin = true;
29         list[figure.type] = figure;
30         // And we add algorithm too since LyX has
31         // supported that for a long time
32         Floating algorithm;
33         algorithm.type = "algorithm";
34         algorithm.placement = "htbp";
35         algorithm.ext = "loa";
36         algorithm.within = "";
37         algorithm.style = "ruled";
38         algorithm.name = "Algorithm";
39         algorithm.builtin = false;
40         list[algorithm.type] = algorithm;
41 }
42
43
44 void FloatList::newFloat(Floating const & fl)
45 {
46         list[fl.type] = fl;
47 }
48
49
50 string const FloatList::defaultPlacement(string const & t) const
51 {
52         List::const_iterator cit = list.find(t);
53         if (cit != list.end())
54                 return (*cit).second.placement;
55         return string();
56 }
57
58
59 bool FloatList::typeExist(string const & t) const
60 {
61         List::const_iterator cit = list.find(t);
62         return cit != list.end();
63 }
64
65
66 Floating const & FloatList::getType(string const & t) const
67 {
68         // I wish we could use exceptions
69         List::const_iterator cit = list.find(t);
70         if (cit != list.end())
71                 return (*cit).second;
72 #ifdef HAVE_EXCEPTIONS
73         throw UnknownFloatType(t);
74 #else
75         static Floating empty_float;
76         return empty_float;
77 #endif
78 }
79
80 // The global floatlist
81 FloatList floatList;