+
+
+Inset * readInset(LyXLex & lex, Buffer const & buf)
+{
+ // consistency check
+ if (lex.getString() != "\\begin_inset") {
+ lyxerr << "Buffer::readInset: Consistency check failed."
+ << endl;
+ }
+
+ Inset * inset = 0;
+
+ lex.next();
+ string const tmptok = lex.getString();
+
+ // test the different insets
+ if (tmptok == "LatexCommand") {
+ InsetCommandParams inscmd;
+ inscmd.read(lex);
+
+ string const cmdName = inscmd.getCmdName();
+
+ // This strange command allows LyX to recognize "natbib" style
+ // citations: citet, citep, Citet etc.
+ if (compare_ascii_no_case(cmdName.substr(0,4), "cite") == 0) {
+ inset = new InsetCitation(inscmd);
+ } else if (cmdName == "bibitem") {
+ lex.printError("Wrong place for bibitem");
+ inset = new InsetBibitem(inscmd);
+ } else if (cmdName == "bibtex") {
+ inset = new InsetBibtex(inscmd);
+ } else if (cmdName == "index") {
+ inset = new InsetIndex(inscmd);
+ } else if (cmdName == "include") {
+ inset = new InsetInclude(inscmd, buf);
+ } else if (cmdName == "label") {
+ inset = new InsetLabel(inscmd);
+ } else if (cmdName == "url"
+ || cmdName == "htmlurl") {
+ inset = new InsetUrl(inscmd);
+ } else if (cmdName == "ref"
+ || cmdName == "eqref"
+ || cmdName == "pageref"
+ || cmdName == "vref"
+ || cmdName == "vpageref"
+ || cmdName == "prettyref") {
+ if (!inscmd.getOptions().empty()
+ || !inscmd.getContents().empty()) {
+ inset = new InsetRef(inscmd, buf);
+ }
+ } else if (cmdName == "tableofcontents") {
+ inset = new InsetTOC(inscmd);
+ } else if (cmdName == "listofalgorithms") {
+ inset = new InsetFloatList("algorithm");
+ } else if (cmdName == "listoffigures") {
+ inset = new InsetFloatList("figure");
+ } else if (cmdName == "listoftables") {
+ inset = new InsetFloatList("table");
+ } else if (cmdName == "printindex") {
+ inset = new InsetPrintIndex(inscmd);
+ }
+ } else {
+ if (tmptok == "Quotes") {
+ inset = new InsetQuotes;
+ } else if (tmptok == "External") {
+ inset = new InsetExternal;
+ } else if (tmptok == "FormulaMacro") {
+ inset = new InsetFormulaMacro;
+ } else if (tmptok == "Formula") {
+ inset = new InsetFormula;
+ } else if (tmptok == "Graphics") {
+ inset = new InsetGraphics;
+ } else if (tmptok == "Note") {
+ inset = new InsetNote(buf.params);
+ } else if (tmptok == "Include") {
+ InsetCommandParams p("Include");
+ inset = new InsetInclude(p, buf);
+ } else if (tmptok == "Environment") {
+ lex.next();
+ inset = new InsetEnvironment(buf.params, lex.getString());
+ } else if (tmptok == "ERT") {
+ inset = new InsetERT(buf.params);
+ } else if (tmptok == "InsetSpace") {
+ inset = new InsetSpace;
+ } else if (tmptok == "Tabular") {
+ inset = new InsetTabular(buf);
+ } else if (tmptok == "Text") {
+ inset = new InsetText(buf.params);
+ } else if (tmptok == "Foot") {
+ inset = new InsetFoot(buf.params);
+ } else if (tmptok == "Marginal") {
+ inset = new InsetMarginal(buf.params);
+ } else if (tmptok == "OptArg") {
+ inset = new InsetOptArg(buf.params);
+ } else if (tmptok == "Minipage") {
+ inset = new InsetMinipage(buf.params);
+ } else if (tmptok == "Float") {
+ lex.next();
+ string tmptok = lex.getString();
+ inset = new InsetFloat(buf.params, tmptok);
+ } else if (tmptok == "Wrap") {
+ lex.next();
+ string tmptok = lex.getString();
+ inset = new InsetWrap(buf.params, tmptok);
+#if 0
+ } else if (tmptok == "List") {
+ inset = new InsetList;
+ } else if (tmptok == "Theorem") {
+ inset = new InsetList;
+#endif
+ } else if (tmptok == "Caption") {
+ inset = new InsetCaption(buf.params);
+ } else if (tmptok == "FloatList") {
+ inset = new InsetFloatList;
+ }
+
+ if (inset)
+ inset->read(&buf, lex);
+ }
+
+ return inset;
+}