2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetFloat.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* 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
|
|
|
|
*
|
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
|
|
|
|
*/
|
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
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetFloat.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferParams.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
#include "BufferView.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
#include "Cursor.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
#include "debug.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "DispatchResult.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
#include "Floating.h"
|
|
|
|
|
#include "FloatList.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "FuncRequest.h"
|
2005-04-22 08:57:22 +00:00
|
|
|
|
#include "FuncStatus.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#include "gettext.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "OutputParams.h"
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2005-01-06 16:39:35 +00:00
|
|
|
|
#include "support/convert.h"
|
2004-07-24 10:55:30 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using support::contains;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2000-06-28 13:35:52 +00:00
|
|
|
|
using std::endl;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::istringstream;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
2003-09-05 18:02:24 +00:00
|
|
|
|
using std::ostringstream;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
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
|
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
|
InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
|
2007-04-29 12:32:14 +00:00
|
|
|
|
: InsetCollapsable(bp), name_(from_utf8(type))
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2006-10-08 09:36:16 +00:00
|
|
|
|
setLabel(_("float: ") + floatName(type, bp));
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font font(Font::ALL_SANE);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
2007-04-26 17:34:20 +00:00
|
|
|
|
font.setColor(Color::collapsable);
|
2000-07-04 19:16:35 +00:00
|
|
|
|
setLabelFont(font);
|
2003-03-05 17:56:47 +00:00
|
|
|
|
params_.type = type;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
|
InsetFloat::~InsetFloat()
|
|
|
|
|
{
|
2003-11-28 17:13:41 +00:00
|
|
|
|
InsetFloatMailer(*this).hideDialog();
|
2001-07-30 11:56:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2003-03-05 19:46:08 +00:00
|
|
|
|
switch (cmd.action) {
|
2003-08-05 08:07:07 +00:00
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
case LFUN_INSET_MODIFY: {
|
|
|
|
|
InsetFloatParams params;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
InsetFloatMailer::string2params(to_utf8(cmd.argument()), params);
|
2003-03-05 19:46:08 +00:00
|
|
|
|
params_.placement = params.placement;
|
|
|
|
|
params_.wide = params.wide;
|
2004-03-29 11:38:39 +00:00
|
|
|
|
params_.sideways = params.sideways;
|
2004-04-08 15:03:33 +00:00
|
|
|
|
wide(params_.wide, cur.buffer().params());
|
|
|
|
|
sideways(params_.sideways, cur.buffer().params());
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2000-07-17 18:27:53 +00:00
|
|
|
|
}
|
2003-03-07 15:58:02 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE: {
|
2004-01-20 14:25:24 +00:00
|
|
|
|
InsetFloatMailer(*this).updateDialog(&cur.bv());
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2003-03-07 15:58:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-04-01 10:43:45 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE: {
|
|
|
|
|
if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
|
|
|
|
|
InsetFloatMailer(*this).showDialog(&cur.bv());
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-11-24 21:58:42 +00:00
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
2004-04-01 10:43:45 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
default:
|
2004-11-24 21:58:42 +00:00
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2001-05-31 16:48:26 +00:00
|
|
|
|
}
|
2003-03-05 17:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool InsetFloat::getStatus(Cursor & cur, FuncRequest const & cmd,
|
2005-04-22 08:57:22 +00:00
|
|
|
|
FuncStatus & flag) const
|
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_MODIFY:
|
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE:
|
|
|
|
|
flag.enabled(true);
|
2005-04-22 09:16:28 +00:00
|
|
|
|
return true;
|
2005-04-22 08:57:22 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return InsetCollapsable::getStatus(cur, cmd, flag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-05 19:46:08 +00:00
|
|
|
|
void InsetFloatParams::write(ostream & os) const
|
2003-03-05 17:56:47 +00:00
|
|
|
|
{
|
2004-04-02 08:54:37 +00:00
|
|
|
|
os << "Float " << type << '\n';
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2003-08-05 08:07:07 +00:00
|
|
|
|
if (!placement.empty())
|
2003-03-05 19:46:08 +00:00
|
|
|
|
os << "placement " << placement << "\n";
|
2003-08-05 08:07:07 +00:00
|
|
|
|
|
|
|
|
|
if (wide)
|
2003-03-05 19:46:08 +00:00
|
|
|
|
os << "wide true\n";
|
2003-08-05 08:07:07 +00:00
|
|
|
|
else
|
2003-03-05 19:46:08 +00:00
|
|
|
|
os << "wide false\n";
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2004-03-29 11:38:39 +00:00
|
|
|
|
if (sideways)
|
|
|
|
|
os << "sideways true\n";
|
|
|
|
|
else
|
|
|
|
|
os << "sideways false\n";
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void InsetFloatParams::read(Lexer & lex)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2004-04-02 08:54:37 +00:00
|
|
|
|
string token;
|
|
|
|
|
lex >> token;
|
2004-04-01 10:43:45 +00:00
|
|
|
|
if (token == "placement") {
|
2004-04-02 08:54:37 +00:00
|
|
|
|
lex >> placement;
|
2004-04-01 10:43:45 +00:00
|
|
|
|
} else {
|
|
|
|
|
// take countermeasures
|
|
|
|
|
lex.pushToken(token);
|
|
|
|
|
}
|
2004-04-02 08:54:37 +00:00
|
|
|
|
lex >> token;
|
2004-04-01 10:43:45 +00:00
|
|
|
|
if (token == "wide") {
|
2004-04-02 08:54:37 +00:00
|
|
|
|
lex >> wide;
|
2004-04-01 10:43:45 +00:00
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "InsetFloat::Read:: Missing wide!"
|
|
|
|
|
<< endl;
|
|
|
|
|
// take countermeasures
|
|
|
|
|
lex.pushToken(token);
|
|
|
|
|
}
|
2004-04-02 08:54:37 +00:00
|
|
|
|
lex >> token;
|
2004-04-01 10:43:45 +00:00
|
|
|
|
if (token == "sideways") {
|
2004-04-02 08:54:37 +00:00
|
|
|
|
lex >> sideways;
|
2004-04-01 10:43:45 +00:00
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "InsetFloat::Read:: Missing sideways!"
|
|
|
|
|
<< endl;
|
|
|
|
|
// take countermeasures
|
|
|
|
|
lex.pushToken(token);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
2003-03-05 17:56:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetFloat::write(Buffer const & buf, ostream & os) const
|
2003-03-05 19:46:08 +00:00
|
|
|
|
{
|
|
|
|
|
params_.write(os);
|
|
|
|
|
InsetCollapsable::write(buf, os);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void InsetFloat::read(Buffer const & buf, Lexer & lex)
|
2003-03-05 17:56:47 +00:00
|
|
|
|
{
|
2003-03-05 19:46:08 +00:00
|
|
|
|
params_.read(lex);
|
2003-09-09 09:47:59 +00:00
|
|
|
|
wide(params_.wide, buf.params());
|
2004-03-29 11:38:39 +00:00
|
|
|
|
sideways(params_.sideways, 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
|
|
|
|
{
|
2004-02-01 12:46:14 +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
|
|
|
|
}
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2004-03-29 11:38:39 +00:00
|
|
|
|
if (params_.sideways)
|
|
|
|
|
features.require("rotating");
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset> InsetFloat::doClone() const
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
return auto_ptr<Inset>(new InsetFloat(*this));
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 18:52:00 +00:00
|
|
|
|
docstring const InsetFloat::editMessage() const
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2006-09-09 18:52:00 +00:00
|
|
|
|
return _("Opened Float Inset");
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetFloat::latex(Buffer const & buf, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2007-04-29 19:53:54 +00:00
|
|
|
|
FloatList const & floats = buf.params().getTextClass().floats();
|
2004-03-29 11:38:39 +00:00
|
|
|
|
string tmptype = (params_.wide ? params_.type + "*" : params_.type);
|
|
|
|
|
if (params_.sideways) {
|
|
|
|
|
if (params_.type == "table")
|
|
|
|
|
tmptype = "sidewaystable";
|
|
|
|
|
else if (params_.type == "figure")
|
|
|
|
|
tmptype = "sidewaysfigure";
|
|
|
|
|
}
|
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;
|
2003-09-09 09:47:59 +00:00
|
|
|
|
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.
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << "%\n\\begin{" << from_ascii(tmptype) << '}';
|
2001-07-04 07:44:27 +00:00
|
|
|
|
// We only output placement if different from the def_placement.
|
2004-03-29 11:38:39 +00:00
|
|
|
|
// sidewaysfloats always use their own page
|
|
|
|
|
if (!placement.empty() && !params_.sideways) {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << '[' << from_ascii(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
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
int const i = InsetText::latex(buf, os, runparams);
|
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.
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << "\n\\end{" << from_ascii(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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-16 08:15:16 +00:00
|
|
|
|
int InsetFloat::plaintext(Buffer const & buf, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2007-02-16 08:15:16 +00:00
|
|
|
|
{
|
2007-05-01 08:26:40 +00:00
|
|
|
|
os << '[' << buf.B_("float") << ' ' << floatName(params_.type, buf.params()) << ":\n";
|
2007-02-16 08:15:16 +00:00
|
|
|
|
InsetText::plaintext(buf, os, runparams);
|
|
|
|
|
os << "\n]";
|
|
|
|
|
|
2007-02-20 17:52:41 +00:00
|
|
|
|
return PLAINTEXT_NEWLINE + 1; // one char on a separate line
|
2007-02-16 08:15:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
|
int InsetFloat::docbook(Buffer const & buf, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2001-03-23 08:37:44 +00:00
|
|
|
|
{
|
2007-05-28 22:27:45 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
os << '<' << from_ascii(params_.type) << '>';
|
2004-03-25 09:16:36 +00:00
|
|
|
|
int const i = InsetText::docbook(buf, os, runparams);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << "</" << from_ascii(params_.type) << '>';
|
2001-03-23 08:37:44 +00:00
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
bool InsetFloat::insetAllowed(Inset::Code code) const
|
2001-07-12 14:35:38 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
return code != Inset::FLOAT_CODE
|
|
|
|
|
&& code != Inset::FOOT_CODE
|
|
|
|
|
&& code != Inset::MARGIN_CODE;
|
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
|
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (!InsetText::showInsetDialog(bv))
|
2003-11-10 09:06:48 +00:00
|
|
|
|
InsetFloatMailer(const_cast<InsetFloat &>(*this)).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;
|
2006-10-08 09:36:16 +00:00
|
|
|
|
docstring lab = _("float: ") + floatName(params_.type, bp);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-29 11:38:39 +00:00
|
|
|
|
void InsetFloat::sideways(bool s, BufferParams const & bp)
|
|
|
|
|
{
|
|
|
|
|
params_.sideways = s;
|
2006-10-08 09:36:16 +00:00
|
|
|
|
docstring lab = _("float: ") + floatName(params_.type, bp);
|
2004-03-29 11:38:39 +00:00
|
|
|
|
if (params_.sideways)
|
2006-10-08 09:36:16 +00:00
|
|
|
|
lab += _(" (sideways)");
|
2004-03-29 11:38:39 +00:00
|
|
|
|
setLabel(lab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-07-23 09:54:21 +00:00
|
|
|
|
string const InsetFloatMailer::inset2string(Buffer const &) const
|
2003-03-05 19:46:08 +00:00
|
|
|
|
{
|
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-09-15 11:00:00 +00:00
|
|
|
|
istringstream data(in);
|
2007-04-26 11:30:54 +00:00
|
|
|
|
Lexer lex(0,0);
|
2003-03-07 14:08:10 +00:00
|
|
|
|
lex.setStream(data);
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2003-12-11 15:23:15 +00:00
|
|
|
|
string name;
|
|
|
|
|
lex >> name;
|
|
|
|
|
if (!lex || name != name_)
|
|
|
|
|
return print_mailer_error("InsetFloatMailer", in, 1, name_);
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
|
|
|
|
// This is part of the inset proper that is usually swallowed
|
2007-04-29 23:33:02 +00:00
|
|
|
|
// by Text::readInset
|
2003-12-11 15:23:15 +00:00
|
|
|
|
string id;
|
|
|
|
|
lex >> id;
|
|
|
|
|
if (!lex || id != "Float")
|
|
|
|
|
return print_mailer_error("InsetBoxMailer", in, 2, "Float");
|
2003-03-05 19:46:08 +00:00
|
|
|
|
|
2004-04-02 08:54:37 +00:00
|
|
|
|
// We have to read the type here!
|
|
|
|
|
lex >> params.type;
|
2003-12-11 15:23:15 +00:00
|
|
|
|
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-09-15 11:00:00 +00:00
|
|
|
|
return data.str();
|
2003-03-05 19:46:08 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|