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"
|
|
|
|
|
|
2001-03-11 03:20:44 +00:00
|
|
|
|
// This class is now mostly finished, except one thing, it is a global
|
|
|
|
|
// object. This will not do. The user (and layout files) are free to
|
|
|
|
|
// create floats and modify them to fit into a certain document. So it is
|
|
|
|
|
// pretty clear that each layout needs its own list, as do documents.
|
|
|
|
|
// However this is also not enough since we really want the user to be
|
|
|
|
|
// able to create "presistent" floats, in the sense that a user created
|
|
|
|
|
// float can be used across sessions and across documents. So we need a
|
|
|
|
|
// global<61> floatlist as well. The interaction between these are not quite
|
|
|
|
|
// clear, but it seems natural that the definition found in the document
|
|
|
|
|
// takes precedence.
|
|
|
|
|
// We also have the issue about what get stored _in_ the lyx file.
|
|
|
|
|
//
|
|
|
|
|
// <20> not absolutely global but somewhere where documents,layouts and
|
|
|
|
|
// the bufferview can have access to it.
|
|
|
|
|
//
|
|
|
|
|
// Lgb
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
FloatList::FloatList()
|
|
|
|
|
{
|
|
|
|
|
// Insert the latex builtin float-types
|
2001-03-11 03:20:44 +00:00
|
|
|
|
// (these will later be read from a layout file)
|
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
// table
|
|
|
|
|
Floating table("table", "htbp", "lot", "", "plain", "Table", true);
|
2001-03-11 03:20:44 +00:00
|
|
|
|
newFloat(table);
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
|
|
|
|
// figure
|
|
|
|
|
Floating figure("figure", "htbp", "lof", "", "plain", "Figure", true);
|
2001-03-11 03:20:44 +00:00
|
|
|
|
newFloat(figure);
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
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");
|
2001-03-11 03:20:44 +00:00
|
|
|
|
newFloat(algorithm);
|
2000-12-29 12:48:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|