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
|
|
|
*
|
2003-08-23 00:17:00 +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"
|
2003-02-25 14:51:38 +00:00
|
|
|
#include "Kernel.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
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
ControlCitation::ControlCitation(Dialog & d)
|
2003-02-27 13:26:07 +00:00
|
|
|
: ControlCommand(d, "citation")
|
2002-06-18 15:44:30 +00:00
|
|
|
{}
|
2001-03-15 13:37:04 +00:00
|
|
|
|
|
|
|
|
2003-03-14 00:20:42 +00:00
|
|
|
bool ControlCitation::initialiseParams(string const & data)
|
2001-03-15 13:37:04 +00:00
|
|
|
{
|
2003-02-25 14:51:38 +00:00
|
|
|
ControlCommand::initialiseParams(data);
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2003-02-18 13:25:18 +00:00
|
|
|
vector<pair<string,string> > blist;
|
2003-02-25 14:51:38 +00:00
|
|
|
kernel().buffer()->fillWithBibKeys(blist);
|
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());
|
|
|
|
}
|
2003-03-14 00:20:42 +00:00
|
|
|
|
|
|
|
return true;
|
2001-03-15 13:37:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
void ControlCitation::clearParams()
|
|
|
|
{
|
|
|
|
ControlCommand::clearParams();
|
|
|
|
bibkeysInfo_.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2003-02-25 14:51:38 +00:00
|
|
|
return kernel().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());
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
if (kernel().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;
|
|
|
|
}
|