From a229a78dff24117129d94afc6ed03153f25bbde7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Fri, 28 Dec 2007 16:56:57 +0000 Subject: [PATCH] Support for \nocite* from Berhard Reiter. Increments file format to 210. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22327 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 3 ++ lib/lyx2lyx/LyX.py | 2 +- lib/lyx2lyx/lyx_1_6.py | 33 ++++++++++++++++++-- src/Buffer.cpp | 2 +- src/frontends/qt4/GuiBibtex.cpp | 54 +++++++++++++++++++++------------ src/insets/InsetBibtex.cpp | 5 +++ 6 files changed, 75 insertions(+), 24 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 46a6621e4c..8685cfd338 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,9 @@ LyX file-format changes ----------------------- +2007-12-28 Bernhard Reiter + * Format incremented to 310: support for \nocite{*} + 2007-12-11 Bernhard Reiter * Format incremented to 309: support for \nocite diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index d67c440e57..1ebb67c52c 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)), ("1_3", [221], minor_versions("1.3" , 7)), ("1_4", range(222,246), minor_versions("1.4" , 5)), ("1_5", range(246,277), minor_versions("1.5" , 2)), - ("1_6", range(277,310), minor_versions("1.6" , 0))] # Bernhard Reiter: nocite + ("1_6", range(277,311), minor_versions("1.6" , 0))] # Bernhard Reiter: \nocite{*} def formats_list(): diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index cf6ac5a454..81ca4da28f 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -998,6 +998,33 @@ def revert_nocite(document): i = j +def revert_btprintall(document): + "Revert (non-bibtopic) btPrintAll option to ERT \nocite{*}" + i = find_token(document.header, '\\use_bibtopic', 0) + if i == -1: + document.warning("Malformed lyx document: Missing '\\use_bibtopic'.") + return + if get_value(document.header, '\\use_bibtopic', 0) == "false": + i = 0 + while i < len(document.body): + i = find_token(document.body, "\\begin_inset CommandInset bibtex", i) + if i == -1: + return + j = find_end_of_inset(document.body, i + 1) + if j == -1: + #this should not happen + document.warning("End of CommandInset bibtex not found in revert_btprintall!") + j = len(document.body) + for k in range(i, j): + if (document.body[k] == 'btprint "btPrintAll"'): + del document.body[k] + document.body.insert(i, "\\begin_inset ERT\n" \ + "status collapsed\n\n\\begin_layout Standard\n\n" \ + "\\backslash\nnocite{*}\n" \ + "\\end_layout\n\\end_inset\n") + i = j + + def revert_bahasam(document): "Set language Bahasa Malaysia to Bahasa Indonesia" i = 0 @@ -1086,10 +1113,12 @@ convert = [[277, [fix_wrong_tables]], [306, []], [307, []], [308, []], - [309, []] + [309, []], + [310, []] ] -revert = [[308, [revert_nocite]], +revert = [[309, [revert_btprintall]], + [308, [revert_nocite]], [307, [revert_serbianlatin]], [306, [revert_slash, revert_nobreakdash]], [305, [revert_interlingua]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index a740c6ddab..1926ed988b 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -118,7 +118,7 @@ namespace os = support::os; namespace { -int const LYX_FORMAT = 309; // Bernhard Reiter: support for \nocite +int const LYX_FORMAT = 310; // Bernhard Reiter: support for \nocite{*} } // namespace anon diff --git a/src/frontends/qt4/GuiBibtex.cpp b/src/frontends/qt4/GuiBibtex.cpp index a65b85dc10..c27abde77b 100644 --- a/src/frontends/qt4/GuiBibtex.cpp +++ b/src/frontends/qt4/GuiBibtex.cpp @@ -270,15 +270,20 @@ void GuiBibtex::updateContents() bibtocCB->setChecked(bibtotoc() && !bibtopic); bibtocCB->setEnabled(!bibtopic); + if (!bibtopic && btPrintCO->count() == 3) + btPrintCO->removeItem(1); + else if (bibtopic && btPrintCO->count() < 3) + btPrintCO->insertItem(1, qt_("all uncited references", 0)); + docstring btprint = params_["btprint"]; int btp = 0; - if (btprint == "btPrintNotCited") + if ((bibtopic && btprint == "btPrintNotCited") || + (!bibtopic && btprint == "btPrintAll")) btp = 1; - else if (btprint == "btPrintAll") + else if (bibtopic && btprint == "btPrintAll") btp = 2; btPrintCO->setCurrentIndex(btp); - btPrintCO->setEnabled(bibtopic); styleCB->clear(); @@ -334,26 +339,35 @@ void GuiBibtex::applyView() params_["options"] = bibstyle; } - // bibtopic allows three kinds of sections: - // 1. sections that include all cited references of the database(s) - // 2. sections that include all uncited references of the database(s) - // 3. sections that include all references of the database(s), cited or not int btp = btPrintCO->currentIndex(); - switch (btp) { - case 0: - params_["btprint"] = from_ascii("btPrintCited"); - break; - case 1: - params_["btprint"] = from_ascii("btPrintNotCited"); - break; - case 2: - params_["btprint"] = from_ascii("btPrintAll"); - break; + if (usingBibtopic()) { + // bibtopic allows three kinds of sections: + // 1. sections that include all cited references of the database(s) + // 2. sections that include all uncited references of the database(s) + // 3. sections that include all references of the database(s), cited or not + switch (btp) { + case 0: + params_["btprint"] = from_ascii("btPrintCited"); + break; + case 1: + params_["btprint"] = from_ascii("btPrintNotCited"); + break; + case 2: + params_["btprint"] = from_ascii("btPrintAll"); + break; + } + } else { + switch (btp) { + case 0: + params_["btprint"] = docstring(); + break; + case 1: + // use \nocite{*} + params_["btprint"] = from_ascii("btPrintAll"); + break; + } } - - if (!usingBibtopic()) - params_["btprint"] = docstring(); } diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index fed145068f..4a9e22a13b 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -297,6 +297,11 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os, } if (!db_out.empty() && !buffer.params().use_bibtopic){ + docstring btprint = getParam("btprint"); + if (btprint == "btPrintAll") { + os << "\\nocite{*}\n"; + nlines += 1; + } os << "\\bibliography{" << db_out << "}\n"; nlines += 1; } -- 2.39.2