Prevent outputting \maketitle within an inset embedded in title.

Amends [e4ef8ddc0f8202/lyxgit]

(cherry picked from commit 0bddf448ef)
This commit is contained in:
Juergen Spitzmueller 2020-07-04 10:54:20 +02:00
parent b86b80d74e
commit e2a29fe556
4 changed files with 14 additions and 4 deletions

View File

@ -448,6 +448,8 @@ public:
virtual InsetLayout const & getLayout() const; virtual InsetLayout const & getLayout() const;
/// ///
virtual bool isPassThru() const { return getLayout().isPassThru(); } 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? /// Is this inset's layout defined in the document's textclass?
bool undefined() const; bool undefined() const;
/// should this inset be handled like a normal character? /// should this inset be handled like a normal character?

View File

@ -79,14 +79,14 @@ using graphics::PreviewLoader;
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
InsetText::InsetText(Buffer * buf, UsePlain type) InsetText::InsetText(Buffer * buf, UsePlain type)
: Inset(buf), drawFrame_(false), frame_color_(Color_insetframe), : Inset(buf), drawFrame_(false), intitle_context_(false),
text_(this, type == DefaultLayout) frame_color_(Color_insetframe), text_(this, type == DefaultLayout)
{ {
} }
InsetText::InsetText(InsetText const & in) InsetText::InsetText(InsetText const & in)
: Inset(in), text_(this, in.text_) : Inset(in), intitle_context_(false), text_(this, in.text_)
{ {
drawFrame_ = in.drawFrame_; drawFrame_ = in.drawFrame_;
frame_color_ = in.frame_color_; frame_color_ = in.frame_color_;
@ -793,6 +793,9 @@ void InsetText::updateBuffer(ParIterator const & it, UpdateType utype)
cnt.restoreLastLayout(); cnt.restoreLastLayout();
// FIXME cnt.restoreLastCounter()? // 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 { } else {
DocumentClass const & tclass = buffer().masterBuffer()->params().documentClass(); DocumentClass const & tclass = buffer().masterBuffer()->params().documentClass();
// Note that we do not need to call: // Note that we do not need to call:

View File

@ -157,6 +157,8 @@ public:
/// ///
virtual bool allowMultiPar() const { return getLayout().isMultiPar(); } virtual bool allowMultiPar() const { return getLayout().isMultiPar(); }
/// ///
bool isInTitle() const { return intitle_context_; }
///
/// should paragraphs be forced to use the empty layout? /// should paragraphs be forced to use the empty layout?
virtual bool forcePlainLayout(idx_type = 0) const virtual bool forcePlainLayout(idx_type = 0) const
{ return getLayout().forcePlainLayout(); } { return getLayout().forcePlainLayout(); }
@ -240,6 +242,8 @@ private:
/// ///
bool drawFrame_; bool drawFrame_;
/// ///
bool intitle_context_;
///
ColorCode frame_color_; ColorCode frame_color_;
/// ///
Text text_; Text text_;

View File

@ -1496,7 +1496,8 @@ void latexParagraphs(Buffer const & buf,
<< "}\n"; << "}\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) { if (tclass.titletype() == TITLE_ENVIRONMENT) {
os << "\\end{" << from_ascii(tclass.titlename()) os << "\\end{" << from_ascii(tclass.titlename())
<< "}\n"; << "}\n";