X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FParagraph.cpp;h=6b1e118697cabbd6a2b099f8a5d11a4ac894fdfa;hb=bca1b63d89e27b31b089ab48c63368640084b3a6;hp=dc4be43703d70dc38177c24d17eccd1b5ee02dd7;hpb=045c25cf761dbc2d9efcab73af42a52496dcb075;p=lyx.git diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index dc4be43703..6b1e118697 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -2268,6 +2268,16 @@ bool Paragraph::isPassThru() const return inInset().isPassThru() || d->layout_->pass_thru; } + +bool Paragraph::isPartOfTextSequence() const +{ + for (pos_type i = 0; i < size(); ++i) { + if (!isInset(i) || getInset(i)->isPartOfTextSequence()) + return true; + } + return false; +} + namespace { // paragraphs inside floats need different alignment tags to avoid @@ -2339,24 +2349,29 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams, (layout_->toggle_indent != ITOGGLE_NEVER) : (layout_->toggle_indent == ITOGGLE_ALWAYS); - // Paragraphs that only contain insets which are not part of the text sequence - // (e.g., floats) should not get \\noindent (this would cause extra white space) - bool emptypar = true; - if (canindent) { - for (pos_type i = 0; i < owner_->size(); ++i) { - if (!owner_->isInset(i) || owner_->getInset(i)->isPartOfTextSequence()) { - emptypar = false; - break; - } - } - } - LyXAlignment const curAlign = params_.align(); - if (canindent && !emptypar && params_.noindent() - && !layout_->pass_thru && curAlign != LYX_ALIGN_CENTER) { - os << "\\noindent "; - column += 10; + // Do not output \\noindent for paragraphs + // 1. that cannot have indentation or are indented always, + // 2. that are not part of the immediate text sequence (e.g., contain only floats), + // 3. that are PassThru, + // 4. or that are centered. + if (canindent && params_.noindent() + && owner_->isPartOfTextSequence() + && !layout_->pass_thru + && curAlign != LYX_ALIGN_CENTER) { + if (!owner_->empty() + && (owner_->isInset(0) + && owner_->getInset(0)->lyxCode() == VSPACE_CODE)) + // If the paragraph starts with a vspace, the \\noindent + // needs to come after that (as it leaves vmode). + // If the paragraph consists only of the vspace, + // \\noindent is not needed at all. + runparams.need_noindent = owner_->size() > 1; + else { + os << "\\noindent" << termcmd; + column += 10; + } } if (curAlign == layout_->align)