2003-08-22 09:44:59 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file Floating.cpp
|
2003-08-22 09:44:59 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-22 09:44:59 +00:00
|
|
|
* \author Jean-Marc Lasgouttes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Angus Leeming
|
2000-12-31 05:32:33 +00:00
|
|
|
*
|
2003-08-22 09:44:59 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-12-31 05:32:33 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "Floating.h"
|
|
|
|
|
2010-03-05 21:06:22 +00:00
|
|
|
#include "support/docstring.h"
|
2010-01-07 17:32:04 +00:00
|
|
|
#include "support/lstrings.h"
|
2010-03-05 21:06:22 +00:00
|
|
|
#include "support/Messages.h"
|
2010-01-07 17:32:04 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
2007-07-17 17:46:54 +00:00
|
|
|
namespace lyx {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2000-12-31 05:32:33 +00:00
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
Floating::Floating()
|
2000-12-31 05:32:33 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
Floating::Floating(string const & type, string const & placement,
|
|
|
|
string const & ext, string const & within,
|
|
|
|
string const & style, string const & name,
|
2009-11-30 17:08:56 +00:00
|
|
|
string const & listName, string const & htmlTag,
|
2010-01-07 17:32:04 +00:00
|
|
|
string const & htmlAttrib, string const & htmlStyle,
|
2010-03-05 17:24:38 +00:00
|
|
|
bool needsfloat)
|
2010-03-04 13:42:05 +00:00
|
|
|
: floattype_(type), placement_(placement), ext_(ext), within_(within),
|
2010-03-05 17:24:38 +00:00
|
|
|
style_(style), name_(name), listname_(listName), needsfloatpkg_(needsfloat),
|
2010-03-04 13:42:05 +00:00
|
|
|
html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle)
|
2000-12-31 05:32:33 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
2010-03-05 21:06:22 +00:00
|
|
|
docstring const & Floating::listCommand(string const & lang) const
|
|
|
|
{
|
|
|
|
if (listcommand_.empty()) {
|
|
|
|
if (needsFloatPkg())
|
|
|
|
listcommand_ = from_ascii("\\listof{" + floattype_ + "}{")
|
|
|
|
+ getMessages(lang).get(listName()) + "}";
|
|
|
|
else {
|
|
|
|
if (floattype_ == "table")
|
|
|
|
listcommand_ = from_ascii("\\listoftables");
|
|
|
|
else if (floattype_ == "figure")
|
|
|
|
listcommand_ = from_ascii("\\listoffigures");
|
|
|
|
else
|
|
|
|
// FIXME We really need a special tag for this.
|
|
|
|
listcommand_ = from_ascii("\\listof" + floattype_ + "s");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return listcommand_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-07 17:32:04 +00:00
|
|
|
string const & Floating::htmlAttrib() const
|
2009-06-19 12:49:08 +00:00
|
|
|
{
|
2010-01-07 17:32:04 +00:00
|
|
|
if (html_attrib_.empty())
|
|
|
|
html_attrib_ = "class='float " + defaultCSSClass() + "'";
|
|
|
|
return html_attrib_;
|
2009-06-19 12:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-30 17:08:56 +00:00
|
|
|
string const & Floating::htmlTag() const
|
2009-06-19 12:49:08 +00:00
|
|
|
{
|
2009-11-30 20:17:55 +00:00
|
|
|
if (html_tag_.empty())
|
|
|
|
html_tag_ = "div";
|
|
|
|
return html_tag_;
|
2009-06-19 12:49:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-07 17:32:04 +00:00
|
|
|
string Floating::defaultCSSClass() const
|
|
|
|
{
|
|
|
|
if (!defaultcssclass_.empty())
|
|
|
|
return defaultcssclass_;
|
|
|
|
string d;
|
2010-03-04 13:42:05 +00:00
|
|
|
string n = floattype_;
|
2010-01-07 17:32:04 +00:00
|
|
|
string::const_iterator it = n.begin();
|
|
|
|
string::const_iterator en = n.end();
|
|
|
|
for (; it != en; ++it) {
|
|
|
|
if (!isalpha(*it))
|
|
|
|
d += "_";
|
|
|
|
else if (islower(*it))
|
|
|
|
d += *it;
|
|
|
|
else
|
|
|
|
d += support::lowercase(*it);
|
|
|
|
}
|
|
|
|
// are there other characters we need to remove?
|
|
|
|
defaultcssclass_ = "float-" + d;
|
|
|
|
return defaultcssclass_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|