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