]> git.lyx.org Git - lyx.git/blob - src/Floating.cpp
More requires --> required, for C++2a.
[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, std::string const & allowedplacement,
32                    string const & htmlTag, string const & htmlAttrib,
33                    docstring const & htmlStyle, string const & requires, 
34                    bool usesfloat, bool ispredefined,
35                    bool allowswide, bool allowssideways)
36         : floattype_(type), placement_(placement), ext_(ext), within_(within),
37           style_(style), name_(name), listname_(listName), listcommand_(listCmd),
38           refprefix_(refPrefix), allowedplacement_(allowedplacement), required_(requires),
39           usesfloatpkg_(usesfloat), ispredefined_(ispredefined),
40           allowswide_(allowswide), allowssideways_(allowssideways),
41           html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle)
42 {}
43
44
45 string const & Floating::htmlAttrib() const
46 {
47         if (html_attrib_.empty())
48                 html_attrib_ = "class='" + defaultCSSClass() + "'";
49         return html_attrib_;
50 }
51
52
53 string const & Floating::htmlTag() const
54 {
55         if (html_tag_.empty())
56                 html_tag_ = "div";
57         return html_tag_;
58 }
59
60
61 string Floating::defaultCSSClass() const
62 {
63         if (!defaultcssclass_.empty())
64                 return defaultcssclass_;
65         string d;
66         string n = floattype_;
67         string::const_iterator it = n.begin();
68         string::const_iterator en = n.end();
69         for (; it != en; ++it) {
70                 if (!isAlphaASCII(*it))
71                         d += "_";
72                 else if (isLower(*it))
73                         d += *it;
74                 else
75                         d += support::lowercase(*it);
76         }
77         // are there other characters we need to remove?
78         defaultcssclass_ = "float-" + d;
79         return defaultcssclass_;
80 }
81
82
83 } // namespace lyx