]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibtex.cpp
Added support for natively zipped file formats that do not need decompression for...
[lyx.git] / src / insets / InsetBibtex.cpp
index 88ff6649676b3c9bfc5ec5a4038d82bb054e9d4c..329b32994cf055a7da7528550faadf7c4c8eba99 100644 (file)
@@ -19,6 +19,7 @@
 #include "Cursor.h"
 #include "DispatchResult.h"
 #include "Encoding.h"
+#include "Exporter.h"
 #include "Format.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
@@ -103,7 +104,8 @@ void InsetBibtex::doDispatch(Cursor & cur, FuncRequest & cmd)
                                throw message;
                        break;
                }
-               //
+
+               cur.recordUndo();
                setParams(p);
                buffer().invalidateBibfileCache();
                cur.forceBufferUpdate();
@@ -234,7 +236,7 @@ static string normalizeName(Buffer const & buffer,
 }
 
 
-int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
+void InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
 {
        // the sequence of the commands:
        // 1. \bibliographystyle{style}
@@ -262,6 +264,9 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
        odocstringstream dbs;
        bool didone = false;
 
+       // determine the export format
+       string const tex_format = flavor2format(runparams.flavor);
+
        for (; it != en; ++it) {
                string utf8input = to_utf8(*it);
                string database =
@@ -277,7 +282,6 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
                        database = removeExtension(in_file.mangledFileName());
                        FileName const out_file = makeAbsPath(database + ".bib",
                                        buffer().masterBuffer()->temppath());
-
                        bool const success = in_file.copyTo(out_file);
                        if (!success) {
                                lyxerr << "Failed to copy '" << in_file
@@ -285,6 +289,7 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
                                       << endl;
                        }
                } else if (!runparams.inComment && runparams.nice && not_from_texmf) {
+                       runparams.exportdata->addExternalFile(tex_format, try_in_file, database + ".bib");
                        if (!isValidLaTeXFileName(database)) {
                                frontend::Alert::warning(_("Invalid filename"),
                                         _("The following filename will cause troubles "
@@ -327,9 +332,6 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
                        style = split(style, bibtotoc, ',');
        }
 
-       // line count
-       int nlines = 0;
-
        if (!style.empty()) {
                string base = normalizeName(buffer(), runparams, style, ".bst");
                FileName const try_in_file = 
@@ -357,7 +359,6 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
                os << "\\bibliographystyle{"
                   << from_utf8(latex_path(normalizeName(buffer(), runparams, base, ".bst")))
                   << "}\n";
-               nlines += 1;
        }
 
        // Post this warning only once.
@@ -377,7 +378,6 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
                        btprint = from_ascii("btPrintCited");
                os << "\\" << btprint << "\n"
                   << "\\end{btSect}\n";
-               nlines += 3;
        }
 
        // bibtotoc-Option
@@ -395,13 +395,9 @@ int InsetBibtex::latex(odocstream & os, OutputParams const & runparams) const
                docstring btprint = getParam("btprint");
                if (btprint == "btPrintAll") {
                        os << "\\nocite{*}\n";
-                       nlines += 1;
                }
                os << "\\bibliography{" << db_out << "}\n";
-               nlines += 1;
        }
-
-       return nlines;
 }
 
 
@@ -985,11 +981,11 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
                // which will give us all the cross-referenced info. But for every
                // entry, so there's a lot of repitition. This should be fixed.
                xs << html::StartTag("span", "class='bibtexinfo'") 
-                       << XHTMLStream::ESCAPE_AND
-                       << bibinfo.getInfo(entry.key(), buffer(), true)
-                       << html::EndTag("span")
-                       << html::EndTag("div");
-               xs.cr();
+                  << XHTMLStream::ESCAPE_AND
+                  << bibinfo.getInfo(entry.key(), buffer(), true)
+                  << html::EndTag("span")
+                  << html::EndTag("div")
+                  << html::CR();
        }
        xs << html::EndTag("div");
        return docstring();