]> git.lyx.org Git - features.git/commitdiff
Store the citation engine in BufferParams as biblio::CiteEngine rather
authorAngus Leeming <leeming@lyx.org>
Thu, 13 May 2004 20:44:35 +0000 (20:44 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 13 May 2004 20:44:35 +0000 (20:44 +0000)
than a triplet of bools. Results in a file format change.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8752 a592a061-630c-0410-9148-cb99ea01b6c8

20 files changed:
development/ChangeLog
development/FORMAT
lib/lyx2lyx/ChangeLog
lib/lyx2lyx/lyx_1_4.py
lib/lyx2lyx/parser_tools.py
src/ChangeLog
src/LaTeXFeatures.C
src/buffer.C
src/bufferparams.C
src/bufferparams.h
src/frontends/controllers/ChangeLog
src/frontends/controllers/biblio.C
src/frontends/qt2/ChangeLog
src/frontends/qt2/QDocument.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormDocument.h
src/frontends/xforms/forms/form_document.fd
src/insets/ChangeLog
src/insets/insetcite.C

index 1d2ddf86c08b4a7edfc2d6341bf510b1039b6b0c..656a716481dc85978b7e0d64c2e308382a77bab8 100644 (file)
@@ -1,3 +1,7 @@
+2004-05-12  Angus Leeming  <leeming@lyx.org>
+
+       * FORMAT: document change to format 234.
+
 2003-03-07  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * FORMAT: document jurabib.
index de32b9134b6cea82c07d3b41d31f0c29a7cf90cc..42505511fbc428433c8cc608e20ff41485a13d8f 100644 (file)
@@ -1,6 +1,19 @@
 LyX file-format changes
 -----------------------
 
+2004-05-12  Angus Leeming  <leeming@lyx.org>
+
+       * format incremented to 234.
+       * the citation engine is specified explicitly rather than being
+       deduced from 3 bools.
+
+       \use_natbib 1
+       \use_numerical_citations 0   ->   \cite_engine <style>
+       \use_jurabib 0
+
+       where <style> is one of "basic", "natbib_authoryear",
+       "natbib_numerical" or "jurabib".
+
 2004-04-29  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * format incremented to 233.
index d69e9740c952e96a012d6dd6b2edab8cfe0dd2bd..ff7217b40553d122089ed6233c6d4d36b052fd39 100644 (file)
@@ -1,3 +1,11 @@
+2004-05-12  Angus Leeming  <leeming@lyx.org>
+
+       * lyx_1_4.py (convert_cite_engine, revert_cite_engine): new functions
+       to convert the code that specifies the type of the citation engine
+       (basic, natbib or jurabib).
+
+       * parser_tools.py: up the format to 234.
+
 2004-05-11  José Matos  <jamatos@lyx.org>
 
 
index 5282d0e77a6b1d35af6b39790290903bb9c085f6..4ccb750d5ee7ca4ed9600002bc1ccc1e7402594d 100644 (file)
@@ -1259,6 +1259,69 @@ def revert_names(lines, opt):
         return
 
 
+##
+#    \use_natbib 1                       \cite_engine <style>
+#    \use_numerical_citations 0     ->   where <style> is one of
+#    \use_jurabib 0                      "basic", "natbib_authoryear",
+#                                        "natbib_numerical" or "jurabib"
+def convert_cite_engine(header, opt):
+    a = find_token(header, "\\use_natbib", 0)
+    if a == -1:
+        opt.warning("Malformed lyx file: Missing '\\use_natbib'")
+        return
+
+    b = find_token(header, "\\use_numerical_citations", 0)
+    if b == -1 or b != a+1:
+        opt.warning("Malformed lyx file: Missing '\\use_numerical_citations'")
+        return
+
+    c = find_token(header, "\\use_jurabib", 0)
+    if c == -1 or c != b+1:
+        opt.warning("Malformed lyx file: Missing '\\use_jurabib'")
+        return
+
+    use_natbib = int(split(header[a])[1])
+    use_numerical_citations = int(split(header[b])[1])
+    use_jurabib = int(split(header[c])[1])
+
+    cite_engine = "basic"
+    if use_natbib:
+        if use_numerical_citations:
+            cite_engine = "natbib_numerical"
+        else:
+             cite_engine = "natbib_authoryear"
+    elif use_jurabib:
+        cite_engine = "jurabib"
+
+    del header[a:c+1]
+    header.insert(a, "\\cite_engine " + cite_engine)
+
+
+def revert_cite_engine(header, opt):
+    i = find_token(header, "\\cite_engine", 0)
+    if i == -1:
+        opt.warning("Malformed lyx file: Missing '\\cite_engine'")
+        return
+
+    cite_engine = split(header[i])[1]
+
+    use_natbib = '0'
+    use_numerical = '0'
+    use_jurabib = '0'
+    if cite_engine == "natbib_numerical":
+        use_natbib = '1'
+        use_numerical = '1'
+    elif cite_engine == "natbib_authoryear":
+        use_natbib = '1'
+    elif cite_engine == "jurabib":
+        use_jurabib = '1'
+
+    del header[i]
+    header.insert(i, "\\use_jurabib " + use_jurabib)
+    header.insert(i, "\\use_numerical_citations " + use_numerical)
+    header.insert(i, "\\use_natbib " + use_natbib)
+
+
 ##
 # Convertion hub
 #
@@ -1328,8 +1391,18 @@ def convert(header, body, opt):
         convert_graphics(body, opt)
         convert_names(body, opt)
        opt.format = 233
+    if opt.end == opt.format: return
+
+    if opt.format < 234:
+        convert_cite_engine(header, opt)
+       opt.format = 234
 
 def revert(header, body, opt):
+    if opt.format > 233:
+        revert_cite_engine(header, opt)
+       opt.format = 233
+    if opt.end == opt.format: return
+
     if opt.format > 232:
         revert_names(body, opt)
        opt.format = 232
index 676710f4b758decf68141430fc210485f9b4d9e1..4c698903b5cd2388b6c35d1267cad6de115d9a51 100644 (file)
@@ -265,7 +265,7 @@ def set_version(lines, version):
 format_re = re.compile(r"(\d)[\.,]?(\d\d)")
 fileformat = re.compile(r"\\lyxformat\s*(\S*)")
 lst_ft = [210, 215, 216, 217, 218, 220, 221, 223, 224, 225, 226, 227, 228, 229, 
-          230, 231, 232, 233]
+          230, 231, 232, 233, 234]
 
 format_relation = [("0_10",  [210], ["0.10.7","0.10"]),
                    ("0_12",  [215], ["0.12","0.12.1","0.12"]),
@@ -277,7 +277,7 @@ format_relation = [("0_10",  [210], ["0.10.7","0.10"]),
                    ("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
                    ("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
                    ("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3"]),
-                   ("1_4", [223,224,225,226,227,228,229,230,231,232,233], ["1.4.0cvs","1.4"])]
+                   ("1_4", [223,224,225,226,227,228,229,230,231,232,233,234], ["1.4.0cvs","1.4"])]
 
 
 def lyxformat(format, opt):
@@ -290,7 +290,7 @@ def lyxformat(format, opt):
     if format in lst_ft:
         return format
 
-    opt.error(str(format) + ": " + "Format no supported.")
+    opt.error(str(format) + ": " + "Format not supported.")
     return None
 
 
index e5c9c3db694f7eb75a317b44845db02de9436145..0e1e715b8e324a31c645f0b53dd7690820a42b63 100644 (file)
@@ -1,3 +1,11 @@
+2004-05-12  Angus Leeming  <leeming@lyx.org>
+
+       * buffer.C: up LYX_FORMAT to 234.
+       * bufferparams.[Ch]: replace the three bools, use_natbib, use_jurabib,
+       use_numerical_citations with a single biblio::CiteEngine cite_engine
+       variable.
+       * LaTeXFeatures.C (getPackages): use BufferParams::cite_engine.
+
 2004-05-13  José Matos  <jamatos@lyx.org>
 
        * converter.h:
index c19dd75417c2d1e5155000798e209b986e53d21f..9cbbc3288c564c9e76c60aa34443f15740d92782 100644 (file)
@@ -299,7 +299,7 @@ string const LaTeXFeatures::getPackages() const
        // natbib.sty
        if (isRequired("natbib") && ! tclass.provides(LyXTextClass::natbib)) {
                packages << "\\usepackage[";
-               if (params_.use_numerical_citations) {
+               if (params_.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL) {
                        packages << "numbers";
                } else {
                        packages << "authoryear";
index 5b84c1714713dbcc2bfd12a7e26e50b7ffc5b79d..a1ae1f6f481691d9fb82c79eadc871f24b57343e 100644 (file)
@@ -136,7 +136,7 @@ extern BufferList bufferlist;
 
 namespace {
 
-const int LYX_FORMAT = 233;
+const int LYX_FORMAT = 234;
 
 } // namespace anon
 
index a26ea38935bff89c00dd3bf11a4bedf0b8146836..402297bb5527d44460d8e823583390f98d5006d1 100644 (file)
@@ -113,9 +113,7 @@ BufferParams::BufferParams()
        orientation = ORIENTATION_PORTRAIT;
        use_geometry = false;
        use_amsmath = AMS_AUTO;
-       use_natbib = false;
-       use_numerical_citations = false;
-       use_jurabib = false;
+       cite_engine = biblio::ENGINE_BASIC;
        use_bibtopic = false;
        tracking_changes = false;
        secnumdepth = 3;
@@ -317,15 +315,18 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
                lex.nextToken();
                use_amsmath = static_cast<AMS>(
                        lex.getInteger());
-       } else if (token == "\\use_natbib") {
+       } else if (token == "\\cite_engine") {
                lex.nextToken();
-               use_natbib = lex.getInteger();
-       } else if (token == "\\use_numerical_citations") {
-               lex.nextToken();
-               use_numerical_citations = lex.getInteger();
-       } else if (token == "\\use_jurabib") {
-               lex.nextToken();
-               use_jurabib = lex.getInteger();
+               string const engine = lex.getString();
+
+               cite_engine = biblio::ENGINE_BASIC;
+               if (engine == "natbib_numerical")
+                       cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
+               else if (engine == "natbib_authoryear")
+                       cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+               else if (engine == "jurabib")
+                       cite_engine = biblio::ENGINE_JURABIB;
+               
        } else if (token == "\\use_bibtopic") {
                lex.nextToken();
                use_bibtopic = lex.getInteger();
@@ -540,14 +541,27 @@ void BufferParams::writeFile(ostream & os) const
 
        spacing().writeFile(os);
 
+       string cite_engine_str = "basic";
+       switch (cite_engine) {
+       case biblio::ENGINE_BASIC:
+               break;
+       case biblio::ENGINE_NATBIB_NUMERICAL:
+               cite_engine_str = "natbib_numerical";
+               break;
+       case biblio::ENGINE_NATBIB_AUTHORYEAR:
+               cite_engine_str = "natbib_authoryear";
+               break;
+       case biblio::ENGINE_JURABIB:
+               cite_engine_str = "jurabib";
+               break;
+       }
+       
        os << "\\papersize " << string_papersize[papersize2]
           << "\n\\paperpackage " << string_paperpackages[paperpackage]
           << "\n\\use_geometry " << use_geometry
           << "\n\\use_amsmath " << use_amsmath
-          << "\n\\use_natbib " << use_natbib
-          << "\n\\use_numerical_citations " << use_numerical_citations
-          << "\n\\use_jurabib " << use_jurabib
-           << "\n\\use_bibtopic " << use_bibtopic
+          << "\n\\cite_engine " << cite_engine_str
+          << "\n\\use_bibtopic " << use_bibtopic
           << "\n\\paperorientation " << string_orientation[orientation]
           << '\n';
 
index ab798b19b907082be424c27b200594bedf0e740f..40e82290ac64b2c0928baeef12947966c0e636e9 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "insets/insetquotes.h"
 
+#include "frontends/controllers/biblio.h"
+
 #include "support/copied_ptr.h"
 #include "support/types.h"
 
@@ -179,11 +181,7 @@ public:
        };
        AMS use_amsmath;
        ///
-       bool use_natbib;
-       ///
-       bool use_numerical_citations;
-       ///
-       bool use_jurabib;
+       biblio::CiteEngine cite_engine;
        ///
        bool use_bibtopic;
        /// revision tracking for this buffer ?
index df6d0116835a91df17b6d9ced70ef32780e783b7..e5eedaa63656295eb8dd1d6c8c72391aa0c07773 100644 (file)
@@ -1,3 +1,7 @@
+2004-05-12  Angus Leeming  <leeming@lyx.org>
+
+       * biblio.C (getEngine): reduced to the trivial.
+
 2004-05-10  Angus Leeming  <leeming@lyx.org>
 
        * biblio.[Ch]: create a new biblio::CiteEngine enum. Use it instead of
index 7298b1f7170415d413b8e0a9699c6283ab1ea308..a6992eb957e80336a702f8a619dce953e5c87acf 100644 (file)
@@ -564,20 +564,7 @@ string const getCiteCommand(CiteStyle command, bool full, bool forceUCase)
 
 CiteEngine getEngine(Buffer const & buffer)
 {
-       CiteEngine engine = ENGINE_BASIC;
-
-       if (buffer.params().use_natbib) {
-               if (buffer.params().use_numerical_citations) {
-                       engine = ENGINE_NATBIB_NUMERICAL;
-               } else {
-                       engine = ENGINE_NATBIB_AUTHORYEAR;
-               }
-       }
-
-       if (buffer.params().use_jurabib)
-               engine = ENGINE_JURABIB;
-
-       return engine;
+       return buffer.params().cite_engine;
 }
 
 
index 8f4af3b6a46c0cf9fd50056ab3fe80ee2701e378..e0c7819acb7e5e3d9844700a5f413982254e6e5a 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-12  Angus Leeming  <leeming@lyx.org>
+
+       * QDocument.C (apply, update): get, set data with
+       BufferParams::cite_engine.
+
 2004-05-10  Angus Leeming  <leeming@lyx.org>
 
        * QCitation.C: simplified code to use the biblio::CiteEngine
index 54dba167fd33f05f5dc9b29661ba212e19a05e7e..5d2cf566342321cc29728683d2abf087a3d16b3b 100644 (file)
@@ -191,12 +191,19 @@ void QDocument::apply()
                fromqstr(dialog_->preambleModule->preambleMLE->text());
 
        // biblio
-       params.use_natbib =
-               dialog_->biblioModule->citeNatbibRB->isChecked();
-       params.use_numerical_citations  =
-               dialog_->biblioModule->citeStyleCO->currentItem();
-       params.use_jurabib =
-               dialog_->biblioModule->citeJurabibRB->isChecked();
+       params.cite_engine = biblio::ENGINE_BASIC;
+
+       if (dialog_->biblioModule->citeNatbibRB->isChecked()) {
+               bool const use_numerical_citations =
+                       dialog_->biblioModule->citeStyleCO->currentItem();
+               if (use_numerical_citations)
+                       params.cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
+               else
+                       params.cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+
+       } else if (dialog_->biblioModule->citeJurabibRB->isChecked())
+               params.cite_engine = biblio::ENGINE_JURABIB;
+       
        params.use_bibtopic =
                dialog_->biblioModule->bibtopicCB->isChecked();
 
@@ -446,13 +453,18 @@ void QDocument::update_contents()
 
        // biblio
        dialog_->biblioModule->citeDefaultRB->setChecked(
-               !params.use_natbib && !params.use_jurabib);
+               params.cite_engine == biblio::ENGINE_BASIC);
+
        dialog_->biblioModule->citeNatbibRB->setChecked(
-               params.use_natbib);
+               params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL ||
+               params.cite_engine == biblio::ENGINE_NATBIB_AUTHORYEAR);
+
        dialog_->biblioModule->citeStyleCO->setCurrentItem(
-               params.use_numerical_citations ? 1 : 0);
+               params.cite_engine == biblio::ENGINE_NATBIB_NUMERICAL);
+
        dialog_->biblioModule->citeJurabibRB->setChecked(
-               params.use_jurabib);
+               params.cite_engine == biblio::ENGINE_JURABIB);
+
        dialog_->biblioModule->bibtopicCB->setChecked(
                params.use_bibtopic);
 
