]> git.lyx.org Git - features.git/commitdiff
Support for \nocite* from Berhard Reiter. Increments file format to 210.
authorJürgen Spitzmüller <spitz@lyx.org>
Fri, 28 Dec 2007 16:56:57 +0000 (16:56 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Fri, 28 Dec 2007 16:56:57 +0000 (16:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22327 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_6.py
src/Buffer.cpp
src/frontends/qt4/GuiBibtex.cpp
src/insets/InsetBibtex.cpp

index 46a6621e4c7741d32e02590c99b8b50b2f1c6a65..8685cfd338cc963687f21f605331fcd66d1c3d65 100644 (file)
@@ -1,6 +1,9 @@
 LyX file-format changes
 -----------------------
 
+2007-12-28 Bernhard Reiter <ockham@gmx.net>
+       * Format incremented to 310: support for \nocite{*}
+       
 2007-12-11 Bernhard Reiter <ockham@gmx.net>
        * Format incremented to 309: support for \nocite
 
index d67c440e57f55a04631e9a73eef9f3c601e9ba4c..1ebb67c52c58d08394f985044ab903bfb0764d6a 100644 (file)
@@ -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():
index cf6ac5a454c6210a2149c2c6399fc1fc5870eccc..81ca4da28fc33b0165b1f191a0ef7738fc6f5be0 100644 (file)
@@ -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]],
index a740c6ddab6e2344b72d754339db6911d503cfd3..1926ed988b5927e9b6376aeb16282dbdbabad9e8 100644 (file)
@@ -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
 
index a65b85dc10f276dded0ee14110c097cabd6a108e..c27abde77b7c6bb2636c8f5bce614371c24ba39c 100644 (file)
@@ -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();
 }
 
 
index fed145068fc5b25c9809a4a1e5a8888bc2d6a601..4a9e22a13bf0110ac1515dc68decd72269de2083 100644 (file)
@@ -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;
        }