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