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"
|
2012-04-26 14:31:42 +00:00
|
|
|
#include "support/textutils.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
|
|
|
|
|
|
|
Floating::Floating(string const & type, string const & placement,
|
|
|
|
string const & ext, string const & within,
|
|
|
|
string const & style, string const & name,
|
2015-05-22 08:37:14 +00:00
|
|
|
string const & listName, std::string const & listCmd,
|
|
|
|
string const & refPrefix, std::string const & allowedplacement,
|
|
|
|
string const & htmlTag, string const & htmlAttrib,
|
2015-05-22 16:59:17 +00:00
|
|
|
string const & htmlStyle, bool usesfloat, bool ispredefined,
|
|
|
|
bool allowswide, bool allowssideways)
|
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),
|
2015-05-22 08:37:14 +00:00
|
|
|
refprefix_(refPrefix), allowedplacement_(allowedplacement),
|
|
|
|
usesfloatpkg_(usesfloat), ispredefined_(ispredefined),
|
2015-05-22 16:59:17 +00:00
|
|
|
allowswide_(allowswide), allowssideways_(allowssideways),
|
2015-05-22 08:37:14 +00:00
|
|
|
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) {
|
2012-04-26 14:31:42 +00:00
|
|
|
if (!isAlphaASCII(*it))
|
2010-01-07 17:32:04 +00:00
|
|
|
d += "_";
|
2012-04-26 14:31:42 +00:00
|
|
|
else if (isLower(*it))
|
2010-01-07 17:32:04 +00:00
|
|
|
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
|