Author: baum
Date: Fri Jan  7 22:04:16 2011
New Revision: 37149
URL: http://www.lyx.org/trac/changeset/37149

Log:
Parse Flex insets defined in the layout. This is needed e.g. for
lib/doc/Math.lyx, since tex2lyx swallows the LyX part of the preamble, and
thus \shortcut would not be defined.

Modified:
   lyx-devel/trunk/src/tex2lyx/text.cpp

Modified: lyx-devel/trunk/src/tex2lyx/text.cpp
==============================================================================
--- lyx-devel/trunk/src/tex2lyx/text.cpp        Fri Jan  7 21:21:10 2011        
(r37148)
+++ lyx-devel/trunk/src/tex2lyx/text.cpp        Fri Jan  7 22:04:16 2011        
(r37149)
@@ -447,6 +447,19 @@
 }
 
 
+InsetLayout const * findInsetLayout(TextClass const & textclass, string const 
& name, bool command)
+{
+       DocumentClass::InsetLayouts::const_iterator it = 
textclass.insetLayouts().begin();
+       DocumentClass::InsetLayouts::const_iterator en = 
textclass.insetLayouts().end();
+       for (; it != en; ++it)
+               if (it->second.latexname() == name &&
+                   ((command && it->second.latextype() == 
InsetLayout::COMMAND) ||
+                    (!command && it->second.latextype() == 
InsetLayout::ENVIRONMENT)))
+                       return &(it->second);
+       return 0;
+}
+
+
 void eat_whitespace(Parser &, ostream &, Context &, bool);
 
 
@@ -1334,6 +1347,7 @@
                Context & context)
 {
        Layout const * newlayout = 0;
+       InsetLayout const * newinsetlayout = 0;
        // Store the latest bibliographystyle and nocite{*} option
        // (needed for bibtex inset)
        string btprint;
@@ -2976,6 +2990,17 @@
                        }
                }
 
+               // The single '=' is meant here.
+               else if ((newinsetlayout = findInsetLayout(context.textclass, 
t.cs(), true))) {
+                       p.skip_spaces();
+                       context.check_layout(os);
+                       begin_inset(os, "Flex ");
+                       os << to_utf8(newinsetlayout->name()) << '\n'
+                          << "status collapsed\n";
+                       parse_text_in_inset(p, os, FLAG_ITEM, false, context);
+                       end_inset(os);
+               }
+
                else {
                        // try to see whether the string is in unicodesymbols
                        // Only use text mode commands, since we are in text 
mode here,

Reply via email to