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.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37149 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2011-01-07 21:04:16 +00:00
parent f8f69ca920
commit f49a526afc

View 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,