index 6742b5ede5b34623a20b40dfaf13e4098702b24d..f02cb5e4408f198926dbb4e3e53e4ba5e7474feb 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-12  Angus Leeming  <leeming@lyx.org>
+
+       * FormDocument.[Ch], forms/form_document.fd: get, set data with
+       BufferParams::cite_engine.
+
 2004-05-10  Angus Leeming  <leeming@lyx.org>
 
        * FormCitation.C: simplified code to use the biblio::CiteEngine
index b1607f444e92d974fea21c16c08857d6451281f5..c4b29ab923d2a6ac3820834925730e0535fc0c48 100644 (file)
@@ -308,26 +308,19 @@ void FormDocument::build()
        bcview().addReadOnly(options_->counter_secnumdepth);
        bcview().addReadOnly(options_->counter_tocdepth);
        bcview().addReadOnly(options_->choice_ams_math);
-       bcview().addReadOnly(options_->radio_use_defcite);
-       bcview().addReadOnly(options_->radio_use_jurabib);
-       bcview().addReadOnly(options_->radio_use_natbib);
+       bcview().addReadOnly(options_->choice_cite_engine);
        bcview().addReadOnly(options_->check_bibtopic);
-       bcview().addReadOnly(options_->choice_citation_format);
        bcview().addReadOnly(options_->input_float_placement);
        bcview().addReadOnly(options_->choice_postscript_driver);
 
