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 22:58:29 +00:00
|
|
|
#include "support/debug.h"
|
2010-01-07 17:32:04 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
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,
|
2010-03-05 22:58:29 +00:00
|
|
|
string const & listName, std::string const & listCmd,
|
2010-03-17 12:23:24 +00:00
|
|
|
string const & refPrefix,
|
2010-03-05 22:58:29 +00:00
|
|
|
string const & htmlTag, string const & htmlAttrib,
|
|
|
|
string const & htmlStyle, bool needsfloat)
|
2010-03-04 13:42:05 +00:00
|
|
|
: floattype_(type), placement_(placement), ext_(ext), within_(within),
|
2010-03-05 22:58:29 +00:00
|
|
|
style_(style), name_(name), listname_(listName), listcommand_(listCmd),
|
2010-03-17 12:23:24 +00:00
|
|
|
refprefix_(refPrefix), needsfloatpkg_(needsfloat), html_tag_(htmlTag),
|
|
|
|
html_attrib_(htmlAttrib), html_style_(htmlStyle)
|
2000-12-31 05:32:33 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
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
|