]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCaptionable.cpp
Some things did not need to be mutable after all
[lyx.git] / src / insets / InsetCaptionable.cpp
index f90776ab0408541f1dd672470239359efbd7ac97..c105d5ed99fbe047961dd63764648860d3bb97b4 100644 (file)
@@ -40,23 +40,26 @@ docstring InsetCaptionable::floatName(string const & type) const
        BufferParams const & bp = buffer().params();
        FloatList const & floats = bp.documentClass().floats();
        FloatList::const_iterator it = floats[type];
-       // FIXME UNICODE
-       return (it == floats.end()) ? from_ascii(type) : bp.B_(it->second.name());
+       return (it == floats.end()) ? from_utf8(type) : bp.B_(it->second.name());
 }
 
 
-void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active,
+                                                               UpdateType utype) const
 {
        DocIterator pit = cpit;
        pit.push_back(CursorSlice(const_cast<InsetCaptionable &>(*this)));
        docstring str;
-       int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
-       text().forOutliner(str, length);
-       shared_ptr<TocBuilder> b = buffer().tocBackend().builder(caption_type_);
-       b->pushItem(pit, str, output_active);
+       // Leave str empty if we generate for output (e.g. xhtml lists of figures).
+       // This ensures that there is a caption if and only if the string is
+       // non-empty.
+       if (utype != OutputUpdate)
+               text().forOutliner(str, TOC_ENTRY_LENGTH);
+       TocBuilder & b = buffer().tocBackend().builder(caption_type_);
+       b.pushItem(pit, str, output_active);
        // Proceed with the rest of the inset.
-       InsetCollapsable::addToToc(cpit, output_active);
-       b->pop();
+       InsetCollapsable::addToToc(cpit, output_active, utype);
+       b.pop();
 }
 
 void InsetCaptionable::updateBuffer(ParIterator const & it, UpdateType utype)