-       // add cite style radio buttons
-       citestyle_.init(options_->radio_use_defcite,   DEFCITE);
-       citestyle_.init(options_->radio_use_natbib,  NATBIB);
-       citestyle_.init(options_->radio_use_jurabib,  JURABIB);
+       string const cite_choices =
+               _(" Basic | Natbib author-year | Natbib numerical | Jurabib ");
+       fl_addto_choice(options_->choice_cite_engine, cite_choices.c_str());
 
        // set up the tooltips for optionss form
-       string str = _("Use LaTeX's default citation style");
-       tooltips().init(options_->radio_use_defcite, str);
-       str = _("Use the natbib styles for natural sciences and arts");
-       tooltips().init(options_->radio_use_natbib, str);
-       str = _("Use the jurabib styles for law and humanities");
-       tooltips().init(options_->radio_use_jurabib, str);
+       string str = _("Natbib is used often for natural sciences and arts\n"
+               "Jurabib is more common in law and humanities");
+       tooltips().init(options_->choice_cite_engine, str);
        str = _("Select this if you want to split your bibliography into sections");
        tooltips().init(options_->check_bibtopic, str);
 
@@ -343,8 +336,6 @@ void FormDocument::build()
                fl_addto_choice(options_->choice_postscript_driver,
                                tex_graphics[n]);
        }
