2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetnote.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 Angus Leeming
|
2003-08-01 15:36:47 +00:00
|
|
|
|
* \author Martin Vermeer
|
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
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.
|
2001-07-20 09:57:23 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "insetnote.h"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
|
2001-07-20 09:57:23 +00:00
|
|
|
|
#include "BufferView.h"
|
2004-01-20 14:25:24 +00:00
|
|
|
|
#include "cursor.h"
|
2003-12-10 17:28:14 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2006-01-09 21:00:24 +00:00
|
|
|
|
#include "exporter.h"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
#include "funcrequest.h"
|
2005-04-22 08:57:22 +00:00
|
|
|
|
#include "FuncStatus.h"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
#include "gettext.h"
|
2003-09-04 03:54:04 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-09-16 10:54:23 +00:00
|
|
|
|
#include "LColor.h"
|
2003-07-08 14:19:25 +00:00
|
|
|
|
#include "lyxlex.h"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2006-01-09 21:00:24 +00:00
|
|
|
|
#include "outputparams.h"
|
2003-09-06 12:36:58 +00:00
|
|
|
|
#include "paragraph.h"
|
2003-09-04 01:01:13 +00:00
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
#include "support/lyxalgo.h"
|
|
|
|
|
#include "support/translator.h"
|
2001-07-20 09:57:23 +00:00
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2006-09-09 18:52:00 +00:00
|
|
|
|
using lyx::docstring;
|
|
|
|
|
|
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;
|
2001-07-20 09:57:23 +00:00
|
|
|
|
|
2001-11-27 10:34:16 +00:00
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
typedef Translator<std::string, InsetNoteParams::Type> NoteTranslator;
|
|
|
|
|
|
2006-09-09 15:27:44 +00:00
|
|
|
|
NoteTranslator const init_notetranslator()
|
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
NoteTranslator translator("Note", InsetNoteParams::Note);
|
|
|
|
|
translator.addPair("Comment", InsetNoteParams::Comment);
|
|
|
|
|
translator.addPair("Greyedout", InsetNoteParams::Greyedout);
|
2006-06-03 16:46:27 +00:00
|
|
|
|
translator.addPair("Framed", InsetNoteParams::Framed);
|
|
|
|
|
translator.addPair("Shaded", InsetNoteParams::Shaded);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 15:27:44 +00:00
|
|
|
|
NoteTranslator const init_notetranslator_loc()
|
|
|
|
|
{
|
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
NoteTranslator translator(lyx::to_utf8(_("Note")), InsetNoteParams::Note);
|
|
|
|
|
translator.addPair(lyx::to_utf8(_("Comment")), InsetNoteParams::Comment);
|
|
|
|
|
translator.addPair(lyx::to_utf8(_("Greyed out")), InsetNoteParams::Greyedout);
|
|
|
|
|
translator.addPair(lyx::to_utf8(_("Framed")), InsetNoteParams::Framed);
|
|
|
|
|
translator.addPair(lyx::to_utf8(_("Shaded")), InsetNoteParams::Shaded);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 15:27:44 +00:00
|
|
|
|
NoteTranslator const & notetranslator()
|
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
static NoteTranslator translator = init_notetranslator();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 15:27:44 +00:00
|
|
|
|
NoteTranslator const & notetranslator_loc()
|
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
static NoteTranslator translator = init_notetranslator_loc();
|
|
|
|
|
return translator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // anon
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InsetNoteParams::InsetNoteParams()
|
|
|
|
|
: type(Note)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNoteParams::write(ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
string const label = notetranslator().find(type);
|
|
|
|
|
os << "Note " << label << "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNoteParams::read(LyXLex & lex)
|
|
|
|
|
{
|
|
|
|
|
string label;
|
|
|
|
|
lex >> label;
|
|
|
|
|
if (lex)
|
|
|
|
|
type = notetranslator().find(label);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
|
void InsetNote::init()
|
2001-07-20 09:57:23 +00:00
|
|
|
|
{
|
|
|
|
|
setInsetName("Note");
|
2003-07-08 14:19:25 +00:00
|
|
|
|
setButtonLabel();
|
2001-07-20 09:57:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-07-24 10:13:19 +00:00
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
InsetNote::InsetNote(BufferParams const & bp, string const & label)
|
2002-03-03 20:25:07 +00:00
|
|
|
|
: InsetCollapsable(bp)
|
2001-07-23 09:11:14 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
params_.type = notetranslator().find(label);
|
2001-07-23 09:11:14 +00:00
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-24 10:13:19 +00:00
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetNote::InsetNote(InsetNote const & in)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
: InsetCollapsable(in), params_(in.params_)
|
2001-07-27 12:03:36 +00:00
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-22 07:39:46 +00:00
|
|
|
|
InsetNote::~InsetNote()
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 14:49:51 +00:00
|
|
|
|
InsetNoteMailer(*this).hideDialog();
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetNote::doClone() const
|
2001-07-27 12:03:36 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetNote(*this));
|
2001-07-27 12:03:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-09 18:52:00 +00:00
|
|
|
|
docstring const InsetNote::editMessage() const
|
2001-07-20 09:57:23 +00:00
|
|
|
|
{
|
2006-09-09 18:52:00 +00:00
|
|
|
|
return _("Opened Note Inset");
|
2001-07-20 09:57:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetNote::write(Buffer const & buf, ostream & os) const
|
2001-07-20 09:57:23 +00:00
|
|
|
|
{
|
2003-07-08 14:19:25 +00:00
|
|
|
|
params_.write(os);
|
2001-07-20 09:57:23 +00:00
|
|
|
|
InsetCollapsable::write(buf, os);
|
|
|
|
|
}
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetNote::read(Buffer const & buf, LyXLex & lex)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
params_.read(lex);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
InsetCollapsable::read(buf, lex);
|
|
|
|
|
setButtonLabel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNote::setButtonLabel()
|
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
string const label = notetranslator_loc().find(params_.type);
|
|
|
|
|
setLabel(label);
|
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
switch (params_.type) {
|
|
|
|
|
case InsetNoteParams::Note:
|
2003-07-08 14:19:25 +00:00
|
|
|
|
font.setColor(LColor::note);
|
|
|
|
|
setBackgroundColor(LColor::notebg);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
break;
|
|
|
|
|
case InsetNoteParams::Comment:
|
2003-07-30 21:47:18 +00:00
|
|
|
|
font.setColor(LColor::comment);
|
|
|
|
|
setBackgroundColor(LColor::commentbg);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
break;
|
|
|
|
|
case InsetNoteParams::Greyedout:
|
2003-07-30 21:47:18 +00:00
|
|
|
|
font.setColor(LColor::greyedout);
|
|
|
|
|
setBackgroundColor(LColor::greyedoutbg);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
break;
|
2006-06-03 16:46:27 +00:00
|
|
|
|
case InsetNoteParams::Framed:
|
|
|
|
|
font.setColor(LColor::greyedout);
|
|
|
|
|
setBackgroundColor(LColor::greyedoutbg);
|
|
|
|
|
break;
|
|
|
|
|
case InsetNoteParams::Shaded:
|
|
|
|
|
font.setColor(LColor::greyedout);
|
|
|
|
|
setBackgroundColor(LColor::shadedbg);
|
|
|
|
|
break;
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
setLabelFont(font);
|
|
|
|
|
}
|
2003-07-15 23:52:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool InsetNote::showInsetDialog(BufferView * bv) const
|
|
|
|
|
{
|
2003-12-10 14:49:51 +00:00
|
|
|
|
InsetNoteMailer(const_cast<InsetNote &>(*this)).showDialog(bv);
|
2003-07-15 23:52:05 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
|
|
|
|
|
2004-11-24 21:58:42 +00:00
|
|
|
|
void InsetNote::doDispatch(LCursor & cur, FuncRequest & cmd)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
2003-08-05 08:07:07 +00:00
|
|
|
|
|
2004-02-16 11:58:51 +00:00
|
|
|
|
case LFUN_INSET_MODIFY:
|
2006-09-01 15:41:38 +00:00
|
|
|
|
InsetNoteMailer::string2params(lyx::to_utf8(cmd.argument()), params_);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
setButtonLabel();
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2003-08-05 08:07:07 +00:00
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE:
|
2004-01-20 14:25:24 +00:00
|
|
|
|
InsetNoteMailer(*this).updateDialog(&cur.bv());
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2003-08-05 08:07:07 +00:00
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
2004-02-16 11:58:51 +00:00
|
|
|
|
if (cmd.button() == mouse_button::button3 && hitButton(cmd))
|
2004-01-20 14:25:24 +00:00
|
|
|
|
InsetNoteMailer(*this).showDialog(&cur.bv());
|
2004-02-16 11:58:51 +00:00
|
|
|
|
else
|
2004-11-24 21:58:42 +00:00
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2003-08-05 08:07:07 +00:00
|
|
|
|
|
2003-07-08 14:19:25 +00:00
|
|
|
|
default:
|
2004-11-24 21:58:42 +00:00
|
|
|
|
InsetCollapsable::doDispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-22 08:57:22 +00:00
|
|
|
|
bool InsetNote::getStatus(LCursor & cur, FuncRequest const & cmd,
|
|
|
|
|
FuncStatus & flag) const
|
|
|
|
|
{
|
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_MODIFY:
|
|
|
|
|
case LFUN_INSET_DIALOG_UPDATE:
|
|
|
|
|
flag.enabled(true);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return InsetCollapsable::getStatus(cur, cmd, flag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int InsetNote::latex(Buffer const & buf, ostream & os,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
OutputParams const & runparams_in) const
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Note)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2006-01-09 21:00:24 +00:00
|
|
|
|
OutputParams runparams(runparams_in);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
string type;
|
2006-01-09 21:00:24 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Comment) {
|
2003-12-10 17:28:14 +00:00
|
|
|
|
type = "comment";
|
2006-01-09 21:00:24 +00:00
|
|
|
|
runparams.inComment = true;
|
|
|
|
|
// Ignore files that are exported inside a comment
|
|
|
|
|
runparams.exportdata.reset(new ExportData);
|
|
|
|
|
} else if (params_.type == InsetNoteParams::Greyedout)
|
2003-12-10 17:28:14 +00:00
|
|
|
|
type = "lyxgreyedout";
|
2006-06-03 16:46:27 +00:00
|
|
|
|
else if (params_.type == InsetNoteParams::Framed)
|
|
|
|
|
type = "framed";
|
|
|
|
|
else if (params_.type == InsetNoteParams::Shaded)
|
|
|
|
|
type = "shaded";
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
|
|
|
|
ostringstream ss;
|
|
|
|
|
ss << "%\n\\begin{" << type << "}\n";
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::latex(buf, ss, runparams);
|
2006-08-15 15:12:26 +00:00
|
|
|
|
ss << "\n\\end{" << type << "}\n";
|
|
|
|
|
// the space after the comment in 'a[comment] b' will be eaten by the
|
|
|
|
|
// comment environment since the space before b is ignored with the
|
|
|
|
|
// following latex output:
|
|
|
|
|
//
|
|
|
|
|
// a%
|
|
|
|
|
// \begin{comment}
|
|
|
|
|
// comment
|
|
|
|
|
// \end{comment}
|
|
|
|
|
// b
|
|
|
|
|
//
|
|
|
|
|
// Adding {} before ' b' fixes this.
|
|
|
|
|
if (params_.type == InsetNoteParams::Comment)
|
|
|
|
|
ss << "{}";
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
|
|
|
|
string const str = ss.str();
|
|
|
|
|
os << str;
|
|
|
|
|
// Return how many newlines we issued.
|
2005-03-31 14:34:57 +00:00
|
|
|
|
return int(lyx::count(str.begin(), str.end(),'\n'));
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int InsetNote::docbook(Buffer const & buf, std::ostream & os,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
OutputParams const & runparams_in) const
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Note)
|
|
|
|
|
return 0;
|
2003-07-27 13:02:26 +00:00
|
|
|
|
|
2006-01-09 21:00:24 +00:00
|
|
|
|
OutputParams runparams(runparams_in);
|
2003-12-10 17:28:14 +00:00
|
|
|
|
ostringstream ss;
|
2006-01-09 21:00:24 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Comment) {
|
2003-12-10 17:28:14 +00:00
|
|
|
|
ss << "<remark>\n";
|
2006-01-09 21:00:24 +00:00
|
|
|
|
runparams.inComment = true;
|
|
|
|
|
// Ignore files that are exported inside a comment
|
|
|
|
|
runparams.exportdata.reset(new ExportData);
|
|
|
|
|
}
|
2003-07-27 13:02:26 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::docbook(buf, ss, runparams);
|
2003-07-27 13:02:26 +00:00
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Comment)
|
|
|
|
|
ss << "\n</remark>\n";
|
|
|
|
|
|
|
|
|
|
string const str = ss.str();
|
|
|
|
|
os << str;
|
|
|
|
|
// Return how many newlines we issued.
|
2005-03-31 14:34:57 +00:00
|
|
|
|
return int(lyx::count(str.begin(), str.end(),'\n'));
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int InsetNote::plaintext(Buffer const & buf, std::ostream & os,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
OutputParams const & runparams_in) const
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Note)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2006-01-09 21:00:24 +00:00
|
|
|
|
OutputParams runparams(runparams_in);
|
|
|
|
|
if (params_.type == InsetNoteParams::Comment) {
|
|
|
|
|
runparams.inComment = true;
|
|
|
|
|
// Ignore files that are exported inside a comment
|
|
|
|
|
runparams.exportdata.reset(new ExportData);
|
|
|
|
|
}
|
2006-09-10 08:41:39 +00:00
|
|
|
|
os << "[";
|
|
|
|
|
int const nlines = InsetText::plaintext(buf, os, runparams);
|
|
|
|
|
os << "]";
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
|
|
|
|
// Return how many newlines we issued.
|
2006-09-10 08:41:39 +00:00
|
|
|
|
return nlines;
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNote::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Comment)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
features.require("verbatim");
|
2003-12-10 17:28:14 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Greyedout) {
|
2003-07-08 14:19:25 +00:00
|
|
|
|
features.require("color");
|
2003-07-29 12:20:04 +00:00
|
|
|
|
features.require("lyxgreyedout");
|
|
|
|
|
}
|
2006-06-03 16:46:27 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Shaded) {
|
|
|
|
|
features.require("color");
|
|
|
|
|
features.require("framed");
|
2006-09-09 15:27:44 +00:00
|
|
|
|
}
|
2006-06-03 16:46:27 +00:00
|
|
|
|
if (params_.type == InsetNoteParams::Framed)
|
|
|
|
|
features.require("framed");
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::validate(features);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
string const InsetNoteMailer::name_("note");
|
2003-12-10 14:49:51 +00:00
|
|
|
|
|
|
|
|
|
InsetNoteMailer::InsetNoteMailer(InsetNote & inset)
|
|
|
|
|
: inset_(inset)
|
|
|
|
|
{}
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
|
|
|
|
|
2003-07-23 09:54:21 +00:00
|
|
|
|
string const InsetNoteMailer::inset2string(Buffer const &) const
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
2003-12-10 14:49:51 +00:00
|
|
|
|
return params2string(inset_.params());
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-10 14:49:51 +00:00
|
|
|
|
string const InsetNoteMailer::params2string(InsetNoteParams const & params)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
|
|
|
|
ostringstream data;
|
2003-12-10 14:49:51 +00:00
|
|
|
|
data << name_ << ' ';
|
2003-07-08 14:19:25 +00:00
|
|
|
|
params.write(data);
|
2003-09-15 11:00:00 +00:00
|
|
|
|
return data.str();
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNoteMailer::string2params(string const & in,
|
2003-12-10 14:49:51 +00:00
|
|
|
|
InsetNoteParams & params)
|
2003-07-08 14:19:25 +00:00
|
|
|
|
{
|
|
|
|
|
params = InsetNoteParams();
|
|
|
|
|
|
|
|
|
|
if (in.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
2003-09-15 11:00:00 +00:00
|
|
|
|
istringstream data(in);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
LyXLex lex(0,0);
|
|
|
|
|
lex.setStream(data);
|
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
string name;
|
|
|
|
|
lex >> name;
|
2003-12-11 15:23:15 +00:00
|
|
|
|
if (!lex || name != name_)
|
|
|
|
|
return print_mailer_error("InsetNoteMailer", in, 1, name_);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
|
2003-12-10 17:28:14 +00:00
|
|
|
|
// This is part of the inset proper that is usually swallowed
|
|
|
|
|
// by LyXText::readInset
|
2003-12-11 15:23:15 +00:00
|
|
|
|
string id;
|
|
|
|
|
lex >> id;
|
|
|
|
|
if (!lex || id != "Note")
|
|
|
|
|
return print_mailer_error("InsetBoxMailer", in, 2, "Note");
|
2003-12-10 17:28:14 +00:00
|
|
|
|
|
|
|
|
|
params.read(lex);
|
2003-07-08 14:19:25 +00:00
|
|
|
|
}
|