+
+} // namespace anon
+
+
+void latexArgInsets(Paragraph const & par, otexstream & os,
+ OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs, string const & prefix)
+{
+ map<int, InsetArgument const *> ilist;
+ vector<string> required;
+
+ 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());
+ }
+ }
+ }
+ }
+ }
+ getArgInsets(os, runparams, latexargs, ilist, required, prefix);
+}
+
+
+void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pit,
+ otexstream & os, OutputParams const & runparams, Layout::LaTeXArgMap const & latexargs,
+ string const & prefix)
+{
+ map<int, InsetArgument const *> ilist;
+ vector<string> required;
+
+ depth_type const current_depth = pit->params().depth();
+ Layout const current_layout = pit->layout();
+
+ // get the first paragraph in sequence with this layout and depth
+ pit_type offset = 0;
+ while (true) {
+ if (prev(pit, offset) == pars.begin())
+ break;
+ ParagraphList::const_iterator priorpit = prev(pit, offset + 1);
+ if (priorpit->layout() == current_layout
+ && priorpit->params().depth() == current_depth)
+ ++offset;
+ else
+ break;
+ }
+
+ ParagraphList::const_iterator spit = prev(pit, offset);
+
+ for (; spit != pars.end(); ++spit) {
+ if (spit->layout() != current_layout || spit->params().depth() < current_depth)
+ break;
+ if (spit->params().depth() > current_depth)
+ continue;
+ InsetList::const_iterator it = spit->insetList().begin();
+ InsetList::const_iterator end = spit->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);
+ if (ilist.find(nr) == ilist.end())
+ 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());
+ }
+ }
+ }
+ }
+ }
+ }
+ getArgInsets(os, runparams, latexargs, ilist, required, prefix);
+}
+