]> 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, 2 Oct 2018 06:09:04 +0000 (08:09 +0200)
Fixes #11309

(cherry picked from commit a89e3c344bdafd2922321e434c2384020318ed2e)

src/insets/InsetBibtex.cpp
src/insets/InsetBibtex.h
status.23x

index 7a045932ba8d6e03ce4aa8871500396b6874ee2d..8fd5fdef4de11cf7dae068d813af7c1240631ffd 100644 (file)
@@ -31,6 +31,7 @@
 #include "PDFOptions.h"
 #include "texstream.h"
 #include "TextClass.h"
+#include "TocBackend.h"
 
 #include "frontends/alert.h"
 
@@ -877,10 +878,31 @@ void InsetBibtex::validate(LaTeXFeatures & features) const
 }
 
 
+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 ec783d857bfc4e0edaf33aaa307f15594083f668..bcad1a6b95f86c7e44cc3bf6befce4355047e2f2 100644 (file)
@@ -57,6 +57,9 @@ public:
        int plaintext(odocstringstream & ods, OutputParams const & op,
                      size_t max_length = INT_MAX) const;
        ///
+       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
        //@{
index c07d5058a88838b1f81b1cf983ee2eeec2b2c7fb..39cbc4cf4d224dec141f15b58ed78af903c03266 100644 (file)
@@ -65,6 +65,8 @@ What's new
 
 - Allow the 'module in child not used in master' warning to be disabled.
 
+- Add bibtex inset to outliner if "add to toc" is checked (bug 11309).
+
 
 * DOCUMENTATION AND LOCALIZATION