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