Do not require cprotect if we only have a cprotectible inset in the maintext.

This commit is contained in:
Juergen Spitzmueller 2018-04-23 11:04:18 +02:00
parent 8da025014d
commit 1af0832f75
4 changed files with 5 additions and 5 deletions

View File

@ -3475,7 +3475,7 @@ bool Paragraph::needsCProtection() const
// 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())
if (isInset(i) && getInset(i)->needsCProtection(maintext))
return true;
return false;

View File

@ -595,7 +595,7 @@ public:
virtual void rejectChanges() {}
///
virtual bool needsCProtection() const { return false; }
virtual bool needsCProtection(bool const) const { return false; }
///
virtual ColorCode backgroundColor(PainterInfo const &) const;

View File

@ -1086,7 +1086,7 @@ InsetText::XHTMLOptions operator|(InsetText::XHTMLOptions a1, InsetText::XHTMLOp
}
bool InsetText::needsCProtection() const
bool InsetText::needsCProtection(bool const maintext) const
{
// Nested cprotect content needs \cprotect
// on each level
@ -1098,7 +1098,7 @@ bool InsetText::needsCProtection() const
// Environments and "no latex" types (e.g., knitr chunks)
// need cprotection regardless the content
if (getLayout().latextype() != InsetLayout::COMMAND)
if (!maintext && getLayout().latextype() != InsetLayout::COMMAND)
return true;
// Commands need cprotection if they contain specific chars

View File

@ -224,7 +224,7 @@ public:
bool confirmDeletion() const { return !text().empty(); }
///
bool needsCProtection() const;
bool needsCProtection(bool const maintext = false) const;
///
bool hasCProtectContent() const;