]> git.lyx.org Git - features.git/commitdiff
Allow InPreamble to be used with Paragraph-type environments. There is
authorRichard Heck <rgheck@comcast.net>
Sun, 28 Nov 2010 22:08:11 +0000 (22:08 +0000)
committerRichard Heck <rgheck@comcast.net>
Sun, 28 Nov 2010 22:08:11 +0000 (22:08 +0000)
no reason not to permit this, and using it with PassThru 1 allows for a
very simple Preamble layout-type that acts as ERT for the premable. Of
course, we do have the preamble in Document>Settings, but that allows
the embedding of preamble code in branches.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36562 a592a061-630c-0410-9148-cb99ea01b6c8

lib/doc/Customization.lyx
src/Layout.cpp
src/Paragraph.cpp

index 2f76dadb26242a7c1f275d878181476efd3413c8..1c192d9c3f73aad235f8930490da015c163bd528 100644 (file)
@@ -1,5 +1,5 @@
 #LyX 2.0.0svn created this file. For more info see http://www.lyx.org/
-\lyxformat 404
+\lyxformat 410
 \begin_document
 \begin_header
 \textclass scrbook
@@ -76,7 +76,7 @@ End
 \font_sans default
 \font_typewriter default
 \font_default_family default
-\use_xetex false
+\use_non_tex_fonts false
 \font_sc false
 \font_osf false
 \font_sf_scale 100
@@ -138,6 +138,7 @@ End
 \html_math_output 0
 \html_be_strict true
 \author 1 "Jean-Marc Lasgouttes" 
+\author 223010757 "Richard Heck" rgheck@brown.edu
 \end_header
 
 \begin_body
@@ -10181,6 +10182,24 @@ Command
 
 \end_inset
 
+
+\change_inserted 223010757 1290981996
+ or 
+\begin_inset Flex Code
+status collapsed
+
+\begin_layout Plain Layout
+
+\change_inserted 223010757 1290981998
+Paragraph
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+
+\change_unchanged
 .
 \end_layout
 
index 5ba77ce1c6d0c67a0c8983d6f4c4231b6b5ed5a9..cdfc1746b9fd530cb1a1d793f88aeffcb92f9b06 100644 (file)
@@ -577,8 +577,8 @@ bool Layout::read(Lexer & lex, TextClass const & tclass)
        }
        lex.popTable();
        // make sure we only have inpreamble = true for commands
-       if (inpreamble && latextype != LATEX_COMMAND) {
-               LYXERR0("InPreamble not permitted except with Command-type layouts.");
+       if (inpreamble && latextype != LATEX_COMMAND && latextype != LATEX_PARAGRAPH) {
+               LYXERR0("InPreamble not permitted except with command and paragraph layouts.");
                LYXERR0("Layout name: " << name());
                inpreamble = false;
        }
index 3eb13ec0d157c49ceec36ed01a694e0bfc01fa20..4d31441d4f37ab848600667d51bb39e00e2446fa 100644 (file)
@@ -1328,6 +1328,7 @@ bool Paragraph::Private::latexSpecialPhrase(odocstream & os, pos_type & i,
 void Paragraph::Private::validate(LaTeXFeatures & features) const
 {
        if (layout_->inpreamble && inset_owner_) {
+               bool const is_command = layout_->latextype == LATEX_COMMAND;
                Buffer const & buf = inset_owner_->buffer();
                BufferParams const & bp = buf.params();
                Font f;
@@ -1337,20 +1338,23 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
                // output is wrong if this paragraph contains content
                // that needs to switch encoding.
                odocstringstream ods;
-               ods << '\\' << from_ascii(layout_->latexname());
-               // we have to provide all the optional arguments here, even though
-               // the last one is the only one we care about.
-               // Separate handling of optional argument inset.
-               if (layout_->optargs != 0 || layout_->reqargs != 0)
-                       latexArgInsets(*owner_, ods, features.runparams(),
-                                      layout_->reqargs, layout_->optargs);
-               else
-                       ods << from_ascii(layout_->latexparam());
+               if (is_command) {
+                       ods << '\\' << from_ascii(layout_->latexname());
+                       // we have to provide all the optional arguments here, even though
+                       // the last one is the only one we care about.
+                       // Separate handling of optional argument inset.
+                       if (layout_->optargs != 0 || layout_->reqargs != 0)
+                               latexArgInsets(*owner_, ods, features.runparams(),
+                                                                                        layout_->reqargs, layout_->optargs);
+                       else
+                               ods << from_ascii(layout_->latexparam());
+               }
                docstring::size_type const length = ods.str().length();
                // this will output "{" at the beginning, but not at the end
                owner_->latex(bp, f, ods, tr, features.runparams(), 0, -1, true);
                if (ods.str().length() > length) {
-                       ods << '}';
+                       if (is_command)
+                               ods << '}';
                        string const snippet = to_utf8(ods.str());
                        features.addPreambleSnippet(snippet);
                }