2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
|
* \file FloatList.cpp
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "FloatList.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "Floating.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
2007-07-17 17:46:54 +00:00
|
|
|
|
using std::string;
|
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
|
|
|
|
|
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()
|
|
|
|
|
{
|
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
|
|
|
|
|
2002-09-11 07:39:55 +00:00
|
|
|
|
void FloatList::erase(string const & t)
|
|
|
|
|
{
|
|
|
|
|
list.erase(t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
|
FloatList::const_iterator FloatList::operator[](string const & t) const
|
|
|
|
|
{
|
|
|
|
|
return list.find(t);
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|