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"
|
2004-05-14 13:13:20 +00:00
|
|
|
#include "bufferparams.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "debug.h" // temporary
|
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
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
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)
|
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")
|
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());
|
2004-10-05 10:11:42 +00:00
|
|
|
|
2004-05-10 20:55:00 +00:00
|
|
|
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-14 13:13:20 +00:00
|
|
|
biblio::CiteEngine_enum 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;
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|