+2003-12-11 Angus Leeming <leeming@lyx.org>
+
+ * factory.C (createInset): changes due to the changed interface to
+ InsetCommandMailer::string2params.
+
2003-12-10 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): enable all inset dialogs to be opened with
if (name == "bibitem") {
InsetCommandParams icp;
- InsetCommandMailer::string2params(cmd.argument, icp);
+ InsetCommandMailer::string2params(name, cmd.argument,
+ icp);
return new InsetBibitem(icp);
} else if (name == "bibtex") {
InsetCommandParams icp;
- InsetCommandMailer::string2params(cmd.argument, icp);
+ InsetCommandMailer::string2params(name, cmd.argument,
+ icp);
return new InsetBibtex(icp);
} else if (name == "citation") {
InsetCommandParams icp;
- InsetCommandMailer::string2params(cmd.argument, icp);
+ InsetCommandMailer::string2params(name, cmd.argument,
+ icp);
return new InsetCitation(icp);
} else if (name == "ert") {
} else if (name == "index") {
InsetCommandParams icp;
- InsetCommandMailer::string2params(cmd.argument, icp);
+ InsetCommandMailer::string2params(name, cmd.argument,
+ icp);
return new InsetIndex(icp);
} else if (name == "label") {
InsetCommandParams icp;
- InsetCommandMailer::string2params(cmd.argument, icp);
+ InsetCommandMailer::string2params(name, cmd.argument,
+ icp);
return new InsetLabel(icp);
} else if (name == "ref") {
InsetCommandParams icp;
- InsetCommandMailer::string2params(cmd.argument, icp);
+ InsetCommandMailer::string2params(name, cmd.argument,
+ icp);
return new InsetRef(icp, *bv->buffer());
} else if (name == "toc") {
InsetCommandParams icp;
- InsetCommandMailer::string2params(cmd.argument, icp);
+ InsetCommandMailer::string2params(name, cmd.argument,
+ icp);
return new InsetTOC(icp);
} else if (name == "url") {
InsetCommandParams icp;
- InsetCommandMailer::string2params(cmd.argument, icp);
+ InsetCommandMailer::string2params(name, cmd.argument,
+ icp);
return new InsetUrl(icp);
} else if (name == "vspace") {
+2003-12-11 Angus Leeming <leeming@lyx.org>
+
+ * ControlCommand.C (initialiseParams): changes due to the changed
+ interface to InsetCommandMailer::string2params.
+
2003-12-10 Angus Leeming <leeming@lyx.org>
* ControlNote.[Ch] (note_gui_tokens): removed; no longer needed.
bool ControlCommand::initialiseParams(string const & data)
{
- InsetCommandMailer::string2params(data, params_);
+ // The name passed with LFUN_INSET_APPLY is also the name
+ // used to identify the mailer.
+ InsetCommandMailer::string2params(lfun_name_, data, params_);
return true;
}
+2003-12-11 Angus Leeming <leeming@lyx.org>
+
+ * mailinset.[Ch] (print_mailer_error): new helper function.
+
+ * insetcommand.[Ch]: add a mailer_name_ variable and use it when
+ calling InsetCommandMailer.
+ (InsetCommandMailer::string2params): pass the name of the dialog.
+
+ * insetbibitem.[Ch] (d-tor):
+ * insetbibtex.[Ch] (d-tor):
+ * insetcite.[Ch] (d-tor):
+ * insetfloatlist.[Ch] (d-tor):
+ * insetindex.[Ch] (d-tor):
+ * insetlabel.[Ch] (d-tor):
+ * insetref.[Ch] (d-tor):
+ * insettoc.[Ch] (d-tor):
+ * inseturl.[Ch] (d-tor): removed.
+ Hiding the dialog is handled by InsetCommand.
+
+ * insetbibtex.[Ch] (draw, metrics):
+ * insetfloatlist.[Ch] (draw, metrics):
+ * insetindex.[Ch] (draw, metrics): removed.
+ Drawing is handled by InsetCommand.
+
+ * insetbibitem.[Ch] (priv_dispatch):
+ * insetbibtex.[Ch] (priv_dispatch):
+ * insetcite.[Ch] (priv_dispatch):
+ * insetfloatlist.[Ch] (priv_dispatch):
+ * insetindex.[Ch] (priv_dispatch):
+ * insetlabel.[Ch] (priv_dispatch):
+ * insettoc.[Ch] (priv_dispatch):
+ * inseturl.[Ch] (priv_dispatch): removed or simplified.
+ let InsetCommand handle LFUN_MOUSE_PRESS, LFUN_MOUSE_RELEASE,
+ LFUN_INSET_DIALOG_SHOW.
+
+ * insetbox.C (string2params):
+ * insetbranch.C (string2params):
+ * insetert.C (string2params):
+ * insetexternal.C (string2params):
+ * insetfloat.C (string2params):
+ * insetinclude.C (string2params):
+ * insetminipage.C (string2params):
+ * insetnote.C (string2params):
+ * insetvspace.C (string2params):
+ * insetwrap.C (string2params): over-hauled.
+
2003-12-10 Angus Leeming <leeming@lyx.org>
* insetexternal.[Ch]: add a draft option and respect it when
InsetBibitem::InsetBibitem(InsetCommandParams const & p)
- : InsetCommand(p), counter(1)
+ : InsetCommand(p, "bibitem"), counter(1)
{
if (getContents().empty())
setContents(key_prefix + tostr(++key_counter));
}
-InsetBibitem::~InsetBibitem()
-{
- InsetCommandMailer("bibitem", *this).hideDialog();
-}
-
-
auto_ptr<InsetBase> InsetBibitem::clone() const
{
auto_ptr<InsetBibitem> b(new InsetBibitem(params()));
{
switch (cmd.action) {
- case LFUN_MOUSE_PRESS:
- InsetCommandMailer("bibitem", *this).showDialog(cmd.view());
- return DispatchResult(true, true);
-
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
- InsetCommandMailer::string2params(cmd.argument, p);
+ InsetCommandMailer::string2params("bibitem", cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(true, true);
setParams(p);
///
InsetBibitem(InsetCommandParams const &);
///
- ~InsetBibitem();
- ///
std::auto_ptr<InsetBase> clone() const;
/** Currently \bibitem is used as a LyX2.x command,
so we need this method.
InsetBibtex::InsetBibtex(InsetCommandParams const & p)
- : InsetCommand(p)
+ : InsetCommand(p, "bibtex")
{}
-InsetBibtex::~InsetBibtex()
-{
- InsetCommandMailer("bibtex", *this).hideDialog();
-}
-
-
std::auto_ptr<InsetBase> InsetBibtex::clone() const
{
return std::auto_ptr<InsetBase>(new InsetBibtex(*this));
}
-void InsetBibtex::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- InsetCommand::metrics(mi, dim);
- int center_indent = (mi.base.textwidth - dim.wid) / 2;
- Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
- button().setBox(b);
- dim.wid = mi.base.textwidth;
- dim_ = dim;
-}
-
-
-void InsetBibtex::draw(PainterInfo & pi, int x, int y) const
-{
- InsetCommand::draw(pi, x + button().box().x1, y);
-}
-
-
DispatchResult
InsetBibtex::priv_dispatch(FuncRequest const & cmd,
idx_type & idx, pos_type & pos)
switch (cmd.action) {
- case LFUN_INSET_DIALOG_SHOW:
- InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
- result.dispatched(true);
- break;
-
- case LFUN_MOUSE_RELEASE:
- if (button().box().contains(cmd.x, cmd.y))
- InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
- result.dispatched(true);
- break;
-
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
- InsetCommandMailer::string2params(cmd.argument, p);
+ InsetCommandMailer::string2params("bibtex", cmd.argument, p);
if (!p.getCmdName().empty())
setParams(p);
result.dispatched(true);
///
InsetBibtex(InsetCommandParams const &);
///
- ~InsetBibtex();
- ///
std::auto_ptr<InsetBase> clone() const;
///
- void metrics(MetricsInfo &, Dimension &) const;
- ///
- void draw(PainterInfo & pi, int x, int y) const;
- ///
std::string const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
InsetBoxParams & params)
{
params = InsetBoxParams(string());
-
if (in.empty())
return;
string name;
lex >> name;
- if (!lex || name != name_) {
- lyxerr << "InsetBoxMailer::string2params(" << in << ")\n"
- << "Missing identifier \"" << name_ << '"' << std::endl;
- return;
- }
+ if (!lex || name != name_)
+ return print_mailer_error("InsetBoxMailer", in, 1, name_);
// This is part of the inset proper that is usually swallowed
// by LyXText::readInset
- string inset_id;
- lex >> inset_id;
- if (!lex || inset_id != "Box")
- return;
+ string id;
+ lex >> id;
+ if (!lex || id != "Box")
+ return print_mailer_error("InsetBoxMailer", in, 2, "Box");
params.read(lex);
}
InsetBranchParams & params)
{
params = InsetBranchParams();
-
if (in.empty())
return;
string name;
lex >> name;
if (name != name_)
- return;
+ return print_mailer_error("InsetBranchMailer", in, 1, name_);
params.read(lex);
// Process all_branches here:
InsetCitation::InsetCitation(InsetCommandParams const & p)
- : InsetCommand(p)
+ : InsetCommand(p, "citation")
{}
-// InsetCitation::InsetCitation(InsetCommandParams const & p, bool)
-// : InsetCommand(p, false)
-// {}
-
-
-InsetCitation::~InsetCitation()
-{
- InsetCommandMailer("citation", *this).hideDialog();
-}
-
-
string const InsetCitation::generateLabel(Buffer const & buffer) const
{
string const before = string();
}
-DispatchResult
-InsetCitation::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
-{
- switch (cmd.action) {
-
- case LFUN_MOUSE_PRESS:
- InsetCommandMailer("citation", *this).showDialog(cmd.view());
- return DispatchResult(true, true);
-
- default:
- return InsetCommand::priv_dispatch(cmd, idx, pos);
- }
-}
-
-
int InsetCitation::plaintext(Buffer const & buffer, ostream & os, int) const
{
if (cache.params == params() && cache.style == getStyle(buffer))
///
InsetCitation(InsetCommandParams const &);
///
- ~InsetCitation();
- ///
std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetCitation(params()));
}
OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
-protected:
- ///
- virtual
- DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
private:
struct Cache {
///
using std::ostringstream;
-InsetCommand::InsetCommand(InsetCommandParams const & p)
+InsetCommand::InsetCommand(InsetCommandParams const & p,
+ string const & mailer_name)
: p_(p.getCmdName(), p.getContents(), p.getOptions()),
+ mailer_name_(mailer_name),
set_label_(false)
{}
+InsetCommand::~InsetCommand()
+{
+ if (!mailer_name_.empty())
+ InsetCommandMailer(mailer_name_, *this).hideDialog();
+}
+
+
void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (!set_label_) {
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
- InsetCommandMailer::string2params(cmd.argument, p);
+ InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(false);
InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view());
return DispatchResult(true, true);
- case LFUN_MOUSE_RELEASE:
- edit(cmd.view(), true);
+ case LFUN_INSET_DIALOG_SHOW:
+ case LFUN_MOUSE_RELEASE: {
+ if (!mailer_name_.empty())
+ InsetCommandMailer(mailer_name_, *this).
+ showDialog(cmd.view());
return DispatchResult(true);
+ }
default:
return DispatchResult(false);
}
-void InsetCommandMailer::string2params(string const & in,
+void InsetCommandMailer::string2params(string const & name,
+ string const & in,
InsetCommandParams & params)
{
params = InsetCommandParams();
-
if (in.empty())
return;
LyXLex lex(0,0);
lex.setStream(data);
- if (lex.isOK()) {
- lex.next();
- string const name = lex.getString();
- }
+ string n;
+ lex >> n;
+ if (!lex || n != name)
+ return print_mailer_error("InsetCommandMailer", in, 1, name);
// This is part of the inset proper that is usually swallowed
- // by Buffer::readInset
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != "LatexCommand")
- return;
- }
- if (lex.isOK()) {
- params.read(lex);
- }
+ // by LyXText::readInset
+ string id;
+ lex >> id;
+ if (!lex || id != "LatexCommand")
+ return print_mailer_error("InsetCommandMailer", in, 2, "LatexCommand");
+
+ params.read(lex);
}
-string const InsetCommandMailer::params2string(string const & name,
+string const
+InsetCommandMailer::params2string(string const & name,
InsetCommandParams const & params)
{
ostringstream data;
public:
///
explicit
- InsetCommand(InsetCommandParams const &);
+ InsetCommand(InsetCommandParams const &,
+ std::string const & mailer_name);
+ ///
+ ~InsetCommand();
///
void metrics(MetricsInfo &, Dimension &) const;
///
private:
///
InsetCommandParams p_;
+ std::string mailer_name_;
mutable bool set_label_;
mutable RenderButton button_;
};
///
virtual std::string const inset2string(Buffer const &) const;
///
- static void string2params(std::string const &, InsetCommandParams &);
+ static void string2params(std::string const &, std::string const & name,
+ InsetCommandParams &);
///
static std::string const params2string(std::string const & name,
- InsetCommandParams const &);
+ InsetCommandParams const &);
private:
///
std::string const name_;
InsetCollapsable::CollapseStatus & status)
{
status = InsetCollapsable::Collapsed;
+ if (in.empty())
+ return;
istringstream data(in);
LyXLex lex(0,0);
string name;
lex >> name;
- if (name != name_) {
- lyxerr << "InsetERTMailer::string2params(" << in << ")\n"
- << "Missing identifier \"" << name_ << '"' << std::endl;
- return;
- }
+ if (name != name_)
+ return print_mailer_error("InsetERTMailer", in, 1, name_);
int s;
lex >> s;
InsetExternalParams & params)
{
params = InsetExternalParams();
-
if (in.empty())
return;
LyXLex lex(0,0);
lex.setStream(data);
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != name_)
- return;
- }
+ string name;
+ lex >> name;
+ if (!lex || name != name_)
+ return print_mailer_error("InsetExternalMailer", in, 1, name_);
// This is part of the inset proper that is usually swallowed
- // by Buffer::readInset
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != "External")
- return;
- }
+ // by LyXText::readInset
+ string id;
+ lex >> id;
+ if (!lex || id != "External")
+ return print_mailer_error("InsetBoxMailer", in, 2, "External");
- if (lex.isOK()) {
- params.read(buffer, lex);
- }
+ params.read(buffer, lex);
}
InsetFloatParams & params)
{
params = InsetFloatParams();
-
if (in.empty())
return;
LyXLex lex(0,0);
lex.setStream(data);
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != name_)
- return;
- }
+ string name;
+ lex >> name;
+ if (!lex || name != name_)
+ return print_mailer_error("InsetFloatMailer", in, 1, name_);
// This is part of the inset proper that is usually swallowed
- // by Buffer::readInset
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != "Float" || !lex.eatLine())
- return;
- }
+ // by LyXText::readInset
+ string id;
+ lex >> id;
+ if (!lex || id != "Float")
+ return print_mailer_error("InsetBoxMailer", in, 2, "Float");
- if (lex.isOK()) {
- params.read(lex);
- }
+ params.read(lex);
}
InsetFloatList::InsetFloatList()
- : InsetCommand(InsetCommandParams())
+ : InsetCommand(InsetCommandParams(), "toc")
{}
InsetFloatList::InsetFloatList(string const & type)
- : InsetCommand(InsetCommandParams())
+ : InsetCommand(InsetCommandParams(), "toc")
{
setCmdName(type);
}
-InsetFloatList::~InsetFloatList()
-{
- InsetCommandMailer("toc", *this).hideDialog();
-}
-
-
string const InsetFloatList::getScreenLabel(Buffer const & buf) const
{
FloatList const & floats = buf.params().getLyXTextClass().floats();
}
-void InsetFloatList::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- InsetCommand::metrics(mi, dim);
- int center_indent = (mi.base.textwidth - dim.wid) / 2;
- Box b(center_indent, center_indent + dim.wid, -dim.asc, dim.des);
- button().setBox(b);
-
- dim.wid = mi.base.textwidth;
- dim_ = dim;
-}
-
-
-void InsetFloatList::draw(PainterInfo & pi, int x, int y) const
-{
- InsetCommand::draw(pi, x + button().box().x1, y);
-}
-
-
-DispatchResult
-InsetFloatList::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
-{
- switch (cmd.action) {
- case LFUN_MOUSE_RELEASE:
- if (button().box().contains(cmd.x, cmd.y))
- InsetCommandMailer("toc", *this).showDialog(cmd.view());
- return DispatchResult(true, true);
-
- case LFUN_INSET_DIALOG_SHOW:
- InsetCommandMailer("toc", *this).showDialog(cmd.view());
- return DispatchResult(true, true);
-
- default:
- return InsetCommand::priv_dispatch(cmd, idx, pos);
- }
-}
-
-
int InsetFloatList::latex(Buffer const & buf, ostream & os,
OutputParams const &) const
{
///
InsetFloatList(std::string const & type);
///
- ~InsetFloatList();
- ///
virtual std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetFloatList(getCmdName()));
}
///
- void metrics(MetricsInfo &, Dimension &) const;
- ///
- void draw(PainterInfo & pi, int x, int y) const;
- ///
std::string const getScreenLabel(Buffer const &) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
OutputParams const & runparams) const;
///
void validate(LaTeXFeatures & features) const;
-protected:
- ///
- virtual
- DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
};
#endif
InsetGraphicsParams & params)
{
params = InsetGraphicsParams();
-
if (in.empty())
return;
LyXLex lex(0,0);
lex.setStream(data);
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != name_)
- return;
- }
+ string name;
+ lex >> name;
+ if (!lex || name != name_)
+ return print_mailer_error("InsetGraphicsMailer", in, 1, name_);
- if (lex.isOK()) {
- InsetGraphics inset;
- inset.readInsetGraphics(lex, buffer.filePath());
- params = inset.params();
- }
+ InsetGraphics inset;
+ inset.readInsetGraphics(lex, buffer.filePath());
+ params = inset.params();
}
InsetHFill::InsetHFill()
- : InsetCommand(InsetCommandParams("hfill"))
+ : InsetCommand(InsetCommandParams("hfill"), std::string())
{}
InsetCommandParams & params)
{
params = InsetCommandParams();
-
if (in.empty())
return;
LyXLex lex(0,0);
lex.setStream(data);
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != name_)
- return;
- }
+ string name;
+ lex >> name;
+ if (!lex || name != name_)
+ return print_mailer_error("InsetIncludeMailer", in, 1, name_);
// This is part of the inset proper that is usually swallowed
- // by Buffer::readInset
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != "Include")
- return;
- }
+ // by LyXText::readInset
+ string id;
+ lex >> id;
+ if (!lex || id != "Include")
+ return print_mailer_error("InsetBoxMailer", in, 2, "Include");
- if (lex.isOK()) {
- InsetInclude inset(params);
- inset.read(lex);
- params = inset.params();
- }
+ InsetInclude inset(params);
+ inset.read(lex);
+ params = inset.params();
}
InsetIndex::InsetIndex(InsetCommandParams const & p)
- : InsetCommand(p)
+ : InsetCommand(p, "index")
{}
// {}
-InsetIndex::~InsetIndex()
-{
- InsetCommandMailer("index", *this).hideDialog();
-}
-
-
string const InsetIndex::getScreenLabel(Buffer const &) const
{
return _("Idx");
}
-void InsetPrintIndex::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- InsetCommand::metrics(mi, dim);
- center_indent_ = (mi.base.textwidth - dim.wid) / 2;
- dim.wid = mi.base.textwidth;
- dim_ = dim;
-}
-
-
-void InsetPrintIndex::draw(PainterInfo & pi, int x, int y) const
-{
- InsetCommand::draw(pi, x + center_indent_, y);
-}
-
-
-DispatchResult InsetIndex::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
-{
- switch (cmd.action) {
- case LFUN_MOUSE_RELEASE:
- InsetCommandMailer("index", *this).showDialog(cmd.view());
- return DispatchResult(true, true);
-
- default:
- return InsetCommand::priv_dispatch(cmd, idx, pos);
- }
-}
-
-
int InsetIndex::docbook(Buffer const &, ostream & os,
OutputParams const &) const
{
InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
- : InsetCommand(p)
+ : InsetCommand(p, string())
{}
// {}
-InsetPrintIndex::~InsetPrintIndex()
-{}
-
-
string const InsetPrintIndex::getScreenLabel(Buffer const &) const
{
return _("Index");
///
InsetIndex(InsetCommandParams const &);
///
- ~InsetIndex();
- ///
virtual std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetIndex(params()));
}
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
- ///
- DispatchResult priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos);
};
///
InsetPrintIndex(InsetCommandParams const &);
///
- ~InsetPrintIndex();
- ///
virtual std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetPrintIndex(params()));
}
bool display() const { return true; }
///
std::string const getScreenLabel(Buffer const &) const;
- ///
- void metrics(MetricsInfo &, Dimension &) const;
- ///
- void draw(PainterInfo & pi, int x, int y) const;
-private:
- ///
- mutable unsigned int center_indent_;
};
#endif
InsetLabel::InsetLabel(InsetCommandParams const & p)
- : InsetCommand(p)
+ : InsetCommand(p, "label")
{}
-InsetLabel::~InsetLabel()
-{
- InsetCommandMailer("label", *this).hideDialog();
-}
-
-
std::auto_ptr<InsetBase> InsetLabel::clone() const
{
return std::auto_ptr<InsetBase>(new InsetLabel(params()));
switch (cmd.action) {
- case LFUN_MOUSE_RELEASE:
- InsetCommandMailer("label", *this).showDialog(bv);
- return DispatchResult(true, true);
-
case LFUN_INSET_MODIFY: {
InsetCommandParams p;
- InsetCommandMailer::string2params(cmd.argument, p);
+ InsetCommandMailer::string2params("label", cmd.argument, p);
if (p.getCmdName().empty())
return DispatchResult(false);
///
InsetLabel(InsetCommandParams const &);
///
- ~InsetLabel();
- ///
std::auto_ptr<InsetBase> clone() const;
///
std::string const getScreenLabel(Buffer const &) const;
InsetMinipage::Params & params)
{
params = InsetMinipage::Params();
-
if (in.empty())
return;
LyXLex lex(0, 0);
lex.setStream(data);
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != "minipage")
- return;
- }
+ string name;
+ lex >> name;
+ if (!lex || name != name_)
+ return print_mailer_error("InsetMinipageMailer", in, 1, name_);
// This is part of the inset proper that is usually swallowed
- // by Buffer::readInset
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != "Minipage")
- return;
- }
+ // by LyXText::readInset
+ string id;
+ lex >> id;
+ if (!lex || id != "Minipage")
+ return print_mailer_error("InsetBoxMailer", in, 2, "Minipage");
- if (lex.isOK()) {
- params.read(lex);
- }
+ params.read(lex);
}
string name;
lex >> name;
- if (!lex || name != name_) {
- lyxerr << "InsetNoteMailer::string2params(" << in << ")\n"
- << "Missing identifier \"" << name_ << '"' << std::endl;
- return;
- }
+ if (!lex || name != name_)
+ return print_mailer_error("InsetNoteMailer", in, 1, name_);
// This is part of the inset proper that is usually swallowed
// by LyXText::readInset
- string inset_id;
- lex >> inset_id;
- if (!lex || inset_id != "Note")
- return;
+ string id;
+ lex >> id;
+ if (!lex || id != "Note")
+ return print_mailer_error("InsetBoxMailer", in, 2, "Note");
params.read(lex);
}
InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf)
- : InsetCommand(p), isLatex(buf.isLatex())
+ : InsetCommand(p, "ref"), isLatex(buf.isLatex())
{}
InsetRef::InsetRef(InsetRef const & ir)
: InsetCommand(ir), isLatex(ir.isLatex)
-{
-}
-
-
-InsetRef::~InsetRef()
-{
- InsetCommandMailer("ref", *this).hideDialog();
-}
+{}
DispatchResult
InsetRef(InsetRef const &);
- ~InsetRef();
///
virtual std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetRef(*this));
InsetTOC::InsetTOC(InsetCommandParams const & p)
- : InsetCommand(p)
+ : InsetCommand(p, "toc")
{}
-InsetTOC::~InsetTOC()
-{
- InsetCommandMailer("toc", *this).hideDialog();
-}
-
-
std::auto_ptr<InsetBase> InsetTOC::clone() const
{
return std::auto_ptr<InsetBase>(new InsetTOC(*this));
}
-DispatchResult
-InsetTOC::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
-{
- switch (cmd.action) {
- case LFUN_MOUSE_RELEASE:
- case LFUN_INSET_DIALOG_SHOW:
- InsetCommandMailer("toc", *this).showDialog(cmd.view());
- return DispatchResult(true, true);
-
- default:
- return InsetCommand::priv_dispatch(cmd, idx, pos);
- }
-}
-
-
int InsetTOC::plaintext(Buffer const & buffer, ostream & os,
OutputParams const &) const
{
///
explicit InsetTOC(InsetCommandParams const &);
///
- ~InsetTOC();
- ///
std::auto_ptr<InsetBase> clone() const;
///
std::string const getScreenLabel(Buffer const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
-protected:
- ///
- virtual
- DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
};
#endif
InsetUrl::InsetUrl(InsetCommandParams const & p)
- : InsetCommand(p)
+ : InsetCommand(p, "url")
{}
-// InsetUrl::InsetUrl(InsetCommandParams const & p, bool)
-// : InsetCommand(p, false)
-// {}
-
-
-InsetUrl::~InsetUrl()
-{
- InsetCommandMailer("url", *this).hideDialog();
-}
-
-
-DispatchResult
-InsetUrl::priv_dispatch(FuncRequest const & cmd,
- idx_type & idx, pos_type & pos)
-{
- switch (cmd.action) {
- case LFUN_MOUSE_PRESS:
- InsetCommandMailer("url", *this).showDialog(cmd.view());
- return DispatchResult(true, true);
- default:
- return InsetCommand::priv_dispatch(cmd, idx, pos);
- }
-}
-
-
string const InsetUrl::getScreenLabel(Buffer const &) const
{
string temp;
explicit
InsetUrl(InsetCommandParams const &);
///
- ~InsetUrl();
- ///
virtual std::auto_ptr<InsetBase> clone() const {
return std::auto_ptr<InsetBase>(new InsetUrl(params()));
}
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
-protected:
- ///
- virtual
- DispatchResult
- priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
};
#endif
void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
{
vspace = VSpace();
-
if (in.empty())
return;
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
- string name, vsp;
- lex >> name >> vsp;
+
+ string name;
+ lex >> name;
+ if (!lex || name != name_)
+ return print_mailer_error("InsetVSpaceMailer", in, 1, name_);
+
+ string vsp;
+ lex >> vsp;
if (lex)
vspace = VSpace(vsp);
}
void InsetWrapMailer::string2params(string const & in, InsetWrapParams & params)
{
params = InsetWrapParams();
-
if (in.empty())
return;
LyXLex lex(0,0);
lex.setStream(data);
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != name_)
- return;
- }
+ string name;
+ lex >> name;
+ if (!lex || name != name_)
+ return print_mailer_error("InsetWrapMailer", in, 1, name_);
// This is part of the inset proper that is usually swallowed
- // by Buffer::readInset
- if (lex.isOK()) {
- lex.next();
- string const token = lex.getString();
- if (token != "Wrap" || !lex.eatLine())
- return;
- }
+ // by LyXText::readInset
+ string id;
+ lex >> id;
+ if (!lex || id != "Wrap")
+ return print_mailer_error("InsetBoxMailer", in, 2, "Wrap");
- if (lex.isOK()) {
- params.read(lex);
- }
+ params.read(lex);
}
#include "mailinset.h"
#include "BufferView.h"
+#include "debug.h"
#include "frontends/Dialogs.h"
#include "frontends/LyXView.h"
+using std::string;
+
void MailInset::showDialog(BufferView * bv) const
{
{
Dialogs::hide(name(), &inset());
}
+
+
+void print_mailer_error(string const & class_name,
+ string const & data, int arg_id, string const & arg)
+{
+ lyxerr << class_name << "::string2params(" << data << ")\n"
+ << "Expected arg " << arg_id << "to be \"" << arg << '"'
+ << std::endl;
+}
virtual std::string const & name() const = 0;
};
+void print_mailer_error(std::string const & class_name,
+ std::string const & data,
+ int arg_id, std::string const & arg);
+
#endif // MAILINSET_H