X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetLayout.cpp;h=6b30f5a37b9f5aa2a240c7f213337e633d06a443;hb=e30db1e44474ee379bedb0d1c752297541156497;hp=ee415b1b9b6ebbc3ec67af2d95f51d31d228d231;hpb=cfeddb9293bb1e3b45fe2f118a6ce35e37bbebf3;p=lyx.git diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index ee415b1b9b..6b30f5a37b 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -34,20 +34,21 @@ namespace lyx { InsetLayout::InsetLayout() : name_(from_ascii("undefined")), lyxtype_(STANDARD), labelstring_(from_ascii("UNDEFINED")), contentaslabel_(false), - decoration_(DEFAULT), latextype_(NOLATEXTYPE), font_(inherit_font), - labelfont_(sane_font), bgcolor_(Color_error), - htmlforcecss_ (false), htmlisblock_(true), - multipar_(true), custompars_(true), forceplain_(false), - passthru_(false), parbreakisnewline_(false), freespacing_(false), - keepempty_(false), forceltr_(false), - needprotect_(false), intoc_(false), spellcheck_(true), - resetsfont_(false), display_(true), forcelocalfontswitch_(false) -{ + decoration_(DEFAULT), latextype_(NOLATEXTYPE), font_(inherit_font), + labelfont_(sane_font), bgcolor_(Color_error), + fixedwidthpreambleencoding_(false), htmlforcecss_ (false), + htmlisblock_(true), multipar_(true), custompars_(true), + forceplain_(false), passthru_(false), parbreakisnewline_(false), + freespacing_(false), keepempty_(false), forceltr_(false), + forceownlines_(false), needprotect_(false), intoc_(false), + spellcheck_(true), resetsfont_(false), display_(true), + forcelocalfontswitch_(false) +{ labelfont_.setColor(Color_error); } -InsetLayout::InsetDecoration translateDecoration(std::string const & str) +InsetLayout::InsetDecoration translateDecoration(std::string const & str) { if (support::compare_ascii_no_case(str, "classic") == 0) return InsetLayout::CLASSIC; @@ -86,6 +87,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) IL_CUSTOMPARS, IL_DECORATION, IL_DISPLAY, + IL_FIXEDWIDTH_PREAMBLE_ENCODING, IL_FONT, IL_FORCE_LOCAL_FONT_SWITCH, IL_FORCELTR, @@ -132,12 +134,13 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) { "babelpreamble", IL_BABELPREAMBLE }, { "bgcolor", IL_BGCOLOR }, { "contentaslabel", IL_CONTENTASLABEL }, - { "copystyle", IL_COPYSTYLE }, + { "copystyle", IL_COPYSTYLE }, { "counter", IL_COUNTER}, { "custompars", IL_CUSTOMPARS }, { "decoration", IL_DECORATION }, { "display", IL_DISPLAY }, { "end", IL_END }, + { "fixedwidthpreambleencoding", IL_FIXEDWIDTH_PREAMBLE_ENCODING }, { "font", IL_FONT }, { "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH }, { "forceltr", IL_FORCELTR }, @@ -186,7 +189,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) // for issuing a warning in case MultiPars comes later bool readCustomOrPlain = false; - string tmp; + string tmp; while (!getout && lex.isOK()) { int le = lex.lex(); switch (le) { @@ -246,6 +249,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) leftdelim_ = support::subst(leftdelim_, from_ascii("
"), from_ascii("\n")); break; + case IL_FIXEDWIDTH_PREAMBLE_ENCODING: + lex >> fixedwidthpreambleencoding_; + break; case IL_FORCE_LOCAL_FONT_SWITCH: lex >> forcelocalfontswitch_; break; @@ -313,7 +319,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) // We don't want to apply the algorithm in DocumentClass::insetLayout() // here. So we do it the long way. - TextClass::InsetLayouts::const_iterator it = + TextClass::InsetLayouts::const_iterator it = tclass.insetLayouts().find(style); if (it != tclass.insetLayouts().end()) { docstring const tmpname = name_; @@ -321,11 +327,12 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) name_ = tmpname; } else { LYXERR0("Cannot copy unknown InsetLayout `" - << style << "'\n" + << style << "' to InsetLayout `" + << name() << "'\n" << "All InsetLayouts so far:"); - TextClass::InsetLayouts::const_iterator lit = + TextClass::InsetLayouts::const_iterator lit = tclass.insetLayouts().begin(); - TextClass::InsetLayouts::const_iterator len = + TextClass::InsetLayouts::const_iterator len = tclass.insetLayouts().end(); for (; lit != len; ++lit) lyxerr << lit->second.name() << "\n"; @@ -348,8 +355,17 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) if (obsoleted_by().empty()) obsoleted_by_ = style; } else { - LYXERR0("Cannot replace with unknown InsetLayout `" - << style << '\''); + LYXERR0("Cannot replace InsetLayout `" + << name() + << "' with unknown InsetLayout `" + << style << "'\n" + << "All InsetLayouts so far:"); + TextClass::InsetLayouts::const_iterator lit = + tclass.insetLayouts().begin(); + TextClass::InsetLayouts::const_iterator len = + tclass.insetLayouts().end(); + for (; lit != len; ++lit) + lyxerr << lit->second.name() << "\n"; } break; } @@ -417,7 +433,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) break; case IL_REQUIRES: { lex.eatLine(); - vector const req + vector const req = support::getVectorFromString(lex.getString()); requires_.insert(req.begin(), req.end()); break; @@ -440,7 +456,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) // Here add element to list if getout == true if (!getout) return false; - + // The label font is generally used as-is without // any realization against a given context. labelfont_.realize(sane_font); @@ -450,9 +466,8 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) } -InsetLayout::InsetLyXType translateLyXType(std::string const & str) +InsetLayout::InsetLyXType translateLyXType(std::string const & str) { - if (support::compare_ascii_no_case(str, "charstyle") == 0) return InsetLayout::CHARSTYLE; if (support::compare_ascii_no_case(str, "custom") == 0) @@ -471,7 +486,7 @@ string const & InsetLayout::htmltag() const { if (htmltag_.empty()) htmltag_ = multipar_ ? "div" : "span"; - return htmltag_; + return htmltag_; } @@ -479,7 +494,7 @@ string const & InsetLayout::htmlattr() const { if (htmlattr_.empty()) htmlattr_ = "class=\"" + defaultCSSClass() + "\""; - return htmlattr_; + return htmlattr_; } @@ -487,12 +502,12 @@ string const & InsetLayout::htmlinnerattr() const { if (htmlinnerattr_.empty()) htmlinnerattr_ = "class=\"" + defaultCSSClass() + "_inner\""; - return htmlinnerattr_; + return htmlinnerattr_; } string InsetLayout::defaultCSSClass() const -{ +{ if (!defaultcssclass_.empty()) return defaultcssclass_; string d; @@ -515,18 +530,18 @@ string InsetLayout::defaultCSSClass() const void InsetLayout::makeDefaultCSS() const { - if (!htmldefaultstyle_.empty()) + if (!htmldefaultstyle_.empty()) return; docstring const mainfontCSS = font_.asCSS(); if (!mainfontCSS.empty()) - htmldefaultstyle_ = + htmldefaultstyle_ = from_ascii(htmltag() + "." + defaultCSSClass() + " {\n") + mainfontCSS + from_ascii("\n}\n"); } -docstring InsetLayout::htmlstyle() const -{ +docstring InsetLayout::htmlstyle() const +{ if (!htmlstyle_.empty() && !htmlforcecss_) return htmlstyle_; if (htmldefaultstyle_.empty())