-       fl_addto_choice(options_->choice_citation_format,
-                       _(" Author-year | Numerical ").c_str());
 
        // the document bullets form
        bullets_.reset(build_document_bullet(this));
@@ -535,12 +526,6 @@ ButtonPolicy::SMInput FormDocument::input(FL_OBJECT * ob, long)
                        fl_set_choice_text(class_->choice_skip_units,
                                           default_unit.c_str());
 
-       } else if (ob == options_->radio_use_jurabib ||
-                  ob == options_->radio_use_defcite ||
-                  ob == options_->radio_use_natbib) {
-               setEnabled(options_->choice_citation_format,
-                          fl_get_button(options_->radio_use_natbib));
-
        } else if (ob == branch_->browser_all_branches ||
                        ob == branch_->browser_selection ||
                        ob == branch_->button_add_branch ||
@@ -1028,10 +1013,23 @@ bool FormDocument::options_apply(BufferParams & params)
        params.graphicsDriver = getString(options_->choice_postscript_driver);
        params.use_amsmath = static_cast<BufferParams::AMS>(
                fl_get_choice(options_->choice_ams_math) - 1);
-       params.use_natbib  = fl_get_button(options_->radio_use_natbib);
-       params.use_numerical_citations  =
-               fl_get_choice(options_->choice_citation_format) - 1;
-       params.use_jurabib  = fl_get_button(options_->radio_use_jurabib);
+
+       int const cite_choice = fl_get_choice(options_->choice_cite_engine);
+       switch (cite_choice) {
+       case 1:
+               params.cite_engine = biblio::ENGINE_BASIC;
+               break;
+       case 2:
+               params.cite_engine = biblio::ENGINE_NATBIB_AUTHORYEAR;
+               break;
+       case 3:
+               params.cite_engine = biblio::ENGINE_NATBIB_NUMERICAL;
+               break;
+       case 4:
+               params.cite_engine = biblio::ENGINE_JURABIB;
+               break;
+       }
+       
        params.use_bibtopic  = fl_get_button(options_->check_bibtopic);
 
        int tmpchar = int(fl_get_counter_value(options_->counter_secnumdepth));
@@ -1198,11 +1196,24 @@ void FormDocument::options_update(BufferParams const & params)
        fl_set_choice_text(options_->choice_postscript_driver,
                           params.graphicsDriver.c_str());
        fl_set_choice(options_->choice_ams_math, params.use_amsmath + 1);
-       fl_set_button(options_->radio_use_natbib,  params.use_natbib);
-       fl_set_choice(options_->choice_citation_format,
-                     int(params.use_numerical_citations)+1);
-       setEnabled(options_->choice_citation_format, params.use_natbib);
-       fl_set_button(options_->radio_use_jurabib,  params.use_jurabib);
+
+       int cite_choice = 1;
+       switch (params.cite_engine) {
+       case biblio::ENGINE_BASIC:
+               cite_choice = 1;
+               break;
+       case biblio::ENGINE_NATBIB_AUTHORYEAR:
+               cite_choice = 2;
+               break;
+       case biblio::ENGINE_NATBIB_NUMERICAL:
+               cite_choice = 3;
+               break;
+       case biblio::ENGINE_JURABIB:
+               cite_choice = 4;
+               break;
+       }
+       fl_set_choice(options_->choice_cite_engine, cite_choice);
+
        fl_set_button(options_->check_bibtopic,  params.use_bibtopic);
        fl_set_counter_value(options_->counter_secnumdepth, params.secnumdepth);
        fl_set_counter_value(options_->counter_tocdepth, params.tocdepth);
index 99024e76b919705cf78f002c98cd0fa3f523ba21..64fcedcbb99f8d86d1b886762d7dc7e9ca6e111b 100644 (file)
@@ -14,7 +14,6 @@
 
 #include "FormDialogView.h"
 #include "BranchList.h"
-#include "RadioButtonGroup.h"
 
 #include <boost/scoped_ptr.hpp>
 
@@ -133,9 +132,6 @@ private:
        std::vector<std::string> lang_;
        /// Contains all legal branches for this doc
        BranchList branchlist_;
-
-       /// citation style buttons
-       RadioButtonGroup citestyle_;
 };
 
 #endif
