2003-11-12 14:38:26 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetCharStyle.cpp
|
2003-11-12 14:38:26 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author Martin Vermeer
|
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetCharStyle.h"
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferParams.h"
|
2006-09-26 21:11:22 +00:00
|
|
|
|
#include "BufferView.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "DispatchResult.h"
|
|
|
|
|
#include "FuncRequest.h"
|
2004-11-04 19:50:04 +00:00
|
|
|
|
#include "FuncStatus.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
#include "Cursor.h"
|
2003-11-12 14:38:26 +00:00
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "LaTeXFeatures.h"
|
2007-04-26 17:34:20 +00:00
|
|
|
|
#include "Color.h"
|
2007-04-26 11:30:54 +00:00
|
|
|
|
#include "Lexer.h"
|
2007-04-29 23:33:02 +00:00
|
|
|
|
#include "Text.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
#include "Paragraph.h"
|
2004-10-30 22:14:02 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2004-10-28 15:10:10 +00:00
|
|
|
|
#include "sgml.h"
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
2006-10-07 16:15:06 +00:00
|
|
|
|
#include "frontends/FontMetrics.h"
|
2003-12-06 09:31:30 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
2004-07-24 10:55:30 +00:00
|
|
|
|
|
2006-10-16 07:06:41 +00:00
|
|
|
|
#include "support/convert.h"
|
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2003-11-12 14:38:26 +00:00
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
using std::istringstream;
|
2005-09-06 16:27:24 +00:00
|
|
|
|
using std::max;
|
2003-11-12 14:38:26 +00:00
|
|
|
|
using std::ostream;
|
|
|
|
|
using std::ostringstream;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCharStyle::init()
|
|
|
|
|
{
|
2005-05-06 20:00:31 +00:00
|
|
|
|
setInlined();
|
2004-10-31 12:30:26 +00:00
|
|
|
|
setDrawFrame(false);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-04 11:21:14 +00:00
|
|
|
|
InsetCharStyle::InsetCharStyle(BufferParams const & bp, string const s)
|
|
|
|
|
: InsetCollapsable(bp)
|
|
|
|
|
{
|
|
|
|
|
params_.type = s;
|
|
|
|
|
setUndefined();
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-22 14:44:59 +00:00
|
|
|
|
InsetCharStyle::InsetCharStyle(BufferParams const & bp,
|
2003-11-12 14:38:26 +00:00
|
|
|
|
CharStyles::iterator cs)
|
2004-10-31 12:30:26 +00:00
|
|
|
|
: InsetCollapsable(bp)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
|
|
|
|
params_.type = cs->name;
|
2005-05-04 11:21:14 +00:00
|
|
|
|
setDefined(cs);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InsetCharStyle::InsetCharStyle(InsetCharStyle const & in)
|
2004-10-31 12:30:26 +00:00
|
|
|
|
: InsetCollapsable(in), params_(in.params_)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset> InsetCharStyle::doClone() const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
return auto_ptr<Inset>(new InsetCharStyle(*this));
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-04 11:21:14 +00:00
|
|
|
|
bool InsetCharStyle::undefined() const
|
|
|
|
|
{
|
|
|
|
|
return params_.latexname.empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCharStyle::setUndefined()
|
|
|
|
|
{
|
|
|
|
|
params_.latextype.clear();
|
|
|
|
|
params_.latexname.clear();
|
|
|
|
|
params_.latexparam.clear();
|
2007-04-29 18:17:15 +00:00
|
|
|
|
params_.font = Font(Font::ALL_INHERIT);
|
|
|
|
|
params_.labelfont = Font(Font::ALL_INHERIT);
|
2007-04-26 17:34:20 +00:00
|
|
|
|
params_.labelfont.setColor(Color::error);
|
2006-10-16 07:06:41 +00:00
|
|
|
|
params_.show_label = true;
|
2005-05-04 11:21:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCharStyle::setDefined(CharStyles::iterator cs)
|
|
|
|
|
{
|
|
|
|
|
params_.latextype = cs->latextype;
|
|
|
|
|
params_.latexname = cs->latexname;
|
|
|
|
|
params_.latexparam = cs->latexparam;
|
|
|
|
|
params_.font = cs->font;
|
|
|
|
|
params_.labelfont = cs->labelfont;
|
2006-10-16 07:06:41 +00:00
|
|
|
|
params_.show_label = true;
|
2005-05-04 11:21:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 18:52:00 +00:00
|
|
|
|
docstring const InsetCharStyle::editMessage() const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2006-09-09 18:52:00 +00:00
|
|
|
|
return _("Opened CharStyle Inset");
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCharStyle::write(Buffer const & buf, ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
params_.write(os);
|
|
|
|
|
InsetCollapsable::write(buf, os);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void InsetCharStyle::read(Buffer const & buf, Lexer & lex)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2006-10-16 07:06:41 +00:00
|
|
|
|
params_.read(lex);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
InsetCollapsable::read(buf, lex);
|
2005-05-06 20:00:31 +00:00
|
|
|
|
setInlined();
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font tmpfont = mi.base.font;
|
2003-12-16 18:49:04 +00:00
|
|
|
|
getDrawFont(mi.base.font);
|
2007-04-29 18:17:15 +00:00
|
|
|
|
mi.base.font.reduce(Font(Font::ALL_SANE));
|
2005-04-10 14:07:33 +00:00
|
|
|
|
mi.base.font.realize(tmpfont);
|
2005-02-22 13:19:11 +00:00
|
|
|
|
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
|
2004-10-31 12:30:26 +00:00
|
|
|
|
InsetText::metrics(mi, dim);
|
2003-12-16 18:49:04 +00:00
|
|
|
|
mi.base.font = tmpfont;
|
2006-10-16 07:06:41 +00:00
|
|
|
|
if (params_.show_label) {
|
2005-09-06 16:27:24 +00:00
|
|
|
|
// consider width of the inset label
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font font(params_.labelfont);
|
|
|
|
|
font.realize(Font(Font::ALL_SANE));
|
2005-09-06 16:27:24 +00:00
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
|
|
|
|
int w = 0;
|
|
|
|
|
int a = 0;
|
|
|
|
|
int d = 0;
|
2006-11-11 20:55:40 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
docstring s(from_utf8(params_.type));
|
2005-09-06 16:27:24 +00:00
|
|
|
|
if (undefined())
|
2006-11-11 20:55:40 +00:00
|
|
|
|
s = _("Undef: ") + s;
|
|
|
|
|
theFontMetrics(font).rectText(s, w, a, d);
|
2005-09-06 16:27:24 +00:00
|
|
|
|
dim.wid = max(dim.wid, w);
|
|
|
|
|
}
|
2005-02-22 13:19:11 +00:00
|
|
|
|
dim.asc += TEXT_TO_INSET_OFFSET;
|
|
|
|
|
dim.des += TEXT_TO_INSET_OFFSET;
|
|
|
|
|
dim.wid += 2 * TEXT_TO_INSET_OFFSET;
|
|
|
|
|
mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
|
2006-10-16 07:06:41 +00:00
|
|
|
|
if (params_.show_label)
|
2006-11-28 15:15:49 +00:00
|
|
|
|
dim.des += ascent();
|
|
|
|
|
bool const changed = dim_ != dim;
|
|
|
|
|
dim_ = dim;
|
|
|
|
|
return changed;
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-06 09:31:30 +00:00
|
|
|
|
void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2004-01-30 11:41:12 +00:00
|
|
|
|
setPosCache(pi, x, y);
|
2003-12-06 09:31:30 +00:00
|
|
|
|
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font tmpfont = pi.base.font;
|
2003-12-16 18:49:04 +00:00
|
|
|
|
getDrawFont(pi.base.font);
|
2005-04-26 11:12:20 +00:00
|
|
|
|
// I don't understand why the above .reduce and .realize aren't
|
2005-04-10 14:07:33 +00:00
|
|
|
|
//needed, or even wanted, here. It just works. -- MV 10.04.2005
|
2007-03-26 19:16:49 +00:00
|
|
|
|
InsetText::draw(pi, x + TEXT_TO_INSET_OFFSET, y);
|
2003-12-16 18:49:04 +00:00
|
|
|
|
pi.base.font = tmpfont;
|
2003-12-06 09:31:30 +00:00
|
|
|
|
|
2004-10-31 12:30:26 +00:00
|
|
|
|
int desc = InsetText::descent();
|
2006-10-16 07:06:41 +00:00
|
|
|
|
if (params_.show_label)
|
2004-10-31 12:30:26 +00:00
|
|
|
|
desc -= ascent();
|
2004-11-23 23:04:52 +00:00
|
|
|
|
|
2004-10-31 12:30:26 +00:00
|
|
|
|
pi.pain.line(x, y + desc - 4, x, y + desc, params_.labelfont.color());
|
2005-02-22 13:19:11 +00:00
|
|
|
|
pi.pain.line(x, y + desc, x + dim_.wid - 3, y + desc,
|
2004-10-31 12:30:26 +00:00
|
|
|
|
params_.labelfont.color());
|
2005-02-22 13:19:11 +00:00
|
|
|
|
pi.pain.line(x + dim_.wid - 3, y + desc, x + dim_.wid - 3, y + desc - 4,
|
2004-10-31 12:30:26 +00:00
|
|
|
|
params_.labelfont.color());
|
2004-11-23 23:04:52 +00:00
|
|
|
|
|
2004-11-04 19:50:04 +00:00
|
|
|
|
// the name of the charstyle. Can be toggled.
|
2006-10-16 07:06:41 +00:00
|
|
|
|
if (params_.show_label) {
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font font(params_.labelfont);
|
|
|
|
|
font.realize(Font(Font::ALL_SANE));
|
2004-03-25 09:16:36 +00:00
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
|
|
|
|
int w = 0;
|
|
|
|
|
int a = 0;
|
|
|
|
|
int d = 0;
|
2006-11-11 20:55:40 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
docstring s(from_utf8(params_.type));
|
2005-05-04 11:21:14 +00:00
|
|
|
|
if (undefined())
|
2006-11-11 20:55:40 +00:00
|
|
|
|
s = _("Undef: ") + s;
|
|
|
|
|
theFontMetrics(font).rectText(s, w, a, d);
|
2004-10-31 12:30:26 +00:00
|
|
|
|
pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a,
|
2007-04-26 17:34:20 +00:00
|
|
|
|
s, font, Color::none, Color::none);
|
2003-12-06 09:31:30 +00:00
|
|
|
|
}
|
2004-11-23 23:04:52 +00:00
|
|
|
|
|
2004-11-04 19:50:04 +00:00
|
|
|
|
// a visual clue when the cursor is inside the inset
|
2007-04-26 14:56:30 +00:00
|
|
|
|
Cursor & cur = pi.base.bv->cursor();
|
2004-11-04 19:50:04 +00:00
|
|
|
|
if (cur.isInside(this)) {
|
|
|
|
|
y -= ascent();
|
|
|
|
|
pi.pain.line(x, y + 4, x, y, params_.labelfont.color());
|
|
|
|
|
pi.pain.line(x + 4, y, x, y, params_.labelfont.color());
|
2005-02-22 13:19:11 +00:00
|
|
|
|
pi.pain.line(x + dim_.wid - 3, y + 4, x + dim_.wid - 3, y,
|
2004-11-04 19:50:04 +00:00
|
|
|
|
params_.labelfont.color());
|
2005-02-22 13:19:11 +00:00
|
|
|
|
pi.pain.line(x + dim_.wid - 7, y, x + dim_.wid - 3, y,
|
2004-11-04 19:50:04 +00:00
|
|
|
|
params_.labelfont.color());
|
|
|
|
|
}
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 18:17:15 +00:00
|
|
|
|
void InsetCharStyle::getDrawFont(Font & font) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
|
|
|
|
font = params_.font;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void InsetCharStyle::doDispatch(Cursor & cur, FuncRequest & cmd)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2005-05-06 20:00:31 +00:00
|
|
|
|
setInlined();
|
2003-12-06 09:31:30 +00:00
|
|
|
|
switch (cmd.action) {
|
2006-09-19 09:39:17 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_MOUSE_PRESS:
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (cmd.button() == mouse_button::button3)
|
2006-10-16 07:06:41 +00:00
|
|
|
|
params_.show_label = !params_.show_label;
|
2004-02-16 11:58:51 +00:00
|
|
|
|
else
|
2004-11-24 21:58:42 +00:00
|
|
|
|
InsetText::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2006-09-19 09:39:17 +00:00
|
|
|
|
|
2006-10-16 07:06:41 +00:00
|
|
|
|
case LFUN_INSET_TOGGLE:
|
|
|
|
|
if (cmd.argument() == "open")
|
|
|
|
|
params_.show_label = true;
|
|
|
|
|
else if (cmd.argument() == "close")
|
|
|
|
|
params_.show_label = false;
|
|
|
|
|
else if (cmd.argument() == "toggle" || cmd.argument().empty())
|
|
|
|
|
params_.show_label = !params_.show_label;
|
|
|
|
|
else // if assign or anything else
|
|
|
|
|
cur.undispatched();
|
|
|
|
|
cur.dispatched();
|
|
|
|
|
break;
|
|
|
|
|
|
2006-09-19 09:39:17 +00:00
|
|
|
|
default:
|
2006-03-25 16:23:06 +00:00
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
|
|
|
|
break;
|
2003-12-06 09:31:30 +00:00
|
|
|
|
}
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool InsetCharStyle::getStatus(Cursor & cur, FuncRequest const & cmd,
|
2004-11-04 19:50:04 +00:00
|
|
|
|
FuncStatus & status) const
|
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
// paragraph breaks not allowed in charstyle insets
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BREAK_PARAGRAPH:
|
2006-05-08 18:09:19 +00:00
|
|
|
|
case LFUN_BREAK_PARAGRAPH_KEEP_LAYOUT:
|
2006-05-05 20:23:12 +00:00
|
|
|
|
case LFUN_BREAK_PARAGRAPH_SKIP:
|
2004-11-04 19:50:04 +00:00
|
|
|
|
status.enabled(false);
|
|
|
|
|
return true;
|
2004-11-23 23:04:52 +00:00
|
|
|
|
|
2004-11-04 19:50:04 +00:00
|
|
|
|
default:
|
|
|
|
|
return InsetCollapsable::getStatus(cur, cmd, status);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetCharStyle::latex(Buffer const & buf, odocstream & os,
|
2007-02-17 15:28:50 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2005-05-04 11:21:14 +00:00
|
|
|
|
if (!undefined()) {
|
2006-10-19 16:51:30 +00:00
|
|
|
|
// FIXME UNICODE
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << '\\' << from_utf8(params_.latexname);
|
2005-05-04 11:21:14 +00:00
|
|
|
|
if (!params_.latexparam.empty())
|
2006-10-21 00:16:43 +00:00
|
|
|
|
os << from_utf8(params_.latexparam);
|
2006-10-19 16:51:30 +00:00
|
|
|
|
os << '{';
|
2005-05-04 11:21:14 +00:00
|
|
|
|
}
|
2004-10-30 13:27:30 +00:00
|
|
|
|
int i = InsetText::latex(buf, os, runparams);
|
2005-05-04 11:21:14 +00:00
|
|
|
|
if (!undefined())
|
|
|
|
|
os << "}";
|
2003-11-12 14:38:26 +00:00
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-02-17 15:28:50 +00:00
|
|
|
|
int InsetCharStyle::plaintext(Buffer const & buf, odocstream & os,
|
|
|
|
|
OutputParams const & runparams) const
|
|
|
|
|
{
|
|
|
|
|
return InsetText::plaintext(buf, os, runparams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
|
int InsetCharStyle::docbook(Buffer const & buf, odocstream & os,
|
2007-02-17 15:28:50 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2006-03-23 20:11:06 +00:00
|
|
|
|
ParagraphList::const_iterator beg = paragraphs().begin();
|
2004-10-30 22:14:02 +00:00
|
|
|
|
ParagraphList::const_iterator par = paragraphs().begin();
|
2006-04-05 23:56:29 +00:00
|
|
|
|
ParagraphList::const_iterator end = paragraphs().end();
|
2004-10-30 22:14:02 +00:00
|
|
|
|
|
2005-05-04 11:21:14 +00:00
|
|
|
|
if (!undefined())
|
2006-10-19 21:00:33 +00:00
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
sgml::openTag(os, params_.latexname,
|
|
|
|
|
par->getID(buf, runparams) + params_.latexparam);
|
2004-10-30 22:14:02 +00:00
|
|
|
|
|
2006-04-05 23:56:29 +00:00
|
|
|
|
for (; par != end; ++par) {
|
2004-10-30 22:14:02 +00:00
|
|
|
|
par->simpleDocBookOnePar(buf, os, runparams,
|
2006-03-23 20:11:06 +00:00
|
|
|
|
outerFont(std::distance(beg, par),
|
2004-10-30 22:14:02 +00:00
|
|
|
|
paragraphs()));
|
2006-04-05 23:56:29 +00:00
|
|
|
|
}
|
2004-10-30 22:14:02 +00:00
|
|
|
|
|
2005-05-04 11:21:14 +00:00
|
|
|
|
if (!undefined())
|
|
|
|
|
sgml::closeTag(os, params_.latexname);
|
|
|
|
|
|
2004-10-30 22:14:02 +00:00
|
|
|
|
return 0;
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-01-19 16:23:13 +00:00
|
|
|
|
void InsetCharStyle::textString(Buffer const & buf, odocstream & os) const
|
2005-11-25 14:40:34 +00:00
|
|
|
|
{
|
2007-01-19 16:23:13 +00:00
|
|
|
|
os << paragraphs().begin()->asString(buf, true);
|
2005-11-25 14:40:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-12 14:38:26 +00:00
|
|
|
|
void InsetCharStyle::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
2005-05-04 11:21:14 +00:00
|
|
|
|
// Force inclusion of preamble snippet in layout file
|
2003-11-12 14:38:26 +00:00
|
|
|
|
features.require(params_.type);
|
2005-04-18 11:22:02 +00:00
|
|
|
|
InsetText::validate(features);
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCharStyleParams::write(ostream & os) const
|
|
|
|
|
{
|
2003-11-28 10:12:04 +00:00
|
|
|
|
os << "CharStyle " << type << "\n";
|
2006-10-16 07:06:41 +00:00
|
|
|
|
os << "show_label " << convert<string>(show_label) << "\n";
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void InsetCharStyleParams::read(Lexer & lex)
|
2003-11-12 14:38:26 +00:00
|
|
|
|
{
|
2006-10-16 07:06:41 +00:00
|
|
|
|
while (lex.isOK()) {
|
2003-11-12 14:38:26 +00:00
|
|
|
|
lex.next();
|
|
|
|
|
string token = lex.getString();
|
|
|
|
|
|
2006-10-16 07:06:41 +00:00
|
|
|
|
if (token == "CharStyle") {
|
|
|
|
|
lex.next();
|
|
|
|
|
type = lex.getString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (token == "show_label") {
|
|
|
|
|
lex.next();
|
|
|
|
|
show_label = lex.getBool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (token == "status") {
|
|
|
|
|
lex.pushToken(token);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-11-12 14:38:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|