commit 1af0832f750ac7e0c48c6efe1367a9d96447bfdc
Author: Juergen Spitzmueller <[email protected]>
Date: Mon Apr 23 11:04:18 2018 +0200
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 4bd483e..dc41fb9 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 f6df439..b6b8db6 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 b38a1dc..61c4a19 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 54f9a57..e4e4bfc 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;