From: Jean-Marc Lasgouttes Date: Tue, 14 Jul 2009 18:27:54 +0000 (+0000) Subject: move the the latex and validate methods from InsetCollapsable to InsetText; small... X-Git-Tag: 2.0.0~6020 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ace4f7d3b868bab8ebcf32319ce70527073d87ae;p=features.git move the the latex and validate methods from InsetCollapsable to InsetText; small cleanups git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30582 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index 060d4da271..bbadb5a4a7 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -76,6 +76,7 @@ InsetLayout Marginal Size Small EndFont MultiPar true + NeedProtect true HTMLTag span HTMLAttr class='marginal' HTMLStyle @@ -240,8 +241,6 @@ End InsetLayout Index LabelString Idx - LatexType command - LatexName index Decoration classic Font Color foreground @@ -260,7 +259,6 @@ InsetLayout Index MultiPar false CustomPars false ForcePlain true - NeedProtect true End InsetLayout Box @@ -307,11 +305,16 @@ End InsetLayout URL LyXType standard - LatexName url - LatexType command Decoration classic LabelString URL + LatexName url + LatexType command + Requires url + MultiPar false + CustomPars false + ForcePlain true PassThru true + FreeSpacing true ForceLTR true Font Family Typewriter @@ -322,7 +325,6 @@ InsetLayout URL Color urllabel Size Small EndFont - Requires url End InsetLayout OptArg diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index bd5fbf2d72..5a2e9b67dd 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -26,10 +26,10 @@ #include "InsetLayout.h" #include "InsetList.h" #include "Language.h" -#include "LaTeXFeatures.h" #include "Lexer.h" #include "MetricsInfo.h" #include "output_xhtml.h" +#include "OutputParams.h" #include "paragraph_funcs.h" #include "ParagraphParameters.h" #include "sgml.h" @@ -616,47 +616,6 @@ InsetLayout::InsetDecoration InsetCollapsable::decoration() const } -int InsetCollapsable::latex(odocstream & os, - OutputParams const & runparams) const -{ - // This implements the standard way of handling the LaTeX output of - // a collapsable inset, either a command or an environment. Standard - // collapsable insets should not redefine this, non-standard ones may - // call this. - InsetLayout const & il = getLayout(); - if (!il.latexname().empty()) { - if (il.latextype() == InsetLayout::COMMAND) { - // FIXME UNICODE - if (runparams.moving_arg) - os << "\\protect"; - os << '\\' << from_utf8(il.latexname()); - if (!il.latexparam().empty()) - os << from_utf8(il.latexparam()); - os << '{'; - } else if (il.latextype() == InsetLayout::ENVIRONMENT) { - os << "%\n\\begin{" << from_utf8(il.latexname()) << "}\n"; - if (!il.latexparam().empty()) - os << from_utf8(il.latexparam()); - } - } - OutputParams rp = runparams; - if (il.isPassThru()) - rp.verbatim = true; - if (il.isNeedProtect()) - rp.moving_arg = true; - int i = InsetText::latex(os, rp); - if (!il.latexname().empty()) { - if (il.latextype() == InsetLayout::COMMAND) { - os << "}"; - } else if (il.latextype() == InsetLayout::ENVIRONMENT) { - os << "\n\\end{" << from_utf8(il.latexname()) << "}\n"; - i += 4; - } - } - return i; -} - - // FIXME It seems as if it ought to be possible to do this more simply, // maybe by calling InsetText::docbook() in the middle there. int InsetCollapsable::docbook(odocstream & os, OutputParams const & runparams) const @@ -709,13 +668,6 @@ docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparam } -void InsetCollapsable::validate(LaTeXFeatures & features) const -{ - features.useInsetLayout(getLayout()); - InsetText::validate(features); -} - - bool InsetCollapsable::undefined() const { docstring const & n = getLayout().name(); diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index f082462e7e..18fca146e4 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -126,16 +126,12 @@ public: /// ColorCode labelColor() const { return getLayout().labelfont().color(); } /// - int latex(odocstream &, OutputParams const &) const; - /// int docbook(odocstream &, OutputParams const &) const; /// It will rarely be right to call this from subclasses, due /// to the fact that it steps counters, etc. Instead, call /// InsetText::xhtml(). docstring xhtml(odocstream &, OutputParams const &) const; /// - void validate(LaTeXFeatures &) const; - /// InsetCode lyxCode() const { return COLLAPSABLE_CODE; } /// diff --git a/src/insets/InsetMarginal.cpp b/src/insets/InsetMarginal.cpp index aa90baf2d7..2dbd9e3383 100644 --- a/src/insets/InsetMarginal.cpp +++ b/src/insets/InsetMarginal.cpp @@ -35,18 +35,6 @@ docstring InsetMarginal::editMessage() const } -int InsetMarginal::latex(odocstream & os, OutputParams const & runparams) const -{ - os << "%\n"; - if (runparams.moving_arg) - os << "\\protect"; - os << "\\marginpar{"; - int const i = InsetText::latex(os, runparams); - os << "%\n}"; - return i + 2; -} - - int InsetMarginal::plaintext(odocstream & os, OutputParams const & runparams) const { diff --git a/src/insets/InsetMarginal.h b/src/insets/InsetMarginal.h index dbfb761922..249f083afa 100644 --- a/src/insets/InsetMarginal.h +++ b/src/insets/InsetMarginal.h @@ -31,8 +31,6 @@ public: /// docstring name() const { return from_ascii("Marginal"); } /// - int latex(odocstream &, OutputParams const &) const; - /// int plaintext(odocstream &, OutputParams const & runparams) const; /// int docbook(odocstream &, OutputParams const & runparams) const; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index e960e87347..eb01cfb23c 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -30,6 +30,7 @@ #include "InsetList.h" #include "Intl.h" #include "Language.h" +#include "LaTeXFeatures.h" #include "Lexer.h" #include "lyxfind.h" #include "LyXRC.h" @@ -377,9 +378,48 @@ void InsetText::rejectChanges() int InsetText::latex(odocstream & os, OutputParams const & runparams) const { + // This implements the standard way of handling the LaTeX + // output of a text inset, either a command or an + // environment. Standard collapsable insets should not + // redefine this, non-standard ones may call this. + InsetLayout const & il = getLayout(); + int rows = 0; + if (!il.latexname().empty()) { + if (il.latextype() == InsetLayout::COMMAND) { + // FIXME UNICODE + if (runparams.moving_arg) + os << "\\protect"; + os << '\\' << from_utf8(il.latexname()); + if (!il.latexparam().empty()) + os << from_utf8(il.latexparam()); + os << '{'; + } else if (il.latextype() == InsetLayout::ENVIRONMENT) { + os << "%\n\\begin{" << from_utf8(il.latexname()) << "}\n"; + if (!il.latexparam().empty()) + os << from_utf8(il.latexparam()); + rows += 2; + } + } + OutputParams rp = runparams; + if (il.isPassThru()) + rp.verbatim = true; + if (il.isNeedProtect()) + rp.moving_arg = true; + + // Output the contents of the inset TexRow texrow; - latexParagraphs(buffer(), text_, os, texrow, runparams); - return texrow.rows(); + latexParagraphs(buffer(), text_, os, texrow, rp); + rows += texrow.rows(); + + if (!il.latexname().empty()) { + if (il.latextype() == InsetLayout::COMMAND) { + os << "}"; + } else if (il.latextype() == InsetLayout::ENVIRONMENT) { + os << "\n\\end{" << from_utf8(il.latexname()) << "}\n"; + rows += 2; + } + } + return rows; } @@ -425,6 +465,7 @@ docstring InsetText::xhtml(odocstream & os, OutputParams const & runparams) cons void InsetText::validate(LaTeXFeatures & features) const { + features.useInsetLayout(getLayout()); for_each(paragraphs().begin(), paragraphs().end(), bind(&Paragraph::validate, _1, ref(features))); }