]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBibtex.cpp
Allow row-breaking after some insets
[lyx.git] / src / insets / InsetBibtex.cpp
index d20f67187cdaf652f9ecdda1d28590106eed60ef..3bfc5930130b575825ba7c3cebf4832abb839a8e 100644 (file)
@@ -28,6 +28,7 @@
 #include "LaTeXFeatures.h"
 #include "output_latex.h"
 #include "output_xhtml.h"
+#include "xml.h"
 #include "OutputParams.h"
 #include "PDFOptions.h"
 #include "texstream.h"
@@ -132,7 +133,7 @@ bool InsetBibtex::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-void InsetBibtex::editDatabases(docstring const db) const
+void InsetBibtex::editDatabases(docstring const db) const
 {
        vector<docstring> bibfilelist = getVectorFromString(getParam("bibfiles"));
 
@@ -266,6 +267,15 @@ void InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
            && buffer().params().multibib == "child")
                return;
 
+       if (runparams.inDeletedInset) {
+               // We cannot strike-out bibligraphies,
+               // so we just output a note.
+               os << "\\textbf{"
+                  << buffer().B_("[BIBLIOGRAPHY DELETED!]")
+                  << "}";
+               return;
+       }
+
        string style = to_utf8(getParam("options")); // maybe empty! and with bibtotoc
        string bibtotoc;
        if (prefixIs(style, "bibtotoc")) {
@@ -363,7 +373,8 @@ void InsetBibtex::latex(otexstream & os, OutputParams const & runparams) const
                           << "\\end{btSect}\n";
                }
                // bibtotoc option
-               if (!bibtotoc.empty() && !buffer().masterParams().useBibtopic()) {
+               if (!bibtotoc.empty() && !buffer().masterParams().useBibtopic()
+                   && !buffer().masterParams().documentClass().bibInToc()) {
                        // set label for hyperref, see http://www.lyx.org/trac/ticket/6470
                        if (buffer().masterParams().pdfoptions().use_hyperref)
                                        os << "\\phantomsection";
@@ -898,7 +909,7 @@ void InsetBibtex::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetBibtex::updateBuffer(ParIterator const &, UpdateType)
+void InsetBibtex::updateBuffer(ParIterator const &, UpdateType, bool const /*deleted*/)
 {
        buffer().registerBibfiles(getBibFiles());
        // record encoding of bib files for biblatex
@@ -951,9 +962,12 @@ void InsetBibtex::addToToc(DocIterator const & cpit, bool output_active,
                return;
 
        docstring const str = getRefLabel();
-       TocBuilder & b = backend.builder("tableofcontents");
-       b.pushItem(cpit, str, output_active);
-       b.pop();
+       shared_ptr<Toc> toc = backend.toc("tableofcontents");
+       // Assign to appropriate level
+       int const item_depth =
+               (buffer().masterParams().documentClass().hasLaTeXLayout("chapter")) 
+                       ? 1 : 2;
+       toc->push_back(TocItem(cpit, item_depth, str, output_active));
 }
 
 
@@ -995,7 +1009,7 @@ int InsetBibtex::plaintext(odocstringstream & os,
                refoutput += "[" + entry.label() + "] ";
                // FIXME Right now, we are calling BibInfo::getInfo on the key,
                // which will give us all the cross-referenced info. But for every
-               // entry, so there's a lot of repitition. This should be fixed.
+               // entry, so there's a lot of repetition. This should be fixed.
                refoutput += bibinfo.getInfo(entry.key(), buffer(), ci) + "\n\n";
        }
        os << refoutput;
@@ -1006,7 +1020,7 @@ int InsetBibtex::plaintext(odocstringstream & os,
 // FIXME
 // docstring InsetBibtex::entriesAsXHTML(vector<docstring> const & entries)
 // And then here just: entriesAsXHTML(buffer().masterBibInfo().citedEntries())
-docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetBibtex::xhtml(XMLStream & xs, OutputParams const &) const
 {
        BiblioInfo const & bibinfo = buffer().masterBibInfo();
        bool const all_entries = getParam("btprint") == "btPrintAll";
@@ -1021,10 +1035,10 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
        ci.richtext = true;
        ci.max_key_size = UINT_MAX;
 
-       xs << html::StartTag("h2", "class='bibtex'")
+       xs << xml::StartTag("h2", "class='bibtex'")
                << reflabel
-               << html::EndTag("h2")
-               << html::StartTag("div", "class='bibtex'");
+               << xml::EndTag("h2")
+               << xml::StartTag("div", "class='bibtex'");
 
        // Now we loop over the entries
        vector<docstring>::const_iterator vit = cites.begin();
@@ -1036,27 +1050,27 @@ docstring InsetBibtex::xhtml(XHTMLStream & xs, OutputParams const &) const
 
                BibTeXInfo const & entry = biit->second;
                string const attr = "class='bibtexentry' id='LyXCite-"
-                   + to_utf8(html::cleanAttr(entry.key())) + "'";
-               xs << html::StartTag("div", attr);
+                   + to_utf8(xml::cleanAttr(entry.key())) + "'";
+               xs << xml::StartTag("div", attr);
 
                // don't print labels if we're outputting all entries
                if (!all_entries) {
-                       xs << html::StartTag("span", "class='bibtexlabel'")
+                       xs << xml::StartTag("span", "class='bibtexlabel'")
                                << entry.label()
-                               << html::EndTag("span");
+                               << xml::EndTag("span");
                }
 
                // FIXME Right now, we are calling BibInfo::getInfo on the key,
                // 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
+               xs << xml::StartTag("span", "class='bibtexinfo'")
+                  << XMLStream::ESCAPE_AND
                   << bibinfo.getInfo(entry.key(), buffer(), ci)
-                  << html::EndTag("span")
-                  << html::EndTag("div")
-                  << html::CR();
+                  << xml::EndTag("span")
+                  << xml::EndTag("div")
+                  << xml::CR();
        }
-       xs << html::EndTag("div");
+       xs << xml::EndTag("div");
        return docstring();
 }