]> git.lyx.org Git - features.git/commitdiff
Add bibtex inset to outliner if "add to toc" is checked.
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 25 Sep 2018 13:24:46 +0000 (15:24 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 25 Sep 2018 13:24:46 +0000 (15:24 +0200)
Fixes #11309

src/insets/InsetBibtex.cpp
src/insets/InsetBibtex.h

index 399ddb6012075cbd11b81ab7f4bc828f04ef0662..d5798630a75a693f645c2ef2d15ac24e9b3c5b63 100644 (file)
@@ -32,6 +32,7 @@
 #include "PDFOptions.h"
 #include "texstream.h"
 #include "TextClass.h"
+#include "TocBackend.h"
 
 #include "frontends/alert.h"
 
@@ -900,10 +901,31 @@ void InsetBibtex::updateBuffer(ParIterator const &, UpdateType)
 }
 
 
+docstring InsetBibtex::getRefLabel() const
+{
+       if (buffer().masterParams().documentClass().hasLaTeXLayout("chapter"))
+               return buffer().B_("Bibliography");
+       return buffer().B_("References");
+}
+
+
+void InsetBibtex::addToToc(DocIterator const & cpit, bool output_active,
+                          UpdateType, TocBackend & backend) const
+{
+       if (!prefixIs(to_utf8(getParam("options")), "bibtotoc"))
+               return;
+
+       docstring const str = getRefLabel();
+       TocBuilder & b = backend.builder("tableofcontents");
+       b.pushItem(cpit, str, output_active);
+       b.pop();
+}
+
+
 int InsetBibtex::plaintext(odocstringstream & os,
        OutputParams const & op, size_t max_length) const
 {
-       docstring const reflabel = buffer().B_("References");
+       docstring const reflabel = getRefLabel();
 
        // We could output more information here, e.g., what databases are included
        // and information about options. But I don't necessarily see any reason to
index f2b8dd15763a141ffaebd810b6cf5c00273372aa..63c99f9ad5783ea47ef260a2301c487284e6d77f 100644 (file)
@@ -57,6 +57,9 @@ public:
        ///
        void updateBuffer(ParIterator const &, UpdateType);
        ///
+       void addToToc(DocIterator const & di, bool output_active,
+                                 UpdateType utype, TocBackend & backend) const;
+       ///
        void collectBibKeys(InsetIterator const &, support::FileNameList &) const;
        ///
        void validate(LaTeXFeatures &) const;
@@ -84,6 +87,8 @@ private:
        void parseBibTeXFiles(support::FileNameList &) const;
        ///
        bool usingBiblatex() const;
+       ///
+       docstring getRefLabel() const;
 
        /// \name Private functions inherited from Inset class
        //@{