]> git.lyx.org Git - lyx.git/blobdiff - src/factory.cpp
HTML for math fonts.
[lyx.git] / src / factory.cpp
index 91bce06e94540c4b8d7657477afbdd04d6a51d5c..bdad713932da2346b3b06ae605cc0a019c882712 100644 (file)
@@ -47,6 +47,7 @@
 #include "insets/InsetNote.h"
 #include "insets/InsetOptArg.h"
 #include "insets/InsetPhantom.h"
+#include "insets/InsetPreview.h"
 #include "insets/InsetRef.h"
 #include "insets/InsetSpace.h"
 #include "insets/InsetTabular.h"
@@ -77,8 +78,6 @@ namespace Alert = frontend::Alert;
 
 Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
 {
-       BufferParams const & params = buf->params();
-
        try {
 
                switch (cmd.action) {
@@ -148,24 +147,13 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                case LFUN_OPTIONAL_INSERT:
                        return new InsetOptArg(buf);
 
-               case LFUN_FLOAT_INSERT: {
-                       // check if the float type exists
-                       string const argument = to_utf8(cmd.argument());
-                       if (params.documentClass().floats().typeExist(argument))
-                               return new InsetFloat(buf, argument);
-                       lyxerr << "Non-existent float type: " << argument << endl;
-               }
+               case LFUN_FLOAT_INSERT:
+                       return new InsetFloat(buf, to_utf8(cmd.argument()));
 
                case LFUN_FLOAT_WIDE_INSERT: {
-                       // check if the float type exists
-                       string const argument = to_utf8(cmd.argument());
-                       if (params.documentClass().floats().typeExist(argument)) {
-                               auto_ptr<InsetFloat> p(new InsetFloat(buf, argument));
-                               p->setWide(true);
-                               return p.release();
-                       }
-                       lyxerr << "Non-existent float type: " << argument << endl;
-                       return 0;
+                       InsetFloat * fl = new InsetFloat(buf, to_utf8(cmd.argument()));
+                       fl->setWide(true);
+                       return fl;
                }
 
                case LFUN_WRAP_INSERT: {
@@ -224,6 +212,9 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                        return inset;
                }
 
+               case LFUN_PREVIEW_INSERT:
+                       return new InsetPreview(buf);
+
                case LFUN_INSET_INSERT: {
                        string const name = cmd.getArg(0);
                        InsetCode code = insetCode(name);
@@ -336,6 +327,9 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                                InsetVSpace::string2params(to_utf8(cmd.argument()), vspace);
                                return new InsetVSpace(vspace);
                        }
+
+                       case PREVIEW_CODE:
+                               return new InsetPreview(buf);
                        
                        default:
                                lyxerr << "Inset '" << name << "' not permitted with LFUN_INSET_INSERT."
@@ -571,9 +565,7 @@ Inset * readInset(Lexer & lex, Buffer * buf)
                } else if (tmptok == "OptArg") {
                        inset.reset(new InsetOptArg(buf));
                } else if (tmptok == "Float") {
-                       lex.next();
-                       string tmptok = lex.getString();
-                       inset.reset(new InsetFloat(buf, tmptok));
+                       inset.reset(new InsetFloat(buf, string()));
                } else if (tmptok == "Wrap") {
                        lex.next();
                        string tmptok = lex.getString();
@@ -586,6 +578,8 @@ Inset * readInset(Lexer & lex, Buffer * buf)
                        inset.reset(new InsetFloatList(buf));
                } else if (tmptok == "Info") {
                        inset.reset(new InsetInfo(buf));
+               } else if (tmptok == "Preview") {
+                       inset.reset(new InsetPreview(buf));
                } else {
                        lyxerr << "unknown Inset type '" << tmptok
                               << "'" << endl;