d->validate(features);
bool fragile = features.runparams().moving_arg;
fragile |= layout().needprotect;
+ if (inInset().getLayout().isNeedProtect())
+ fragile = true;
if (needsCProtection(fragile))
features.require("cprotect");
}
}
// now check whether we have insets that need cprotection
- pos_type size = d->text_.size();
- for (pos_type i = 0; i < size; ++i)
- if (isInset(i) && getInset(i)->needsCProtection(maintext, fragile))
+ pos_type size = pos_type(d->text_.size());
+ for (pos_type i = 0; i < size; ++i) {
+ if (!isInset(i))
+ continue;
+ Inset const * ins = getInset(i);
+ if (ins->needsCProtection(maintext, fragile))
+ return true;
+ if (ins->getLayout().latextype() == InsetLayout::ENVIRONMENT)
+ // Environments need cprotection regardless the content
+ return true;
+ // Now check math environments
+ InsetMath const * im = getInset(i)->asInsetMath();
+ if (!im || im->cell(0).empty())
+ continue;
+ switch(im->cell(0)[0]->lyxCode()) {
+ case MATH_AMSARRAY_CODE:
+ case MATH_SUBSTACK_CODE:
+ case MATH_ENV_CODE:
+ case MATH_XYMATRIX_CODE:
+ // these need cprotection
return true;
+ default:
+ break;
+ }
+ }
return false;
}
}
-bool InsetText::hasCProtectContent(bool const fragile) const
+bool InsetText::hasCProtectContent(bool fragile) const
{
+ fragile |= getLayout().isNeedProtect();
ParagraphList const & pars = paragraphs();
- pit_type pend = paragraphs().size();
+ pit_type pend = pit_type(paragraphs().size());
for (pit_type pit = 0; pit != pend; ++pit) {
- Paragraph const & par = pars[pit];
+ Paragraph const & par = pars[size_type(pit)];
if (par.needsCProtection(fragile))
return true;
}
'&', '_', '$', '%', '#', '^', '{', '}', '\\'};
ParagraphList const & pars = paragraphs();
- pit_type pend = paragraphs().size();
+ pit_type pend = pit_type(paragraphs().size());
for (pit_type pit = 0; pit != pend; ++pit) {
- Paragraph const & par = pars[pit];
+ Paragraph const & par = pars[size_type(pit)];
if (par.needsCProtection(fragile))
return true;
docstring const pars = par.asString();
bool needsCProtection(bool const maintext = false,
bool const fragile = false) const;
///
- bool hasCProtectContent(bool const fragile = false) const;
+ bool hasCProtectContent(bool fragile = false) const;
protected:
///