lyx_mirror/src/frontends/controllers/ControlCitation.C

103 lines
2.1 KiB
C++
Raw Normal View History

/**
* \file ControlCitation.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "ControlCitation.h"
#include "buffer.h"
#include "bufferparams.h"
#include "debug.h" // temporary
using std::string;
using std::vector;
using std::pair;
namespace lyx {
namespace frontend {
vector<biblio::CiteStyle> ControlCitation::citeStyles_;
ControlCitation::ControlCitation(Dialog & d)
Rework InsetCommandParams interface and file storage * src/insets/insetcommandparams.[Ch]: (operator[]): New, access a parameter (clear): New, clear all parameters (info_): New, stire info about this command (cmdname): Rename to name_ (contents, options, sec_options): Replace with params_. Parameters are now stored as docstring. (findInfo): New factor for command info for all commands (read, write): Use new syntax (parameter set and get methods): reimplemenmt for new parameter storage * src/insets/insetcommand.h (getParam): New, get a parameter (setParam): New, set a parameter (parameter set and get methods): Adjust to InsetCommandParams changes * src/insets/insetbibitem.[Ch] (write): Remove, not needed anymore (directWrite): ditto * src/insets/insetbibitem.C (InsetBibitem::read): Use InsetCommand::read * src/insets/insetref.C (InsetRef::latex): Use new InsetCommandParams interface * src/mathed/InsetMathHull.C (InsetMathHull::doDispatch): ditto * src/text3.C (LyXText::dispatch): ditto * src/factory.C (createInset): Create InsetCommandParams with command name (readInset): ditto (readInset): Remove error message for bibitem, since bibitem is now a normal command inset * src/buffer.C: Bump file format number * src/frontends/controllers/ControlCommand.[Ch] (ControlCommand): take an additional command name parameter * src/text.C (readParToken): Remove code for \bibitem * lib/lyx2lyx/LyX.py: Bump latest file format number * lib/lyx2lyx/lyx_1_5.py (convert_bibitem, convert_commandparams): new, convert to new format (revert_commandparams): new, convert to old format * development/FORMAT: document new format * many other files: Adjust to the changes above git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15357 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-17 21:07:16 +00:00
: ControlCommand(d, "cite", "citation")
{}
bool ControlCitation::initialiseParams(string const & data)
{
ControlCommand::initialiseParams(data);
vector<pair<string, string> > blist;
kernel().buffer().fillWithBibKeys(blist);
biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
bool use_styles = engine != biblio::ENGINE_BASIC;
typedef std::map<string, string>::value_type InfoMapValue;
for (vector<pair<string,string> >::size_type i = 0;
i < blist.size(); ++i) {
bibkeysInfo_.insert(InfoMapValue(blist[i].first,
blist[i].second));
}
if (citeStyles_.empty())
citeStyles_ = biblio::getCiteStyles(engine);
else {
if ((use_styles && citeStyles_.size() == 1) ||
(!use_styles && citeStyles_.size() != 1))
citeStyles_ = biblio::getCiteStyles(engine);
}
return true;
}
void ControlCitation::clearParams()
{
ControlCommand::clearParams();
bibkeysInfo_.clear();
}
biblio::InfoMap const & ControlCitation::bibkeysInfo() const
{
return bibkeysInfo_;
}
biblio::CiteEngine_enum ControlCitation::getEngine() const
{
return biblio::getEngine(kernel().buffer());
}
vector<string> const ControlCitation::getCiteStrings(string const & key) const
{
vector<string> styles;
biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer());
vector<biblio::CiteStyle> const cs = biblio::getCiteStyles(engine);
if (engine == biblio::ENGINE_NATBIB_NUMERICAL)
styles = biblio::getNumericalStrings(key, bibkeysInfo_, cs);
else
styles = biblio::getAuthorYearStrings(key, bibkeysInfo_, cs);
return styles;
}
} // namespace frontend
} // namespace lyx