- // This strange command allows LyX to recognize "natbib" style
- // citations: citet, citep, Citet etc.
- // FIXME: We already have partial support for \\fullcite and
- // the various \\footcite commands. We should increase the
- // file format number and read these commands here, too.
- // Then we should use is_possible_cite_command() in
- // InsetCitation to test for valid cite commands.
- if (compare_ascii_no_case(cmdName.substr(0,4), "cite") == 0) {
- inset.reset(new InsetCitation(inscmd));
- } else if (cmdName == "bibitem") {
- inset.reset(new InsetBibitem(inscmd));
- } else if (cmdName == "bibtex") {
- inset.reset(new InsetBibtex(inscmd));
- } else if (cmdName == "index") {
- inset.reset(new InsetIndex(inscmd));
- } else if (cmdName == "nomenclature") {
- inset.reset(new InsetNomencl(inscmd));
- } else if (cmdName == "include") {
- inset.reset(new InsetInclude(inscmd));
- } else if (cmdName == "label") {
- inset.reset(new InsetLabel(inscmd));
- } else if (cmdName == "url"
- || cmdName == "htmlurl") {
- inset.reset(new InsetUrl(inscmd));
- } else if (cmdName == "ref"
- || cmdName == "eqref"
- || cmdName == "pageref"
- || cmdName == "vref"
- || cmdName == "vpageref"
- || cmdName == "prettyref") {
- if (!inscmd["name"].empty()
- || !inscmd["reference"].empty()) {
- inset.reset(new InsetRef(inscmd, buf));
- }
- } else if (cmdName == "tableofcontents") {
- inset.reset(new InsetTOC(inscmd));
- } else if (cmdName == "listofalgorithms") {
- inset.reset(new InsetFloatList("algorithm"));
- } else if (cmdName == "listoffigures") {
- inset.reset(new InsetFloatList("figure"));
- } else if (cmdName == "listoftables") {
- inset.reset(new InsetFloatList("table"));
- } else if (cmdName == "printindex") {
- inset.reset(new InsetPrintIndex(inscmd));
- } else if (cmdName == "printnomenclature") {
- inset.reset(new InsetPrintNomencl(inscmd));
- } else {
- lyxerr << "unknown CommandInset '" << cmdName
- << "'" << std::endl;
- while (lex.isOK() && lex.getString() != "\\end_inset")
- lex.next();
- return 0;
+ switch (code) {
+ case BIBITEM_CODE:
+ inset.reset(new InsetBibitem(inscmd));
+ break;
+ case BIBTEX_CODE:
+ inset.reset(new InsetBibtex(inscmd));
+ break;
+ case CITE_CODE:
+ inset.reset(new InsetCitation(inscmd));
+ break;
+ case HYPERLINK_CODE:
+ inset.reset(new InsetHyperlink(inscmd));
+ break;
+ case INCLUDE_CODE:
+ inset.reset(new InsetInclude(inscmd));
+ break;
+ case INDEX_PRINT_CODE:
+ inset.reset(new InsetPrintIndex(inscmd));
+ break;
+ case LABEL_CODE:
+ inset.reset(new InsetLabel(inscmd));
+ break;
+ case NOMENCL_CODE:
+ inset.reset(new InsetNomencl(inscmd));
+ break;
+ case NOMENCL_PRINT_CODE:
+ inset.reset(new InsetPrintNomencl(inscmd));
+ break;
+ case REF_CODE:
+ if (!inscmd["name"].empty() || !inscmd["reference"].empty())
+ inset.reset(new InsetRef(inscmd, buf));
+ break;
+ case TOC_CODE:
+ inset.reset(new InsetTOC(inscmd));
+ break;
+ case NO_CODE:
+ default:
+ lyxerr << "unknown CommandInset '" << insetType
+ << "'" << endl;
+ while (lex.isOK() && lex.getString() != "\\end_inset")
+ lex.next();
+ return 0;