* BufferParams:

* transfer CiteEngine enum declaration to biblio.h
  * delete unneeded CiteEngine_enum
  * cite_engine is now cite_engine_ and is private.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17537 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-03-25 01:12:38 +00:00
parent 35173d515b
commit dfbc9cfccc
10 changed files with 50 additions and 46 deletions

View File

@ -31,6 +31,7 @@
#include "support/docstream.h"
#include "support/filetools.h"
#include "frontends/controllers/biblio.h"
namespace lyx {
@ -378,7 +379,7 @@ string const LaTeXFeatures::getPackages() const
// natbib.sty
if (isRequired("natbib") && ! tclass.provides(LyXTextClass::natbib)) {
packages << "\\usepackage[";
if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
if (params_.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL) {
packages << "numbers";
} else {
packages << "authoryear";

View File

@ -37,6 +37,7 @@
#include "vspace.h"
#include "frontends/Alert.h"
#include "frontends/controllers/biblio.h"
#include "support/lyxalgo.h" // for lyx::count
#include "support/convert.h"
@ -303,7 +304,7 @@ BufferParams::BufferParams()
use_geometry = false;
use_amsmath = package_auto;
use_esint = package_auto;
cite_engine = biblio::ENGINE_BASIC;
cite_engine_ = biblio::ENGINE_BASIC;
use_bibtopic = false;
trackChanges = false;
outputChanges = false;
@ -495,7 +496,7 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
} else if (token == "\\cite_engine") {
string engine;
lex >> engine;
cite_engine = citeenginetranslator().find(engine);
cite_engine_ = citeenginetranslator().find(engine);
} else if (token == "\\use_bibtopic") {
lex >> use_bibtopic;
} else if (token == "\\tracking_changes") {
@ -642,7 +643,7 @@ void BufferParams::writeFile(ostream & os) const
<< "\n\\use_geometry " << convert<string>(use_geometry)
<< "\n\\use_amsmath " << use_amsmath
<< "\n\\use_esint " << use_esint
<< "\n\\cite_engine " << citeenginetranslator().find(cite_engine)
<< "\n\\cite_engine " << citeenginetranslator().find(cite_engine_)
<< "\n\\use_bibtopic " << convert<string>(use_bibtopic)
<< "\n\\paperorientation " << string_orientation[orientation]
<< '\n';
@ -1483,14 +1484,20 @@ Encoding const & BufferParams::encoding() const
}
biblio::CiteEngine_enum BufferParams::getEngine() const
biblio::CiteEngine BufferParams::getEngine() const
{
// FIXME the class should provide the numerical/
// authoryear choice
if (getLyXTextClass().provides(LyXTextClass::natbib)
&& cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
&& cite_engine_ != biblio::ENGINE_NATBIB_NUMERICAL)
return biblio::ENGINE_NATBIB_AUTHORYEAR;
return cite_engine;
return cite_engine_;
}
void BufferParams::setCiteEngine(biblio::CiteEngine const cite_engine)
{
cite_engine_ = cite_engine;
}
} // namespace lyx

View File

@ -39,23 +39,8 @@ class TexRow;
class VSpace;
class Language;
namespace biblio {
enum CiteEngine {
ENGINE_BASIC,
ENGINE_NATBIB_AUTHORYEAR,
ENGINE_NATBIB_NUMERICAL,
ENGINE_JURABIB
};
class CiteEngine_enum {
CiteEngine val_;
public:
CiteEngine_enum(CiteEngine val) : val_(val) {}
operator CiteEngine() const{ return val_; }
};
enum CiteEngine;
} // namespace biblio
@ -240,8 +225,6 @@ public:
/// Whether and how to load esint
Package use_esint;
///
biblio::CiteEngine cite_engine;
///
bool use_bibtopic;
/// revision tracking for this buffer ?
bool trackChanges;
@ -278,7 +261,10 @@ public:
/// path of the current buffer
std::string filepath;
/// get the appropriate cite engine (natbib handling)
biblio::CiteEngine_enum getEngine() const;
biblio::CiteEngine getEngine() const;
///
void setCiteEngine(biblio::CiteEngine const);
private:
/** Use the Pimpl idiom to hide those member variables that would otherwise
@ -291,6 +277,9 @@ private:
static void destroy(Impl *);
};
support::copied_ptr<Impl, MemoryTraits> pimpl_;
///
biblio::CiteEngine cite_engine_;
};
} // namespace lyx

View File

@ -133,7 +133,7 @@ string const ControlBibtex::getStylefile() const
{
// the different bibtex packages have (and need) their
// own "plain" stylefiles
biblio::CiteEngine_enum const & engine =
biblio::CiteEngine const engine =
kernel().buffer().params().getEngine();
docstring defaultstyle;
switch (engine) {

View File

@ -111,7 +111,7 @@ static const docstring TheBibliographyRef(from_ascii("TheBibliographyRef"));
string const asValidLatexCommand(string const & input,
CiteEngine_enum const & engine)
CiteEngine const engine)
{
string const default_str = default_cite_command(engine);
if (!is_possible_cite_command(input))
@ -688,7 +688,7 @@ string const CitationStyle::asLatexStr() const
}
vector<CiteStyle> const getCiteStyles(CiteEngine_enum const & engine)
vector<CiteStyle> const getCiteStyles(CiteEngine const engine)
{
unsigned int nStyles = 0;
unsigned int start = 0;

View File

@ -23,7 +23,12 @@ class Buffer;
namespace lyx {
namespace biblio {
class CiteEngine_enum;
enum CiteEngine {
ENGINE_BASIC,
ENGINE_NATBIB_AUTHORYEAR,
ENGINE_NATBIB_NUMERICAL,
ENGINE_JURABIB
};
enum CiteStyle {
@ -55,7 +60,7 @@ enum Direction {
* returns an appropriate command, valid for \c engine.
*/
std::string const asValidLatexCommand(std::string const & input,
CiteEngine_enum const & engine);
CiteEngine const engine);
/// First entry is the bibliography key, second the data
typedef std::map<std::string, docstring> InfoMap;
@ -121,7 +126,7 @@ public:
/// Returns a vector of available Citation styles.
std::vector<CiteStyle> const getCiteStyles(CiteEngine_enum const &);
std::vector<CiteStyle> const getCiteStyles(CiteEngine const );
/**
"Translates" the available Citation Styles into strings for this key.

View File

@ -35,6 +35,7 @@
#include "tex-strings.h" // tex_graphics
#include "Spacing.h"
#include "frontends/controllers/biblio.h"
#include "controllers/ControlDocument.h"
#include "controllers/frnt_lang.h"
@ -642,18 +643,18 @@ void QDocumentDialog::apply(BufferParams & params)
fromqstr(preambleModule->preambleTE->document()->toPlainText());
// biblio
params.cite_engine = biblio::ENGINE_BASIC;
params.setCiteEngine(biblio::ENGINE_BASIC);
if (biblioModule->citeNatbibRB->isChecked()) {
bool const use_numerical_citations =
biblioModule->citeStyleCO->currentIndex();
if (use_numerical_citations)
params.cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
params.setCiteEngine(biblio::ENGINE_NATBIB_NUMERICAL);
else
params.cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
params.setCiteEngine(biblio::ENGINE_NATBIB_AUTHORYEAR);
} else if (biblioModule->citeJurabibRB->isChecked())
params.cite_engine = biblio::ENGINE_JURABIB;
params.setCiteEngine(biblio::ENGINE_JURABIB);
params.use_bibtopic =
biblioModule->bibtopicCB->isChecked();
@ -920,17 +921,17 @@ void QDocumentDialog::updateParams(BufferParams const & params)
// biblio
biblioModule->citeDefaultRB->setChecked(
params.cite_engine == biblio::ENGINE_BASIC);
params.getEngine() == biblio::ENGINE_BASIC);
biblioModule->citeNatbibRB->setChecked(
params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL ||
params.cite_engine == biblio::ENGINE_NATBIB_AUTHORYEAR);
params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL ||
params.getEngine() == biblio::ENGINE_NATBIB_AUTHORYEAR);
biblioModule->citeStyleCO->setCurrentIndex(
params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL);
params.getEngine() == biblio::ENGINE_NATBIB_NUMERICAL);
biblioModule->citeJurabibRB->setChecked(
params.cite_engine == biblio::ENGINE_JURABIB);
params.getEngine() == biblio::ENGINE_JURABIB);
biblioModule->bibtopicCB->setChecked(
params.use_bibtopic);

View File

@ -317,7 +317,7 @@ docstring const InsetCitation::generateLabel(Buffer const & buffer) const
docstring const after = getParam("after");
docstring label;
biblio::CiteEngine const engine = buffer.params().cite_engine;
biblio::CiteEngine const engine = buffer.params().getEngine();
if (engine != biblio::ENGINE_BASIC) {
// FIXME UNICODE
label = getNatbibLabel(buffer, getCmdName(), to_utf8(getParam("key")),
@ -446,7 +446,7 @@ int InsetCitation::latex(Buffer const & buffer, odocstream & os,
void InsetCitation::validate(LaTeXFeatures & features) const
{
switch (features.bufferParams().cite_engine) {
switch (features.bufferParams().getEngine()) {
case biblio::ENGINE_BASIC:
break;
case biblio::ENGINE_NATBIB_AUTHORYEAR:

View File

@ -15,7 +15,8 @@
#include "insetcommand.h"
#include "bufferparams.h"
#include "frontends/controllers/biblio.h"
namespace lyx {

View File

@ -1623,7 +1623,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
case LFUN_BUFFER_PARAMS_APPLY: {
BOOST_ASSERT(lyx_view_);
biblio::CiteEngine const engine =
lyx_view_->buffer()->params().cite_engine;
lyx_view_->buffer()->params().getEngine();
istringstream ss(argument);
LyXLex lex(0,0);
@ -1637,7 +1637,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
<< (unknown_tokens == 1 ? "" : "s")
<< endl;
}
if (engine == lyx_view_->buffer()->params().cite_engine)
if (engine == lyx_view_->buffer()->params().getEngine())
break;
LCursor & cur = view()->cursor();