]> git.lyx.org Git - lyx.git/commitdiff
tex2lyx/text.cpp: support \nocite{*} (since format 310)
authorUwe Stöhr <uwestoehr@web.de>
Mon, 20 Dec 2010 02:47:58 +0000 (02:47 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Mon, 20 Dec 2010 02:47:58 +0000 (02:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36961 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/text.cpp

index 2a23a8830432cb420cc3fff1be67e1ab07b59bda..4c15a856961253dc0b984f944413d940d0ccbcb1 100644 (file)
@@ -1308,7 +1308,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                Context & context)
 {
        Layout const * newlayout = 0;
-       // Store the latest bibliographystyle (needed for bibtex inset)
+       // Store the latest bibliographystyle and nocite{*} option
+       // (needed for bibtex inset)
+       string btprint;
        string bibliographystyle;
        bool const use_natbib = used_packages.find("natbib") != used_packages.end();
        bool const use_jurabib = used_packages.find("jurabib") != used_packages.end();
@@ -2209,10 +2211,16 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        context.check_layout(os);
                        // LyX cannot handle newlines in a latex command
                        string after = subst(p.getOptContent(), "\n", " ");
-                       begin_command_inset(os, "citation", t.cs());
-                       os << "after " << '"' << after << '"' << "\n";
-                       os << "key " << '"' << subst(p.verbatim_item(), "\n", " ") << '"' << "\n";
-                       end_inset(os);
+                       string key = subst(p.verbatim_item(), "\n", " ");
+                       // store the case that it is "\nocite{*}" to use it later for
+                       // the BibTeX inset
+                       if (key != "*") {
+                               begin_command_inset(os, "citation", t.cs());
+                               os << "after " << '"' << after << '"' << "\n";
+                               os << "key " << '"' << key << '"' << "\n";
+                               end_inset(os);
+                       } else
+                               btprint = key;
                }
 
                else if (t.cs() == "index") {
@@ -2641,6 +2649,12 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                else if (t.cs() == "bibliography") {
                        context.check_layout(os);
                        begin_command_inset(os, "bibtex", "bibtex");
+                       if (!btprint.empty()) {
+                               os << "btprint " << '"' << "btPrintAll" << '"' << "\n";
+                               // clear the string because the next BibTeX inset can be without the
+                               // \nocite{*} option
+                               btprint.clear();
+                       }
                        os << "bibfiles " << '"' << p.verbatim_item() << '"' << "\n";
                        // Do we have a bibliographystyle set?
                        if (!bibliographystyle.empty())