]> git.lyx.org Git - features.git/commitdiff
Parse Flex insets defined in the layout. This is needed e.g. for
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 7 Jan 2011 21:04:16 +0000 (21:04 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 7 Jan 2011 21:04:16 +0000 (21:04 +0000)
lib/doc/Math.lyx, since tex2lyx swallows the LyX part of the preamble, and
thus \shortcut would not be defined.

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

src/tex2lyx/text.cpp

index be604629b399e4e47c445552a89fbc725acc242d..113d9c547314bcbb6b7f3688a59fdf6491632dae 100644 (file)
@@ -447,6 +447,19 @@ Layout const * findLayout(TextClass const & textclass, string const & name)
 }
 
 
+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 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                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 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        }
                }
 
+               // 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,