2002-09-05 14:10:50 +00:00
|
|
|
/**
|
|
|
|
* \file ControlCitation.C
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-03-15 13:37:04 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Angus Leeming
|
2001-03-15 13:37:04 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-15 13:37:04 +00:00
|
|
|
*/
|
|
|
|
|
2001-04-03 14:30:58 +00:00
|
|
|
#include <config.h>
|
2001-03-15 13:37:04 +00:00
|
|
|
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include "ControlCitation.h"
|
2002-08-12 20:17:41 +00:00
|
|
|
#include "buffer.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
using std::vector;
|
2002-06-18 15:44:30 +00:00
|
|
|
using std::pair;
|
2001-03-16 12:08:14 +00:00
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
vector<biblio::CiteStyle> ControlCitation::citeStyles_;
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlCommand(lv, d, LFUN_CITATION_INSERT)
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-03-15 13:37:04 +00:00
|
|
|
|
|
|
|
|
2001-03-23 17:09:34 +00:00
|
|
|
void ControlCitation::clearDaughterParams()
|
2001-03-15 13:37:04 +00:00
|
|
|
{
|
|
|
|
bibkeysInfo_.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
void ControlCitation::setDaughterParams()
|
2001-03-15 13:37:04 +00:00
|
|
|
{
|
2002-08-12 20:17:41 +00:00
|
|
|
vector<pair<string,string> > blist = buffer()->getBibkeyList();
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
typedef std::map<string, string>::value_type InfoMapValue;
|
|
|
|
|
2002-10-21 17:38:09 +00:00
|
|
|
for (vector<pair<string,string> >::size_type i = 0;
|
|
|
|
i < blist.size(); ++i) {
|
2001-03-15 13:37:04 +00:00
|
|
|
bibkeysInfo_.insert(InfoMapValue(blist[i].first,
|
|
|
|
blist[i].second));
|
|
|
|
}
|
2001-07-19 14:12:37 +00:00
|
|
|
|
|
|
|
if (citeStyles_.empty())
|
|
|
|
citeStyles_ = biblio::getCiteStyles(usingNatbib());
|
|
|
|
else {
|
|
|
|
if ((usingNatbib() && citeStyles_.size() == 1) ||
|
|
|
|
(!usingNatbib() && citeStyles_.size() != 1))
|
|
|
|
citeStyles_ = biblio::getCiteStyles(usingNatbib());
|
|
|
|
}
|
2001-03-15 13:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
biblio::InfoMap const & ControlCitation::bibkeysInfo() const
|
2001-03-15 13:37:04 +00:00
|
|
|
{
|
2001-03-28 12:59:29 +00:00
|
|
|
return bibkeysInfo_;
|
2001-03-15 13:37:04 +00:00
|
|
|
}
|
2001-07-19 14:12:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool ControlCitation::usingNatbib() const
|
|
|
|
{
|
2002-08-12 20:17:41 +00:00
|
|
|
return buffer()->params.use_natbib;
|
2001-07-19 14:12:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vector<string> const ControlCitation::getCiteStrings(string const & key) const
|
|
|
|
{
|
|
|
|
vector<string> styles;
|
|
|
|
|
|
|
|
vector<biblio::CiteStyle> const cs =
|
|
|
|
biblio::getCiteStyles(usingNatbib());
|
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
if (buffer()->params.use_numerical_citations)
|
2001-07-19 14:12:37 +00:00
|
|
|
styles = biblio::getNumericalStrings(key, bibkeysInfo_, cs);
|
|
|
|
else
|
|
|
|
styles = biblio::getAuthorYearStrings(key, bibkeysInfo_, cs);
|
|
|
|
|
|
|
|
return styles;
|
|
|
|
}
|