]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCitation.cpp
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[lyx.git] / src / insets / InsetCitation.cpp
index 7b1dbc5a49d5e327acde7def69fe74f1715405e7..3abb9a6b2ebc3a8cc7dfa14b47d86d4cc446b92a 100644 (file)
@@ -417,8 +417,8 @@ docstring InsetCitation::toolTip(BufferView const & bv, int, int) const
 
 docstring InsetCitation::generateLabel() const
 {
-       docstring const before = getParam("before");
-       docstring const after  = getParam("after");
+       docstring const before = getParam("before");
+       docstring const after  = getParam("after");
 
        docstring label;
        CiteEngine const engine = buffer().params().citeEngine();
@@ -466,7 +466,7 @@ void InsetCitation::updateLabels(ParIterator const &)
 void InsetCitation::addToToc(DocIterator const & cpit)
 {
        Toc & toc = buffer().tocBackend().toc("citation");
-       toc.push_back(TocItem(cpit, 0, cache.screen_label));
+       toc.push_back(TocItem(cpit, 0, getParam("key")));
 }
 
 
@@ -504,6 +504,47 @@ int InsetCitation::docbook(odocstream & os, OutputParams const &) const
 }
 
 
+docstring InsetCitation::xhtml(odocstream & os, OutputParams const &) const
+{
+       BiblioInfo const & bi = buffer().masterBibInfo();
+       docstring const & keyList = getParam("key");
+       if (keyList.empty())
+               return docstring();
+
+       // FIXME We shuld do a better job outputing different things for the
+       // different citation styles.   For now, we use square brackets for every
+       // case.
+       os << '[';
+       docstring const & before = getParam("before");
+       if (!before.empty())
+               os << before << " ";
+
+       vector<docstring> keys = getVectorFromString(keyList);
+       vector<docstring>::const_iterator it = keys.begin();
+       vector<docstring>::const_iterator en = keys.end();
+       bool first = true;
+       for (; it != en; ++it) {
+               BiblioInfo::const_iterator const bt = bi.find(*it);
+               if (bt == bi.end())
+                       continue;
+               BibTeXInfo const & bibinfo = bt->second;
+               if (!first) {
+                       os << ", ";
+                       first = false;
+               }
+               docstring const & label = bibinfo.label();
+               docstring const & target = label.empty() ? *it : label;
+               os << "<a href='#" << *it << "'>" << target << "</a>";
+       }
+
+       docstring const & after = getParam("after");
+       if (!after.empty())
+               os << ", " << after;
+       os << "]\n";
+       return docstring();
+}
+
+
 void InsetCitation::tocString(odocstream & os) const
 {
        plaintext(os, OutputParams(0));