]> git.lyx.org Git - lyx.git/blob - src/FloatList.C
Alfredo's second patch
[lyx.git] / src / FloatList.C
1 #include <config.h>
2
3 #include "FloatList.h"
4 #include "gettext.h"
5
6 // This class is now mostly finished, except one thing, it is a global
7 // object. This will not do. The user (and layout files) are free to
8 // create floats and modify them to fit into a certain document. So it is
9 // pretty clear that each layout needs its own list, as do documents.
10 // However this is also not enough since we really want the user to be
11 // able to create "presistent" floats, in the sense that a user created
12 // float can be used across sessions and across documents. So we need a
13 // global¹ floatlist as well. The interaction between these are not quite
14 // clear, but it seems natural that the definition found in the document
15 // takes precedence.
16 // We also have the issue about what get stored _in_ the lyx file.
17 //
18 // ¹ not absolutely global but somewhere where documents,layouts and
19 // the bufferview can have access to it.
20 //
21 // Lgb
22
23 FloatList::FloatList()
24 {
25 }
26
27
28 FloatList::const_iterator FloatList::begin() const
29 {
30         return list.begin();
31 }
32
33
34 FloatList::const_iterator FloatList::end() const
35 {
36         return list.end();
37 }
38
39
40 void FloatList::newFloat(Floating const & fl)
41 {
42         list[fl.type()] = fl;
43 }
44
45
46 string const FloatList::defaultPlacement(string const & t) const
47 {
48         List::const_iterator cit = list.find(t);
49         if (cit != list.end())
50                 return cit->second.placement();
51         return string();
52 }
53
54
55 bool FloatList::typeExist(string const & t) const
56 {
57         List::const_iterator cit = list.find(t);
58         return cit != list.end();
59 }
60
61
62 Floating const & FloatList::getType(string const & t) const
63 {
64         // I wish we could use exceptions
65         List::const_iterator cit = list.find(t);
66         if (cit != list.end())
67                 return cit->second;
68 #ifdef HAVE_EXCEPTIONS
69         throw UnknownFloatType(t);
70 #else
71         static Floating empty_float;
72         return empty_float;
73 #endif
74 }
75
76
77 void FloatList::erase(string const & t)
78 {
79         list.erase(t);
80 }
81
82
83 FloatList::const_iterator FloatList::operator[](string const & t) const
84 {
85         return list.find(t);
86 }