index d09c332368f9af1c16534605dec192690719bf3c..1dfa4988c19464c8c59dd8314c6ebacb25e767bb 100644 (file)
@@ -328,7 +328,7 @@ argument:
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
@@ -928,7 +928,7 @@ argument: 0
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
@@ -1000,7 +1000,7 @@ argument:
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
@@ -1072,7 +1072,7 @@ argument:
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
@@ -1260,7 +1260,7 @@ argument: 0
 Name: form_document_options
 Width: 395
 Height: 315
-Number of Objects: 12
+Number of Objects: 8
 
 --------------------
 class: FL_BOX
@@ -1360,42 +1360,6 @@ name: choice_postscript_driver
 callback: C_FormDialogView_InputCB
 argument: 0
 
---------------------
-class: FL_ROUND3DBUTTON
-type: RADIO_BUTTON
-box: 25 205 140 25
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Natbib|#N
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: radio_use_natbib
-callback: C_FormDialogView_InputCB
-argument: 0
-
---------------------
-class: FL_CHOICE
-type: NORMAL_CHOICE
-box: 235 230 140 25
-boxtype: FL_FRAME_BOX
-colors: FL_COL1 FL_BLACK
-alignment: FL_ALIGN_TOP_LEFT
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Natbib style:|#i
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: choice_citation_format
-callback: C_FormDialogView_InputCB
-argument: 0
-
 --------------------
 class: FL_CHOICE
 type: NORMAL_CHOICE
