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"
|
2002-03-27 00:05:28 +00:00
|
|
|
|
#include "gettext.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
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()
|
|
|
|
|
{
|
2002-09-04 06:52:26 +00:00
|
|
|
|
#if 0
|
2000-07-04 19:16:35 +00:00
|
|
|
|
// Insert the latex builtin float-types
|
2001-03-11 03:20:44 +00:00
|
|
|
|
// (these will later be read from a layout file)
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
// table
|
2002-07-25 11:06:25 +00:00
|
|
|
|
Floating table("table", "tbp", "lot", "", "plain", N_("Table"),
|
2002-04-04 14:39:55 +00:00
|
|
|
|
N_("List of Tables"), true);
|
2001-03-11 03:20:44 +00:00
|
|
|
|
newFloat(table);
|
2000-12-29 12:48:02 +00:00
|
|
|
|
|
|
|
|
|
// figure
|
2002-07-25 11:06:25 +00:00
|
|
|
|
Floating figure("figure", "tbp", "lof",
|
2002-09-04 06:52:26 +00:00
|
|
|
|
"", "plain", N_("Figure"),
|
2002-04-04 14:39:55 +00:00
|
|
|
|
N_("List of Figures"), true);
|
2001-03-11 03:20:44 +00:00
|
|
|
|
newFloat(figure);
|
2002-03-21 17:27:08 +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",
|
2002-04-04 14:39:55 +00:00
|
|
|
|
"", "ruled", N_("Algorithm"),
|
|
|
|
|
N_("List of Algorithms"));
|
2001-03-11 03:20:44 +00:00
|
|
|
|
newFloat(algorithm);
|
2002-09-04 06:52:26 +00:00
|
|
|
|
#endif
|
2000-12-29 12:48:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
FloatList::const_iterator FloatList::begin() const
|
2000-12-29 12:48:02 +00:00
|
|
|
|
{
|
|
|
|
|
return list.begin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
FloatList::const_iterator FloatList::end() const
|
2000-12-29 12:48:02 +00:00
|
|
|
|
{
|
|
|
|
|
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())
|
2001-07-12 11:11:10 +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())
|
2001-07-12 11:11:10 +00:00
|
|
|
|
return cit->second;
|
2000-07-15 23:51:46 +00:00
|
|
|
|
#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);
|
|
|
|
|
}
|