]> git.lyx.org Git - lyx.git/blob - src/FloatList.C
Fix export of graphics file with relative path name.
[lyx.git] / src / FloatList.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "FloatList.h"
8
9 // This class is now mostly finished, except one thing, it is a global
10 // object. This will not do. The user (and layout files) are free to
11 // create floats and modify them to fit into a certain document. So it is
12 // pretty clear that each layout needs its own list, as do documents.
13 // However this is also not enough since we really want the user to be
14 // able to create "presistent" floats, in the sense that a user created
15 // float can be used across sessions and across documents. So we need a
16 // global¹ floatlist as well. The interaction between these are not quite
17 // clear, but it seems natural that the definition found in the document
18 // takes precedence.
19 // We also have the issue about what get stored _in_ the lyx file.
20 //
21 // ¹ not absolutely global but somewhere where documents,layouts and
22 // the bufferview can have access to it.
23 //
24 // Lgb
25
26 FloatList::FloatList()
27 {
28         // Insert the latex builtin float-types
29         // (these will later be read from a layout file)
30
31         // table
32         Floating table("table", "htbp", "lot", "", "plain", "Table", true);
33         newFloat(table);
34
35         // figure
36         Floating figure("figure", "htbp", "lof", "", "plain", "Figure", true);
37         newFloat(figure);
38
39         // And we add algorithm too since LyX has
40         // supported that for a long time,
41         // but support for this should probably be moved to a layout file.
42         Floating algorithm("algorithm", "htbp", "loa",
43                            "", "ruled", "Algorithm");
44         newFloat(algorithm);
45 }
46
47
48 FloatList::const_iterator FloatList::begin() const
49 {
50         return list.begin();
51 }
52
53
54 FloatList::const_iterator FloatList::end() const
55 {
56         return list.end();
57 }
58
59
60 void FloatList::newFloat(Floating const & fl)
61 {
62         list[fl.type()] = fl;
63 }
64
65
66 string const FloatList::defaultPlacement(string const & t) const
67 {
68         List::const_iterator cit = list.find(t);
69         if (cit != list.end())
70                 return cit->second.placement();
71         return string();
72 }
73
74
75 bool FloatList::typeExist(string const & t) const
76 {
77         List::const_iterator cit = list.find(t);
78         return cit != list.end();
79 }
80
81
82 Floating const & FloatList::getType(string const & t) const
83 {
84         // I wish we could use exceptions
85         List::const_iterator cit = list.find(t);
86         if (cit != list.end())
87                 return cit->second;
88 #ifdef HAVE_EXCEPTIONS
89         throw UnknownFloatType(t);
90 #else
91         static Floating empty_float;
92         return empty_float;
93 #endif
94 }
95
96
97 FloatList::const_iterator FloatList::operator[](string const & t) const
98 {
99         return list.find(t);
100 }
101
102
103 // The global floatlist
104 FloatList floatList;