2000-06-28 13:35:52 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
#include "FloatList.h"
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
FloatList::FloatList()
|
|
|
|
{
|
|
|
|
// Insert the latex builtin float-types
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
|
|
// table
|
|
|
|
Floating table("table", "htbp", "lot", "", "plain", "Table", true);
|
|
|
|
list[table.type()] = table;
|
|
|
|
|
|
|
|
// figure
|
|
|
|
Floating figure("figure", "htbp", "lof", "", "plain", "Figure", true);
|
|
|
|
list[figure.type()] = figure;
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
// And we add algorithm too since LyX has
|
2000-12-29 12:48:02 +00:00
|
|
|
// supported that for a long time,
|
|
|
|
// but support for this should probably be moved to a layout file.
|
|
|
|
Floating algorithm("algorithm", "htbp", "loa",
|
|
|
|
"", "ruled", "Algorithm");
|
|
|
|
list[algorithm.type()] = algorithm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FloatList::const_iterator FloatList::begin() const
|
|
|
|
{
|
|
|
|
return list.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FloatList::const_iterator FloatList::end() const
|
|
|
|
{
|
|
|
|
return list.end();
|
2000-07-04 19:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FloatList::newFloat(Floating const & fl)
|
|
|
|
{
|
2000-12-29 12:48:02 +00:00
|
|
|
list[fl.type()] = fl;
|
2000-07-04 19:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
string const FloatList::defaultPlacement(string const & t) const
|
2000-07-04 19:16:35 +00:00
|
|
|
{
|
|
|
|
List::const_iterator cit = list.find(t);
|
|
|
|
if (cit != list.end())
|
2000-12-29 12:48:02 +00:00
|
|
|
return (*cit).second.placement();
|
2000-07-04 19:16:35 +00:00
|
|
|
return string();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
bool FloatList::typeExist(string const & t) const
|
|
|
|
{
|
|
|
|
List::const_iterator cit = list.find(t);
|
|
|
|
return cit != list.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Floating const & FloatList::getType(string const & t) const
|
|
|
|
{
|
|
|
|
// I wish we could use exceptions
|
|
|
|
List::const_iterator cit = list.find(t);
|
|
|
|
if (cit != list.end())
|
|
|
|
return (*cit).second;
|
|
|
|
#ifdef HAVE_EXCEPTIONS
|
|
|
|
throw UnknownFloatType(t);
|
|
|
|
#else
|
|
|
|
static Floating empty_float;
|
|
|
|
return empty_float;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
|
|
FloatList::const_iterator FloatList::operator[](string const & t) const
|
|
|
|
{
|
|
|
|
return list.find(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
// The global floatlist
|
2000-06-28 13:35:52 +00:00
|
|
|
FloatList floatList;
|