]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibtex.cpp
Fix logic of new InsetFlex::updateBuffer() routine from a9614f1.
[lyx.git] / src / insets / InsetBibtex.cpp
index 9c51355a2190e0e1a8d8ceff91c91325eba007f5..1abafd60b3189679a6c57d3a41ba4d47770d3406 100644 (file)
@@ -928,21 +928,33 @@ void InsetBibtex::validate(LaTeXFeatures & features) const
 }
 
 
-int InsetBibtex::plaintext(odocstream & os, OutputParams const &) const
+int InsetBibtex::plaintext(odocstringstream & os,
+       OutputParams const & op, size_t max_length) const
 {
+       docstring const reflabel = buffer().B_("References");
+
+       // We could output more information here, e.g., what databases are included
+       // and information about options. But I don't necessarily see any reason to
+       // do this right now.
+       if (op.for_tooltip || op.for_toc || op.for_search) {
+               os << '[' << reflabel << ']' << '\n';
+               return PLAINTEXT_NEWLINE;
+       }
+
        BiblioInfo bibinfo = buffer().masterBibInfo();
        bibinfo.makeCitationLabels(buffer());
        vector<docstring> const & cites = bibinfo.citedEntries();
 
+       size_t start_size = os.str().size();
        docstring refoutput;
-       docstring const reflabel = buffer().B_("References");
-
        refoutput += reflabel + "\n\n";
 
        // Now we loop over the entries
        vector<docstring>::const_iterator vit = cites.begin();
        vector<docstring>::const_iterator const ven = cites.end();
        for (; vit != ven; ++vit) {
+               if (start_size + refoutput.size() >= max_length)
+                       break;
                BiblioInfo::const_iterator const biit = bibinfo.find(*vit);
                if (biit == bibinfo.end())
                        continue;