]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCaption.cpp
Compute and output numbers for numerical citations.
[lyx.git] / src / insets / InsetCaption.cpp
index 37913bc480ad79e2b169dcd78d77adfa81e2e881..a239fb9061486e18b6f2fe32c165a95e5602e375 100644 (file)
@@ -97,7 +97,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 +107,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 +230,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(
@@ -279,11 +279,11 @@ void InsetCaption::latex(otexstream & os,
 }
 
 
-int InsetCaption::plaintext(odocstream & os,
-                           OutputParams const & runparams) const
+int InsetCaption::plaintext(odocstringstream & os,
+                           OutputParams const & runparams, size_t max_length) const
 {
        os << '[' << full_label_ << "\n";
-       InsetText::plaintext(os, runparams);
+       InsetText::plaintext(os, runparams, max_length);
        os << "\n]";
 
        return PLAINTEXT_NEWLINE + 1; // one char on a separate line
@@ -350,7 +350,10 @@ int InsetCaption::getCaptionAsPlaintext(odocstream & os,
                        OutputParams const & runparams) const
 {
        os << full_label_ << ' ';
-       return InsetText::plaintext(os, runparams);
+       odocstringstream ods;
+       int const retval = InsetText::plaintext(ods, runparams);
+       os << ods.str();
+       return retval;
 }