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