X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetCaption.cpp;h=aaf06286f9abf3ee1f685b9b52ae5496d1f4e32b;hb=6b49b6b129af9417fea7ea907a44a46fbbd38340;hp=764e940a130b1a0d10438be66dc04b3c827c39c6;hpb=ecef54500d4d77baf4fa47eac2253679875ac08c;p=lyx.git diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 764e940a13..aaf06286f9 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -31,6 +31,7 @@ #include "output_xhtml.h" #include "OutputParams.h" #include "Paragraph.h" +#include "ParIterator.h" #include "TextClass.h" #include "TextMetrics.h" #include "TocBackend.h" @@ -97,7 +98,7 @@ void InsetCaption::setCustomLabel(docstring const & label) } -void InsetCaption::addToToc(DocIterator const & cpit) const +void InsetCaption::addToToc(DocIterator const & cpit, bool output_active) const { if (floattype_.empty()) return; @@ -107,11 +108,12 @@ void InsetCaption::addToToc(DocIterator const & cpit) const Toc & toc = buffer().tocBackend().toc(floattype_); docstring str = full_label_; - text().forToc(str, TOC_ENTRY_LENGTH); - toc.push_back(TocItem(pit, 0, str)); + int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH; + text().forToc(str, length); + toc.push_back(TocItem(pit, 0, str, output_active)); // Proceed with the rest of the inset. - InsetText::addToToc(cpit); + InsetText::addToToc(cpit, output_active); } @@ -229,12 +231,11 @@ bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd, if (first_arg == "changetype") { string const type = cmd.getArg(1); status.setOnOff(type == type_); - bool varia = true; + bool varia = type != "LongTableNoNumber"; // check if the immediate parent inset allows caption variation if (cur.depth() > 1) { - if (&cur[cur.depth() - 2].inset() - && !cur[cur.depth() - 2].inset().allowsCaptionVariation()) - varia = false; + if (&cur[cur.depth() - 2].inset()) + varia = cur[cur.depth() - 2].inset().allowsCaptionVariation(type); } status.setEnabled(varia && buffer().params().documentClass().hasInsetLayout( @@ -275,6 +276,9 @@ void InsetCaption::latex(otexstream & os, // optional argument. runparams.moving_arg = !runparams.inTableCell; InsetText::latex(os, runparams); + // Backwards compatibility: We always had a linebreak after + // the caption (see #8514) + os << breakln; runparams_in.encoding = runparams.encoding; } @@ -312,7 +316,9 @@ docstring InsetCaption::xhtml(XHTMLStream & xs, OutputParams const & rp) const string const our_class = "float-caption-" + type_; size_t const loc = attr.find("class='"); if (loc != string::npos) - attr.insert(loc + 1, our_class); + attr.insert(loc + 7, our_class+ " "); + else + attr = attr + " class='" + our_class + "'"; } xs << html::StartTag(tag, attr); docstring def = getCaptionAsHTML(xs, rp); @@ -351,8 +357,9 @@ int InsetCaption::getCaptionAsPlaintext(odocstream & os, { os << full_label_ << ' '; odocstringstream ods; - return InsetText::plaintext(ods, runparams); + int const retval = InsetText::plaintext(ods, runparams); os << ods.str(); + return retval; }