#include "support/ExceptionMessage.h"
#include <boost/assert.hpp>
-#include <boost/current_function.hpp>
#include <sstream>
-using std::auto_ptr;
-using std::endl;
-using std::string;
-
+using namespace std;
+using namespace lyx::support;
namespace lyx {
namespace Alert = frontend::Alert;
-using support::compare_ascii_no_case;
-
-Inset * createInset(Buffer & buf, FuncRequest const & cmd)
+Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
{
BufferParams const & params = buf.params();
case LFUN_FLEX_INSERT: {
string s = cmd.getArg(0);
- TextClass const & tclass = params.getTextClass();
- InsetLayout const & il = tclass.insetlayout(from_utf8(s));
- return new InsetFlex(params, il);
+ return new InsetFlex(params, params.documentClassPtr(), s);
}
case LFUN_NOTE_INSERT: {
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;
}
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();
case LFUN_TABULAR_INSERT: {
if (cmd.argument().empty())
return 0;
- std::istringstream ss(to_utf8(cmd.argument()));
+ istringstream ss(to_utf8(cmd.argument()));
int r = 0, c = 0;
ss >> r >> c;
if (r <= 0)
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();
}
default:
lyxerr << "Inset '" << name << "' not permitted with LFUN_INSET_INSERT."
- << std::endl;
+ << endl;
return 0;
}
break;
}
- } catch (support::ExceptionMessage const & message) {
- if (message.type_ == support::ErrorException) {
+ } catch (ExceptionMessage const & message) {
+ if (message.type_ == ErrorException) {
+ // This should never happen!
Alert::error(message.title_, message.details_);
- LyX::cref().emergencyCleanup();
- abort();
- } else if (message.type_ == support::WarningException) {
+ LyX::cref().exit(1);
+ } else if (message.type_ == WarningException) {
Alert::warning(message.title_, message.details_);
return 0;
}
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)
{
auto_ptr<Inset> inset;
- TextClass const & tclass = buf.params().getTextClass();
-
lex.next();
string tmptok = lex.getString();
case NO_CODE:
default:
lyxerr << "unknown CommandInset '" << insetType
- << "'" << std::endl;
+ << "'" << endl;
while (lex.isOK() && lex.getString() != "\\end_inset")
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
} else if (tmptok == "Flex") {
lex.next();
string s = lex.getString();
- InsetLayout const & il = tclass.insetlayout(from_utf8(s));
- inset.reset(new InsetFlex(buf.params(), il));
+ inset.reset(new InsetFlex(buf.params(),
+ buf.params().documentClassPtr(), s));
} else if (tmptok == "Branch") {
inset.reset(new InsetBranch(buf.params(),
InsetBranchParams()));
inset.reset(new InsetInfo(buf.params()));
} else {
lyxerr << "unknown Inset type '" << tmptok
- << "'" << std::endl;
+ << "'" << endl;
while (lex.isOK() && lex.getString() != "\\end_inset")
lex.next();
return 0;
}
- inset->read(buf, lex);
+ inset->setBuffer(const_cast<Buffer &>(buf));
+ inset->read(lex);
}
-
return inset.release();
}