2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetfloat.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
|
*/
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
2003-05-13 09:48:57 +00:00
|
|
|
|
#include <config.h>
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
|
|
|
|
#include "insetfloat.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
#include "insettext.h"
|
|
|
|
|
|
|
|
|
|
#include "buffer.h"
|
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "Floating.h"
|
|
|
|
|
#include "FloatList.h"
|
|
|
|
|
#include "funcrequest.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#include "gettext.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
#include "iterators.h"
|
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-05-13 16:24:49 +00:00
|
|
|
|
#include "Lsstream.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#include "lyxfont.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
#include "lyxlex.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#include "lyxtext.h"
|
2003-05-13 09:48:57 +00:00
|
|
|
|
#include "Lsstream.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#include "support/LOstream.h"
|
2001-07-30 11:56:00 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2003-05-13 14:36:24 +00:00
|
|
|
|
#include "support/tostr.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2002-05-23 12:08:47 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2001-07-30 11:56:00 +00:00
|
|
|
|
#include "frontends/Dialogs.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
|
|
|
|
using std::ostream;
|
|
|
|
|
using std::endl;
|
|
|
|
|
|
2003-05-13 16:24:49 +00:00
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
// With this inset it will be possible to support the latex package
|
|
|
|
|
// float.sty, and I am sure that with this and some additional support
|
|
|
|
|
// classes we can support similar functionality in other formats
|
|
|
|
|
// (read DocBook).
|
|
|
|
|
// By using float.sty we will have the same handling for all floats, both
|
|
|
|
|
// for those already in existance (table and figure) and all user created
|
|
|
|
|
// ones<65>. So suddenly we give the users the possibility of creating new
|
|
|
|
|
// kinds of floats on the fly. (and with a uniform look)
|
|
|
|
|
//
|
|
|
|
|
// API to float.sty:
|
|
|
|
|
// \newfloat{type}{placement}{ext}[within]
|
|
|
|
|
// type - The "type" of the new class of floats, like program or
|
|
|
|
|
// algorithm. After the appropriate \newfloat, commands
|
|
|
|
|
// such as \begin{program} or \end{algorithm*} will be
|
|
|
|
|
// available.
|
|
|
|
|
// placement - The default placement for the given class of floats.
|
|
|
|
|
// They are like in standard LaTeX: t, b, p and h for top,
|
|
|
|
|
// bottom, page, and here, respectively. On top of that
|
|
|
|
|
// there is a new type, H, which does not really correspond
|
|
|
|
|
// to a float, since it means: put it "here" and nowhere else.
|
|
|
|
|
// Note, however that the H specifier is special and, because
|
|
|
|
|
// of implementation details cannot be used in the second
|
|
|
|
|
// argument of \newfloat.
|
|
|
|
|
// ext - The file name extension of an auxiliary file for the list
|
|
|
|
|
// of figures (or whatever). LaTeX writes the captions to
|
|
|
|
|
// this file.
|
|
|
|
|
// within - This (optional) argument determines whether floats of this
|
|
|
|
|
// class will be numbered within some sectional unit of the
|
|
|
|
|
// document. For example, if within is equal to chapter, the
|
2002-03-21 17:09:55 +00:00
|
|
|
|
// floats will be numbered within chapters.
|
2000-06-28 13:35:52 +00:00
|
|
|
|
// \floatstyle{style}
|
|
|
|
|
// style - plain, boxed, ruled
|
|
|
|
|
// \floatname{float}{floatname}
|
|
|
|
|
// float -
|
|
|
|
|
// floatname -
|
|
|
|
|
// \floatplacement{float}{placement}
|
|
|
|
|
// float -
|
|
|
|
|
// placement -
|
|
|
|
|
// \restylefloat{float}
|
|
|
|
|
// float -
|
|
|
|
|
// \listof{type}{title}
|
|
|
|
|
// title -
|
|
|
|
|
|
|
|
|
|
// <20> the algorithm float is defined using the float.sty package. Like this
|
|
|
|
|
// \floatstyle{ruled}
|
|
|
|
|
// \newfloat{algorithm}{htbp}{loa}[<sect>]
|
|
|
|
|
// \floatname{algorithm}{Algorithm}
|
|
|
|
|
//
|
2001-03-11 03:20:44 +00:00
|
|
|
|
// The intention is that floats should be definable from two places:
|
|
|
|
|
// - layout files
|
|
|
|
|
// - the "gui" (i.e. by the user)
|
|
|
|
|
//
|
|
|
|
|
// From layout files.
|
|
|
|
|
// This should only be done for floats defined in a documentclass and that
|
|
|
|
|
// does not need any additional packages. The two most known floats in this
|
|
|
|
|
// category is "table" and "figure". Floats defined in layout files are only
|
|
|
|
|
// stored in lyx files if the user modifies them.
|
|
|
|
|
//
|
|
|
|
|
// By the user.
|
|
|
|
|
// There should be a gui dialog (and also a collection of lyxfuncs) where
|
|
|
|
|
// the user can modify existing floats and/or create new ones.
|
|
|
|
|
//
|
|
|
|
|
// The individual floats will also have some settable
|
|
|
|
|
// variables: wide and placement.
|
|
|
|
|
//
|
2000-06-28 13:35:52 +00:00
|
|
|
|
// Lgb
|
|
|
|
|
|
2002-04-26 15:38:15 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
2002-07-21 21:21:06 +00:00
|
|
|
|
// this should not be hardcoded, but be part of the definition
|
|
|
|
|
// of the float (JMarc)
|
|
|
|
|
string const caplayout("Caption");
|
|
|
|
|
|
2002-08-27 15:51:19 +00:00
|
|
|
|
string floatname(string const & type, BufferParams const & bp)
|
2002-04-26 15:38:15 +00:00
|
|
|
|
{
|
2002-08-27 15:51:19 +00:00
|
|
|
|
FloatList const & floats = bp.getLyXTextClass().floats();
|
|
|
|
|
FloatList::const_iterator it = floats[type];
|
|
|
|
|
if (it == floats.end())
|
2002-04-26 15:38:15 +00:00
|
|
|
|
return type;
|
|
|
|
|
|
|
|
|
|
return _(it->second.name());
|
|
|
|
|
}
|
2002-05-01 22:17:09 +00:00
|
|
|
|
|
2002-04-26 15:38:15 +00:00
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
|
InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
|
2003-03-05 17:56:47 +00:00
|
|
|
|
: InsetCollapsable(bp)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2002-04-26 15:38:15 +00:00
|
|
|
|
string lab(_("float: "));
|
2002-08-27 15:51:19 +00:00
|
|
|
|
lab += floatname(type, bp);
|
2000-07-15 23:51:46 +00:00
|
|
|
|
setLabel(lab);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
2001-06-05 17:05:51 +00:00
|
|
|
|
font.setColor(LColor::collapsable);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
setLabelFont(font);
|
2003-03-05 17:56:47 +00:00
|
|
|
|
params_.type = type;
|
2000-09-26 13:54:57 +00:00
|
|
|
|
setInsetName(type);
|
2002-07-21 21:21:06 +00:00
|
|
|
|
LyXTextClass const & tclass = bp.getLyXTextClass();
|
|
|
|
|
if (tclass.hasLayout(caplayout))
|
2003-04-02 17:11:38 +00:00
|
|
|
|
inset.paragraphs.begin()->layout(tclass[caplayout]);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-24 15:07:09 +00:00
|
|
|
|
InsetFloat::InsetFloat(InsetFloat const & in, bool same_id)
|
2003-03-05 17:56:47 +00:00
|
|
|
|
: InsetCollapsable(in, same_id), params_(in.params_)
|
2001-07-24 15:07:09 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
|
InsetFloat::~InsetFloat()
|
|
|
|
|
{
|
2003-03-05 19:46:08 +00:00
|
|
|
|
InsetFloatMailer mailer(*this);
|
|
|
|
|
mailer.hideDialog();
|
2001-07-30 11:56:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
dispatch_result InsetFloat::localDispatch(FuncRequest const & cmd)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2003-03-05 19:46:08 +00:00
|
|
|
|
Inset::RESULT result = UNDISPATCHED;
|
2000-07-17 18:27:53 +00:00
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
case LFUN_INSET_MODIFY: {
|
|
|
|
|
InsetFloatParams params;
|
|
|
|
|
InsetFloatMailer::string2params(cmd.argument, params);
|
|
|
|
|
|
|
|
|
|
params_.placement = params.placement;
|
|
|
|
|
params_.wide = params.wide;
|
|
|
|
|
|
2003-03-28 17:24:33 +00:00
|
|
|
|
wide(params_.wide, cmd.view()->buffer()->params);
|
2003-03-19 14:45:22 +00:00
|
|
|
|
cmd.view()->updateInset(this);
|
2003-03-05 19:46:08 +00:00
|
|
|
|
result = DISPATCHED;
|
2000-07-17 18:27:53 +00:00
|
|
|
|
}
|
2003-03-05 19:46:08 +00:00
|
|
|
|
break;
|
2003-03-07 15:58:02 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE: {
|
|
|
|
|
InsetFloatMailer mailer(*this);
|
2003-03-10 22:12:07 +00:00
|
|
|
|
mailer.updateDialog(cmd.view());
|
2003-03-07 15:58:02 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
default:
|
|
|
|
|
result = InsetCollapsable::localDispatch(cmd);
|
2001-05-31 16:48:26 +00:00
|
|
|
|
}
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
|
|
|
|
return result;
|
2003-03-05 17:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
void InsetFloatParams::write(ostream & os) const
|
2003-03-05 17:56:47 +00:00
|
|
|
|
{
|
2003-03-05 19:46:08 +00:00
|
|
|
|
os << "Float " // getInsetName()
|
|
|
|
|
<< type << '\n';
|
|
|
|
|
|
|
|
|
|
if (!placement.empty()) {
|
|
|
|
|
os << "placement " << placement << "\n";
|
|
|
|
|
}
|
|
|
|
|
if (wide) {
|
|
|
|
|
os << "wide true\n";
|
|
|
|
|
} else {
|
|
|
|
|
os << "wide false\n";
|
|
|
|
|
}
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
void InsetFloatParams::read(LyXLex & lex)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2001-08-06 19:13:25 +00:00
|
|
|
|
if (lex.isOK()) {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
|
string token = lex.getString();
|
2000-06-28 13:35:52 +00:00
|
|
|
|
if (token == "placement") {
|
|
|
|
|
lex.next();
|
2003-03-05 19:46:08 +00:00
|
|
|
|
placement = lex.getString();
|
2000-07-17 18:27:53 +00:00
|
|
|
|
} else {
|
2001-07-25 20:41:22 +00:00
|
|
|
|
// take countermeasures
|
|
|
|
|
lex.pushToken(token);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
2001-05-31 16:48:26 +00:00
|
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
|
token = lex.getString();
|
2001-05-31 16:48:26 +00:00
|
|
|
|
if (token == "wide") {
|
|
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
|
string const tmptoken = lex.getString();
|
2003-03-05 19:46:08 +00:00
|
|
|
|
wide = (tmptoken == "true");
|
2001-05-31 16:48:26 +00:00
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "InsetFloat::Read:: Missing wide!"
|
|
|
|
|
<< endl;
|
2001-07-25 20:41:22 +00:00
|
|
|
|
// take countermeasures
|
|
|
|
|
lex.pushToken(token);
|
2001-05-31 16:48:26 +00:00
|
|
|
|
}
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
2003-03-05 17:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
void InsetFloat::write(Buffer const * buf, ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
params_.write(os);
|
|
|
|
|
InsetCollapsable::write(buf, os);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-05 17:56:47 +00:00
|
|
|
|
void InsetFloat::read(Buffer const * buf, LyXLex & lex)
|
|
|
|
|
{
|
2003-03-05 19:46:08 +00:00
|
|
|
|
params_.read(lex);
|
|
|
|
|
wide(params_.wide, buf->params);
|
2001-06-28 10:25:20 +00:00
|
|
|
|
InsetCollapsable::read(buf, lex);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetFloat::validate(LaTeXFeatures & features) const
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2003-03-19 18:25:36 +00:00
|
|
|
|
if (contains(params_.placement, "H")) {
|
2002-01-10 10:05:45 +00:00
|
|
|
|
features.require("float");
|
2001-07-30 11:56:00 +00:00
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-03-05 17:56:47 +00:00
|
|
|
|
features.useFloat(params_.type);
|
2001-06-28 10:25:20 +00:00
|
|
|
|
InsetCollapsable::validate(features);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
Inset * InsetFloat::clone(Buffer const &, bool same_id) const
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2001-07-24 15:07:09 +00:00
|
|
|
|
return new InsetFloat(*const_cast<InsetFloat *>(this), same_id);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
string const InsetFloat::editMessage() const
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2000-07-04 19:16:35 +00:00
|
|
|
|
return _("Opened Float Inset");
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int InsetFloat::latex(Buffer const * buf,
|
2000-06-28 13:35:52 +00:00
|
|
|
|
ostream & os, bool fragile, bool fp) const
|
|
|
|
|
{
|
2002-08-27 15:51:19 +00:00
|
|
|
|
FloatList const & floats = buf->params.getLyXTextClass().floats();
|
2003-03-05 17:56:47 +00:00
|
|
|
|
string const tmptype = (params_.wide ? params_.type + "*" : params_.type);
|
2001-07-04 07:44:27 +00:00
|
|
|
|
// Figure out the float placement to use.
|
|
|
|
|
// From lowest to highest:
|
|
|
|
|
// - float default placement
|
|
|
|
|
// - document wide default placement
|
|
|
|
|
// - specific float placement
|
|
|
|
|
string placement;
|
|
|
|
|
string const buf_placement = buf->params.float_placement;
|
2003-03-05 17:56:47 +00:00
|
|
|
|
string const def_placement = floats.defaultPlacement(params_.type);
|
|
|
|
|
if (!params_.placement.empty()
|
|
|
|
|
&& params_.placement != def_placement) {
|
|
|
|
|
placement = params_.placement;
|
|
|
|
|
} else if (params_.placement.empty()
|
2002-09-26 08:59:34 +00:00
|
|
|
|
&& !buf_placement.empty()
|
2001-07-04 07:44:27 +00:00
|
|
|
|
&& buf_placement != def_placement) {
|
|
|
|
|
placement = buf_placement;
|
|
|
|
|
}
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2002-05-05 15:15:51 +00:00
|
|
|
|
// The \n is used to force \begin{<floatname>} to appear in a new line.
|
|
|
|
|
// The % is needed to prevent two consecutive \n chars in the case
|
|
|
|
|
// when the current output line is empty.
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << "%\n\\begin{" << tmptype << '}';
|
2001-07-04 07:44:27 +00:00
|
|
|
|
// We only output placement if different from the def_placement.
|
|
|
|
|
if (!placement.empty()) {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '[' << placement << ']';
|
2001-07-04 07:44:27 +00:00
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
os << '\n';
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
int const i = inset.latex(buf, os, fragile, fp);
|
2002-05-05 15:15:51 +00:00
|
|
|
|
|
|
|
|
|
// The \n is used to force \end{<floatname>} to appear in a new line.
|
|
|
|
|
// In this case, we do not case if the current output line is empty.
|
|
|
|
|
os << "\n\\end{" << tmptype << "}\n";
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2002-05-09 13:36:45 +00:00
|
|
|
|
return i + 4;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
int InsetFloat::docbook(Buffer const * buf, ostream & os, bool mixcont) const
|
2001-03-23 08:37:44 +00:00
|
|
|
|
{
|
2003-03-05 17:56:47 +00:00
|
|
|
|
os << '<' << params_.type << '>';
|
2002-06-18 15:44:30 +00:00
|
|
|
|
int const i = inset.docbook(buf, os, mixcont);
|
2003-03-05 17:56:47 +00:00
|
|
|
|
os << "</" << params_.type << '>';
|
2001-03-23 08:37:44 +00:00
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-19 08:52:59 +00:00
|
|
|
|
bool InsetFloat::insetAllowed(Inset::Code code) const
|
2001-07-12 14:35:38 +00:00
|
|
|
|
{
|
|
|
|
|
if (code == Inset::FLOAT_CODE)
|
2001-07-12 12:26:06 +00:00
|
|
|
|
return false;
|
2001-07-13 10:26:31 +00:00
|
|
|
|
if (inset.getLockingInset() != const_cast<InsetFloat *>(this))
|
2001-07-19 08:52:59 +00:00
|
|
|
|
return inset.insetAllowed(code);
|
2001-07-12 14:35:38 +00:00
|
|
|
|
if ((code == Inset::FOOT_CODE) || (code == Inset::MARGIN_CODE))
|
2000-07-04 19:16:35 +00:00
|
|
|
|
return false;
|
|
|
|
|
return true;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-04 19:16:35 +00:00
|
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
|
bool InsetFloat::showInsetDialog(BufferView * bv) const
|
|
|
|
|
{
|
|
|
|
|
if (!inset.showInsetDialog(bv)) {
|
2003-03-05 19:46:08 +00:00
|
|
|
|
InsetFloat * tmp = const_cast<InsetFloat *>(this);
|
|
|
|
|
InsetFloatMailer mailer(*tmp);
|
2003-03-10 22:12:07 +00:00
|
|
|
|
mailer.showDialog(bv);
|
2001-07-30 11:56:00 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-27 15:51:19 +00:00
|
|
|
|
void InsetFloat::wide(bool w, BufferParams const & bp)
|
2000-07-15 23:51:46 +00:00
|
|
|
|
{
|
2003-03-05 17:56:47 +00:00
|
|
|
|
params_.wide = w;
|
2002-04-26 15:38:15 +00:00
|
|
|
|
|
|
|
|
|
string lab(_("float:"));
|
2003-03-05 17:56:47 +00:00
|
|
|
|
lab += floatname(params_.type, bp);
|
2002-04-26 15:38:15 +00:00
|
|
|
|
|
2003-03-05 17:56:47 +00:00
|
|
|
|
if (params_.wide)
|
2002-11-27 10:30:28 +00:00
|
|
|
|
lab += '*';
|
2002-04-26 15:38:15 +00:00
|
|
|
|
|
|
|
|
|
setLabel(lab);
|
2000-07-15 23:51:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-21 21:21:06 +00:00
|
|
|
|
void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const
|
|
|
|
|
{
|
2003-05-21 21:20:50 +00:00
|
|
|
|
ParIterator pit(inset.paragraphs.begin(), inset.paragraphs);
|
|
|
|
|
ParIterator end(inset.paragraphs.end(), inset.paragraphs);
|
2002-10-30 15:09:55 +00:00
|
|
|
|
|
2003-05-22 10:47:31 +00:00
|
|
|
|
a // Find a caption layout in one of the (child inset's) pars
|
2002-10-30 15:09:55 +00:00
|
|
|
|
for (; pit != end; ++pit) {
|
2003-05-22 10:47:31 +00:00
|
|
|
|
if (pit->layout()->name() == caplayout) {
|
2003-05-06 06:16:59 +00:00
|
|
|
|
string const name = floatname(params_.type, buf->params);
|
2002-07-21 21:21:06 +00:00
|
|
|
|
string const str =
|
2002-12-08 22:33:55 +00:00
|
|
|
|
tostr(toclist[name].size() + 1)
|
2003-05-22 10:47:31 +00:00
|
|
|
|
+ ". " + pit->asString(buf, false);
|
|
|
|
|
toc::TocItem const item(pit->id(), 0 , str);
|
2002-12-08 22:33:55 +00:00
|
|
|
|
toclist[name].push_back(item);
|
2002-07-21 21:21:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
|
|
|
|
|
2003-03-07 14:08:10 +00:00
|
|
|
|
string const InsetFloatMailer::name_("float");
|
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
InsetFloatMailer::InsetFloatMailer(InsetFloat & inset)
|
2003-03-07 14:08:10 +00:00
|
|
|
|
: inset_(inset)
|
2003-03-05 19:46:08 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const InsetFloatMailer::inset2string() const
|
|
|
|
|
{
|
2003-03-07 14:08:10 +00:00
|
|
|
|
return params2string(inset_.params());
|
2003-03-05 19:46:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetFloatMailer::string2params(string const & in,
|
|
|
|
|
InsetFloatParams & params)
|
|
|
|
|
{
|
|
|
|
|
params = InsetFloatParams();
|
|
|
|
|
|
2003-04-24 20:02:49 +00:00
|
|
|
|
if (in.empty())
|
|
|
|
|
return;
|
2003-05-21 21:20:50 +00:00
|
|
|
|
|
2003-05-13 16:24:49 +00:00
|
|
|
|
istringstream data(STRCONV(in));
|
2003-03-07 14:08:10 +00:00
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
|
lex.setStream(data);
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2003-03-07 14:08:10 +00:00
|
|
|
|
if (lex.isOK()) {
|
|
|
|
|
lex.next();
|
|
|
|
|
string const token = lex.getString();
|
|
|
|
|
if (token != name_)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
|
|
|
|
// This is part of the inset proper that is usually swallowed
|
|
|
|
|
// by Buffer::readInset
|
2003-03-07 14:08:10 +00:00
|
|
|
|
if (lex.isOK()) {
|
|
|
|
|
lex.next();
|
|
|
|
|
string const token = lex.getString();
|
|
|
|
|
if (token != "Float" || !lex.eatLine())
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2003-03-10 03:11:54 +00:00
|
|
|
|
if (lex.isOK()) {
|
|
|
|
|
params.read(lex);
|
|
|
|
|
}
|
2003-03-05 19:46:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-13 16:24:49 +00:00
|
|
|
|
string const InsetFloatMailer::params2string(InsetFloatParams const & params)
|
2003-03-05 19:46:08 +00:00
|
|
|
|
{
|
|
|
|
|
ostringstream data;
|
2003-03-07 14:08:10 +00:00
|
|
|
|
data << name_ << ' ';
|
2003-03-05 19:46:08 +00:00
|
|
|
|
params.write(data);
|
2003-05-13 16:24:49 +00:00
|
|
|
|
return STRCONV(data.str());
|
2003-03-05 19:46:08 +00:00
|
|
|
|
}
|