]> git.lyx.org Git - lyx.git/blob - src/Floating.cpp
* add PreBabelPreamble to Language definition (fixes #4786).
[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/debug.h"
18 #include "support/lstrings.h"
19
20 using namespace std;
21
22
23 namespace lyx {
24
25
26 Floating::Floating()
27 {}
28
29
30 Floating::Floating(string const & type, string const & placement,
31                    string const & ext, string const & within,
32                    string const & style, string const & name,
33                    string const & listName, std::string const & listCmd, 
34                          string const & refPrefix,
35                          string const & htmlTag, string const & htmlAttrib, 
36                          string const & htmlStyle, bool needsfloat)
37         : floattype_(type), placement_(placement), ext_(ext), within_(within),
38           style_(style), name_(name), listname_(listName), listcommand_(listCmd),
39           refprefix_(refPrefix), needsfloatpkg_(needsfloat), html_tag_(htmlTag), 
40                 html_attrib_(htmlAttrib), html_style_(htmlStyle)
41 {}
42
43
44 string const & Floating::htmlAttrib() const
45 {
46         if (html_attrib_.empty())
47                 html_attrib_ = "class='float " + defaultCSSClass() + "'";
48         return html_attrib_;
49 }
50
51
52 string const & Floating::htmlTag() const
53 {
54         if (html_tag_.empty())
55                 html_tag_ = "div";
56         return html_tag_;
57 }
58
59
60 string Floating::defaultCSSClass() const
61
62         if (!defaultcssclass_.empty())
63                 return defaultcssclass_;
64         string d;
65         string n = floattype_;
66         string::const_iterator it = n.begin();
67         string::const_iterator en = n.end();
68         for (; it != en; ++it) {
69                 if (!isalpha(*it))
70                         d += "_";
71                 else if (islower(*it))
72                         d += *it;
73                 else
74                         d += support::lowercase(*it);
75         }
76         // are there other characters we need to remove?
77         defaultcssclass_ = "float-" + d;
78         return defaultcssclass_;
79 }
80
81
82 } // namespace lyx