]> git.lyx.org Git - lyx.git/blobdiff - src/BiblioInfo.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / BiblioInfo.cpp
index d8297d03036c31210b40ca014a2dfff5d530f77e..bb9b27f7feab4b11993cedc35dcd0454ee5df9cd 100644 (file)
@@ -26,6 +26,7 @@
 #include "insets/InsetBibtex.h"
 #include "insets/InsetInclude.h"
 
+#include "support/convert.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
@@ -657,6 +658,26 @@ void BiblioInfo::collectCitedEntries(Buffer const & buf)
 }
 
 
+void BiblioInfo::makeCitationLabels(Buffer const & buf)
+{
+       collectCitedEntries(buf);
+       // FIXME It'd be nice to do author-year as well as numerical
+       // and maybe even some other sorts of labels.
+       vector<docstring>::const_iterator it = cited_entries_.begin();
+       vector<docstring>::const_iterator const en = cited_entries_.end();
+       int keynumber = 0;
+       for (; it != en; ++it) {
+               map<docstring, BibTeXInfo>::iterator const biit = bimap_.find(*it);
+               // this shouldn't happen, but...
+               if (biit == bimap_.end())
+                       continue;
+               BibTeXInfo & entry = biit->second;
+               docstring const key = convert<docstring>(++keynumber);
+               entry.setCiteKey(key);
+       }
+}
+
+
 //////////////////////////////////////////////////////////////////////
 //
 // CitationStyle