commit 0bddf448ef5756eee90c771ff3277dd805b2b0a3
Author: Juergen Spitzmueller <[email protected]>
Date:   Sat Jul 4 10:54:20 2020 +0200

    Prevent outputting \maketitle within an inset embedded in title.
    
    Amends [e4ef8ddc0f8202/lyxgit]
---
 src/insets/Inset.h       |    2 ++
 src/insets/InsetText.cpp |    8 ++++++--
 src/insets/InsetText.h   |    4 ++++
 src/output_latex.cpp     |    3 ++-
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index c2a4bec..6531230 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -469,6 +469,8 @@ public:
        virtual InsetLayout const & getLayout() const;
        ///
        virtual bool isPassThru() const { return getLayout().isPassThru(); }
+       /// Is this inset embedded in a title?
+       virtual bool isInTitle() const { return false; }
        /// Is this inset's layout defined in the document's textclass?
        bool undefined() const;
        /// should this inset be handled like a normal character?
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index ba716ae..aeb4c43 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -78,7 +78,8 @@ using graphics::PreviewLoader;
 /////////////////////////////////////////////////////////////////////
 
 InsetText::InsetText(Buffer * buf, UsePlain type)
-       : Inset(buf), drawFrame_(false), is_changed_(false), 
frame_color_(Color_insetframe),
+       : Inset(buf), drawFrame_(false), is_changed_(false), 
intitle_context_(false),
+         frame_color_(Color_insetframe),
        text_(this, type == DefaultLayout)
 {
 }
@@ -86,7 +87,7 @@ InsetText::InsetText(Buffer * buf, UsePlain type)
 
 InsetText::InsetText(InsetText const & in)
        : Inset(in), drawFrame_(in.drawFrame_), is_changed_(in.is_changed_),
-         frame_color_(in.frame_color_),
+         intitle_context_(false), frame_color_(in.frame_color_),
          text_(this, in.text_)
 {
 }
@@ -838,6 +839,9 @@ void InsetText::updateBuffer(ParIterator const & it, 
UpdateType utype, bool cons
                        cnt.restoreLastLayout();
                        // FIXME cnt.restoreLastCounter()?
                }
+               // Record in this inset is embedded in a title layout
+               // This is needed to decide when \maketitle is output.
+               intitle_context_ = it.paragraph().layout().intitle;
        } else {
                DocumentClass const & tclass = 
buffer().masterBuffer()->params().documentClass();
                // Note that we do not need to call:
diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h
index d50d555..59f1202 100644
--- a/src/insets/InsetText.h
+++ b/src/insets/InsetText.h
@@ -161,6 +161,8 @@ public:
        ///
        virtual bool allowMultiPar() const { return getLayout().isMultiPar(); }
        ///
+       bool isInTitle() const { return intitle_context_; }
+       ///
        /// should paragraphs be forced to use the empty layout?
        virtual bool forcePlainLayout(idx_type = 0) const
                { return getLayout().forcePlainLayout(); }
@@ -252,6 +254,8 @@ private:
        /// true if the inset contains change
        mutable bool is_changed_;
        ///
+       bool intitle_context_;
+       ///
        ColorCode frame_color_;
        ///
        Text text_;
diff --git a/src/output_latex.cpp b/src/output_latex.cpp
index d567ecc..12f58aa 100644
--- a/src/output_latex.cpp
+++ b/src/output_latex.cpp
@@ -1627,7 +1627,8 @@ void latexParagraphs(Buffer const & buf,
                                                        << "}\n";
                                }
                        }
-               } else if (runparams.need_maketitle && 
!runparams.have_maketitle && !layout.inpreamble) {
+               } else if (runparams.need_maketitle && !runparams.have_maketitle
+                          && !layout.inpreamble && !text.inset().isInTitle()) {
                        if (tclass.titletype() == TITLE_ENVIRONMENT) {
                                os << "\\end{" << from_ascii(tclass.titlename())
                                                << "}\n";
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to