]> git.lyx.org Git - features.git/commitdiff
move the the latex and validate methods from InsetCollapsable to InsetText; small...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2009 18:27:54 +0000 (18:27 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2009 18:27:54 +0000 (18:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30582 a592a061-630c-0410-9148-cb99ea01b6c8

lib/layouts/stdinsets.inc
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetMarginal.cpp
src/insets/InsetMarginal.h
src/insets/InsetText.cpp

index 060d4da2711026bae332d626c5c0bb2b65be60b6..bbadb5a4a7461c4aaa32010ffacdca34f3e8e414 100644 (file)
@@ -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
index bd5fbf2d729d079a9f3637e5a0097b6ba198e86f..5a2e9b67dd58c7f651b024ff23fdf77de08f0582 100644 (file)
 #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();
index f082462e7e410aa489432e217617350f296c180d..18fca146e46a1cc3ef28c3b55095bcbaac36d5e0 100644 (file)
@@ -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; }
 
        ///
index aa90baf2d76c75cb97d5076bb4146cedd674f369..2dbd9e33831c5b95cd1a994dc62d3e6b8a2c64a9 100644 (file)
@@ -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
 {
index dbfb76192203dd12993890c05ac869e638d98e51..249f083afaa9df820e17040b06c3be27624020ed 100644 (file)
@@ -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;
index e960e87347afbbda4abac8b00e088a0a061b7f90..eb01cfb23c1cfd36330fb5e131a08c5fedb79e9b 100644 (file)
@@ -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)));
 }