2001-07-19 14:12:37 +00:00
|
|
|
// -*- C++ -*-
|
2001-03-15 13:37:04 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2001-03-21 13:27:03 +00:00
|
|
|
* Copyright 2001 The LyX Team.
|
2001-03-15 13:37:04 +00:00
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file ControlCitation.C
|
|
|
|
* \author Angus Leeming <a.leeming@ic.ac.uk>
|
|
|
|
*/
|
|
|
|
|
2001-04-03 14:30:58 +00:00
|
|
|
#include <config.h>
|
2001-03-15 13:37:04 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-04-26 18:40:38 +00:00
|
|
|
#include "ViewBase.h"
|
|
|
|
#include "ButtonControllerBase.h"
|
2001-03-15 13:37:04 +00:00
|
|
|
#include "ControlCitation.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
|
|
|
|
using std::pair;
|
|
|
|
using std::vector;
|
2001-03-16 12:08:14 +00:00
|
|
|
using SigC::slot;
|
|
|
|
|
2001-07-19 14:12:37 +00:00
|
|
|
vector<biblio::CiteStyle> ControlCitation::citeStyles_;
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlCommand(lv, d, LFUN_CITATION_INSERT)
|
|
|
|
{
|
|
|
|
// These are permanent connections so we won't bother
|
|
|
|
// storing a copy because we won't be disconnecting.
|
|
|
|
d_.showCitation.connect(slot(this, &ControlCitation::showInset));
|
|
|
|
d_.createCitation.connect(slot(this, &ControlCitation::createInset));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
vector<pair<string,string> > blist = lv_.buffer()->getBibkeyList();
|
|
|
|
|
2001-03-28 12:59:29 +00:00
|
|
|
typedef std::map<string, string>::value_type InfoMapValue;
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
for (vector<pair<string,string> >::size_type i=0; i<blist.size(); ++i) {
|
|
|
|
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
|
|
|
|
{
|
|
|
|
return lv_.buffer()->params.use_natbib;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vector<string> const ControlCitation::getCiteStrings(string const & key) const
|
|
|
|
{
|
|
|
|
vector<string> styles;
|
|
|
|
|
|
|
|
vector<biblio::CiteStyle> const cs =
|
|
|
|
biblio::getCiteStyles(usingNatbib());
|
|
|
|
|
|
|
|
if (lv_.buffer()->params.use_numerical_citations)
|
|
|
|
styles = biblio::getNumericalStrings(key, bibkeysInfo_, cs);
|
|
|
|
else
|
|
|
|
styles = biblio::getAuthorYearStrings(key, bibkeysInfo_, cs);
|
|
|
|
|
|
|
|
return styles;
|
|
|
|
}
|