On Mon, Mar 19, 2007 at 06:08:48PM +0100, Jean-Marc Lasgouttes wrote: > >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes: > > Martin> Yes indeed, why not ;-/ Getting dumber by the day. > > Martin> New attached. > > Very good. If you think it is good enough and working for 1.4, you can > apply it (since having egs working better in 1.4 would be valuable, > from what I understand).
Here is the version for 1.4, tried and works as advertised for me. I will apply this tomorrow if nobody spots a problem. - Martin
Index: src/insets/insetcite.C =================================================================== --- src/insets/insetcite.C (revision 15477) +++ src/insets/insetcite.C (working copy) @@ -304,7 +304,7 @@ string const after = getOptions(); string label; - biblio::CiteEngine const engine = buffer.params().cite_engine; + biblio::CiteEngine const engine = buffer.params().getEngine(); if (engine != biblio::ENGINE_BASIC) { label = getNatbibLabel(buffer, getCmdName(), getContents(), before, after, engine); @@ -321,7 +321,7 @@ string const InsetCitation::getScreenLabel(Buffer const & buffer) const { - biblio::CiteEngine const engine = biblio::getEngine(buffer); + biblio::CiteEngine const engine = buffer.params().getEngine(); if (cache.params == params() && cache.engine == engine) return cache.screen_label; @@ -351,7 +351,7 @@ int InsetCitation::plaintext(Buffer const & buffer, ostream & os, OutputParams const &) const { if (cache.params == params() && - cache.engine == biblio::getEngine(buffer)) + cache.engine == buffer.params().getEngine()) os << cache.generated_label; else os << generateLabel(buffer); Index: src/bufferparams.C =================================================================== --- src/bufferparams.C (revision 15477) +++ src/bufferparams.C (working copy) @@ -1253,3 +1253,21 @@ tmp = string("\\usepackage[") + lang_opts + "]{babel}"; return tmp; } + + +biblio::CiteEngine_enum BufferParams::getEngine() const +{ + // FIXME the class should provide the numerical/ + // authoryear choice + lyxerr << "getEngine" << endl; + if (getLyXTextClass().provides(LyXTextClass::natbib) + && cite_engine != biblio::ENGINE_NATBIB_NUMERICAL) { + lyxerr << "authoryear" << endl; + return biblio::ENGINE_NATBIB_AUTHORYEAR; + } + lyxerr << "cite_engine=" << cite_engine << endl; + return cite_engine; +} + + + Index: src/bufferparams.h =================================================================== --- src/bufferparams.h (revision 15477) +++ src/bufferparams.h (working copy) @@ -230,7 +230,10 @@ std::string const paperSizeName() const; /// std::string const babelCall(std::string const & lang_opts) const; + /// get the appropriate cite engine (natbib handling) + lyx::biblio::CiteEngine_enum getEngine() const; + private: /** Use the Pimpl idiom to hide those member variables that would otherwise * drag in other header files. Index: lib/layouts/egs.layout =================================================================== --- lib/layouts/egs.layout (revision 15216) +++ lib/layouts/egs.layout (working copy) @@ -12,6 +12,7 @@ Columns 2 Sides 1 PageStyle Plain +ProvidesNatbib 1 Style Standard Index: src/frontends/controllers/ControlBibtex.C =================================================================== --- src/frontends/controllers/ControlBibtex.C (revision 15477) +++ src/frontends/controllers/ControlBibtex.C (working copy) @@ -133,7 +133,7 @@ // the different bibtex packages have (and need) their // own "plain" stylefiles biblio::CiteEngine_enum const & engine = - biblio::getEngine(kernel().buffer()); + kernel().buffer().params().getEngine(); string defaultstyle; switch (engine) { case biblio::ENGINE_BASIC: Index: src/frontends/controllers/ControlCitation.C =================================================================== --- src/frontends/controllers/ControlCitation.C (revision 15477) +++ src/frontends/controllers/ControlCitation.C (working copy) @@ -39,7 +39,7 @@ vector<pair<string, string> > blist; kernel().buffer().fillWithBibKeys(blist); - biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer()); + biblio::CiteEngine const engine = kernel().buffer().params().getEngine(); bool use_styles = engine != biblio::ENGINE_BASIC; @@ -79,7 +79,7 @@ biblio::CiteEngine_enum ControlCitation::getEngine() const { - return biblio::getEngine(kernel().buffer()); + return kernel().buffer().params().getEngine(); } @@ -87,7 +87,7 @@ { vector<string> styles; - biblio::CiteEngine const engine = biblio::getEngine(kernel().buffer()); + biblio::CiteEngine const engine = kernel().buffer().params().getEngine(); vector<biblio::CiteStyle> const cs = biblio::getCiteStyles(engine); if (engine == biblio::ENGINE_NATBIB_NUMERICAL) Index: src/frontends/controllers/biblio.C =================================================================== --- src/frontends/controllers/biblio.C (revision 15477) +++ src/frontends/controllers/biblio.C (working copy) @@ -679,12 +679,6 @@ } -CiteEngine_enum getEngine(Buffer const & buffer) -{ - return buffer.params().cite_engine; -} - - vector<CiteStyle> const getCiteStyles(CiteEngine_enum const & engine) { unsigned int nStyles = 0; Index: src/frontends/controllers/biblio.h =================================================================== --- src/frontends/controllers/biblio.h (revision 15477) +++ src/frontends/controllers/biblio.h (working copy) @@ -24,9 +24,7 @@ class CiteEngine_enum; -CiteEngine_enum getEngine(Buffer const &); - enum CiteStyle { CITE, CITET,