mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
InsetCommandParams() now takes an InsetCode rather than a string.
These changes are just adaptations to the new signature. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21072 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b6c89e2db0
commit
e158e07c29
@ -1409,7 +1409,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
case REF_CODE:
|
case REF_CODE:
|
||||||
case TOC_CODE:
|
case TOC_CODE:
|
||||||
case HYPERLINK_CODE: {
|
case HYPERLINK_CODE: {
|
||||||
InsetCommandParams p(name);
|
InsetCommandParams p(code);
|
||||||
data = InsetCommandMailer::params2string(name, p);
|
data = InsetCommandMailer::params2string(name, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1419,7 +1419,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
if (data.empty())
|
if (data.empty())
|
||||||
// default type is requested
|
// default type is requested
|
||||||
data = "include";
|
data = "include";
|
||||||
InsetCommandParams p("include", data);
|
InsetCommandParams p(INCLUDE_CODE, data);
|
||||||
data = InsetIncludeMailer::params2string(p);
|
data = InsetIncludeMailer::params2string(p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1435,7 +1435,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CITE_CODE: {
|
case CITE_CODE: {
|
||||||
InsetCommandParams p("cite");
|
InsetCommandParams p(CITE_CODE);
|
||||||
data = InsetCommandMailer::params2string(name, p);
|
data = InsetCommandMailer::params2string(name, p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1539,7 +1539,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
arg = token(argument, '|', 0);
|
arg = token(argument, '|', 0);
|
||||||
opt1 = token(argument, '|', 1);
|
opt1 = token(argument, '|', 1);
|
||||||
}
|
}
|
||||||
InsetCommandParams icp("cite");
|
InsetCommandParams icp(CITE_CODE);
|
||||||
icp["key"] = from_utf8(arg);
|
icp["key"] = from_utf8(arg);
|
||||||
if (!opt1.empty())
|
if (!opt1.empty())
|
||||||
icp["before"] = from_utf8(opt1);
|
icp["before"] = from_utf8(opt1);
|
||||||
|
@ -2432,7 +2432,7 @@ int Paragraph::checkBiblio(bool track_changes)
|
|||||||
|
|
||||||
//There was no inset at the beginning, so we need to create one with
|
//There was no inset at the beginning, so we need to create one with
|
||||||
//the key and label of the one we erased.
|
//the key and label of the one we erased.
|
||||||
InsetBibitem * inset(new InsetBibitem(InsetCommandParams("bibitem")));
|
InsetBibitem * inset(new InsetBibitem(InsetCommandParams(BIBITEM_CODE)));
|
||||||
// restore values of previously deleted item in this par.
|
// restore values of previously deleted item in this par.
|
||||||
if (!oldkey.empty())
|
if (!oldkey.empty())
|
||||||
inset->setParam("key", oldkey);
|
inset->setParam("key", oldkey);
|
||||||
|
@ -1060,7 +1060,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_HYPERLINK_INSERT: {
|
case LFUN_HYPERLINK_INSERT: {
|
||||||
InsetCommandParams p("href");
|
InsetCommandParams p(HYPERLINK_CODE);
|
||||||
docstring content;
|
docstring content;
|
||||||
if (cur.selection()) {
|
if (cur.selection()) {
|
||||||
content = cur.selectionAsString(false);
|
content = cur.selectionAsString(false);
|
||||||
@ -1079,7 +1079,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_LABEL_INSERT: {
|
case LFUN_LABEL_INSERT: {
|
||||||
InsetCommandParams p("label");
|
InsetCommandParams p(LABEL_CODE);
|
||||||
// Try to generate a valid label
|
// Try to generate a valid label
|
||||||
p["name"] = (cmd.argument().empty()) ?
|
p["name"] = (cmd.argument().empty()) ?
|
||||||
cur.getPossibleLabel() :
|
cur.getPossibleLabel() :
|
||||||
|
205
src/factory.cpp
205
src/factory.cpp
@ -147,7 +147,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
return new InsetOptArg(params);
|
return new InsetOptArg(params);
|
||||||
|
|
||||||
case LFUN_BIBITEM_INSERT:
|
case LFUN_BIBITEM_INSERT:
|
||||||
return new InsetBibitem(InsetCommandParams("bibitem"));
|
return new InsetBibitem(InsetCommandParams(BIBITEM_CODE));
|
||||||
|
|
||||||
case LFUN_FLOAT_INSERT: {
|
case LFUN_FLOAT_INSERT: {
|
||||||
// check if the float type exists
|
// check if the float type exists
|
||||||
@ -182,7 +182,7 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
return new InsetIndex(params);
|
return new InsetIndex(params);
|
||||||
|
|
||||||
case LFUN_NOMENCL_INSERT: {
|
case LFUN_NOMENCL_INSERT: {
|
||||||
InsetCommandParams icp("nomenclature");
|
InsetCommandParams icp(NOMENCL_CODE);
|
||||||
icp["symbol"] = cmd.argument().empty() ?
|
icp["symbol"] = cmd.argument().empty() ?
|
||||||
bv->cursor().innerText()->getStringToIndex(bv->cursor()) :
|
bv->cursor().innerText()->getStringToIndex(bv->cursor()) :
|
||||||
cmd.argument();
|
cmd.argument();
|
||||||
@ -211,13 +211,13 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INDEX_PRINT:
|
case LFUN_INDEX_PRINT:
|
||||||
return new InsetPrintIndex(InsetCommandParams("index_print"));
|
return new InsetPrintIndex(InsetCommandParams(INDEX_PRINT_CODE));
|
||||||
|
|
||||||
case LFUN_NOMENCL_PRINT:
|
case LFUN_NOMENCL_PRINT:
|
||||||
return new InsetPrintNomencl(InsetCommandParams("nomencl_print"));
|
return new InsetPrintNomencl(InsetCommandParams(NOMENCL_PRINT_CODE));
|
||||||
|
|
||||||
case LFUN_TOC_INSERT:
|
case LFUN_TOC_INSERT:
|
||||||
return new InsetTOC(InsetCommandParams("toc"));
|
return new InsetTOC(InsetCommandParams(TOC_CODE));
|
||||||
|
|
||||||
case LFUN_ENVIRONMENT_INSERT:
|
case LFUN_ENVIRONMENT_INSERT:
|
||||||
return new InsetEnvironment(params, cmd.argument());
|
return new InsetEnvironment(params, cmd.argument());
|
||||||
@ -237,103 +237,104 @@ Inset * createInset(BufferView * bv, FuncRequest const & cmd)
|
|||||||
lyxerr << "No such inset '" << name << "'.";
|
lyxerr << "No such inset '" << name << "'.";
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case BIBITEM_CODE: {
|
case BIBITEM_CODE: {
|
||||||
InsetCommandParams icp(name);
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
||||||
return new InsetBibitem(icp);
|
return new InsetBibitem(icp);
|
||||||
}
|
}
|
||||||
|
|
||||||
case BIBTEX_CODE: {
|
case BIBTEX_CODE: {
|
||||||
InsetCommandParams icp(name);
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
||||||
return new InsetBibtex(icp);
|
return new InsetBibtex(icp);
|
||||||
}
|
}
|
||||||
|
|
||||||
case CITE_CODE: {
|
case CITE_CODE: {
|
||||||
InsetCommandParams icp("citation");
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
||||||
return new InsetCitation(icp);
|
return new InsetCitation(icp);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ERT_CODE: {
|
case ERT_CODE: {
|
||||||
InsetCollapsable::CollapseStatus st;
|
InsetCollapsable::CollapseStatus st;
|
||||||
InsetERTMailer::string2params(to_utf8(cmd.argument()), st);
|
InsetERTMailer::string2params(to_utf8(cmd.argument()), st);
|
||||||
return new InsetERT(params, st);
|
return new InsetERT(params, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
case LISTINGS_CODE: {
|
case LISTINGS_CODE: {
|
||||||
InsetListingsParams par;
|
InsetListingsParams par;
|
||||||
InsetListingsMailer::string2params(to_utf8(cmd.argument()), par);
|
InsetListingsMailer::string2params(to_utf8(cmd.argument()), par);
|
||||||
return new InsetListings(params, par);
|
return new InsetListings(params, par);
|
||||||
}
|
}
|
||||||
|
|
||||||
case EXTERNAL_CODE: {
|
case EXTERNAL_CODE: {
|
||||||
Buffer const & buffer = bv->buffer();
|
Buffer const & buffer = bv->buffer();
|
||||||
InsetExternalParams iep;
|
InsetExternalParams iep;
|
||||||
InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer, iep);
|
InsetExternalMailer::string2params(to_utf8(cmd.argument()), buffer, iep);
|
||||||
auto_ptr<InsetExternal> inset(new InsetExternal);
|
auto_ptr<InsetExternal> inset(new InsetExternal);
|
||||||
inset->setParams(iep, buffer);
|
inset->setParams(iep, buffer);
|
||||||
return inset.release();
|
return inset.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
case GRAPHICS_CODE: {
|
case GRAPHICS_CODE: {
|
||||||
Buffer const & buffer = bv->buffer();
|
Buffer const & buffer = bv->buffer();
|
||||||
InsetGraphicsParams igp;
|
InsetGraphicsParams igp;
|
||||||
InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer, igp);
|
InsetGraphicsMailer::string2params(to_utf8(cmd.argument()), buffer, igp);
|
||||||
auto_ptr<InsetGraphics> inset(new InsetGraphics);
|
auto_ptr<InsetGraphics> inset(new InsetGraphics);
|
||||||
inset->setParams(igp);
|
inset->setParams(igp);
|
||||||
return inset.release();
|
return inset.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
case HYPERLINK_CODE: {
|
case HYPERLINK_CODE: {
|
||||||
InsetCommandParams icp(name);
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
||||||
return new InsetHyperlink(icp);
|
return new InsetHyperlink(icp);
|
||||||
}
|
}
|
||||||
|
|
||||||
case INCLUDE_CODE: {
|
case INCLUDE_CODE: {
|
||||||
InsetCommandParams iip(name);
|
InsetCommandParams iip(code);
|
||||||
InsetIncludeMailer::string2params(to_utf8(cmd.argument()), iip);
|
InsetIncludeMailer::string2params(to_utf8(cmd.argument()), iip);
|
||||||
return new InsetInclude(iip);
|
return new InsetInclude(iip);
|
||||||
}
|
}
|
||||||
|
|
||||||
case INDEX_CODE:
|
case INDEX_CODE:
|
||||||
return new InsetIndex(params);
|
return new InsetIndex(params);
|
||||||
|
|
||||||
case NOMENCL_CODE: {
|
case NOMENCL_CODE: {
|
||||||
InsetCommandParams icp(name);
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, lyx::to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, lyx::to_utf8(cmd.argument()), icp);
|
||||||
return new InsetNomencl(icp);
|
return new InsetNomencl(icp);
|
||||||
}
|
}
|
||||||
|
|
||||||
case LABEL_CODE: {
|
case LABEL_CODE: {
|
||||||
InsetCommandParams icp(name);
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
||||||
return new InsetLabel(icp);
|
return new InsetLabel(icp);
|
||||||
}
|
}
|
||||||
|
|
||||||
case REF_CODE: {
|
case REF_CODE: {
|
||||||
InsetCommandParams icp(name);
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
||||||
return new InsetRef(icp, bv->buffer());
|
return new InsetRef(icp, bv->buffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOC_CODE: {
|
case TOC_CODE: {
|
||||||
InsetCommandParams icp("toc");
|
InsetCommandParams icp(code);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp);
|
||||||
return new InsetTOC(icp);
|
return new InsetTOC(icp);
|
||||||
}
|
}
|
||||||
|
|
||||||
case VSPACE_CODE: {
|
case VSPACE_CODE: {
|
||||||
VSpace vspace;
|
VSpace vspace;
|
||||||
InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), vspace);
|
InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), vspace);
|
||||||
return new InsetVSpace(vspace);
|
return new InsetVSpace(vspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
lyxerr << "Inset '" << name << "' not permitted with LFUN_INSET_INSERT."
|
lyxerr << "Inset '" << name << "' not permitted with LFUN_INSET_INSERT."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
} //end LFUN_INSET_INSERT
|
} //end LFUN_INSET_INSERT
|
||||||
|
|
||||||
@ -417,7 +418,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
|
|||||||
//we do not know in advance that we're dealing with a command inset.
|
//we do not know in advance that we're dealing with a command inset.
|
||||||
//Worst case, we could put it in each case below. Better, we could
|
//Worst case, we could put it in each case below. Better, we could
|
||||||
//pass the lexer to the constructor and let the params be built there.
|
//pass the lexer to the constructor and let the params be built there.
|
||||||
InsetCommandParams inscmd(insetType);
|
InsetCommandParams inscmd(code);
|
||||||
inscmd.read(lex);
|
inscmd.read(lex);
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
@ -499,7 +500,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
|
|||||||
InsetBranchParams()));
|
InsetBranchParams()));
|
||||||
} else if (tmptok == "Include") {
|
} else if (tmptok == "Include") {
|
||||||
//FIXME
|
//FIXME
|
||||||
InsetCommandParams p("include");
|
InsetCommandParams p(INCLUDE_CODE);
|
||||||
inset.reset(new InsetInclude(p));
|
inset.reset(new InsetInclude(p));
|
||||||
} else if (tmptok == "Environment") {
|
} else if (tmptok == "Environment") {
|
||||||
lex.next();
|
lex.next();
|
||||||
|
@ -270,7 +270,7 @@ namespace lyx {
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
GuiCommand::GuiCommand(LyXView & lv, string const & name)
|
GuiCommand::GuiCommand(LyXView & lv, string const & name)
|
||||||
: GuiDialog(lv, name), params_(name), lfun_name_(name)
|
: GuiDialog(lv, name), params_(insetCode(name)), lfun_name_(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ using support::getVectorFromString;
|
|||||||
|
|
||||||
|
|
||||||
GuiInclude::GuiInclude(LyXView & lv)
|
GuiInclude::GuiInclude(LyXView & lv)
|
||||||
: GuiDialog(lv, "include"), params_("include")
|
: GuiDialog(lv, "include"), params_(INCLUDE_CODE)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setViewTitle(_("Child Document"));
|
setViewTitle(_("Child Document"));
|
||||||
|
@ -52,7 +52,7 @@ using support::makeDisplayPath;
|
|||||||
static std::string const lfun_name_ = "ref";
|
static std::string const lfun_name_ = "ref";
|
||||||
|
|
||||||
GuiRef::GuiRef(LyXView & lv)
|
GuiRef::GuiRef(LyXView & lv)
|
||||||
: GuiDialog(lv, "ref"), params_("ref")
|
: GuiDialog(lv, "ref"), params_(REF_CODE)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setViewTitle(_("Cross-reference"));
|
setViewTitle(_("Cross-reference"));
|
||||||
|
@ -44,7 +44,7 @@ namespace lyx {
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
GuiToc::GuiToc(GuiViewBase & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
|
GuiToc::GuiToc(GuiViewBase & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
|
||||||
: DockView(parent, "toc", area, flags), params_("toc")
|
: DockView(parent, "toc", area, flags), params_(TOC_CODE)
|
||||||
{
|
{
|
||||||
widget_ = new TocWidget(*this);
|
widget_ = new TocWidget(*this);
|
||||||
setWidget(widget_);
|
setWidget(widget_);
|
||||||
|
@ -139,6 +139,20 @@ InsetCode insetCode(std::string const & name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string insetName(InsetCode c)
|
||||||
|
{
|
||||||
|
static TranslatorMap const translator = build_translator();
|
||||||
|
|
||||||
|
TranslatorMap::const_iterator it = translator.begin();
|
||||||
|
TranslatorMap::const_iterator end = translator.end();
|
||||||
|
for (; it != end; ++it) {
|
||||||
|
if (it->second == c)
|
||||||
|
return it->first;
|
||||||
|
}
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Inset::dispatch(Cursor & cur, FuncRequest & cmd)
|
void Inset::dispatch(Cursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
cur.updateFlags(Update::Force | Update::FitCursor);
|
cur.updateFlags(Update::Force | Update::FitCursor);
|
||||||
|
@ -59,7 +59,7 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
InsetCommandParams p("bibitem");
|
InsetCommandParams p(BIBITEM_CODE);
|
||||||
InsetCommandMailer::string2params("bibitem", to_utf8(cmd.argument()), p);
|
InsetCommandMailer::string2params("bibitem", to_utf8(cmd.argument()), p);
|
||||||
if (p.getCmdName().empty()) {
|
if (p.getCmdName().empty()) {
|
||||||
cur.noUpdate();
|
cur.noUpdate();
|
||||||
|
@ -89,7 +89,7 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
InsetCommandParams p("bibtex");
|
InsetCommandParams p(BIBTEX_CODE);
|
||||||
try {
|
try {
|
||||||
if (!InsetCommandMailer::string2params("bibtex",
|
if (!InsetCommandMailer::string2params("bibtex",
|
||||||
to_utf8(cmd.argument()), p)) {
|
to_utf8(cmd.argument()), p)) {
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "InsetCommand.h"
|
#include "InsetCommand.h"
|
||||||
|
#include "InsetCode.h"
|
||||||
|
|
||||||
#include "BiblioInfo.h"
|
#include "BiblioInfo.h"
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ private:
|
|||||||
class Cache {
|
class Cache {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
Cache() : engine(biblio::ENGINE_BASIC), params("citation") {}
|
Cache() : engine(biblio::ENGINE_BASIC), params(CITE_CODE) {}
|
||||||
///
|
///
|
||||||
biblio::CiteEngine engine;
|
biblio::CiteEngine engine;
|
||||||
///
|
///
|
||||||
|
@ -112,7 +112,7 @@ void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
InsetCommandParams p(p_.insetType());
|
InsetCommandParams p(p_.code());
|
||||||
InsetCommandMailer::string2params(mailer_name_, to_utf8(cmd.argument()), p);
|
InsetCommandMailer::string2params(mailer_name_, to_utf8(cmd.argument()), p);
|
||||||
if (p.getCmdName().empty())
|
if (p.getCmdName().empty())
|
||||||
cur.noUpdate();
|
cur.noUpdate();
|
||||||
@ -187,6 +187,7 @@ string const InsetCommandMailer::inset2string(Buffer const &) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//FIXME This could take an InsetCode instead of a string
|
||||||
bool InsetCommandMailer::string2params(
|
bool InsetCommandMailer::string2params(
|
||||||
string const & name, string const & in, InsetCommandParams & params)
|
string const & name, string const & in, InsetCommandParams & params)
|
||||||
{
|
{
|
||||||
@ -219,6 +220,7 @@ bool InsetCommandMailer::string2params(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//FIXME This could take an InsetCode instead of a string
|
||||||
string const
|
string const
|
||||||
InsetCommandMailer::params2string(string const & name,
|
InsetCommandMailer::params2string(string const & name,
|
||||||
InsetCommandParams const & params)
|
InsetCommandParams const & params)
|
||||||
|
@ -35,24 +35,21 @@ using support::ExceptionMessage;
|
|||||||
using support::WarningException;
|
using support::WarningException;
|
||||||
|
|
||||||
|
|
||||||
//FIXME There is no reason now for this to take a string argument.
|
InsetCommandParams::InsetCommandParams(InsetCode code)
|
||||||
//It'd be much more robust if it took an InsetCode, since then
|
: insetCode_(code), preview_(false)
|
||||||
//the compiler would do some checking for us.
|
|
||||||
InsetCommandParams::InsetCommandParams(string const & insetType)
|
|
||||||
: insetType_(insetType), preview_(false)
|
|
||||||
{
|
{
|
||||||
cmdName_ = getDefaultCmd(insetType);
|
cmdName_ = getDefaultCmd(code);
|
||||||
info_ = findInfo(insetType, cmdName_);
|
info_ = findInfo(code, cmdName_);
|
||||||
BOOST_ASSERT(info_);
|
BOOST_ASSERT(info_);
|
||||||
params_.resize(info_->n);
|
params_.resize(info_->n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetCommandParams::InsetCommandParams(string const & insetType,
|
InsetCommandParams::InsetCommandParams(InsetCode code,
|
||||||
string const & cmdName)
|
string const & cmdName)
|
||||||
: insetType_(insetType), cmdName_(cmdName), preview_(false)
|
: insetCode_(code), cmdName_(cmdName), preview_(false)
|
||||||
{
|
{
|
||||||
info_ = findInfo(insetType, cmdName);
|
info_ = findInfo(code, cmdName);
|
||||||
BOOST_ASSERT(info_);
|
BOOST_ASSERT(info_);
|
||||||
params_.resize(info_->n);
|
params_.resize(info_->n);
|
||||||
}
|
}
|
||||||
@ -64,30 +61,26 @@ InsetCommandParams::InsetCommandParams(string const & insetType,
|
|||||||
//a reason to use it in some cases? What should happen in the single
|
//a reason to use it in some cases? What should happen in the single
|
||||||
//arg case, then? Maybe use the default? or leave that up to the inset?
|
//arg case, then? Maybe use the default? or leave that up to the inset?
|
||||||
InsetCommandParams::CommandInfo const *
|
InsetCommandParams::CommandInfo const *
|
||||||
InsetCommandParams::findInfo(std::string const & insetType)
|
InsetCommandParams::findInfo(InsetCode code)
|
||||||
{
|
{
|
||||||
// No parameter may be named "preview", because that is a required
|
// No parameter may be named "preview", because that is a required
|
||||||
// flag for all commands.
|
// flag for all commands.
|
||||||
|
|
||||||
// InsetBibitem
|
switch (code) {
|
||||||
if (insetType == "bibitem") {
|
case BIBITEM_CODE: {
|
||||||
static const char * const paramnames[] = {"label", "key", ""};
|
static const char * const paramnames[] = {"label", "key", ""};
|
||||||
static const bool isoptional[] = {true, false};
|
static const bool isoptional[] = {true, false};
|
||||||
static const CommandInfo info = {2, paramnames, isoptional};
|
static const CommandInfo info = {2, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case BIBTEX_CODE: {
|
||||||
// InsetBibtex
|
|
||||||
if (insetType == "bibtex") {
|
|
||||||
static const char * const paramnames[] =
|
static const char * const paramnames[] =
|
||||||
{"options", "btprint", "bibfiles", ""};
|
{"options", "btprint", "bibfiles", ""};
|
||||||
static const bool isoptional[] = {true, true, false};
|
static const bool isoptional[] = {true, true, false};
|
||||||
static const CommandInfo info = {3, paramnames, isoptional};
|
static const CommandInfo info = {3, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case CITE_CODE: {
|
||||||
// InsetCitation
|
|
||||||
if (insetType == "citation") {
|
|
||||||
// standard cite does only take one argument if jurabib is
|
// standard cite does only take one argument if jurabib is
|
||||||
// not used, but jurabib extends this to two arguments, so
|
// not used, but jurabib extends this to two arguments, so
|
||||||
// we have to allow both here. InsetCitation takes care that
|
// we have to allow both here. InsetCitation takes care that
|
||||||
@ -98,127 +91,115 @@ InsetCommandParams::findInfo(std::string const & insetType)
|
|||||||
static const CommandInfo info = {3, paramnames, isoptional};
|
static const CommandInfo info = {3, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case FLOAT_LIST_CODE: {
|
||||||
// InsetFloatlist
|
|
||||||
if (insetType == "floatlist") {
|
|
||||||
static const char * const paramnames[] = {"type", ""};
|
static const char * const paramnames[] = {"type", ""};
|
||||||
static const bool isoptional[] = {false};
|
static const bool isoptional[] = {false};
|
||||||
static const CommandInfo info = {1, paramnames, isoptional};
|
static const CommandInfo info = {1, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case HFILL_CODE: {
|
||||||
// InsetHfill
|
|
||||||
if (insetType == "hfill") {
|
|
||||||
static const char * const paramnames[] = {""};
|
static const char * const paramnames[] = {""};
|
||||||
static const CommandInfo info = {0, paramnames, 0};
|
static const CommandInfo info = {0, paramnames, 0};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case HYPERLINK_CODE: {
|
||||||
// InsetHyperlink
|
|
||||||
if (insetType == "href") {
|
|
||||||
static const char * const paramnames[] =
|
static const char * const paramnames[] =
|
||||||
{"name", "target", ""};
|
{"name", "target", ""};
|
||||||
static const bool isoptional[] = {true, false};
|
static const bool isoptional[] = {true, false};
|
||||||
static const CommandInfo info = {2, paramnames, isoptional};
|
static const CommandInfo info = {2, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case INCLUDE_CODE: {
|
||||||
// InsetInclude
|
//This is only correct for the case of listings, but it'll do for now.
|
||||||
//FIXME This is really correct only for lstinputlistings, but it shouldn't
|
//In the other cases, this second parameter should just be empty.
|
||||||
//cause a problem before we get things sorted out. Eventually, this calls
|
|
||||||
//InsetInclude::getParams(cmdName_), or something of the sort.
|
|
||||||
if (insetType == "include") {
|
|
||||||
static const char * const paramnames[] = {"filename", "lstparams", ""};
|
static const char * const paramnames[] = {"filename", "lstparams", ""};
|
||||||
static const bool isoptional[] = {false, true};
|
static const bool isoptional[] = {false, true};
|
||||||
static const CommandInfo info = {2, paramnames, isoptional};
|
static const CommandInfo info = {2, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case INDEX_CODE:
|
||||||
// InsetIndex, InsetPrintIndex, InsetLabel
|
case INDEX_PRINT_CODE:
|
||||||
if (insetType == "index" || insetType == "index_print" || insetType == "label") {
|
case LABEL_CODE: {
|
||||||
static const char * const paramnames[] = {"name", ""};
|
static const char * const paramnames[] = {"name", ""};
|
||||||
static const bool isoptional[] = {false};
|
static const bool isoptional[] = {false};
|
||||||
static const CommandInfo info = {1, paramnames, isoptional};
|
static const CommandInfo info = {1, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case NOMENCL_CODE: {
|
||||||
// InsetNomencl
|
|
||||||
if (insetType == "nomenclature") {
|
|
||||||
static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
|
static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
|
||||||
static const bool isoptional[] = {true, false, false};
|
static const bool isoptional[] = {true, false, false};
|
||||||
static const CommandInfo info = {3, paramnames, isoptional};
|
static const CommandInfo info = {3, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case NOMENCL_PRINT_CODE: {
|
||||||
// InsetPrintNomencl
|
|
||||||
if (insetType == "nomencl_print") {
|
|
||||||
static const char * const paramnames[] = {"labelwidth", ""};
|
static const char * const paramnames[] = {"labelwidth", ""};
|
||||||
static const bool isoptional[] = {true};
|
static const bool isoptional[] = {true};
|
||||||
static const CommandInfo info = {1, paramnames, isoptional};
|
static const CommandInfo info = {1, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case REF_CODE: {
|
||||||
// InsetRef
|
|
||||||
if (insetType == "ref") {
|
|
||||||
static const char * const paramnames[] =
|
static const char * const paramnames[] =
|
||||||
{"name", "reference", ""};
|
{"name", "reference", ""};
|
||||||
static const bool isoptional[] = {true, false};
|
static const bool isoptional[] = {true, false};
|
||||||
static const CommandInfo info = {2, paramnames, isoptional};
|
static const CommandInfo info = {2, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
case TOC_CODE: {
|
||||||
// InsetTOC
|
|
||||||
if (insetType == "toc") {
|
|
||||||
static const char * const paramnames[] = {"type", ""};
|
static const char * const paramnames[] = {"type", ""};
|
||||||
static const bool isoptional[] = {false};
|
static const bool isoptional[] = {false};
|
||||||
static const CommandInfo info = {1, paramnames, isoptional};
|
static const CommandInfo info = {1, paramnames, isoptional};
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
BOOST_ASSERT(false);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//FIXME Will eventually call a static method, etc.
|
//FIXME Will eventually call a static method, etc.
|
||||||
InsetCommandParams::CommandInfo const *
|
InsetCommandParams::CommandInfo const *
|
||||||
InsetCommandParams::findInfo(std::string const & insetType,
|
InsetCommandParams::findInfo(InsetCode code,
|
||||||
std::string const & cmdName)
|
std::string const &/* cmdName*/)
|
||||||
{
|
{
|
||||||
return findInfo(insetType);
|
return findInfo(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//FIXME Should call InsetBibitem::getDefaultCmd(), eg
|
//FIXME Should call InsetBibitem::getDefaultCmd(), eg
|
||||||
std::string InsetCommandParams::getDefaultCmd(std::string insetType) {
|
std::string InsetCommandParams::getDefaultCmd(InsetCode code) {
|
||||||
if (insetType == "bibitem")
|
switch (code) {
|
||||||
return "bibitem";
|
case BIBITEM_CODE:
|
||||||
if (insetType == "bibtex")
|
return "bibitem";
|
||||||
return "bibtex"; //this is an unused dummy
|
case BIBTEX_CODE:
|
||||||
if (insetType == "citation")
|
return "bibtex"; //this is an unused dummy
|
||||||
return "cite";
|
case CITE_CODE:
|
||||||
if (insetType == "floatlist")
|
return "cite";
|
||||||
return "listoftables";
|
case FLOAT_LIST_CODE:
|
||||||
if (insetType == "hfill")
|
return "listoftables";
|
||||||
return "hfill";
|
case HFILL_CODE:
|
||||||
if (insetType == "href")
|
return "hfill";
|
||||||
return "href";
|
case HYPERLINK_CODE:
|
||||||
if (insetType == "include")
|
return "href";
|
||||||
return "include";
|
case INCLUDE_CODE:
|
||||||
if (insetType == "index")
|
return "include";
|
||||||
return "index";
|
case INDEX_CODE:
|
||||||
if (insetType == "index_print")
|
return "index";
|
||||||
return "print_index";
|
case INDEX_PRINT_CODE:
|
||||||
if (insetType == "label")
|
return "print_index";
|
||||||
return "label";
|
case LABEL_CODE:
|
||||||
if (insetType == "nomenclature")
|
return "label";
|
||||||
return "nomenclature";
|
case NOMENCL_CODE:
|
||||||
if (insetType == "nomencl_print")
|
return "nomenclature";
|
||||||
return "printnomenclature";
|
case NOMENCL_PRINT_CODE:
|
||||||
if (insetType == "ref")
|
return "printnomenclature";
|
||||||
return "ref";
|
case REF_CODE:
|
||||||
if (insetType == "toc")
|
return "ref";
|
||||||
return "tableofcontents";
|
case TOC_CODE:
|
||||||
BOOST_ASSERT(false);
|
return "tableofcontents";
|
||||||
|
default:
|
||||||
|
BOOST_ASSERT(false);
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,9 +208,12 @@ void InsetCommandParams::setCmdName(string const & name)
|
|||||||
{
|
{
|
||||||
//FIXME Check command compatibility
|
//FIXME Check command compatibility
|
||||||
cmdName_ = name;
|
cmdName_ = name;
|
||||||
BOOST_ASSERT(!insetType_.empty());
|
CommandInfo const * const info = findInfo(insetCode_, cmdName_);
|
||||||
CommandInfo const * const info = findInfo(insetType_, cmdName_);
|
if (!info) {
|
||||||
BOOST_ASSERT(info);
|
lyxerr << "Command '" << name << "' is not compatible with a '" <<
|
||||||
|
insetType() << "' inset." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
ParamVector params(info->n);
|
ParamVector params(info->n);
|
||||||
// Overtake parameters with the same name
|
// Overtake parameters with the same name
|
||||||
for (size_t i = 0; i < info_->n; ++i) {
|
for (size_t i = 0; i < info_->n; ++i) {
|
||||||
@ -318,19 +302,18 @@ void InsetCommandParams::read(Lexer & lex)
|
|||||||
//FIXME
|
//FIXME
|
||||||
if (lex.isOK()) {
|
if (lex.isOK()) {
|
||||||
lex.next();
|
lex.next();
|
||||||
string insetType = lex.getString();
|
string const insetType = lex.getString();
|
||||||
if (!insetType_.empty() && insetType != insetType_) {
|
InsetCode const code = insetCode(insetType);
|
||||||
|
if (code != insetCode_) {
|
||||||
lex.printError("InsetCommand: Attempt to change type of parameters.");
|
lex.printError("InsetCommand: Attempt to change type of parameters.");
|
||||||
throw ExceptionMessage(WarningException, _("InsetCommand Error: "),
|
throw ExceptionMessage(WarningException, _("InsetCommand Error: "),
|
||||||
from_utf8("Attempt to change type of parameters."));
|
from_utf8("Attempt to change type of parameters."));
|
||||||
}
|
}
|
||||||
// OK, we survived...
|
|
||||||
insetType_ = insetType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lex.isOK()) {
|
if (lex.isOK()) {
|
||||||
lex.next();
|
lex.next();
|
||||||
string test = lex.getString();
|
string const test = lex.getString();
|
||||||
if (test != "LatexCommand") {
|
if (test != "LatexCommand") {
|
||||||
lex.printError("InsetCommand: no LatexCommand line found.");
|
lex.printError("InsetCommand: no LatexCommand line found.");
|
||||||
throw ExceptionMessage(WarningException, _("InsetCommand error:"),
|
throw ExceptionMessage(WarningException, _("InsetCommand error:"),
|
||||||
@ -345,11 +328,11 @@ void InsetCommandParams::read(Lexer & lex)
|
|||||||
//upon what insetType_ is.
|
//upon what insetType_ is.
|
||||||
//it's possible that should go into InsetCommand.cpp,
|
//it's possible that should go into InsetCommand.cpp,
|
||||||
//or maybe it's a standalone function.
|
//or maybe it's a standalone function.
|
||||||
info_ = findInfo(insetType_, cmdName_);
|
info_ = findInfo(insetCode_, cmdName_);
|
||||||
if (!info_) {
|
if (!info_) {
|
||||||
lex.printError("InsetCommand: Unknown inset name `$$Token'");
|
lex.printError("InsetCommand: Unknown inset name `$$Token'");
|
||||||
throw ExceptionMessage(WarningException,
|
throw ExceptionMessage(WarningException,
|
||||||
_("Unknown inset name: "), from_utf8(insetType_));
|
_("Unknown inset name: "), from_utf8(insetType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
string token;
|
string token;
|
||||||
@ -387,7 +370,7 @@ void InsetCommandParams::read(Lexer & lex)
|
|||||||
|
|
||||||
void InsetCommandParams::write(ostream & os) const
|
void InsetCommandParams::write(ostream & os) const
|
||||||
{
|
{
|
||||||
os << "CommandInset " << insetType_ << '\n';
|
os << "CommandInset " << insetType() << '\n';
|
||||||
os << "LatexCommand " << cmdName_ << '\n';
|
os << "LatexCommand " << cmdName_ << '\n';
|
||||||
for (size_t i = 0; i < info_->n; ++i)
|
for (size_t i = 0; i < info_->n; ++i)
|
||||||
if (!params_[i].empty())
|
if (!params_[i].empty())
|
||||||
@ -440,7 +423,7 @@ std::string const InsetCommandParams::getOptions() const
|
|||||||
if (info_->optional[i])
|
if (info_->optional[i])
|
||||||
return to_utf8(params_[i]);
|
return to_utf8(params_[i]);
|
||||||
lyxerr << "Programming error: get nonexisting option in "
|
lyxerr << "Programming error: get nonexisting option in "
|
||||||
<< insetType_ << " inset." << endl;
|
<< insetType() << " inset." << endl;
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,7 +440,7 @@ std::string const InsetCommandParams::getSecOptions() const
|
|||||||
}
|
}
|
||||||
// Happens in InsetCitation
|
// Happens in InsetCitation
|
||||||
lyxerr << "Programming error: get nonexisting second option in "
|
lyxerr << "Programming error: get nonexisting second option in "
|
||||||
<< insetType_ << " inset." << endl;
|
<< insetType() << " inset." << endl;
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +463,7 @@ void InsetCommandParams::setOptions(std::string const & o)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lyxerr << "Programming error: set nonexisting option in "
|
lyxerr << "Programming error: set nonexisting option in "
|
||||||
<< insetType_ << " inset." << endl;
|
<< insetType() << " inset." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -498,7 +481,7 @@ void InsetCommandParams::setSecOptions(std::string const & s)
|
|||||||
}
|
}
|
||||||
// Happens in InsetCitation
|
// Happens in InsetCitation
|
||||||
lyxerr << "Programming error: set nonexisting second option in "
|
lyxerr << "Programming error: set nonexisting second option in "
|
||||||
<< insetType_ << " inset." << endl;
|
<< insetType() << " inset." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -539,7 +522,7 @@ void InsetCommandParams::clear()
|
|||||||
bool operator==(InsetCommandParams const & o1,
|
bool operator==(InsetCommandParams const & o1,
|
||||||
InsetCommandParams const & o2)
|
InsetCommandParams const & o2)
|
||||||
{
|
{
|
||||||
return o1.insetType_ == o2.insetType_ &&
|
return o1.insetCode_ == o2.insetCode_ &&
|
||||||
o1.cmdName_ == o2.cmdName_ &&
|
o1.cmdName_ == o2.cmdName_ &&
|
||||||
o1.info_ == o2.info_ &&
|
o1.info_ == o2.info_ &&
|
||||||
o1.params_ == o2.params_ &&
|
o1.params_ == o2.params_ &&
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#ifndef INSETCOMMANDPARAMS_H
|
#ifndef INSETCOMMANDPARAMS_H
|
||||||
#define INSETCOMMANDPARAMS_H
|
#define INSETCOMMANDPARAMS_H
|
||||||
|
|
||||||
|
#include "InsetCode.h"
|
||||||
#include "support/docstring.h"
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
@ -25,15 +26,16 @@ class Lexer;
|
|||||||
|
|
||||||
class InsetCommandParams {
|
class InsetCommandParams {
|
||||||
public:
|
public:
|
||||||
/// Construct parameters for inset \p insetType, using
|
/// Construct parameters for inset of type \p code.
|
||||||
/// \p insetType as default for \p cmdName_.
|
explicit InsetCommandParams(InsetCode code);
|
||||||
explicit InsetCommandParams(std::string const & insetType);
|
/// Construct parameters for inset of type \p code with
|
||||||
/// Construct parameters for inset \p insetType with
|
|
||||||
/// command name \p cmdName.
|
/// command name \p cmdName.
|
||||||
explicit InsetCommandParams(std::string const & insetType,
|
explicit InsetCommandParams(InsetCode code,
|
||||||
std::string const & cmdName);
|
std::string const & cmdName);
|
||||||
///
|
///
|
||||||
std::string insetType() const { return insetType_; }
|
std::string insetType() const { return insetName(insetCode_); }
|
||||||
|
///
|
||||||
|
InsetCode code() const { return insetCode_; }
|
||||||
///
|
///
|
||||||
void read(Lexer &);
|
void read(Lexer &);
|
||||||
/// Parse the command
|
/// Parse the command
|
||||||
@ -82,21 +84,21 @@ private:
|
|||||||
/// Tells whether a parameter is optional
|
/// Tells whether a parameter is optional
|
||||||
bool const * optional;
|
bool const * optional;
|
||||||
};
|
};
|
||||||
/// Get information for inset type \p insetType.
|
/// Get information for inset type \p code.
|
||||||
/// Returns 0 if the inset is not known.
|
/// Returns 0 if the inset is not known.
|
||||||
static CommandInfo const * findInfo(std::string const & insetType);
|
static CommandInfo const * findInfo(InsetCode code);
|
||||||
/// Get information for \p insetType and command \p cmdName.
|
/// Get information for \p code and command \p cmdName.
|
||||||
/// Returns 0 if the combination is not known.
|
/// Returns 0 if the combination is not known.
|
||||||
/// Don't call this without first making sure the command name is
|
/// Don't call this without first making sure the command name is
|
||||||
/// acceptable to the inset.
|
/// acceptable to the inset.
|
||||||
static CommandInfo const * findInfo(std::string const & insetType,
|
static CommandInfo const * findInfo(InsetCode code,
|
||||||
std::string const & cmdName);
|
std::string const & cmdName);
|
||||||
///
|
///
|
||||||
std::string getDefaultCmd(std::string insetType);
|
std::string getDefaultCmd(InsetCode);
|
||||||
/// Description of all command properties
|
/// Description of all command properties
|
||||||
CommandInfo const * info_;
|
CommandInfo const * info_;
|
||||||
/// what kind of inset we're the parameters for
|
/// what kind of inset we're the parameters for
|
||||||
std::string insetType_;
|
InsetCode insetCode_;
|
||||||
/// The name of this command as it appears in .lyx and .tex files
|
/// The name of this command as it appears in .lyx and .tex files
|
||||||
std::string cmdName_;
|
std::string cmdName_;
|
||||||
///
|
///
|
||||||
|
@ -38,12 +38,12 @@ using std::ostream;
|
|||||||
|
|
||||||
|
|
||||||
InsetFloatList::InsetFloatList()
|
InsetFloatList::InsetFloatList()
|
||||||
: InsetCommand(InsetCommandParams("floatlist"), "toc")
|
: InsetCommand(InsetCommandParams(FLOAT_LIST_CODE), "toc")
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
InsetFloatList::InsetFloatList(string const & type)
|
InsetFloatList::InsetFloatList(string const & type)
|
||||||
: InsetCommand(InsetCommandParams("floatlist"), "toc")
|
: InsetCommand(InsetCommandParams(FLOAT_LIST_CODE), "toc")
|
||||||
{
|
{
|
||||||
setParam("type", from_ascii(type));
|
setParam("type", from_ascii(type));
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace lyx {
|
|||||||
|
|
||||||
|
|
||||||
InsetHFill::InsetHFill()
|
InsetHFill::InsetHFill()
|
||||||
: InsetCommand(InsetCommandParams("hfill"), std::string())
|
: InsetCommand(InsetCommandParams(HFILL_CODE), std::string())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
InsetCommandParams p("include");
|
InsetCommandParams p(INCLUDE_CODE);
|
||||||
InsetIncludeMailer::string2params(to_utf8(cmd.argument()), p);
|
InsetIncludeMailer::string2params(to_utf8(cmd.argument()), p);
|
||||||
if (!p.getCmdName().empty()) {
|
if (!p.getCmdName().empty()) {
|
||||||
if (isListings(p)){
|
if (isListings(p)){
|
||||||
|
@ -54,7 +54,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
|
|
||||||
case LFUN_INSET_MODIFY: {
|
case LFUN_INSET_MODIFY: {
|
||||||
InsetCommandParams p("label");
|
InsetCommandParams p(LABEL_CODE);
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
|
InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
|
||||||
if (p.getCmdName().empty()) {
|
if (p.getCmdName().empty()) {
|
||||||
|
@ -84,7 +84,7 @@ int InsetRef::latex(Buffer const &, odocstream & os,
|
|||||||
{
|
{
|
||||||
// We don't want to output p_["name"], since that is only used
|
// We don't want to output p_["name"], since that is only used
|
||||||
// in docbook. So we construct new params, without it, and use that.
|
// in docbook. So we construct new params, without it, and use that.
|
||||||
InsetCommandParams p("ref", getCmdName());
|
InsetCommandParams p(REF_CODE, getCmdName());
|
||||||
p["reference"] = getParam("reference");
|
p["reference"] = getParam("reference");
|
||||||
os << escape(p.getCommand());
|
os << escape(p.getCommand());
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1095,7 +1095,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
if (old_label.empty())
|
if (old_label.empty())
|
||||||
old_label = default_label;
|
old_label = default_label;
|
||||||
|
|
||||||
InsetCommandParams p("label");
|
InsetCommandParams p(LABEL_CODE);
|
||||||
p["name"] = cmd.argument().empty() ? old_label : cmd.argument();
|
p["name"] = cmd.argument().empty() ? old_label : cmd.argument();
|
||||||
std::string const data = InsetCommandMailer::params2string("label", p);
|
std::string const data = InsetCommandMailer::params2string("label", p);
|
||||||
|
|
||||||
@ -1112,7 +1112,7 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
//lyxerr << "arg: " << to_utf8(cmd.argument()) << endl;
|
//lyxerr << "arg: " << to_utf8(cmd.argument()) << endl;
|
||||||
std::string const name = cmd.getArg(0);
|
std::string const name = cmd.getArg(0);
|
||||||
if (name == "label") {
|
if (name == "label") {
|
||||||
InsetCommandParams p("label");
|
InsetCommandParams p(LABEL_CODE);
|
||||||
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), p);
|
InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), p);
|
||||||
docstring str = p["name"];
|
docstring str = p["name"];
|
||||||
cur.recordUndoInset();
|
cur.recordUndoInset();
|
||||||
|
@ -174,7 +174,7 @@ int InsetMathRef::docbook(Buffer const & buf, odocstream & os,
|
|||||||
|
|
||||||
string const InsetMathRef::createDialogStr(string const & name) const
|
string const InsetMathRef::createDialogStr(string const & name) const
|
||||||
{
|
{
|
||||||
InsetCommandParams icp(to_ascii(commandname()));
|
InsetCommandParams icp(REF_CODE, to_ascii(commandname()));
|
||||||
icp["reference"] = asString(cell(0));
|
icp["reference"] = asString(cell(0));
|
||||||
if (!cell(1).empty())
|
if (!cell(1).empty())
|
||||||
icp["name"] = asString(cell(1));
|
icp["name"] = asString(cell(1));
|
||||||
|
@ -424,7 +424,7 @@ bool createInsetMath_fromDialogStr(docstring const & str, MathData & ar)
|
|||||||
if (name != "ref" )
|
if (name != "ref" )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
InsetCommandParams icp("ref");
|
InsetCommandParams icp(REF_CODE);
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
InsetCommandMailer::string2params("ref", to_utf8(str), icp);
|
InsetCommandMailer::string2params("ref", to_utf8(str), icp);
|
||||||
mathed_parse_cell(ar, icp.getCommand());
|
mathed_parse_cell(ar, icp.getCommand());
|
||||||
|
Loading…
Reference in New Issue
Block a user