X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffactory.cpp;h=fd823085ee6e6b194dbc2f95ca3b05585224946e;hb=3256dbc78a76f947080dc8e3414abc60e4b5c5af;hp=b8d79a5537dd4cd3875a754e44cd4d4ad7e0a85b;hpb=4bf0bed36acca6139d905a6c004886ea5c93f608;p=lyx.git diff --git a/src/factory.cpp b/src/factory.cpp index b8d79a5537..fd823085ee 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -14,7 +14,6 @@ #include "Buffer.h" #include "BufferParams.h" -#include "debug.h" #include "FloatList.h" #include "FuncRequest.h" #include "Lexer.h" @@ -46,7 +45,7 @@ #include "insets/InsetBox.h" #include "insets/InsetBranch.h" #include "insets/InsetOptArg.h" -#include "insets/InsetPagebreak.h" +#include "insets/InsetNewpage.h" #include "insets/InsetRef.h" #include "insets/InsetSpace.h" #include "insets/InsetTabular.h" @@ -60,25 +59,21 @@ #include "frontends/alert.h" +#include "support/debug.h" #include "support/lstrings.h" #include "support/ExceptionMessage.h" #include -#include #include -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) { @@ -93,6 +88,9 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd) case LFUN_LINE_INSERT: return new InsetLine; + case LFUN_NEWPAGE_INSERT: + return new InsetNewpage; + case LFUN_PAGEBREAK_INSERT: return new InsetPagebreak; @@ -104,9 +102,7 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd) 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.getTextClassPtr(), s); } case LFUN_NOTE_INSERT: { @@ -188,7 +184,7 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd) 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) @@ -326,7 +322,7 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd) default: lyxerr << "Inset '" << name << "' not permitted with LFUN_INSET_INSERT." - << std::endl; + << endl; return 0; } @@ -361,12 +357,12 @@ Inset * createInset(Buffer & buf, FuncRequest const & cmd) 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; } @@ -387,8 +383,6 @@ Inset * readInset(Lexer & lex, Buffer const & buf) auto_ptr inset; - TextClass const & tclass = buf.params().getTextClass(); - lex.next(); string tmptok = lex.getString(); @@ -453,7 +447,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf) case NO_CODE: default: lyxerr << "unknown CommandInset '" << insetType - << "'" << std::endl; + << "'" << endl; while (lex.isOK() && lex.getString() != "\\end_inset") lex.next(); return 0; @@ -482,8 +476,8 @@ Inset * readInset(Lexer & lex, Buffer const & buf) } 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().getTextClassPtr(), s)); } else if (tmptok == "Branch") { inset.reset(new InsetBranch(buf.params(), InsetBranchParams())); @@ -530,7 +524,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf) 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;