Added as an attachment to http://bugzilla.lyx.org/show_bug.cgi?id=994 :
> Re-uses the "Contents" combo box in the Bibtex dialog (currently only used for
> sectioned bibliographies using bibtopic).
Bernhard Reiter
Index: src/insets/InsetBibtex.cpp
===================================================================
--- src/insets/InsetBibtex.cpp (Revision 22324)
+++ src/insets/InsetBibtex.cpp (Arbeitskopie)
@@ -297,6 +297,11 @@
}
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;
}
Index: src/frontends/qt4/GuiBibtex.cpp
===================================================================
--- src/frontends/qt4/GuiBibtex.cpp (Revision 22324)
+++ src/frontends/qt4/GuiBibtex.cpp (Arbeitskopie)
@@ -270,15 +270,20 @@
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 @@
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();
}
Index: lib/lyx2lyx/lyx_1_6.py
===================================================================
--- lib/lyx2lyx/lyx_1_6.py (Revision 22324)
+++ lib/lyx2lyx/lyx_1_6.py (Arbeitskopie)
@@ -998,6 +998,33 @@
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
@@ -1089,7 +1116,7 @@
[309, []]
]
-revert = [[308, [revert_nocite]],
+revert = [[308, [revert_nocite, revert_btprintall]],
[307, [revert_serbianlatin]],
[306, [revert_slash, revert_nobreakdash]],
[305, [revert_interlingua]],