- if (insetType == "citation") {
- inset.reset(new InsetCitation(inscmd));
- } else if (insetType == "bibitem") {
- inset.reset(new InsetBibitem(inscmd));
- } else if (insetType == "bibtex") {
- inset.reset(new InsetBibtex(inscmd));
- } else if (insetType == "index") {
- inset.reset(new InsetIndex(buf.params()));
- } else if (insetType == "nomenclature") {
- inset.reset(new InsetNomencl(inscmd));
- } else if (insetType == "include") {
- inset.reset(new InsetInclude(inscmd));
- } else if (insetType == "label") {
- inset.reset(new InsetLabel(inscmd));
- } else if (insetType == "url") {
- inset.reset(new InsetUrl(inscmd));
- } else if (insetType == "ref") {
- if (!inscmd["name"].empty()
- || !inscmd["reference"].empty()) {
- inset.reset(new InsetRef(inscmd, buf));
- }
- } else if (insetType == "toc") {
- inset.reset(new InsetTOC(inscmd));
- } else if (insetType == "index_print") {
- inset.reset(new InsetPrintIndex(inscmd));
- } else if (insetType == "nomencl_print") {
- inset.reset(new InsetPrintNomencl(inscmd));
- } else {
- lyxerr << "unknown CommandInset '" << insetType
- << "'" << 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;