@@ -1415,74 +1379,38 @@ callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
-class: FL_LABELFRAME
-type: ENGRAVED_FRAME
-box: 15 170 370 95
-boxtype: FL_NO_BOX
-colors: FL_BLACK FL_COL1
-alignment: FL_ALIGN_TOP_LEFT
-style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
-lcol: FL_BLACK
-label: Cite Styles
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: 
-callback: 
-argument: 
-
---------------------
-class: FL_ROUND3DBUTTON
-type: RADIO_BUTTON
-box: 25 230 140 25
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: Jurabib|#J
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: radio_use_jurabib
-callback: C_FormDialogView_InputCB
-argument: 0
-
---------------------
-class: FL_ROUND3DBUTTON
-type: RADIO_BUTTON
-box: 25 180 155 25
+class: FL_CHECKBUTTON
+type: PUSH_BUTTON
+box: 185 190 25 25
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
+alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Default (numerical)|#D
+label: Sectioned bibliography|#e
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: radio_use_defcite
+name: check_bibtopic
 callback: C_FormDialogView_InputCB
 argument: 0
 
 --------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 15 270 255 25
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
+class: FL_CHOICE
+type: NORMAL_CHOICE
+box: 185 160 140 25
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Sectioned bibliography|#e
+label: Citation Style:|#C
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name: check_bibtopic
+name: choice_cite_engine
 callback: C_FormDialogView_InputCB
 argument: 0
 
