*
* \author André Pönitz
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#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/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>
-
-using namespace lyx::support;
+using lyx::support::compare_ascii_no_case;
using std::endl;
-Inset * createInset(FuncRequest const & cmd)
+
+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);
case LFUN_INSERT_NOTE:
- return new InsetNote(params, "Note");
+ {
+ string arg = cmd.getArg(0);
+ if (arg.empty())
+ arg = "Note";
+ return new InsetNote(params, arg);
+ }
+ case LFUN_INSERT_BRANCH:
+ {
+ string arg = cmd.getArg(0);
+ if (arg.empty())
+ arg = "none";
+ return new InsetBranch(params, arg);
+ }
case LFUN_INSET_ERT:
return new InsetERT(params);
if (icp.getContents().empty()) {
lv->getDialogs().show("index", data, 0);
} else {
- FuncRequest fr(bv, LFUN_INSET_APPLY, data);
- lv->dispatch(fr);
+ lv->dispatch(FuncRequest(bv, LFUN_INSET_APPLY, data));
}
return 0;
}
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");
InsetCaption * inset = new InsetCaption(params);
inset->setOwner(bv->theLockingInset());
inset->setAutoBreakRows(true);
- inset->setDrawFrame(0, InsetText::LOCKED);
- inset->setFrameColor(0, LColor::captionframe);
+ inset->setDrawFrame(InsetText::LOCKED);
+ inset->setFrameColor(LColor::captionframe);
return inset;
}
return 0;
InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp);
InsetCitation * inset = new InsetCitation(icp);
- inset->setLoadingBuffer(bv->buffer(), false);
+ inset->setLoadingBuffer(*bv->buffer(), false);
return inset;
} else if (name == "ert") {
InsetExternalMailer::string2params(cmd.argument,
buffer, iep);
InsetExternal * inset = new InsetExternal;
- inset->setParams(iep);
+ inset->setParams(iep, buffer);
return inset;
} else if (name == "graphics") {
return inset;
} else if (name == "include") {
- InsetInclude::Params iip;
+ InsetCommandParams iip;
InsetIncludeMailer::string2params(cmd.argument, iip);
return new InsetInclude(iip);
}
-Inset * readInset(LyXLex & lex, Buffer const & buf)
+InsetOld * readInset(LyXLex & lex, Buffer const & buf)
{
// consistency check
if (lex.getString() != "\\begin_inset") {
<< endl;
}
- Inset * inset = 0;
+ InsetOld * inset = 0;
lex.next();
string const tmptok = lex.getString();
} 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"
inset = new InsetFormula;
} else if (tmptok == "Graphics") {
inset = new InsetGraphics;
- } else if (tmptok == "Note" || tmptok == "Comment"
+ } else if (tmptok == "Note" || tmptok == "Comment"
|| tmptok == "Greyedout") {
- inset = new InsetNote(buf.params, tmptok);
+ inset = new InsetNote(buf.params(), tmptok);
+ } else if (tmptok == "Branch") {
+ 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;
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;
}
if (inset)
- inset->read(&buf, lex);
+ inset->read(buf, lex);
}
return inset;