2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetfloatlist.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-25 14:26:13 +00:00
|
|
|
|
*/
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
2003-05-13 09:48:57 +00:00
|
|
|
|
#include <config.h>
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
|
|
|
|
#include "insetfloatlist.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
|
|
|
|
|
#include "buffer.h"
|
2003-09-09 11:24:33 +00:00
|
|
|
|
#include "bufferparams.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "Floating.h"
|
2001-05-04 10:36:36 +00:00
|
|
|
|
#include "FloatList.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "funcrequest.h"
|
|
|
|
|
#include "gettext.h"
|
2002-04-04 14:39:55 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2002-07-21 15:51:07 +00:00
|
|
|
|
#include "lyxlex.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2002-07-21 15:51:07 +00:00
|
|
|
|
#include "toc.h"
|
2003-05-13 09:48:57 +00:00
|
|
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
using lyx::docstring;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::support::bformat;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2001-05-04 13:17:01 +00:00
|
|
|
|
using std::endl;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
2001-11-27 10:56:14 +00:00
|
|
|
|
InsetFloatList::InsetFloatList()
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
|
: InsetCommand(InsetCommandParams("floatlist"), "toc")
|
2003-05-13 09:48:57 +00:00
|
|
|
|
{}
|
2001-11-27 10:56:14 +00:00
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-11-27 10:56:14 +00:00
|
|
|
|
InsetFloatList::InsetFloatList(string const & type)
|
Rework InsetCommandParams interface and file storage
* src/insets/insetcommandparams.[Ch]:
(operator[]): New, access a parameter
(clear): New, clear all parameters
(info_): New, stire info about this command
(cmdname): Rename to name_
(contents, options, sec_options): Replace with params_. Parameters
are now stored as docstring.
(findInfo): New factor for command info for all commands
(read, write): Use new syntax
(parameter set and get methods): reimplemenmt for new parameter storage
* src/insets/insetcommand.h
(getParam): New, get a parameter
(setParam): New, set a parameter
(parameter set and get methods): Adjust to InsetCommandParams changes
* src/insets/insetbibitem.[Ch]
(write): Remove, not needed anymore
(directWrite): ditto
* src/insets/insetbibitem.C
(InsetBibitem::read): Use InsetCommand::read
* src/insets/insetref.C
(InsetRef::latex): Use new InsetCommandParams interface
* src/mathed/InsetMathHull.C
(InsetMathHull::doDispatch): ditto
* src/text3.C
(LyXText::dispatch): ditto
* src/factory.C
(createInset): Create InsetCommandParams with command name
(readInset): ditto
(readInset): Remove error message for bibitem, since bibitem is
now a normal command inset
* src/buffer.C: Bump file format number
* src/frontends/controllers/ControlCommand.[Ch]
(ControlCommand): take an additional command name parameter
* src/text.C
(readParToken): Remove code for \bibitem
* lib/lyx2lyx/LyX.py: Bump latest file format number
* lib/lyx2lyx/lyx_1_5.py
(convert_bibitem, convert_commandparams): new, convert to new format
(revert_commandparams): new, convert to old format
* development/FORMAT: document new format
* many other files: Adjust to the changes above
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
|
|
|
|
: InsetCommand(InsetCommandParams("floatlist"), "toc")
|
2001-11-27 10:56:14 +00:00
|
|
|
|
{
|
|
|
|
|
setCmdName(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
docstring const InsetFloatList::getScreenLabel(Buffer const & buf) const
|
2001-05-04 10:36:36 +00:00
|
|
|
|
{
|
2003-09-09 09:47:59 +00:00
|
|
|
|
FloatList const & floats = buf.params().getLyXTextClass().floats();
|
2002-08-27 15:51:19 +00:00
|
|
|
|
FloatList::const_iterator it = floats[getCmdName()];
|
|
|
|
|
if (it != floats.end())
|
2006-10-11 19:40:50 +00:00
|
|
|
|
return buf.B_(it->second.listName());
|
2002-04-28 14:00:48 +00:00
|
|
|
|
else
|
2006-10-11 19:40:50 +00:00
|
|
|
|
return _("ERROR: Nonexistent float type!");
|
2001-05-04 10:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-25 19:13:07 +00:00
|
|
|
|
InsetBase::Code InsetFloatList::lyxCode() const
|
2001-05-04 10:36:36 +00:00
|
|
|
|
{
|
2004-11-25 19:13:07 +00:00
|
|
|
|
return InsetBase::FLOAT_LIST_CODE;
|
2001-05-04 10:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetFloatList::write(Buffer const &, ostream & os) const
|
2001-05-04 10:36:36 +00:00
|
|
|
|
{
|
2001-11-27 10:56:14 +00:00
|
|
|
|
os << "FloatList " << getCmdName() << "\n";
|
2001-05-04 10:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetFloatList::read(Buffer const & buf, LyXLex & lex)
|
2001-05-04 10:36:36 +00:00
|
|
|
|
{
|
2006-10-19 16:36:30 +00:00
|
|
|
|
InsetCommand::read(buf, lex);
|
|
|
|
|
lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
|
|
|
|
|
if (!buf.params().getLyXTextClass().floats().typeExist(getCmdName()))
|
|
|
|
|
lex.printError("InsetFloatList: Unknown float type: `$$Token'");
|
2001-05-04 10:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int InsetFloatList::latex(Buffer const & buf, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const
|
2001-05-04 10:36:36 +00:00
|
|
|
|
{
|
2003-09-09 09:47:59 +00:00
|
|
|
|
FloatList const & floats = buf.params().getLyXTextClass().floats();
|
2002-08-27 15:51:19 +00:00
|
|
|
|
FloatList::const_iterator cit = floats[getCmdName()];
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
2002-08-27 15:51:19 +00:00
|
|
|
|
if (cit != floats.end()) {
|
2001-05-04 10:36:36 +00:00
|
|
|
|
if (cit->second.builtin()) {
|
|
|
|
|
// Only two different types allowed here:
|
|
|
|
|
string const type = cit->second.type();
|
|
|
|
|
if (type == "table") {
|
|
|
|
|
os << "\\listoftables\n";
|
|
|
|
|
} else if (type == "figure") {
|
|
|
|
|
os << "\\listoffigures\n";
|
|
|
|
|
} else {
|
|
|
|
|
os << "%% unknown builtin float\n";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2006-09-09 11:16:28 +00:00
|
|
|
|
// FIXME UNICODE
|
2001-11-27 10:56:14 +00:00
|
|
|
|
os << "\\listof{" << getCmdName() << "}{"
|
2006-09-09 11:16:28 +00:00
|
|
|
|
<< lyx::to_utf8(buf.B_(cit->second.listName())) << "}\n";
|
2001-05-04 10:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2006-09-09 15:27:44 +00:00
|
|
|
|
// FIXME UNICODE
|
2003-05-13 09:48:57 +00:00
|
|
|
|
os << "%%\\listof{" << getCmdName() << "}{"
|
2006-09-11 08:54:10 +00:00
|
|
|
|
<< lyx::to_utf8(bformat(_("List of %1$s"), lyx::from_utf8(cit->second.name())))
|
2002-11-24 15:20:31 +00:00
|
|
|
|
<< "}\n";
|
2001-05-04 10:36:36 +00:00
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
|
int InsetFloatList::plaintext(Buffer const & buffer, lyx::odocstream & os,
|
|
|
|
|
OutputParams const &) const
|
2001-05-04 10:36:36 +00:00
|
|
|
|
{
|
2001-07-28 12:24:16 +00:00
|
|
|
|
os << getScreenLabel(buffer) << "\n\n";
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
2003-07-27 13:18:55 +00:00
|
|
|
|
lyx::toc::asciiTocList(getCmdName(), buffer, os);
|
2001-05-04 10:36:36 +00:00
|
|
|
|
|
|
|
|
|
os << "\n";
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2002-04-04 14:39:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetFloatList::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
|
|
|
|
features.useFloat(getCmdName());
|
|
|
|
|
}
|