]> git.lyx.org Git - lyx.git/blobdiff - src/factory.C
ws changes only
[lyx.git] / src / factory.C
index 18bbb04dc2c8d494653f85ef8f2cc5eee337caec..6c728827d22d15f5a48cbb4e86bab3b36165ec48 100644 (file)
 
 #include <config.h>
 
-#include "funcrequest.h"
-#include "bufferparams.h"
+#include "factory.h"
+
 #include "buffer.h"
-#include "FloatList.h"
-#include "debug.h"
 #include "BufferView.h"
-#include "lyxtext.h"
+#include "bufferparams.h"
+#include "debug.h"
+#include "FloatList.h"
+#include "funcrequest.h"
+#include "LColor.h"
 #include "lyxlex.h"
 
 #include "insets/insetbibitem.h"
 #include "insets/insetmarginal.h"
 #include "insets/insetminipage.h"
 #include "insets/insetnote.h"
+#include "insets/insetbox.h"
 #include "insets/insetbranch.h"
 #include "insets/insetoptarg.h"
 #include "insets/insetref.h"
 #include "insets/insetspace.h"
 #include "insets/insettabular.h"
-#include "insets/insettext.h"
 #include "insets/insettoc.h"
 #include "insets/inseturl.h"
 #include "insets/insetwrap.h"
 #include "frontends/Dialogs.h"
 #include "frontends/LyXView.h"
 #include "support/lstrings.h"
+#include "support/std_sstream.h"
 
-#include <cstdio>
+#include <boost/assert.hpp>
 
-using namespace lyx::support;
+using lyx::support::compare_ascii_no_case;
 
 using std::endl;
