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
|
|
|
|
2002-08-12 20:17:41 +00:00
|
|
|
#include "buffer.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
|
|
using std::string;
|
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-10-06 15:43:21 +00:00
|
|
|
vector<pair<string, string> > blist;
|
2003-08-28 07:41:31 +00:00
|
|
|
kernel().buffer().fillWithBibKeys(blist);
|
2001-03-15 13:37:04 +00:00
|
|
|
|
2004-05-10 20:55:00 +00:00
|
|
|
biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
|
|
|
|
|
|
|
|
bool use_styles = engine != biblio::ENGINE_BASIC;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
typedef std::map<string, string>::value_type InfoMapValue;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
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())
|
2004-05-10 20:55:00 +00:00
|
|
|
citeStyles_ = biblio::getCiteStyles(engine);
|
2001-07-19 14:12:37 +00:00
|
|
|
else {
|
2004-03-07 14:33:17 +00:00
|
|
|
if ((use_styles && citeStyles_.size() == 1) ||
|
|
|
|
(!use_styles && citeStyles_.size() != 1))
|
2004-05-10 20:55:00 +00:00
|
|
|
citeStyles_ = biblio::getCiteStyles(engine);
|
2001-07-19 14:12:37 +00:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
2004-05-10 20:55:00 +00:00
|
|
|
biblio::CiteEngine ControlCitation::getEngine() const
|
2001-07-19 14:12:37 +00:00
|
|
|
{
|
2004-05-10 20:55:00 +00:00
|
|
|
return biblio::getEngine(kernel().buffer());
|
2004-03-07 14:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
vector<string> const ControlCitation::getCiteStrings(string const & key) const
|
|
|
|
{
|
|
|
|
vector<string> styles;
|
|
|
|
|
2004-05-10 20:55:00 +00:00
|
|
|
biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
|
|
|
|
vector<biblio::CiteStyle> const cs = biblio::getCiteStyles(engine);
|
2001-07-19 14:12:37 +00:00
|
|
|
|
2004-05-10 20:55:00 +00:00
|
|
|
if (engine == biblio::ENGINE_NATBIB_NUMERICAL)
|
2001-07-19 14:12:37 +00:00
|
|
|
styles = biblio::getNumericalStrings(key, bibkeysInfo_, cs);
|
|
|
|
else
|
|
|
|
styles = biblio::getAuthorYearStrings(key, bibkeysInfo_, cs);
|
|
|
|
|
|
|
|
return styles;
|
|
|
|
}
|