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