]> git.lyx.org Git - lyx.git/blob - src/FloatList.C
another fix
[lyx.git] / src / FloatList.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "FloatList.h"
8 #include "gettext.h"
9
10 // This class is now mostly finished, except one thing, it is a global
11 // object. This will not do. The user (and layout files) are free to
12 // create floats and modify them to fit into a certain document. So it is
13 // pretty clear that each layout needs its own list, as do documents.
14 // However this is also not enough since we really want the user to be
15 // able to create "presistent" floats, in the sense that a user created
16 // float can be used across sessions and across documents. So we need a
17 // global¹ floatlist as well. The interaction between these are not quite
18 // clear, but it seems natural that the definition found in the document
19 // takes precedence.
20 // We also have the issue about what get stored _in_ the lyx file.
21 //
22 // ¹ not absolutely global but somewhere where documents,layouts and
23 // the bufferview can have access to it.
24 //
25 // Lgb
26
27 FloatList::FloatList()
28 {
29 #if 0
30         // Insert the latex builtin float-types
31         // (these will later be read from a layout file)
32
33         // table
34         Floating table("table", "tbp", "lot", "", "plain", N_("Table"),
35                        N_("List of Tables"), true);
36         newFloat(table);
37
38         // figure
39         Floating figure("figure", "tbp", "lof",
40                         "", "plain", N_("Figure"),
41                         N_("List of Figures"), true);
42         newFloat(figure);
43
44         // And we add algorithm too since LyX has
45         // supported that for a long time,
46         // but support for this should probably be moved to a layout file.
47         Floating algorithm("algorithm", "htbp", "loa",
48                            "", "ruled", N_("Algorithm"),
49                            N_("List of Algorithms"));
50         newFloat(algorithm);
51 #endif
52 }
53
54
55 FloatList::const_iterator FloatList::begin() const
56 {
57         return list.begin();
58 }
59
60
61 FloatList::const_iterator FloatList::end() const
62 {
63         return list.end();
64 }
65
66
67 void FloatList::newFloat(Floating const & fl)
68 {
69         list[fl.type()] = fl;
70 }
71
72
73 string const FloatList::defaultPlacement(string const & t) const
74 {
75         List::const_iterator cit = list.find(t);
76         if (cit != list.end())
77                 return cit->second.placement();
78         return string();
79 }
80
81
82 bool FloatList::typeExist(string const & t) const
83 {
84         List::const_iterator cit = list.find(t);
85         return cit != list.end();
86 }
87
88
89 Floating const & FloatList::getType(string const & t) const
90 {
91         // I wish we could use exceptions
92         List::const_iterator cit = list.find(t);
93         if (cit != list.end())
94                 return cit->second;
95 #ifdef HAVE_EXCEPTIONS
96         throw UnknownFloatType(t);
97 #else
98         static Floating empty_float;
99         return empty_float;
100 #endif
101 }
102
103
104 FloatList::const_iterator FloatList::operator[](string const & t) const
105 {
106         return list.find(t);
107 }