- InsetList::const_iterator it = par.insetList().begin();
- InsetList::const_iterator end = par.insetList().end();
- for (; it != end; ++it) {
- if (it->inset->lyxCode() == ARG_CODE) {
- InsetArgument const * ins =
- static_cast<InsetArgument const *>(it->inset);
- if (ins->name().empty())
- LYXERR0("Error: Unnamed argument inset!");
- else {
- string const name = prefix.empty() ? ins->name() : split(ins->name(), ':');
- unsigned int const nr = convert<unsigned int>(name);
- ilist[nr] = ins;
- Layout::LaTeXArgMap::const_iterator const lit =
- latexargs.find(ins->name());
- if (lit != latexargs.end()) {
- Layout::latexarg const & arg = (*lit).second;
- if (!arg.requires.empty()) {
- vector<string> req = getVectorFromString(arg.requires);
- required.insert(required.end(), req.begin(), req.end());
- }
- }
- }
+ int nest_level = localswitch ? -state->nest_level_ : state->nest_level_;
+ state->lang_switch_depth_.push(nest_level);
+ state->open_polyglossia_lang_.push(lang_name);
+}
+
+
+void popLanguageName()
+{
+ OutputState * state = getOutputState();
+
+ state->lang_switch_depth_.pop();
+ state->open_polyglossia_lang_.pop();
+}
+
+
+string const & openLanguageName()
+{
+ OutputState * state = getOutputState();
+
+ return openLanguageName(state);
+}
+
+
+namespace {
+
+void addArgInsets(Paragraph const & par, string const & prefix,
+ Layout::LaTeXArgMap const & latexargs,
+ map<int, InsetArgument const *> & ilist,
+ vector<string> & required)
+{
+ for (auto const & table : par.insetList()) {
+ InsetArgument const * arg = table.inset->asInsetArgument();
+ if (!arg)
+ continue;
+ if (arg->name().empty()) {
+ LYXERR0("Error: Unnamed argument inset!");
+ continue;
+ }
+ string const name = prefix.empty() ?
+ arg->name() : split(arg->name(), ':');
+ // why converting into an integer?
+ unsigned int const nr = convert<unsigned int>(name);
+ if (ilist.find(nr) == ilist.end())
+ ilist[nr] = arg;
+ Layout::LaTeXArgMap::const_iterator const lit =
+ latexargs.find(arg->name());
+ if (lit != latexargs.end()) {
+ Layout::latexarg const & larg = lit->second;
+ vector<string> req = getVectorFromString(larg.requires);
+ move(req.begin(), req.end(), back_inserter(required));