Attached the reworked patch. Works for me.

- Martin


On Fri, Mar 02, 2007 at 01:38:59PM +0200, Martin Vermeer wrote:
> On Fri, Mar 02, 2007 at 11:34:06AM +0100, Jean-Marc Lasgouttes wrote:
> > >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
> > 
> > Martin> On Fri, Mar 02, 2007 at 04:13:14AM +0100, Juergen Spitzmueller
> > Martin> wrote:
> > >> José Matos wrote:
> > >> 
> > >> > What is Jürgen's opinion on the subject?
> > >> 
> > >> Without having a closer look at the patch, my opinion is that
> > >> Martin's approach is good (and necessary) in general. However, it
> > >> should enclose numerical citations in one way or another.
> > >> 
> > >> Jürgen
> > 
> > Martin> That would be like the attached... but note that I don't think
> > Martin> that is right. I agree that numeric should be handled, but
> > Martin> what happens here is that, also when natbib is pre-loaded by
> > Martin> the document class, the _user_ is allowed to choose between
> > Martin> numeric and author-year. I don't think that is right.
> > 
> > I have no idea on the actual logic, but nevertheless:
> > 
> > -   biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
> > +   BufferParams const & p = buffer.params();
> > +   biblio::CiteEngine cite_engine;
> > +   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;
> > 
> > Should getEngine from biblio.C be moved to BufferParams and used
> > there? I'd like to factor code whenever possible.
> 
> Hmm. What would be the advantage? Sure I can do it... won't be next
> Tuesday though.
>  
> > -           features.require("natbib");
> > +           if 
> > (!features.bufferParams().getLyXTextClass().provides(LyXTextClass::natbib))
> > +                   features.require("natbib");
> > 
> > I think it is not necessary because LaTeXFeatures handles it.
> 
> Damn you're right... and I actually looked at that code when preparing
> for this. This was the only thing the old code got right ;-/
> 
> - Martin
> 



-- 
Martin Vermeer   Phone +358 (0)9 451 3910
Professor of Geodesy, TKK Surveying Dept.
:wq
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,13 @@
 int InsetCitation::latex(Buffer const & buffer, odocstream & os,
                          OutputParams const &) const
 {
-       biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
+       BufferParams const & p = buffer.params();
+       biblio::CiteEngine cite_engine;
+       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;
        // 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,13 @@
        return *(language->encoding());
 }
 
+
+biblio::CiteEngine_enum BufferParams::getEngine() const
+{
+       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)

Attachment: pgpRBXdsmorYo.pgp
Description: PGP signature

Reply via email to