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-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,
|
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,
|
2009-06-19 12:49:08 +00:00
|
|
|
bool builtin)
|
2000-12-31 05:32:33 +00:00
|
|
|
: type_(type), placement_(placement), ext_(ext), within_(within),
|
2009-11-30 22:28:22 +00:00
|
|
|
style_(style), name_(name), listName_(listName), html_tag_(htmlTag),
|
2010-01-07 17:32:04 +00:00
|
|
|
html_attrib_(htmlAttrib), html_style_(htmlStyle), builtin_(builtin)
|
2000-12-31 05:32:33 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
string const & Floating::type() const
|
|
|
|
{
|
|
|
|
return type_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const & Floating::placement() const
|
|
|
|
{
|
|
|
|
return placement_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-11 03:20:44 +00:00
|
|
|
string const & Floating::ext() const
|
|
|
|
{
|
|
|
|
return ext_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const & Floating::within() const
|
|
|
|
{
|
|
|
|
return within_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string const & Floating::style() const
|
|
|
|
{
|
|
|
|
return style_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-31 05:32:33 +00:00
|
|
|
string const & Floating::name() const
|
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-04 14:39:55 +00:00
|
|
|
string const & Floating::listName() const
|
|
|
|
{
|
|
|
|
return listName_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-19 12:49:08 +00:00
|
|
|
string const & Floating::htmlStyle() const
|
|
|
|
{
|
2009-11-30 20:17:55 +00:00
|
|
|
return html_style_;
|
2009-06-19 12:49:08 +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;
|
|
|
|
string n = type_;
|
|
|
|
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_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-31 05:32:33 +00:00
|
|
|
bool Floating::builtin() const
|
|
|
|
{
|
|
|
|
return builtin_;
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|