}
+bool Layout::hasArgs() const
+{
+ return !latexargs_.empty() || !postcommandargs_.empty() ||
+ !itemargs_.empty();
+}
+
+
Layout::LaTeXArgMap Layout::args() const
{
LaTeXArgMap args = latexargs_;
LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
///
LaTeXArgMap const & itemargs() const { return itemargs_; }
+ /// Returns true is the layout has arguments. If false, then an
+ /// InsetArgument in this layout stands for the parent InsetText.
+ bool hasArgs() const;
/// Returns latexargs() + postcommandargs() + itemargs().
/// But note that it returns a *copy*, not a reference, so do not do
/// anything like:
void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
{
- Layout::LaTeXArgMap args = it.paragraph().layout().args();
- pass_thru_context_ = it.paragraph().layout().pass_thru;
- bool const insetlayout = args.empty();
- if (insetlayout) {
- args = it.inset().getLayout().args();
- pass_thru_context_ = it.inset().getLayout().isPassThru();
- }
+ bool const insetlayout = !it.paragraph().layout().hasArgs();
+ Layout::LaTeXArgMap const args = insetlayout ?
+ it.inset().getLayout().args() : it.paragraph().layout().args();
+ pass_thru_context_ = insetlayout ?
+ it.inset().getLayout().isPassThru() : it.paragraph().layout().pass_thru;
// Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them)
if (name_ == "999") {
return docstring();
}
+
void InsetText::getArgs(otexstream & os, OutputParams const & runparams_in,
bool const post) const
{
if (isPassThru())
runparams.pass_thru = true;
if (post)
- latexArgInsets(paragraphs(), paragraphs().begin(), os, runparams, getLayout().postcommandargs(), "post:");
+ latexArgInsetsForParent(paragraphs(), os, runparams,
+ getLayout().postcommandargs(), "post:");
else
- latexArgInsets(paragraphs(), paragraphs().begin(), os, runparams, getLayout().latexargs());
+ latexArgInsetsForParent(paragraphs(), os, runparams,
+ getLayout().latexargs());
}
}
+void latexArgInsetsForParent(ParagraphList const & pars, otexstream & os,
+ OutputParams const & runparams,
+ Layout::LaTeXArgMap const & latexargs,
+ string const & prefix)
+{
+ map<int, InsetArgument const *> ilist;
+ vector<string> required;
+
+ for (Paragraph const & par : pars) {
+ if (par.layout().hasArgs())
+ // The InsetArguments inside this paragraph refer to this paragraph
+ continue;
+ addArgInsets(par, prefix, latexargs, ilist, required);
+ }
+ getArgInsets(os, runparams, latexargs, ilist, required, prefix);
+}
+
+
namespace {
// output the proper paragraph start according to latextype.
Non-existing required arguments are output empty: {}.
*/
void latexArgInsets(Paragraph const & par,
- otexstream & os, OutputParams const & runparams,
- Layout::LaTeXArgMap const & latexargs,
- std::string const & prefix = std::string());
-/// Same for multi-par sequences (e.g. merged environments or InsetLayouts)
-void latexArgInsets(ParagraphList const & pars, ParagraphList::const_iterator pit,
- otexstream & os, OutputParams const & runparams,
- Layout::LaTeXArgMap const & latexargs,
- std::string const & prefix = std::string());
+ otexstream & os, OutputParams const & runparams,
+ Layout::LaTeXArgMap const & latexargs,
+ std::string const & prefix = std::string());
+/// Same for merged environments
+void latexArgInsets(ParagraphList const & pars,
+ ParagraphList::const_iterator pit,
+ otexstream & os, OutputParams const & runparams,
+ Layout::LaTeXArgMap const & latexargs,
+ std::string const & prefix = std::string());
+/// Same for InsetLayouts
+void latexArgInsetsForParent(ParagraphList const & pars, otexstream & os,
+ OutputParams const & runparams,
+ Layout::LaTeXArgMap const & latexargs,
+ std::string const & prefix = std::string());
/** Export \p paragraphs of buffer \p buf to LaTeX.
Don't use a temporary stringstream for \p os if the final output is
supposed to go to a file.