]> git.lyx.org Git - lyx.git/blobdiff - src/factory.cpp
Fix bug http://bugzilla.lyx.org/show_bug.cgi?id=4599
[lyx.git] / src / factory.cpp
index fd823085ee6e6b194dbc2f95ca3b05585224946e..9d317b94b02d375ba35f46800648ac745cbb0829 100644 (file)
@@ -75,7 +75,7 @@ namespace lyx {
 namespace Alert = frontend::Alert;
 
 
-Inset * createInset(Buffer & buf, FuncRequest const & cmd)
+Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
 {
        BufferParams const & params = buf.params();
 
@@ -102,7 +102,7 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
 
                case LFUN_FLEX_INSERT: {
                        string s = cmd.getArg(0);
-                       return new InsetFlex(params, params.getTextClassPtr(), s);
+                       return new InsetFlex(params, params.documentClassPtr(), s);
                }
 
                case LFUN_NOTE_INSERT: {
@@ -147,7 +147,7 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
                case LFUN_FLOAT_INSERT: {
                        // check if the float type exists
                        string const argument = to_utf8(cmd.argument());
-                       if (params.getTextClass().floats().typeExist(argument))
+                       if (params.documentClass().floats().typeExist(argument))
                                return new InsetFloat(params, argument);
                        lyxerr << "Non-existent float type: " << argument << endl;
                }
@@ -155,7 +155,7 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
                case LFUN_FLOAT_WIDE_INSERT: {
                        // check if the float type exists
                        string const argument = to_utf8(cmd.argument());
-                       if (params.getTextClass().floats().typeExist(argument)) {
+                       if (params.documentClass().floats().typeExist(argument)) {
                                auto_ptr<InsetFloat> p(new InsetFloat(params, argument));
                                p->wide(true, params);
                                return p.release();
@@ -263,7 +263,7 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
                                InsetExternalParams iep;
                                InsetExternalMailer::string2params(to_utf8(cmd.argument()), buf, iep);
                                auto_ptr<InsetExternal> inset(new InsetExternal);
-                               inset->setParams(iep, buf);
+                               inset->setParams(iep);
                                return inset.release();
                        }
                        
@@ -372,6 +372,13 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd)
        return 0;
 }
 
+Inset * createInset(Buffer & buf, FuncRequest const & cmd)
+{
+       Inset * inset = createInsetHelper(buf, cmd);
+       if (inset)
+               inset->setBuffer(buf);
+       return inset;
+}
 
 Inset * readInset(Lexer & lex, Buffer const & buf)
 {
@@ -452,6 +459,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
                                        lex.next();
                                return 0;
                }
+               inset->setBuffer(const_cast<Buffer &>(buf));
        } else { 
                // FIXME This branch should be made to use inset codes as the preceding 
                // branch does. Unfortunately, that will take some doing. It requires
@@ -477,7 +485,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
                        lex.next();
                        string s = lex.getString();
                        inset.reset(new InsetFlex(buf.params(), 
-                               buf.params().getTextClassPtr(), s));
+                               buf.params().documentClassPtr(), s));
                } else if (tmptok == "Branch") {
                        inset.reset(new InsetBranch(buf.params(),
                                                    InsetBranchParams()));
@@ -530,9 +538,9 @@ Inset * readInset(Lexer & lex, Buffer const & buf)
                        return 0;
                }
 
-               inset->read(buf, lex);
+               inset->setBuffer(const_cast<Buffer &>(buf));
+               inset->read(lex);
        }
-
        return inset.release();
 }