+ 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;
+ // Record PassThru status in order to act on changes.
+ bool const former_pass_thru = pass_thru_;
+
+ // Handle pre 2.1 ArgInsets (lyx2lyx cannot classify them)
+ if (name_ == "999") {
+ unsigned int const req = insetlayout ? it.inset().getLayout().requiredArgs()
+ : it.paragraph().layout().requiredArgs();
+ unsigned int const opts = insetlayout ? it.inset().getLayout().optArgs()
+ : it.paragraph().layout().optArgs();
+ unsigned int nr = 0;
+ unsigned int ours = 0;
+ InsetList::const_iterator parit = it.paragraph().insetList().begin();
+ InsetList::const_iterator parend = it.paragraph().insetList().end();
+ for (; parit != parend; ++parit) {
+ if (parit->inset->lyxCode() == ARG_CODE) {
+ ++nr;
+ if (parit->inset == this)
+ ours = nr;
+ }
+ }
+ bool done = false;
+ unsigned int realopts = 0;
+ if (nr > req) {
+ // We have optional arguments
+ realopts = nr - req;
+ if (ours <= realopts) {
+ name_ = convert<string>(ours);
+ done = true;
+ }
+ }
+ if (!done) {
+ // This is a mandatory argument. We have to consider
+ // non-given optional arguments for the numbering
+ int offset = opts - realopts;
+ ours += offset;
+ name_ = convert<string>(ours);
+ }
+ }
+ Layout::LaTeXArgMap::const_iterator const lait = args.find(name_);
+ caption_of_toc_ = string();
+ if (lait != args.end()) {
+ docstring label = translateIfPossible((*lait).second.labelstring);
+ docstring striplabel;
+ support::rsplit(label, striplabel, '|');
+ labelstring_ = striplabel.empty() ? label: striplabel;
+ tooltip_ = translateIfPossible((*lait).second.tooltip);
+ font_ = (*lait).second.font;
+ labelfont_ = (*lait).second.labelfont;
+ decoration_ = (*lait).second.decoration;
+ pass_thru_chars_ = (*lait).second.pass_thru_chars;
+ pass_thru_local_ = false;
+ if (lait->second.is_toc_caption) {
+ is_toc_caption_ = true;
+ // empty if AddToToc is not set
+ caption_of_toc_ = insetlayout
+ ? it.inset().getLayout().tocType()
+ : it.paragraph().layout().tocType();
+ }
+
+ switch ((*lait).second.passthru) {
+ case PT_INHERITED:
+ pass_thru_ = pass_thru_context_;
+ break;
+ case PT_TRUE:
+ pass_thru_ = true;
+ pass_thru_local_ = true;
+ break;
+ case PT_FALSE:
+ pass_thru_ = false;
+ break;
+ }
+ } else {
+ labelstring_ = _("Unknown Argument");
+ tooltip_ = _("Argument not known in this Layout. Will be suppressed in the output.");
+ }
+
+ if (former_pass_thru != pass_thru_) {
+ // PassThru status changed. We might need to update
+ // the language of the contents
+ Language const * l = insetlayout
+ ? it.inset().buffer().language()
+ : it.buffer()->language();
+ fixParagraphLanguage(l);
+ }
+
+ setButtonLabel();
+ InsetCollapsible::updateBuffer(it, utype);
+}
+
+
+void InsetArgument::setButtonLabel()
+{
+ setLabel(labelstring_);