@@ -1585,7 +1513,7 @@ argument: 0
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
@@ -1694,7 +1622,7 @@ argument:
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
index e4751e51c497d79abc8f72c9daa6f83dda529880..4c0547a5a35dc553ba3e92808bece41be5d3bac2 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-12  Angus Leeming  <leeming@lyx.org>
+
+       * insetcite.C: use BufferParams::cite_engine rather than the three
+       bools, use_natbib, use_jurabib, use_numerical_citations.
+
 2004-05-10  Angus Leeming  <leeming@lyx.org>
 
        * insetcite.[Ch]: move the Cache::Style enum to biblio::CiteEngine.
index 32aa3d10ea9c4edd1b04a34b6a0a28db33c3812b..5d09732bec9acd39f12978d7bf0a61597c6f6132 100644 (file)
@@ -40,7 +40,7 @@ namespace {
 string const getNatbibLabel(Buffer const & buffer,
                            string const & citeType, string const & keyList,
                            string const & before, string const & after,
-                           bool numerical, bool jura)
+                           biblio::CiteEngine engine)
 {
        // Only start the process off after the buffer is loaded from file.
        if (!buffer.fully_loaded())
@@ -136,7 +136,7 @@ string const getNatbibLabel(Buffer const & buffer,
 
                // authors1/<before>;  ... ;
                //  authors_last, <after>
-               if (cite_type == "cite" && jura) {
+               if (cite_type == "cite" && engine == biblio::ENGINE_JURABIB) {
                        if (it == keys.begin())
                                label += author + before_str + sep_str;
                        else
@@ -145,18 +145,27 @@ string const getNatbibLabel(Buffer const & buffer,
                // (authors1 (<before> year);  ... ;
                //  authors_last (<before> year, <after>)
                } else if (cite_type == "citet") {
-                       string const tmp = numerical ? '#' + *it : year;
-                       if (!jura)
-                               label += author + op_str + before_str + tmp +
-                               cp + sep_str;
-                       else
-                               label += before_str + author + op_str + tmp +
-                               cp + sep_str;
+                       switch (engine) {
+                       case biblio::ENGINE_NATBIB_AUTHORYEAR:
+                               label += author + op_str + before_str +
+                                       year + cp + sep_str;
+                               break;
+                       case biblio::ENGINE_NATBIB_NUMERICAL:
+                               label += author + op_str + before_str +
+                                       '#' + *it + cp + sep_str;
+                               break;
+                       case biblio::ENGINE_JURABIB:
+                               label += before_str + author + op_str +
+                                       year + cp + sep_str;
+                               break;
+                       case biblio::ENGINE_BASIC:
+                               break;
+                       }
 
                // author, year; author, year; ...
                } else if (cite_type == "citep" ||
                           cite_type == "citealp") {
-                       if (numerical) {
+                       if (engine == biblio::ENGINE_NATBIB_NUMERICAL) {
                                label += *it + sep_str;
                        } else {
                                label += author + ", " + year + sep_str;
@@ -165,11 +174,22 @@ string const getNatbibLabel(Buffer const & buffer,
                // (authors1 <before> year;
                //  authors_last <before> year, <after>)
                } else if (cite_type == "citealt") {
-                       string const tmp = numerical ? '#' + *it : year;
-                       if (!jura)
-                               label += author + ' ' + before_str + tmp + sep_str;
-                       else
-                               label += before_str + author + ' ' + tmp + sep_str;
+                       switch (engine) {
+                       case biblio::ENGINE_NATBIB_AUTHORYEAR:
+                               label += author + ' ' + before_str +
+                                       year + sep_str;
+                               break;
+                       case biblio::ENGINE_NATBIB_NUMERICAL:
+                               label += author + ' ' + before_str +
+                                       '#' + *it + sep_str;
+                               break;
+                       case biblio::ENGINE_JURABIB:
+                               label += before_str + author + ' ' +
+                                       year + sep_str;
+                               break;
+                       case biblio::ENGINE_BASIC:
+                               break;
+                       }
 
                // author; author; ...
                } else if (cite_type == "citeauthor") {
@@ -188,9 +208,10 @@ string const getNatbibLabel(Buffer const & buffer,
                        // insert "after" before last ')'
                        label.insert(label.size() - 1, after_str);
                } else {
-                       bool const add = !(numerical &&
-                                          (cite_type == "citeauthor" ||
-                                           cite_type == "citeyear"));
+                       bool const add =
+                               !(engine == biblio::ENGINE_NATBIB_NUMERICAL &&
+                                 (cite_type == "citeauthor" ||
+                                  cite_type == "citeyear"));
                        if (add)
                                label += after_str;
                }
@@ -245,23 +266,22 @@ string const InsetCitation::generateLabel(Buffer const & buffer) const
        string const after  = getOptions();
 
        string label;
-       if (buffer.params().use_natbib || buffer.params().use_jurabib) {
+       biblio::CiteEngine const engine = buffer.params().cite_engine;
+       if (engine != biblio::ENGINE_BASIC) {
                string cmd = getCmdName();
-               if (buffer.params().use_natbib && cmd == "cite") {
+               if (cmd == "cite") {
                        // We may be "upgrading" from an older LyX version.
                        // If, however, we use "cite" because the necessary
                        // author/year info is not present in the biblio
                        // database, then getNatbibLabel will exit gracefully
                        // and we'll call getBasicLabel.
-                       if (buffer.params().use_numerical_citations)
+                       if (engine == biblio::ENGINE_NATBIB_NUMERICAL)
                                cmd = "citep";
-                       else
+                       else if (engine == biblio::ENGINE_NATBIB_AUTHORYEAR)
                                cmd = "citet";
                }
                label = getNatbibLabel(buffer, cmd, getContents(),
-                                      before, after,
-                                      buffer.params().use_numerical_citations,
-                                      buffer.params().use_jurabib);
+                                      before, after, engine);
        }
 
        // Fallback to fail-safe
@@ -320,10 +340,19 @@ int InsetCitation::plaintext(Buffer const & buffer, ostream & os, int) const
 int InsetCitation::latex(Buffer const & buffer, ostream & os,
                         OutputParams const &) const
 {
+       biblio::CiteEngine const cite_engine = buffer.params().cite_engine;
+       
        os << "\\";
-       if (buffer.params().use_natbib)
+       switch (cite_engine) {
+       case biblio::ENGINE_BASIC:
+               os << "cite";
+               break;
+       case biblio::ENGINE_NATBIB_AUTHORYEAR:
+       case biblio::ENGINE_NATBIB_NUMERICAL:
                os << getCmdName();
-       else if (buffer.params().use_jurabib) {
+               break;
+       case biblio::ENGINE_JURABIB: 
+       {
                // jurabib does not (yet) support "force upper case"
                // and "full author name". Fallback.
                string cmd = getCmdName();
@@ -333,13 +362,13 @@ int InsetCitation::latex(Buffer const & buffer, ostream & os,
                if (cmd[n] == '*')
                        cmd = cmd.substr(0,n);
                os << cmd;
-       } else
-               os << "cite";
-
+               break;
+       }
+       }
+       
        string const before = getSecOptions();
        string const after  = getOptions();
-       if (!before.empty()
-               && (buffer.params().use_natbib || buffer.params().use_jurabib))
+       if (!before.empty() && cite_engine != biblio::ENGINE_BASIC)
                os << '[' << before << "][" << after << ']';
        else if (!after.empty())
                os << '[' << after << ']';
@@ -364,8 +393,15 @@ int InsetCitation::latex(Buffer const & buffer, ostream & os,
 
 void InsetCitation::validate(LaTeXFeatures & features) const
 {
-       if (features.bufferParams().use_natbib)
+       switch (features.bufferParams().cite_engine) {
+       case biblio::ENGINE_BASIC:
+               break;
+       case biblio::ENGINE_NATBIB_AUTHORYEAR:
+       case biblio::ENGINE_NATBIB_NUMERICAL:
                features.require("natbib");
-       else if (features.bufferParams().use_jurabib)
+               break;
+       case biblio::ENGINE_JURABIB:
                features.require("jurabib");
+               break;
+       }
 }