From 1af0832f750ac7e0c48c6efe1367a9d96447bfdc Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 23 Apr 2018 11:04:18 +0200 Subject: [PATCH] Do not require cprotect if we only have a cprotectible inset in the maintext. --- src/Paragraph.cpp | 2 +- src/insets/Inset.h | 2 +- src/insets/InsetText.cpp | 4 ++-- src/insets/InsetText.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 4bd483e44d..dc41fb9e96 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -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; diff --git a/src/insets/Inset.h b/src/insets/Inset.h index f6df439b3b..b6b8db64a5 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index b38a1dc356..61c4a19b34 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -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 diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h index 54f9a57119..e4e4bfc798 100644 --- a/src/insets/InsetText.h +++ b/src/insets/InsetText.h @@ -224,7 +224,7 @@ public: bool confirmDeletion() const { return !text().empty(); } /// - bool needsCProtection() const; + bool needsCProtection(bool const maintext = false) const; /// bool hasCProtectContent() const;