X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffactory.cpp;h=f259883615c4235e50bbfe57852974f65e6e4929;hb=e995e8556bd670c7183bab7e105073a5f4ccfbc0;hp=93e359323fee6ac03e69db7d0d1ada328ca58557;hpb=6592d5f199f7e5de78da242052ae20d757132e0a;p=lyx.git diff --git a/src/factory.cpp b/src/factory.cpp index 93e359323f..f259883615 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -33,7 +33,6 @@ #include "insets/InsetFloatList.h" #include "insets/InsetFoot.h" #include "insets/InsetGraphics.h" -#include "insets/InsetHFill.h" #include "insets/InsetInclude.h" #include "insets/InsetIndex.h" #include "insets/InsetInfo.h" @@ -82,8 +81,6 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) try { switch (cmd.action) { - case LFUN_HFILL_INSERT: - return new InsetHFill; case LFUN_LINE_INSERT: return new InsetLine; @@ -211,10 +208,6 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) case LFUN_INFO_INSERT: return new InsetInfo(buf, to_utf8(cmd.argument())); -#if 0 - case LFUN_THEOREM_INSERT: - return new InsetTheorem; -#endif case LFUN_INSET_INSERT: { string const name = cmd.getArg(0); @@ -302,6 +295,12 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) InsetCommandMailer::string2params(name, to_utf8(cmd.argument()), icp); return new InsetRef(buf, icp); } + + case SPACE_CODE: { + InsetSpaceParams isp; + InsetSpaceMailer::string2params(to_utf8(cmd.argument()), isp); + return new InsetSpace(isp); + } case TOC_CODE: { InsetCommandParams icp(code); @@ -324,27 +323,60 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd) } //end LFUN_INSET_INSERT case LFUN_SPACE_INSERT: { - string const name = to_utf8(cmd.argument()); + string const name = cmd.getArg(0); + string const len = cmd.getArg(1); + if (name.empty()) { + lyxerr << "LyX function 'space-insert' needs an argument." << endl; + break; + } + InsetSpaceParams isp; if (name == "normal") - return new InsetSpace(InsetSpace::NORMAL); - if (name == "protected") - return new InsetSpace(InsetSpace::PROTECTED); - if (name == "thin") - return new InsetSpace(InsetSpace::THIN); - if (name == "quad") - return new InsetSpace(InsetSpace::QUAD); - if (name == "qquad") - return new InsetSpace(InsetSpace::QQUAD); - if (name == "enspace") - return new InsetSpace(InsetSpace::ENSPACE); - if (name == "enskip") - return new InsetSpace(InsetSpace::ENSKIP); - if (name == "negthinspace") - return new InsetSpace(InsetSpace::NEGTHIN); - if (name.empty()) - lyxerr << "LyX function 'space' needs an argument." << endl; - else - lyxerr << "Wrong argument for LyX function 'space'." << endl; + isp.kind = InsetSpaceParams::NORMAL; + else if (name == "protected") + isp.kind = InsetSpaceParams::PROTECTED; + else if (name == "thin") + isp.kind = InsetSpaceParams::THIN; + else if (name == "quad") + isp.kind = InsetSpaceParams::QUAD; + else if (name == "qquad") + isp.kind = InsetSpaceParams::QQUAD; + else if (name == "enspace") + isp.kind = InsetSpaceParams::ENSPACE; + else if (name == "enskip") + isp.kind = InsetSpaceParams::ENSKIP; + else if (name == "negthinspace") + isp.kind = InsetSpaceParams::NEGTHIN; + else if (name == "hfill") + isp.kind = InsetSpaceParams::HFILL; + else if (name == "hfill*") + isp.kind = InsetSpaceParams::HFILL_PROTECTED; + else if (name == "dotfill") + isp.kind = InsetSpaceParams::DOTFILL; + else if (name == "hrulefill") + isp.kind = InsetSpaceParams::HRULEFILL; + else if (name == "hspace") { + if (len.empty() || !isValidLength(len)) { + lyxerr << "LyX function 'space-insert hspace' " + << "needs a valid length argument." << endl; + break; + } + isp.kind = InsetSpaceParams::CUSTOM; + isp.length = Length(len); + } + else if (name == "hspace*") { + if (len.empty() || !isValidLength(len)) { + lyxerr << "LyX function 'space-insert hspace*' " + << "needs a valid length argument." << endl; + break; + } + isp.kind = InsetSpaceParams::CUSTOM_PROTECTED; + isp.length = Length(len); + } + else { + lyxerr << "Wrong argument for LyX function 'space-insert'." << endl; + break; + } + return new InsetSpace(isp); } break; @@ -491,7 +523,7 @@ Inset * readInset(Lexer & lex, Buffer const & buf) inset.reset(new InsetERT(buf)); } else if (tmptok == "listings") { inset.reset(new InsetListings(buf)); - } else if (tmptok == "InsetSpace") { + } else if (tmptok == "Space") { inset.reset(new InsetSpace); } else if (tmptok == "Tabular") { inset.reset(new InsetTabular(buf));