+using std::string;
+
 
 InsetOld * createInset(FuncRequest const & cmd)
 {
        BufferView * bv = cmd.view();
-       BufferParams const & params = bv->buffer()->params;
+       BufferParams const & params = bv->buffer()->params();
 
        switch (cmd.action) {
        case LFUN_HFILL:
-               return new InsetHFill();
+               return new InsetHFill;
 
        case LFUN_INSET_MINIPAGE:
                return new InsetMinipage(params);
@@ -78,6 +83,13 @@ InsetOld * createInset(FuncRequest const & cmd)
                                arg = "Note";
                        return new InsetNote(params, arg);
                }
+       case LFUN_INSERT_BOX:
+               {
+                       string arg = cmd.getArg(0);
+                       if (arg.empty())
+                               arg = "Boxed";
+                       return new InsetBox(params, arg);
+               }
        case LFUN_INSERT_BRANCH:
                {
                        string arg = cmd.getArg(0);
@@ -144,9 +156,11 @@ InsetOld * createInset(FuncRequest const & cmd)
 
        case LFUN_TABULAR_INSERT:
                if (!cmd.argument.empty()) {
-                       int r = 2;
-                       int c = 2;
-                       ::sscanf(cmd.argument.c_str(),"%d%d", &r, &c);
+                       std::istringstream ss(cmd.argument);
+                       int r, c;
+                       ss >> r >> c;
+                       if (r <= 0) r = 2;
+                       if (c <= 0) c = 2;
                        return new InsetTabular(*bv->buffer(), r, c);
                }
                bv->owner()->getDialogs().show("tabularcreate");
@@ -211,7 +225,7 @@ InsetOld * createInset(FuncRequest const & cmd)
 
                } else if (name == "external") {
                        Buffer const & buffer = *cmd.view()->buffer();
-                       InsetExternal::Params iep;
+                       InsetExternalParams iep;
                        InsetExternalMailer::string2params(cmd.argument,
                                                           buffer, iep);
                        InsetExternal * inset = new InsetExternal;
@@ -228,7 +242,7 @@ InsetOld * createInset(FuncRequest const & cmd)
                        return inset;
 
                } else if (name == "include") {
-                       InsetInclude::Params iip;
+                       InsetCommandParams iip;
                        InsetIncludeMailer::string2params(cmd.argument, iip);
                        return new InsetInclude(iip);
 
@@ -325,7 +339,7 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
                } else if (cmdName == "index") {
                        inset = new InsetIndex(inscmd);
                } else if (cmdName == "include") {
-                       inset = new InsetInclude(inscmd, buf);
+                       inset = new InsetInclude(inscmd);
                } else if (cmdName == "label") {
                        inset = new InsetLabel(inscmd);
                } else if (cmdName == "url"
@@ -351,6 +365,9 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
                        inset = new InsetFloatList("table");
                } else if (cmdName == "printindex") {
                        inset = new InsetPrintIndex(inscmd);
+               } else {
+                       lyxerr << "unknown CommandInset '" << cmdName << "'" << std::endl;
+                       BOOST_ASSERT(false);
                }
        } else {
                if (tmptok == "Quotes") {
@@ -365,39 +382,43 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
                        inset = new InsetGraphics;
                } else if (tmptok == "Note"     || tmptok == "Comment"
                                || tmptok == "Greyedout") {
-                       inset = new InsetNote(buf.params, tmptok);
+                       inset = new InsetNote(buf.params(), tmptok);
+               } else if (tmptok == "Boxed" || tmptok == "ovalbox"
+                       || tmptok == "Shadowbox" || tmptok == "Doublebox"
+                       || tmptok == "Ovalbox" || tmptok == "Frameless") {
+                       inset = new InsetBox(buf.params(), tmptok);
                } else if (tmptok == "Branch") {
-                       inset = new InsetBranch(buf.params, tmptok);
+                       inset = new InsetBranch(buf.params(), string());
                } else if (tmptok == "Include") {
                        InsetCommandParams p("Include");
-                       inset = new InsetInclude(p, buf);
+                       inset = new InsetInclude(p);
                } else if (tmptok == "Environment") {
                        lex.next();
-                       inset = new InsetEnvironment(buf.params, lex.getString());
+                       inset = new InsetEnvironment(buf.params(), lex.getString());
                } else if (tmptok == "ERT") {
-                       inset = new InsetERT(buf.params);
+                       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);
+                       inset = new InsetText(buf.params());
                } else if (tmptok == "Foot") {
-                       inset = new InsetFoot(buf.params);
+                       inset = new InsetFoot(buf.params());
                } else if (tmptok == "Marginal") {
-                       inset = new InsetMarginal(buf.params);
+                       inset = new InsetMarginal(buf.params());
                } else if (tmptok == "OptArg") {
-                       inset = new InsetOptArg(buf.params);
+                       inset = new InsetOptArg(buf.params());
                } else if (tmptok == "Minipage") {
-                       inset = new InsetMinipage(buf.params);
+                       inset = new InsetMinipage(buf.params());
                } else if (tmptok == "Float") {
                        lex.next();
                        string tmptok = lex.getString();
-                       inset = new InsetFloat(buf.params, tmptok);
+                       inset = new InsetFloat(buf.params(), tmptok);
                } else if (tmptok == "Wrap") {
                        lex.next();
                        string tmptok = lex.getString();
-                       inset = new InsetWrap(buf.params, tmptok);
+                       inset = new InsetWrap(buf.params(), tmptok);
 #if 0
                } else if (tmptok == "List") {
                        inset = new InsetList;
@@ -405,13 +426,15 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
                        inset = new InsetList;
 #endif
                } else if (tmptok == "Caption") {
-                       inset = new InsetCaption(buf.params);
+                       inset = new InsetCaption(buf.params());
                } else if (tmptok == "FloatList") {
                        inset = new InsetFloatList;
+               } else {
+                       lyxerr << "unknown Inset type '" << tmptok << "'" << std::endl;
+                       BOOST_ASSERT(false);
                }
 
-               if (inset)
-                       inset->read(buf, lex);
+               inset->read(buf, lex);
        }
 
        return inset;