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