On Mon, 2007-03-19 at 11:14 +0100, Jean-Marc Lasgouttes wrote:
> Why not use 
>     cite_engine = p.getEngine();
> in the code below?
> 
> +     // FIXME the class should also provide 
> +     // the numerical/ authoryear choce
> +     if (p.getLyXTextClass().provides(LyXTextClass::natbib)
> +        && p.cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
> +             cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
> +     else    
> +             cite_engine = p.cite_engine;

Yes indeed, why not ;-/ Getting dumber by the day.

New attached.

> Also, a "trick" could be to allow the value '2' for providenatbib, or
> add a new ProvideNumericalNatbib tag.

Or make it a string valued thing: "No", "Numerical", "AuthorYear". More
legible. Have to sleep on that...

> JMarc

- Martin

Index: src/insets/insetcite.C
===================================================================
--- src/insets/insetcite.C	(revision 17353)
+++ src/insets/insetcite.C	(working copy)
@@ -335,7 +335,7 @@
 
 docstring 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;
 
@@ -368,7 +368,7 @@
 	docstring str;
 
 	if (cache.params == params() &&
-	    cache.engine == biblio::getEngine(buffer))
+	    cache.engine == buffer.params().getEngine())
 		str = cache.generated_label;
 	else
 		str = generateLabel(buffer);
@@ -424,7 +424,7 @@
 int InsetCitation::latex(Buffer const & buffer, odocstream & os,
                          OutputParams const &) const
 {
-	biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
+	biblio::CiteEngine cite_engine = buffer.params().getEngine();
 	// FIXME UNICODE
 	docstring const cite_str = from_utf8(
 		biblio::asValidLatexCommand(getCmdName(), cite_engine));
Index: src/bufferparams.C
===================================================================
--- src/bufferparams.C	(revision 17353)
+++ src/bufferparams.C	(working copy)
@@ -1482,4 +1482,15 @@
 	return *(language->encoding());
 }
 
+
+biblio::CiteEngine_enum BufferParams::getEngine() const
+{
+	// FIXME the class should provide the numerical/
+	// authoryear choice
+	if (getLyXTextClass().provides(LyXTextClass::natbib)
+	    && cite_engine != biblio::ENGINE_NATBIB_NUMERICAL)
+		return biblio::ENGINE_NATBIB_AUTHORYEAR;
+	return cite_engine;
+}
+
 } // namespace lyx
Index: src/bufferparams.h
===================================================================
--- src/bufferparams.h	(revision 17381)
+++ src/bufferparams.h	(working copy)
@@ -277,6 +277,8 @@
 				     int const & sfscale, int const & ttscale) const;
 	/// path of the current buffer
 	std::string filepath;
+	/// get the appropriate cite engine (natbib handling)
+	biblio::CiteEngine_enum getEngine() const;
 
 private:
 	/** Use the Pimpl idiom to hide those member variables that would otherwise
Index: lib/layouts/egs.layout
===================================================================
--- lib/layouts/egs.layout	(revision 17353)
+++ 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 17353)
+++ src/frontends/controllers/ControlBibtex.C	(working copy)
@@ -134,7 +134,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();
 	docstring defaultstyle;
 	switch (engine) {
 	case biblio::ENGINE_BASIC:
Index: src/frontends/controllers/ControlCitation.C
===================================================================
--- src/frontends/controllers/ControlCitation.C	(revision 17353)
+++ src/frontends/controllers/ControlCitation.C	(working copy)
@@ -39,7 +39,7 @@
 	vector<pair<string, docstring> > 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,13 +79,13 @@
 
 biblio::CiteEngine_enum ControlCitation::getEngine() const
 {
-	return biblio::getEngine(kernel().buffer());
+	return kernel().buffer().params().getEngine();
 }
 
 
 vector<docstring> const ControlCitation::getCiteStrings(string const & key) const
 {
-	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 17353)
+++ src/frontends/controllers/biblio.C	(working copy)
@@ -688,12 +688,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 17353)
+++ src/frontends/controllers/biblio.h	(working copy)
@@ -25,9 +25,7 @@
 
 class CiteEngine_enum;
 
-CiteEngine_enum getEngine(Buffer const &);
 
-
 enum CiteStyle {
 	CITE,
 	CITET,

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to