]> git.lyx.org Git - lyx.git/blob - src/FloatList.C
fix typo that put too many include paths for most people
[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         // Insert the latex builtin float-types
30         // (these will later be read from a layout file)
31
32         // table
33         Floating table("table", "htbp", "lot", "", "plain", N_("Table"), true);
34         newFloat(table);
35
36         // figure
37         Floating figure("figure", "htbp", "lof",
38                         "", "plain", N_("Figure"), true);
39         newFloat(figure);
40
41         // And we add algorithm too since LyX has
42         // supported that for a long time,
43         // but support for this should probably be moved to a layout file.
44         Floating algorithm("algorithm", "htbp", "loa",
45                            "", "ruled", N_("Algorithm"));
46         newFloat(algorithm);
47 }
48
49
50 FloatList::const_iterator FloatList::begin() const
51 {
52         return list.begin();
53 }
54
55
56 FloatList::const_iterator FloatList::end() const
57 {
58         return list.end();
59 }
60
61
62 void FloatList::newFloat(Floating const & fl)
63 {
64         list[fl.type()] = fl;
65 }
66
67
68 string const FloatList::defaultPlacement(string const & t) const
69 {
70         List::const_iterator cit = list.find(t);
71         if (cit != list.end())
72                 return cit->second.placement();
73         return string();
74 }
75
76
77 bool FloatList::typeExist(string const & t) const
78 {
79         List::const_iterator cit = list.find(t);
80         return cit != list.end();
81 }
82
83
84 Floating const & FloatList::getType(string const & t) const
85 {
86         // I wish we could use exceptions
87         List::const_iterator cit = list.find(t);
88         if (cit != list.end())
89                 return cit->second;
90 #ifdef HAVE_EXCEPTIONS
91         throw UnknownFloatType(t);
92 #else
93         static Floating empty_float;
94         return empty_float;
95 #endif
96 }
97
98
99 FloatList::const_iterator FloatList::operator[](string const & t) const
100 {
101         return list.find(t);
102 }
103
104
105 // The global floatlist
106 FloatList floatList;