3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
17 #include "support/debug.h"
18 #include "support/lstrings.h"
19 #include "support/textutils.h"
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 & docbookTag,
34 string const & docbookAttr, string const & required,
35 bool usesfloat, bool ispredefined,
36 bool allowswide, bool allowssideways)
37 : floattype_(type), placement_(placement), ext_(ext), within_(within),
38 style_(style), name_(name), listname_(listName), listcommand_(listCmd),
39 refprefix_(refPrefix), allowedplacement_(allowedplacement), required_(required),
40 usesfloatpkg_(usesfloat), ispredefined_(ispredefined),
41 allowswide_(allowswide), allowssideways_(allowssideways),
42 html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle),
43 docbook_tag_(docbookTag), docbook_attr_(docbookAttr)
47 string const & Floating::htmlAttrib() const
49 if (html_attrib_.empty())
50 html_attrib_ = "class='" + defaultCSSClass() + "'";
55 string const & Floating::htmlTag() const
57 if (html_tag_.empty())
63 string Floating::defaultCSSClass() const
65 if (!defaultcssclass_.empty())
66 return defaultcssclass_;
68 string n = floattype_;
69 string::const_iterator it = n.begin();
70 string::const_iterator en = n.end();
71 for (; it != en; ++it) {
72 if (!isAlphaASCII(*it))
74 else if (isLower(*it))
77 d += support::lowercase(*it);
79 // are there other characters we need to remove?
80 defaultcssclass_ = "float-" + d;
81 return defaultcssclass_;
85 string const & Floating::docbookAttr() const
91 string const & Floating::docbookTag(bool hasTitle) const
94 if (floattype_ == "figure") {
95 docbook_tag_ = hasTitle ? "figure" : "informalfigure";
96 } else if (floattype_ == "table") {
97 docbook_tag_ = hasTitle ? "table" : "informaltable";
98 } else if (floattype_ == "algorithm") {
99 // TODO: no good translation for now! Figures are the closest match, as they can contain text.
100 // Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
101 docbook_tag_ = "figure";
107 string const & Floating::docbookCaption() const
109 docbook_caption_ = "";
110 if (floattype_ == "figure") {
111 docbook_caption_ = "title";
112 } else if (floattype_ == "table") {
113 docbook_caption_ = "caption";
114 } else if (floattype_ == "algorithm") {
115 // TODO: no good translation for now! Figures are the closest match, as they can contain text.
116 // Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
117 docbook_caption_ = "title";
119 return docbook_caption_;