X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffactory.cpp;h=fc6468056b086badb5887e428681ba8ae699e7c7;hb=e54ae72e5fac6f750c3f7972c74bb42b57f3a049;hp=242a4fd2fac3c8c039d1e823200fac4e95dc5dc8;hpb=39e79d8602920eefe36e898c9f415afb979521b2;p=lyx.git diff --git a/src/factory.cpp b/src/factory.cpp index 242a4fd2fa..fc6468056b 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -18,18 +18,18 @@ #include "debug.h" #include "FloatList.h" #include "FuncRequest.h" -#include "LColor.h" +#include "Color.h" #include "Lexer.h" #include "LyX.h" -#include "Paragraph.h" #include "insets/InsetBibitem.h" #include "insets/InsetBibtex.h" #include "insets/InsetCaption.h" #include "insets/InsetCitation.h" #include "insets/InsetCharStyle.h" -#include "insets/InsetEnv.h" +#include "insets/InsetEnvironment.h" #include "insets/InsetERT.h" +#include "insets/InsetListings.h" #include "insets/InsetExternal.h" #include "insets/InsetFloat.h" #include "insets/InsetFloatList.h" @@ -58,7 +58,7 @@ #include "mathed/MathMacroTemplate.h" #include "mathed/InsetMathHull.h" -#include "frontends/Alert.h" +#include "frontends/alert.h" #include "support/lstrings.h" #include "support/ExceptionMessage.h" @@ -68,6 +68,10 @@ #include +using std::auto_ptr; +using std::endl; +using std::string; + namespace lyx { @@ -75,12 +79,8 @@ namespace Alert = frontend::Alert; using support::compare_ascii_no_case; -using std::auto_ptr; -using std::endl; -using std::string; - -InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) +Inset * createInset(BufferView * bv, FuncRequest const & cmd) { BufferParams const & params = bv->buffer()->params(); @@ -104,7 +104,7 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) case LFUN_CHARSTYLE_INSERT: { string s = cmd.getArg(0); - LyXTextClass tclass = params.getLyXTextClass(); + TextClass tclass = params.getTextClass(); CharStyles::iterator found_cs = tclass.charstyle(s); if (found_cs != tclass.charstyles().end()) return new InsetCharStyle(params, found_cs); @@ -136,6 +136,9 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) case LFUN_ERT_INSERT: return new InsetERT(params); + case LFUN_LISTING_INSERT: + return new InsetListings(params); + case LFUN_FOOTNOTE_INSERT: return new InsetFoot(params); @@ -151,7 +154,7 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) case LFUN_FLOAT_INSERT: { // check if the float type exists string const argument = to_utf8(cmd.argument()); - if (params.getLyXTextClass().floats().typeExist(argument)) + if (params.getTextClass().floats().typeExist(argument)) return new InsetFloat(params, argument); lyxerr << "Non-existent float type: " << argument << endl; return 0; @@ -160,7 +163,7 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) case LFUN_FLOAT_WIDE_INSERT: { // check if the float type exists string const argument = to_utf8(cmd.argument()); - if (params.getLyXTextClass().floats().typeExist(argument)) { + if (params.getTextClass().floats().typeExist(argument)) { auto_ptr p(new InsetFloat(params, argument)); p->wide(true, params); return p.release(); @@ -211,7 +214,7 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) auto_ptr inset(new InsetCaption(params)); inset->setAutoBreakRows(true); inset->setDrawFrame(true); - inset->setFrameColor(LColor::captionframe); + inset->setFrameColor(Color::captionframe); return inset.release(); } @@ -225,7 +228,7 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) return new InsetTOC(InsetCommandParams("tableofcontents")); case LFUN_ENVIRONMENT_INSERT: - return new InsetEnvironment(params, to_utf8(cmd.argument())); + return new InsetEnvironment(params, cmd.argument()); #if 0 case LFUN_LIST_INSERT: @@ -261,6 +264,11 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) InsetERTMailer::string2params(to_utf8(cmd.argument()), st); return new InsetERT(params, st); + } else if (name == "listings") { + InsetListingsParams par; + InsetListingsMailer::string2params(to_utf8(cmd.argument()), par); + return new InsetListings(params, par); + } else if (name == "external") { Buffer const & buffer = *bv->buffer(); InsetExternalParams iep; @@ -372,7 +380,7 @@ InsetBase * createInset(BufferView * bv, FuncRequest const & cmd) } -InsetBase * readInset(Lexer & lex, Buffer const & buf) +Inset * readInset(Lexer & lex, Buffer const & buf) { // consistency check if (lex.getString() != "\\begin_inset") { @@ -380,9 +388,9 @@ InsetBase * readInset(Lexer & lex, Buffer const & buf) << endl; } - auto_ptr inset; + auto_ptr inset; - LyXTextClass tclass = buf.params().getLyXTextClass(); + TextClass tclass = buf.params().getTextClass(); lex.next(); string tmptok = lex.getString(); @@ -483,9 +491,11 @@ InsetBase * readInset(Lexer & lex, Buffer const & buf) inset.reset(new InsetInclude(p)); } else if (tmptok == "Environment") { lex.next(); - inset.reset(new InsetEnvironment(buf.params(), lex.getString())); + inset.reset(new InsetEnvironment(buf.params(), lex.getDocString())); } else if (tmptok == "ERT") { inset.reset(new InsetERT(buf.params())); + } else if (tmptok == "listings") { + inset.reset(new InsetListings(buf.params())); } else if (tmptok == "InsetSpace") { inset.reset(new InsetSpace); } else if (tmptok == "Tabular") { @@ -528,10 +538,8 @@ InsetBase * readInset(Lexer & lex, Buffer const & buf) inset->read(buf, lex); -#ifdef WITH_WARNINGS -#warning hack.. -#endif - if (inset->lyxCode() == InsetBase::MATHMACRO_CODE) { +// FIXME: hack.. + if (inset->lyxCode() == Inset::MATHMACRO_CODE) { MathMacroTemplate const * tmpl = static_cast(inset.get()); MacroTable::globalMacros().insert