]> git.lyx.org Git - features.git/commitdiff
Do not require cprotect if we only have a cprotectible inset in the maintext.
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 23 Apr 2018 09:04:18 +0000 (11:04 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 23 Apr 2018 09:04:18 +0000 (11:04 +0200)
src/Paragraph.cpp
src/insets/Inset.h
src/insets/InsetText.cpp
src/insets/InsetText.h

index 4bd483e44d3ccf23962b1549ff85c92b2aed22fc..dc41fb9e965a48d7784f21333296595a54279ae5 100644 (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;
index f6df439b3b46a861d279f71079cdeb1c22188921..b6b8db64a582b5bea4272cda7b3b4cc8763f8c45 100644 (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;
index b38a1dc3565de8a43df6741b65dac9513523b1c0..61c4a19b34898617ed36923676c332218e384e77 100644 (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
index 54f9a571192f0cb37b2ab9a1e16da144adf2a23e..e4e4bfc7981c6b92dc2bcbefc53f8c6550d4a4bf 100644 (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;