]> git.lyx.org Git - lyx.git/blob - src/Floating.cpp
* GuiDocument.cpp: before accessing the buffer() in paramsToDialog(), check
[lyx.git] / src / Floating.cpp
1 /**
2  * \file Floating.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  * \author Jean-Marc Lasgouttes
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "Floating.h"
16
17 #include "support/lstrings.h"
18
19 using namespace std;
20
21
22 namespace lyx {
23
24
25 Floating::Floating()
26 {}
27
28
29 Floating::Floating(string const & type, string const & placement,
30                    string const & ext, string const & within,
31                    string const & style, string const & name,
32                    string const & listName, string const & htmlTag,
33                    string const & htmlAttrib, string const & htmlStyle,
34                    bool builtin)
35         : type_(type), placement_(placement), ext_(ext), within_(within),
36           style_(style), name_(name), listName_(listName), html_tag_(htmlTag),
37           html_attrib_(htmlAttrib), html_style_(htmlStyle), builtin_(builtin)
38 {}
39
40
41 string const & Floating::type() const
42 {
43         return type_;
44 }
45
46
47 string const & Floating::placement() const
48 {
49         return placement_;
50 }
51
52
53 string const & Floating::ext() const
54 {
55         return ext_;
56 }
57
58
59 string const & Floating::within() const
60 {
61         return within_;
62 }
63
64
65 string const & Floating::style() const
66 {
67         return style_;
68 }
69
70
71 string const & Floating::name() const
72 {
73         return name_;
74 }
75
76
77 string const & Floating::listName() const
78 {
79         return listName_;
80 }
81
82
83 string const & Floating::htmlStyle() const
84 {
85         return html_style_;
86 }
87
88
89 string const & Floating::htmlAttrib() const
90 {
91         if (html_attrib_.empty())
92                 html_attrib_ = "class='float " + defaultCSSClass() + "'";
93         return html_attrib_;
94 }
95
96
97 string const & Floating::htmlTag() const
98 {
99         if (html_tag_.empty())
100                 html_tag_ = "div";
101         return html_tag_;
102 }
103
104
105 string Floating::defaultCSSClass() const
106
107         if (!defaultcssclass_.empty())
108                 return defaultcssclass_;
109         string d;
110         string n = type_;
111         string::const_iterator it = n.begin();
112         string::const_iterator en = n.end();
113         for (; it != en; ++it) {
114                 if (!isalpha(*it))
115                         d += "_";
116                 else if (islower(*it))
117                         d += *it;
118                 else
119                         d += support::lowercase(*it);
120         }
121         // are there other characters we need to remove?
122         defaultcssclass_ = "float-" + d;
123         return defaultcssclass_;
124 }
125
126
127 bool Floating::builtin() const
128 {
129         return builtin_;
130 }
131
132
133 } // namespace lyx