From 976a59af1ba07858e6ccaabab4a81152e6efd8d2 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 25 Oct 2008 14:02:25 +0000 Subject: [PATCH] Fix another part of 5403, again to do with case sensitivity. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27109 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetCollapsable.cpp | 8 ++++---- src/insets/InsetLayout.cpp | 25 +++++++++++++++++++++---- src/insets/InsetLayout.h | 10 ++++++++-- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 934da30745..77621b3abc 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -785,7 +785,7 @@ int InsetCollapsable::latex(odocstream & os, // collapsable insets should not redefine this, non-standard ones may // call this. if (!layout_->latexname().empty()) { - if (layout_->latextype() == "command") { + if (layout_->latextype() == InsetLayout::COMMAND) { // FIXME UNICODE if (runparams.moving_arg) os << "\\protect"; @@ -793,7 +793,7 @@ int InsetCollapsable::latex(odocstream & os, if (!layout_->latexparam().empty()) os << from_utf8(layout_->latexparam()); os << '{'; - } else if (layout_->latextype() == "environment") { + } else if (layout_->latextype() == InsetLayout::ENVIRONMENT) { os << "%\n\\begin{" << from_utf8(layout_->latexname()) << "}\n"; if (!layout_->latexparam().empty()) os << from_utf8(layout_->latexparam()); @@ -806,9 +806,9 @@ int InsetCollapsable::latex(odocstream & os, rp.moving_arg = true; int i = InsetText::latex(os, rp); if (!layout_->latexname().empty()) { - if (layout_->latextype() == "command") { + if (layout_->latextype() == InsetLayout::COMMAND) { os << "}"; - } else if (layout_->latextype() == "environment") { + } else if (layout_->latextype() == InsetLayout::ENVIRONMENT) { os << "\n\\end{" << from_utf8(layout_->latexname()) << "}\n"; i += 4; } diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index 40873cb49e..9a321c2046 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -32,8 +32,9 @@ namespace lyx { InsetLayout::InsetLayout() : name_(from_ascii("undefined")), lyxtype_(STANDARD), - labelstring_(from_ascii("UNDEFINED")), decoration_(InsetLayout::DEFAULT), - font_(sane_font), labelfont_(sane_font), bgcolor_(Color_error), + labelstring_(from_ascii("UNDEFINED")), decoration_(DEFAULT), + latextype_(NOLATEXTYPE), font_(sane_font), + labelfont_(sane_font), bgcolor_(Color_error), multipar_(false), custompars_(false), forceplain_(true), passthru_(false), needprotect_(false), freespacing_(false), keepempty_(false), forceltr_(false) @@ -55,6 +56,17 @@ InsetLayout::InsetDecoration translateDecoration(std::string const & str) return InsetLayout::DEFAULT; } +InsetLayout::InsetLaTeXType translateLaTeXType(std::string const & str) +{ + if (support::compare_ascii_no_case(str, "command") == 0) + return InsetLayout::COMMAND; + if (support::compare_ascii_no_case(str, "environment") == 0) + return InsetLayout::ENVIRONMENT; + if (support::compare_ascii_no_case(str, "none") == 0) + return InsetLayout::NOLATEXTYPE; + return InsetLayout::ILT_ERROR; +} + } @@ -144,9 +156,14 @@ bool InsetLayout::read(Lexer & lex, TextClass & tclass) LYXERR0("Unknown LyXType `" << lt << "'."); break; } - case IL_LATEXTYPE: - lex >> latextype_; + case IL_LATEXTYPE: { + string lt; + lex >> lt; + latextype_ = translateLaTeXType(lt); + if (latextype_ == ILT_ERROR) + LYXERR0("Unknown LaTeXType `" << lt << "'."); break; + } case IL_LABELSTRING: lex >> labelstring_; break; diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index 84ede0adc8..9b5865c907 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -46,6 +46,12 @@ public: END, STANDARD }; + enum InsetLaTeXType { + NOLATEXTYPE, + COMMAND, + ENVIRONMENT, + ILT_ERROR + }; /// bool read(Lexer & lexrc, TextClass & tclass); /// @@ -57,7 +63,7 @@ public: /// InsetDecoration decoration() const { return decoration_; }; /// - std::string latextype() const { return latextype_; }; + InsetLaTeXType latextype() const { return latextype_; }; /// std::string latexname() const { return latexname_; }; /// @@ -102,7 +108,7 @@ private: /// InsetDecoration decoration_; /// - std::string latextype_; + InsetLaTeXType latextype_; /// std::string latexname_; /// -- 2.39.2